-
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.
fix: token already paused unpaused and frozen validation
- Loading branch information
1 parent
ddf4e67
commit 341afed
Showing
16 changed files
with
275 additions
and
48 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
51 changes: 51 additions & 0 deletions
51
...es/rs-dpp/src/errors/consensus/state/token/identity_token_account_already_frozen_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,51 @@ | ||
use crate::consensus::state::state_error::StateError; | ||
use crate::consensus::ConsensusError; | ||
use crate::ProtocolError; | ||
use bincode::{Decode, Encode}; | ||
use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; | ||
use platform_value::Identifier; | ||
use thiserror::Error; | ||
|
||
#[derive( | ||
Error, Debug, Clone, PartialEq, Eq, Encode, Decode, PlatformSerialize, PlatformDeserialize, | ||
)] | ||
#[error( | ||
"Identity {} account is already frozen for token {}. Action attempted: {}", | ||
identity_id, | ||
token_id, | ||
action | ||
)] | ||
#[platform_serialize(unversioned)] | ||
pub struct IdentityTokenAccountAlreadyFrozenError { | ||
token_id: Identifier, | ||
identity_id: Identifier, | ||
action: String, | ||
} | ||
|
||
impl IdentityTokenAccountAlreadyFrozenError { | ||
pub fn new(token_id: Identifier, identity_id: Identifier, action: String) -> Self { | ||
Self { | ||
token_id, | ||
identity_id, | ||
action, | ||
} | ||
} | ||
|
||
pub fn token_id(&self) -> &Identifier { | ||
&self.token_id | ||
} | ||
|
||
pub fn identity_id(&self) -> &Identifier { | ||
&self.identity_id | ||
} | ||
|
||
pub fn action(&self) -> &str { | ||
&self.action | ||
} | ||
} | ||
|
||
impl From<IdentityTokenAccountAlreadyFrozenError> for ConsensusError { | ||
fn from(err: IdentityTokenAccountAlreadyFrozenError) -> Self { | ||
Self::StateError(StateError::IdentityTokenAccountAlreadyFrozenError(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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,31 @@ | ||
mod identity_does_not_have_enough_token_balance_error; | ||
mod identity_token_account_already_frozen_error; | ||
mod identity_token_account_frozen_error; | ||
mod identity_token_account_not_frozen_error; | ||
mod invalid_group_position_error; | ||
mod new_authorized_action_taker_group_does_not_exist_error; | ||
mod new_authorized_action_taker_identity_does_not_exist_error; | ||
mod new_authorized_action_taker_main_group_not_set_error; | ||
mod new_tokens_destination_identity_does_not_exist_error; | ||
mod token_already_paused_error; | ||
mod token_is_paused_error; | ||
mod token_mint_past_max_supply_error; | ||
mod token_not_paused_error; | ||
mod token_setting_max_supply_to_less_than_current_supply_error; | ||
mod unauthorized_token_action_error; | ||
|
||
pub use identity_does_not_have_enough_token_balance_error::*; | ||
pub use identity_token_account_already_frozen_error::*; | ||
pub use identity_token_account_frozen_error::*; | ||
pub use identity_token_account_not_frozen_error::*; | ||
pub use invalid_group_position_error::*; | ||
pub use new_authorized_action_taker_group_does_not_exist_error::*; | ||
pub use new_authorized_action_taker_identity_does_not_exist_error::*; | ||
pub use new_authorized_action_taker_main_group_not_set_error::*; | ||
pub use new_tokens_destination_identity_does_not_exist_error::*; | ||
pub use token_already_paused_error::*; | ||
pub use token_is_paused_error::*; | ||
pub use token_mint_past_max_supply_error::*; | ||
pub use token_not_paused_error::*; | ||
pub use token_setting_max_supply_to_less_than_current_supply_error::*; | ||
pub use unauthorized_token_action_error::*; |
37 changes: 37 additions & 0 deletions
37
packages/rs-dpp/src/errors/consensus/state/token/token_already_paused_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,37 @@ | ||
use crate::consensus::state::state_error::StateError; | ||
use crate::consensus::ConsensusError; | ||
use crate::ProtocolError; | ||
use bincode::{Decode, Encode}; | ||
use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; | ||
use platform_value::Identifier; | ||
use thiserror::Error; | ||
|
||
#[derive( | ||
Error, Debug, Clone, PartialEq, Eq, Encode, Decode, PlatformSerialize, PlatformDeserialize, | ||
)] | ||
#[error("Token {} is already paused. Action attempted: {}", token_id, action)] | ||
#[platform_serialize(unversioned)] | ||
pub struct TokenAlreadyPausedError { | ||
token_id: Identifier, | ||
action: String, | ||
} | ||
|
||
impl TokenAlreadyPausedError { | ||
pub fn new(token_id: Identifier, action: String) -> Self { | ||
Self { token_id, action } | ||
} | ||
|
||
pub fn token_id(&self) -> &Identifier { | ||
&self.token_id | ||
} | ||
|
||
pub fn action(&self) -> &str { | ||
&self.action | ||
} | ||
} | ||
|
||
impl From<TokenAlreadyPausedError> for ConsensusError { | ||
fn from(err: TokenAlreadyPausedError) -> Self { | ||
Self::StateError(StateError::TokenAlreadyPausedError(err)) | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
packages/rs-dpp/src/errors/consensus/state/token/token_not_paused_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,37 @@ | ||
use crate::consensus::state::state_error::StateError; | ||
use crate::consensus::ConsensusError; | ||
use crate::ProtocolError; | ||
use bincode::{Decode, Encode}; | ||
use platform_serialization_derive::{PlatformDeserialize, PlatformSerialize}; | ||
use platform_value::Identifier; | ||
use thiserror::Error; | ||
|
||
#[derive( | ||
Error, Debug, Clone, PartialEq, Eq, Encode, Decode, PlatformSerialize, PlatformDeserialize, | ||
)] | ||
#[error("Token {} is not paused. Action attempted: {}", token_id, action)] | ||
#[platform_serialize(unversioned)] | ||
pub struct TokenNotPausedError { | ||
token_id: Identifier, | ||
action: String, | ||
} | ||
|
||
impl TokenNotPausedError { | ||
pub fn new(token_id: Identifier, action: String) -> Self { | ||
Self { token_id, action } | ||
} | ||
|
||
pub fn token_id(&self) -> &Identifier { | ||
&self.token_id | ||
} | ||
|
||
pub fn action(&self) -> &str { | ||
&self.action | ||
} | ||
} | ||
|
||
impl From<TokenNotPausedError> for ConsensusError { | ||
fn from(err: TokenNotPausedError) -> Self { | ||
Self::StateError(StateError::TokenNotPausedError(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
Oops, something went wrong.