-
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
a34ff06
commit 279d16f
Showing
12 changed files
with
142 additions
and
166 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
24 changes: 24 additions & 0 deletions
24
...ions/document/documents_batch_transition/document_transition/token_burn_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,24 @@ | ||
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::TokenBurnTransitionV0; | ||
|
||
#[derive(Debug, Clone, Encode, Decode, PartialEq, Display, From)] | ||
#[cfg_attr( | ||
feature = "state-transition-serde-conversion", | ||
derive(Serialize, Deserialize) | ||
)] | ||
pub enum TokenBurnTransition { | ||
#[display("V0({})", "_0")] | ||
V0(TokenBurnTransitionV0), | ||
} | ||
|
||
impl Default for TokenBurnTransition { | ||
fn default() -> Self { | ||
TokenBurnTransition::V0(TokenBurnTransitionV0::default()) // since only v0 | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...s/document/documents_batch_transition/document_transition/token_burn_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,29 @@ | ||
pub mod v0_methods; | ||
|
||
use crate::state_transition::documents_batch_transition::token_base_transition::TokenBaseTransition; | ||
use bincode::{Decode, Encode}; | ||
use derive_more::Display; | ||
#[cfg(feature = "state-transition-serde-conversion")] | ||
use serde::{Deserialize, Serialize}; | ||
|
||
mod property_names { | ||
pub const AMOUNT: &str = "$amount"; | ||
} | ||
/// The Identifier fields in [`TokenBurnTransition`] | ||
pub use super::super::document_base_transition::IDENTIFIER_FIELDS; | ||
|
||
#[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}, Amount: {burn_amount}")] | ||
pub struct TokenBurnTransitionV0 { | ||
/// Document Base Transition | ||
#[cfg_attr(feature = "state-transition-serde-conversion", serde(flatten))] | ||
pub base: TokenBaseTransition, | ||
|
||
/// How much should we burn | ||
pub burn_amount: u64, | ||
} |
33 changes: 33 additions & 0 deletions
33
...ent/documents_batch_transition/document_transition/token_burn_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,33 @@ | ||
use crate::state_transition::documents_batch_transition::token_base_transition::token_base_transition_accessors::TokenBaseTransitionAccessors; | ||
use crate::state_transition::documents_batch_transition::token_base_transition::TokenBaseTransition; | ||
use crate::state_transition::documents_batch_transition::token_burn_transition::TokenBurnTransitionV0; | ||
|
||
impl TokenBaseTransitionAccessors for TokenBurnTransitionV0 { | ||
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 TokenBurnTransitionV0Methods: TokenBaseTransitionAccessors { | ||
fn burn_amount(&self) -> u64; | ||
|
||
fn set_burn_amount(&mut self, amount: u64); | ||
} | ||
|
||
impl TokenBurnTransitionV0Methods for TokenBurnTransitionV0 { | ||
fn burn_amount(&self) -> u64 { | ||
self.burn_amount | ||
} | ||
|
||
fn set_burn_amount(&mut self, amount: u64) { | ||
self.burn_amount = amount; | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
...cument/documents_batch_transition/document_transition/token_burn_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,38 @@ | ||
use crate::state_transition::documents_batch_transition::token_base_transition::token_base_transition_accessors::TokenBaseTransitionAccessors; | ||
use crate::state_transition::documents_batch_transition::token_base_transition::TokenBaseTransition; | ||
use crate::state_transition::documents_batch_transition::token_burn_transition::TokenBurnTransition; | ||
use crate::state_transition::documents_batch_transition::token_burn_transition::v0::v0_methods::TokenBurnTransitionV0Methods; | ||
|
||
impl TokenBaseTransitionAccessors for TokenBurnTransition { | ||
fn base(&self) -> &TokenBaseTransition { | ||
match self { | ||
TokenBurnTransition::V0(v0) => &v0.base, | ||
} | ||
} | ||
|
||
fn base_mut(&mut self) -> &mut TokenBaseTransition { | ||
match self { | ||
TokenBurnTransition::V0(v0) => &mut v0.base, | ||
} | ||
} | ||
|
||
fn set_base(&mut self, base: TokenBaseTransition) { | ||
match self { | ||
TokenBurnTransition::V0(v0) => v0.base = base, | ||
} | ||
} | ||
} | ||
|
||
impl TokenBurnTransitionV0Methods for TokenBurnTransition { | ||
fn burn_amount(&self) -> u64 { | ||
match self { | ||
TokenBurnTransition::V0(v0) => v0.burn_amount(), | ||
} | ||
} | ||
|
||
fn set_burn_amount(&mut self, burn_amount: u64) { | ||
match self { | ||
TokenBurnTransition::V0(v0) => v0.set_burn_amount(burn_amount), | ||
} | ||
} | ||
} |
145 changes: 0 additions & 145 deletions
145
...t/documents_batch_transition/document_transition/token_issuance_transition/convertible.rs
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
.../document/documents_batch_transition/document_transition/token_issuance_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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
mod convertible; | ||
pub mod v0; | ||
mod v0_methods; | ||
|
||
|
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
Oops, something went wrong.