-
Notifications
You must be signed in to change notification settings - Fork 44
feat(dpp): add marketplace rules to token configuration #2635
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
43 changes: 43 additions & 0 deletions
43
packages/rs-dpp/src/data_contract/associated_token/token_marketplace_rules/accessors/mod.rs
This file contains hidden or 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,43 @@ | ||
| use crate::data_contract::associated_token::token_marketplace_rules::accessors::v0::{ | ||
| TokenMarketplaceRulesV0Getters, TokenMarketplaceRulesV0Setters, | ||
| }; | ||
| use crate::data_contract::associated_token::token_marketplace_rules::v0::TokenTradeMode; | ||
| use crate::data_contract::associated_token::token_marketplace_rules::TokenMarketplaceRules; | ||
| use crate::data_contract::change_control_rules::ChangeControlRules; | ||
|
|
||
| pub mod v0; | ||
| /// Implementing `TokenMarketplaceRulesV0Getters` for `TokenMarketplaceRules` | ||
| impl TokenMarketplaceRulesV0Getters for TokenMarketplaceRules { | ||
| fn trade_mode(&self) -> &TokenTradeMode { | ||
| match self { | ||
| TokenMarketplaceRules::V0(inner) => inner.trade_mode(), | ||
| } | ||
| } | ||
|
|
||
| fn trade_mode_change_rules(&self) -> &ChangeControlRules { | ||
| match self { | ||
| TokenMarketplaceRules::V0(inner) => inner.trade_mode_change_rules(), | ||
| } | ||
| } | ||
|
|
||
| fn trade_mode_change_rules_mut(&mut self) -> &mut ChangeControlRules { | ||
| match self { | ||
| TokenMarketplaceRules::V0(inner) => inner.trade_mode_change_rules_mut(), | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /// Implementing `TokenMarketplaceRulesV0Setters` for `TokenMarketplaceRules` | ||
| impl TokenMarketplaceRulesV0Setters for TokenMarketplaceRules { | ||
| fn set_trade_mode(&mut self, trade_mode: TokenTradeMode) { | ||
| match self { | ||
| TokenMarketplaceRules::V0(inner) => inner.set_trade_mode(trade_mode), | ||
| } | ||
| } | ||
|
|
||
| fn set_trade_mode_change_rules(&mut self, rules: ChangeControlRules) { | ||
| match self { | ||
| TokenMarketplaceRules::V0(inner) => inner.set_trade_mode_change_rules(rules), | ||
| } | ||
| } | ||
| } |
23 changes: 23 additions & 0 deletions
23
...ges/rs-dpp/src/data_contract/associated_token/token_marketplace_rules/accessors/v0/mod.rs
This file contains hidden or 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,23 @@ | ||
| use crate::data_contract::associated_token::token_marketplace_rules::v0::TokenTradeMode; | ||
| use crate::data_contract::change_control_rules::ChangeControlRules; | ||
|
|
||
| /// Trait for read accessors for `TokenMarketplaceRulesV0` | ||
| pub trait TokenMarketplaceRulesV0Getters { | ||
| /// Returns the current trade mode for the token | ||
| fn trade_mode(&self) -> &TokenTradeMode; | ||
|
|
||
| /// Returns the change control rules for modifying the trade mode | ||
| fn trade_mode_change_rules(&self) -> &ChangeControlRules; | ||
|
|
||
| /// Returns the change control rules as mutable for modifying the trade mode | ||
| fn trade_mode_change_rules_mut(&mut self) -> &mut ChangeControlRules; | ||
| } | ||
|
|
||
| /// Trait for mutation accessors for `TokenMarketplaceRulesV0` | ||
| pub trait TokenMarketplaceRulesV0Setters { | ||
| /// Sets a new trade mode for the token | ||
| fn set_trade_mode(&mut self, trade_mode: TokenTradeMode); | ||
|
|
||
| /// Sets new change control rules for the trade mode | ||
| fn set_trade_mode_change_rules(&mut self, rules: ChangeControlRules); | ||
| } |
26 changes: 26 additions & 0 deletions
26
packages/rs-dpp/src/data_contract/associated_token/token_marketplace_rules/mod.rs
This file contains hidden or 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,26 @@ | ||
| use bincode::{Decode, Encode}; | ||
| use derive_more::From; | ||
| use serde::{Deserialize, Serialize}; | ||
|
|
||
| pub mod accessors; | ||
| pub mod v0; | ||
|
|
||
| #[derive(Serialize, Deserialize, Encode, Decode, Debug, Clone, PartialEq, Eq, From)] | ||
| #[serde(tag = "$format_version")] | ||
| pub enum TokenMarketplaceRules { | ||
| #[serde(rename = "0")] | ||
| V0(TokenMarketplaceRulesV0), | ||
| } | ||
|
|
||
| use crate::data_contract::associated_token::token_marketplace_rules::v0::TokenMarketplaceRulesV0; | ||
| use std::fmt; | ||
|
|
||
| impl fmt::Display for TokenMarketplaceRules { | ||
| fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
| match self { | ||
| TokenMarketplaceRules::V0(v0) => { | ||
| write!(f, "{}", v0) //just pass through | ||
| } | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.