-
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
da5d87a
commit e701008
Showing
180 changed files
with
2,398 additions
and
468 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
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
25 changes: 25 additions & 0 deletions
25
...document/batch_transition/batched_transition/token_destroy_frozen_funds_transition/mod.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,25 @@ | ||
pub mod v0; | ||
mod v0_methods; | ||
|
||
use bincode::{Decode, Encode}; | ||
use derive_more::{Display, From}; | ||
#[cfg(feature = "state-transition-serde-conversion")] | ||
use serde::{Deserialize, Serialize}; | ||
pub use v0::TokenDestroyFrozenFundsTransitionV0; | ||
|
||
#[derive(Debug, Clone, Encode, Decode, PartialEq, Display, From)] | ||
#[cfg_attr( | ||
feature = "state-transition-serde-conversion", | ||
derive(Serialize, Deserialize) | ||
)] | ||
pub enum TokenDestroyFrozenFundsTransition { | ||
#[display("V0({})", "_0")] | ||
V0(TokenDestroyFrozenFundsTransitionV0), | ||
} | ||
|
||
impl Default for TokenDestroyFrozenFundsTransition { | ||
fn default() -> Self { | ||
TokenDestroyFrozenFundsTransition::V0(TokenDestroyFrozenFundsTransitionV0::default()) | ||
// since only v0 | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...ument/batch_transition/batched_transition/token_destroy_frozen_funds_transition/v0/mod.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,25 @@ | ||
pub mod v0_methods; | ||
|
||
use crate::state_transition::batch_transition::token_base_transition::TokenBaseTransition; | ||
use bincode::{Decode, Encode}; | ||
use derive_more::Display; | ||
use platform_value::Identifier; | ||
#[cfg(feature = "state-transition-serde-conversion")] | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Debug, Clone, Default, Encode, Decode, PartialEq, Display)] | ||
#[cfg_attr( | ||
feature = "state-transition-serde-conversion", | ||
derive(Serialize, Deserialize), | ||
serde(rename_all = "camelCase") | ||
)] | ||
#[display("Base: {base}, Destroyed Account Identity ID: {frozen_identity_id}")] | ||
pub struct TokenDestroyFrozenFundsTransitionV0 { | ||
/// Document Base Transition | ||
#[cfg_attr(feature = "state-transition-serde-conversion", serde(flatten))] | ||
pub base: TokenBaseTransition, | ||
/// The identity id of the account whose balance should be destroyed | ||
pub frozen_identity_id: Identifier, | ||
/// The public note | ||
pub public_note: Option<String>, | ||
} |
78 changes: 78 additions & 0 deletions
78
...atch_transition/batched_transition/token_destroy_frozen_funds_transition/v0/v0_methods.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,78 @@ | ||
use platform_value::Identifier; | ||
use crate::state_transition::batch_transition::batched_transition::multi_party_action::AllowedAsMultiPartyAction; | ||
use crate::state_transition::batch_transition::token_base_transition::token_base_transition_accessors::TokenBaseTransitionAccessors; | ||
use crate::state_transition::batch_transition::token_base_transition::TokenBaseTransition; | ||
use crate::state_transition::batch_transition::token_base_transition::v0::v0_methods::TokenBaseTransitionV0Methods; | ||
use crate::state_transition::batch_transition::token_destroy_frozen_funds_transition::TokenDestroyFrozenFundsTransitionV0; | ||
use crate::state_transition::batch_transition::TokenDestroyFrozenFundsTransition; | ||
|
||
impl TokenBaseTransitionAccessors for TokenDestroyFrozenFundsTransitionV0 { | ||
fn base(&self) -> &TokenBaseTransition { | ||
&self.base | ||
} | ||
|
||
fn base_mut(&mut self) -> &mut TokenBaseTransition { | ||
&mut self.base | ||
} | ||
|
||
fn set_base(&mut self, base: TokenBaseTransition) { | ||
self.base = base; | ||
} | ||
} | ||
|
||
pub trait TokenDestroyFrozenFundsTransitionV0Methods: | ||
TokenBaseTransitionAccessors + AllowedAsMultiPartyAction | ||
{ | ||
/// Returns the `public_note` field of the `TokenDestroyFrozenFundsTransitionV0`. | ||
fn public_note(&self) -> Option<&String>; | ||
|
||
/// Returns the owned `public_note` field of the `TokenDestroyFrozenFundsTransitionV0`. | ||
fn public_note_owned(self) -> Option<String>; | ||
|
||
/// Sets the `public_note` field in the `TokenDestroyFrozenFundsTransitionV0`. | ||
fn set_public_note(&mut self, public_note: Option<String>); | ||
|
||
/// Returns the `frozen_identity_id` field of the `TokenFreezeTransitionV0`. | ||
fn frozen_identity_id(&self) -> Identifier; | ||
|
||
/// Sets the value of the `frozen_identity_id` field in the `TokenFreezeTransitionV0`. | ||
fn set_frozen_identity_id(&mut self, frozen_identity_id: Identifier); | ||
} | ||
|
||
impl TokenDestroyFrozenFundsTransitionV0Methods for TokenDestroyFrozenFundsTransitionV0 { | ||
fn public_note(&self) -> Option<&String> { | ||
self.public_note.as_ref() | ||
} | ||
|
||
fn public_note_owned(self) -> Option<String> { | ||
self.public_note | ||
} | ||
|
||
fn set_public_note(&mut self, public_note: Option<String>) { | ||
self.public_note = public_note; | ||
} | ||
|
||
fn frozen_identity_id(&self) -> Identifier { | ||
self.frozen_identity_id | ||
} | ||
fn set_frozen_identity_id(&mut self, frozen_identity_id: Identifier) { | ||
self.frozen_identity_id = frozen_identity_id; | ||
} | ||
} | ||
|
||
impl AllowedAsMultiPartyAction for TokenDestroyFrozenFundsTransitionV0 { | ||
fn calculate_action_id(&self, owner_id: Identifier) -> Identifier { | ||
let TokenDestroyFrozenFundsTransitionV0 { | ||
base, | ||
frozen_identity_id, | ||
.. | ||
} = self; | ||
|
||
TokenDestroyFrozenFundsTransition::calculate_action_id_with_fields( | ||
base.token_id().as_bytes(), | ||
owner_id.as_bytes(), | ||
frozen_identity_id.as_bytes(), | ||
base.identity_contract_nonce(), | ||
) | ||
} | ||
} |
87 changes: 87 additions & 0 deletions
87
...t/batch_transition/batched_transition/token_destroy_frozen_funds_transition/v0_methods.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,87 @@ | ||
use platform_value::Identifier; | ||
use crate::prelude::IdentityNonce; | ||
use crate::state_transition::batch_transition::batched_transition::multi_party_action::AllowedAsMultiPartyAction; | ||
use crate::state_transition::batch_transition::token_base_transition::token_base_transition_accessors::TokenBaseTransitionAccessors; | ||
use crate::state_transition::batch_transition::token_base_transition::TokenBaseTransition; | ||
use crate::state_transition::batch_transition::token_destroy_frozen_funds_transition::TokenDestroyFrozenFundsTransition; | ||
use crate::state_transition::batch_transition::token_destroy_frozen_funds_transition::v0::v0_methods::TokenDestroyFrozenFundsTransitionV0Methods; | ||
use crate::util::hash::hash_double; | ||
|
||
impl TokenBaseTransitionAccessors for TokenDestroyFrozenFundsTransition { | ||
fn base(&self) -> &TokenBaseTransition { | ||
match self { | ||
TokenDestroyFrozenFundsTransition::V0(v0) => &v0.base, | ||
} | ||
} | ||
|
||
fn base_mut(&mut self) -> &mut TokenBaseTransition { | ||
match self { | ||
TokenDestroyFrozenFundsTransition::V0(v0) => &mut v0.base, | ||
} | ||
} | ||
|
||
fn set_base(&mut self, base: TokenBaseTransition) { | ||
match self { | ||
TokenDestroyFrozenFundsTransition::V0(v0) => v0.base = base, | ||
} | ||
} | ||
} | ||
|
||
impl TokenDestroyFrozenFundsTransitionV0Methods for TokenDestroyFrozenFundsTransition { | ||
fn public_note(&self) -> Option<&String> { | ||
match self { | ||
TokenDestroyFrozenFundsTransition::V0(v0) => v0.public_note(), | ||
} | ||
} | ||
|
||
fn public_note_owned(self) -> Option<String> { | ||
match self { | ||
TokenDestroyFrozenFundsTransition::V0(v0) => v0.public_note_owned(), | ||
} | ||
} | ||
|
||
fn set_public_note(&mut self, public_note: Option<String>) { | ||
match self { | ||
TokenDestroyFrozenFundsTransition::V0(v0) => v0.set_public_note(public_note), | ||
} | ||
} | ||
|
||
fn frozen_identity_id(&self) -> Identifier { | ||
match self { | ||
TokenDestroyFrozenFundsTransition::V0(v0) => v0.frozen_identity_id(), | ||
} | ||
} | ||
|
||
fn set_frozen_identity_id(&mut self, frozen_identity_id: Identifier) { | ||
match self { | ||
TokenDestroyFrozenFundsTransition::V0(v0) => { | ||
v0.set_frozen_identity_id(frozen_identity_id) | ||
} | ||
} | ||
} | ||
} | ||
|
||
impl AllowedAsMultiPartyAction for TokenDestroyFrozenFundsTransition { | ||
fn calculate_action_id(&self, owner_id: Identifier) -> Identifier { | ||
match self { | ||
TokenDestroyFrozenFundsTransition::V0(v0) => v0.calculate_action_id(owner_id), | ||
} | ||
} | ||
} | ||
|
||
impl TokenDestroyFrozenFundsTransition { | ||
pub fn calculate_action_id_with_fields( | ||
token_id: &[u8; 32], | ||
owner_id: &[u8; 32], | ||
target_id: &[u8; 32], | ||
identity_contract_nonce: IdentityNonce, | ||
) -> Identifier { | ||
let mut bytes = b"action_token_destroy".to_vec(); | ||
bytes.extend_from_slice(token_id); | ||
bytes.extend_from_slice(owner_id); | ||
bytes.extend_from_slice(target_id); | ||
bytes.extend_from_slice(&identity_contract_nonce.to_be_bytes()); | ||
|
||
hash_double(bytes).into() | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...ons/document/batch_transition/batched_transition/token_emergency_action_transition/mod.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,25 @@ | ||
pub mod v0; | ||
mod v0_methods; | ||
|
||
use bincode::{Decode, Encode}; | ||
use derive_more::{Display, From}; | ||
#[cfg(feature = "state-transition-serde-conversion")] | ||
use serde::{Deserialize, Serialize}; | ||
pub use v0::TokenEmergencyActionTransitionV0; | ||
|
||
#[derive(Debug, Clone, Encode, Decode, PartialEq, Display, From)] | ||
#[cfg_attr( | ||
feature = "state-transition-serde-conversion", | ||
derive(Serialize, Deserialize) | ||
)] | ||
pub enum TokenEmergencyActionTransition { | ||
#[display("V0({})", "_0")] | ||
V0(TokenEmergencyActionTransitionV0), | ||
} | ||
|
||
impl Default for TokenEmergencyActionTransition { | ||
fn default() -> Self { | ||
TokenEmergencyActionTransition::V0(TokenEmergencyActionTransitionV0::default()) | ||
// since only v0 | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
.../document/batch_transition/batched_transition/token_emergency_action_transition/v0/mod.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,30 @@ | ||
pub mod v0_methods; | ||
|
||
use crate::state_transition::batch_transition::token_base_transition::TokenBaseTransition; | ||
use crate::tokens::emergency_action::TokenEmergencyAction; | ||
use bincode::{Decode, Encode}; | ||
#[cfg(feature = "state-transition-serde-conversion")] | ||
use serde::{Deserialize, Serialize}; | ||
use std::fmt; | ||
|
||
#[derive(Debug, Clone, Default, Encode, Decode, PartialEq)] | ||
#[cfg_attr( | ||
feature = "state-transition-serde-conversion", | ||
derive(Serialize, Deserialize), | ||
serde(rename_all = "camelCase") | ||
)] | ||
pub struct TokenEmergencyActionTransitionV0 { | ||
/// Document Base Transition | ||
#[cfg_attr(feature = "state-transition-serde-conversion", serde(flatten))] | ||
pub base: TokenBaseTransition, | ||
/// The emergency action | ||
pub emergency_action: TokenEmergencyAction, | ||
/// The public note | ||
pub public_note: Option<String>, | ||
} | ||
|
||
impl fmt::Display for TokenEmergencyActionTransitionV0 { | ||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
write!(f, "Base: {}", self.base) | ||
} | ||
} |
Oops, something went wrong.