-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fbcfd6e
commit 39e6d5d
Showing
19 changed files
with
782 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
packages/rs-dpp/src/errors/consensus/basic/data_contract/invalid_token_base_supply_error.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
use crate::consensus::basic::BasicError; | ||
use crate::errors::ProtocolError; | ||
use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; | ||
use thiserror::Error; | ||
|
||
use crate::consensus::ConsensusError; | ||
|
||
use bincode::{Decode, Encode}; | ||
#[derive( | ||
Error, Debug, Clone, PartialEq, Eq, Encode, Decode, PlatformSerialize, PlatformDeserialize, | ||
)] | ||
#[error( | ||
"Invalid token base supply. Given base supply: {}, Max allowed base supply: {}", | ||
base_supply, | ||
i64::MAX | ||
)] | ||
#[platform_serialize(unversioned)] | ||
pub struct InvalidTokenBaseSupplyError { | ||
/* | ||
DO NOT CHANGE ORDER OF FIELDS WITHOUT INTRODUCING OF NEW VERSION | ||
*/ | ||
base_supply: u64, | ||
} | ||
|
||
impl InvalidTokenBaseSupplyError { | ||
pub fn new(base_supply: u64) -> Self { | ||
Self { base_supply } | ||
} | ||
|
||
pub fn base_supply(&self) -> u64 { | ||
self.base_supply | ||
} | ||
} | ||
|
||
impl From<InvalidTokenBaseSupplyError> for ConsensusError { | ||
fn from(err: InvalidTokenBaseSupplyError) -> Self { | ||
Self::BasicError(BasicError::InvalidTokenBaseSupplyError(err)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
...src/errors/consensus/basic/data_contract/non_contiguous_contract_group_positions_error.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
use crate::consensus::basic::BasicError; | ||
use crate::consensus::ConsensusError; | ||
use crate::data_contract::GroupContractPosition; | ||
use crate::errors::ProtocolError; | ||
use bincode::{Decode, Encode}; | ||
use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; | ||
use thiserror::Error; | ||
|
||
#[derive( | ||
Error, Debug, Clone, PartialEq, Eq, Encode, Decode, PlatformSerialize, PlatformDeserialize, | ||
)] | ||
#[error( | ||
"Contract Group Positions are not contiguous. Missing position: {}, Followed position: {}", | ||
missing_position, | ||
followed_position | ||
)] | ||
#[platform_serialize(unversioned)] | ||
pub struct NonContiguousContractGroupPositionsError { | ||
/* | ||
DO NOT CHANGE ORDER OF FIELDS WITHOUT INTRODUCING OF NEW VERSION | ||
*/ | ||
missing_position: GroupContractPosition, | ||
followed_position: GroupContractPosition, | ||
} | ||
|
||
impl NonContiguousContractGroupPositionsError { | ||
pub fn new( | ||
missing_position: GroupContractPosition, | ||
followed_position: GroupContractPosition, | ||
) -> Self { | ||
Self { | ||
missing_position, | ||
followed_position, | ||
} | ||
} | ||
|
||
pub fn missing_position(&self) -> u16 { | ||
self.missing_position | ||
} | ||
|
||
pub fn followed_position(&self) -> u16 { | ||
self.followed_position | ||
} | ||
} | ||
|
||
impl From<NonContiguousContractGroupPositionsError> for ConsensusError { | ||
fn from(err: NonContiguousContractGroupPositionsError) -> Self { | ||
Self::BasicError(BasicError::NonContiguousContractGroupPositionsError(err)) | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
...src/errors/consensus/basic/data_contract/non_contiguous_contract_token_positions_error.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
use crate::consensus::basic::BasicError; | ||
use crate::consensus::ConsensusError; | ||
use crate::data_contract::TokenContractPosition; | ||
use crate::errors::ProtocolError; | ||
use bincode::{Decode, Encode}; | ||
use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; | ||
use thiserror::Error; | ||
|
||
#[derive( | ||
Error, Debug, Clone, PartialEq, Eq, Encode, Decode, PlatformSerialize, PlatformDeserialize, | ||
)] | ||
#[error( | ||
"Contract Token Positions are not contiguous. Missing position: {}, Followed position: {}", | ||
missing_position, | ||
followed_position | ||
)] | ||
#[platform_serialize(unversioned)] | ||
pub struct NonContiguousContractTokenPositionsError { | ||
/* | ||
DO NOT CHANGE ORDER OF FIELDS WITHOUT INTRODUCING OF NEW VERSION | ||
*/ | ||
missing_position: TokenContractPosition, | ||
followed_position: TokenContractPosition, | ||
} | ||
|
||
impl NonContiguousContractTokenPositionsError { | ||
pub fn new( | ||
missing_position: TokenContractPosition, | ||
followed_position: TokenContractPosition, | ||
) -> Self { | ||
Self { | ||
missing_position, | ||
followed_position, | ||
} | ||
} | ||
|
||
pub fn missing_position(&self) -> u16 { | ||
self.missing_position | ||
} | ||
|
||
pub fn followed_position(&self) -> u16 { | ||
self.followed_position | ||
} | ||
} | ||
|
||
impl From<NonContiguousContractTokenPositionsError> for ConsensusError { | ||
fn from(err: NonContiguousContractTokenPositionsError) -> Self { | ||
Self::BasicError(BasicError::NonContiguousContractTokenPositionsError(err)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,12 @@ | ||
use crate::data_contract::TokenContractPosition; | ||
use crate::util::hash::hash_double; | ||
|
||
pub mod allowed_currency; | ||
pub mod errors; | ||
pub mod token_event; | ||
pub fn calculate_token_id(contract_id: &[u8; 32], token_pos: TokenContractPosition) -> [u8; 32] { | ||
let mut bytes = b"dash_token".to_vec(); | ||
bytes.extend_from_slice(contract_id); | ||
bytes.extend_from_slice(&token_pos.to_be_bytes()); | ||
hash_double(bytes) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.