-
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
f886d8d
commit dc8e575
Showing
46 changed files
with
1,013 additions
and
162 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,33 @@ | ||
use crate::data_contract::accessors::v0::{DataContractV0Getters, DataContractV0Setters}; | ||
use crate::data_contract::associated_token::token_configuration::TokenConfiguration; | ||
use crate::data_contract::group::{Group, GroupName}; | ||
use crate::data_contract::TokenName; | ||
use crate::data_contract::TokenContractPosition; | ||
use std::collections::BTreeMap; | ||
|
||
pub trait DataContractV1Getters: DataContractV0Getters { | ||
/// Returns a reference to the groups map. | ||
fn groups(&self) -> &BTreeMap<GroupName, Group>; | ||
|
||
/// Returns a mutable reference to the groups map. | ||
fn groups_mut(&mut self) -> &mut BTreeMap<GroupName, Group>; | ||
fn groups_mut(&mut self) -> Option<&mut BTreeMap<GroupName, Group>>; | ||
|
||
/// Returns a reference to the tokens map. | ||
fn tokens(&self) -> &BTreeMap<TokenName, TokenConfiguration>; | ||
fn tokens(&self) -> &BTreeMap<TokenContractPosition, TokenConfiguration>; | ||
|
||
/// Returns a mutable reference to the tokens map. | ||
fn tokens_mut(&mut self) -> &mut BTreeMap<TokenName, TokenConfiguration>; | ||
fn tokens_mut(&mut self) -> Option<&mut BTreeMap<TokenContractPosition, TokenConfiguration>>; | ||
} | ||
|
||
pub trait DataContractV1Setters: DataContractV0Setters { | ||
/// Sets the groups map for the data contract. | ||
fn set_groups(&mut self, groups: BTreeMap<GroupName, Group>); | ||
|
||
/// Sets the tokens map for the data contract. | ||
fn set_tokens(&mut self, tokens: BTreeMap<TokenName, TokenConfiguration>); | ||
fn set_tokens(&mut self, tokens: BTreeMap<TokenContractPosition, TokenConfiguration>); | ||
|
||
/// Adds or updates a single group in the groups map. | ||
fn add_group(&mut self, name: GroupName, group: Group); | ||
|
||
/// Adds or updates a single token configuration in the tokens map. | ||
fn add_token(&mut self, name: TokenName, token: TokenConfiguration); | ||
fn add_token(&mut self, pos: TokenContractPosition, token: TokenConfiguration); | ||
} |
193 changes: 193 additions & 0 deletions
193
packages/rs-dpp/src/data_contract/associated_token/token_configuration/accessors/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,193 @@ | ||
pub mod v0; | ||
|
||
use crate::data_contract::associated_token::token_configuration::accessors::v0::{ | ||
TokenConfigurationV0Getters, TokenConfigurationV0Setters, | ||
}; | ||
use crate::data_contract::associated_token::token_configuration::v0::TokenConfigurationConventionV0; | ||
use crate::data_contract::associated_token::token_configuration::TokenConfiguration; | ||
use crate::data_contract::change_control_rules::authorized_action_takers::AuthorizedActionTakers; | ||
use crate::data_contract::change_control_rules::ChangeControlRules; | ||
use crate::data_contract::group::RequiredSigners; | ||
use platform_value::Identifier; | ||
use std::collections::BTreeSet; | ||
|
||
/// Implementing TokenConfigurationV0Getters for TokenConfiguration | ||
impl TokenConfigurationV0Getters for TokenConfiguration { | ||
/// Returns a reference to the conventions. | ||
fn conventions(&self) -> &TokenConfigurationConventionV0 { | ||
match self { | ||
TokenConfiguration::V0(v0) => v0.conventions(), | ||
} | ||
} | ||
|
||
/// Returns a mutable reference to the conventions. | ||
fn conventions_mut(&mut self) -> &mut TokenConfigurationConventionV0 { | ||
match self { | ||
TokenConfiguration::V0(v0) => v0.conventions_mut(), | ||
} | ||
} | ||
|
||
/// Returns the base supply. | ||
fn base_supply(&self) -> u64 { | ||
match self { | ||
TokenConfiguration::V0(v0) => v0.base_supply(), | ||
} | ||
} | ||
|
||
/// Returns the maximum supply. | ||
fn max_supply(&self) -> Option<u64> { | ||
match self { | ||
TokenConfiguration::V0(v0) => v0.max_supply(), | ||
} | ||
} | ||
|
||
/// Returns the max supply change rules. | ||
fn max_supply_change_rules(&self) -> &ChangeControlRules { | ||
match self { | ||
TokenConfiguration::V0(v0) => v0.max_supply_change_rules(), | ||
} | ||
} | ||
|
||
/// Returns the new tokens destination identity. | ||
fn new_tokens_destination_identity(&self) -> Option<Identifier> { | ||
match self { | ||
TokenConfiguration::V0(v0) => v0.new_tokens_destination_identity(), | ||
} | ||
} | ||
|
||
/// Returns the new tokens destination identity rules. | ||
fn new_tokens_destination_identity_rules(&self) -> &ChangeControlRules { | ||
match self { | ||
TokenConfiguration::V0(v0) => v0.new_tokens_destination_identity_rules(), | ||
} | ||
} | ||
|
||
/// Returns the manual minting rules. | ||
fn manual_minting_rules(&self) -> &ChangeControlRules { | ||
match self { | ||
TokenConfiguration::V0(v0) => v0.manual_minting_rules(), | ||
} | ||
} | ||
|
||
/// Returns the manual burning rules. | ||
fn manual_burning_rules(&self) -> &ChangeControlRules { | ||
match self { | ||
TokenConfiguration::V0(v0) => v0.manual_burning_rules(), | ||
} | ||
} | ||
|
||
/// Returns the freeze rules. | ||
fn freeze_rules(&self) -> &ChangeControlRules { | ||
match self { | ||
TokenConfiguration::V0(v0) => v0.freeze_rules(), | ||
} | ||
} | ||
|
||
/// Returns the unfreeze rules. | ||
fn unfreeze_rules(&self) -> &ChangeControlRules { | ||
match self { | ||
TokenConfiguration::V0(v0) => v0.unfreeze_rules(), | ||
} | ||
} | ||
|
||
/// Returns the main control group. | ||
fn main_control_group(&self) -> Option<&(BTreeSet<Identifier>, RequiredSigners)> { | ||
match self { | ||
TokenConfiguration::V0(v0) => v0.main_control_group(), | ||
} | ||
} | ||
|
||
/// Returns the main control group can be modified. | ||
fn main_control_group_can_be_modified(&self) -> &AuthorizedActionTakers { | ||
match self { | ||
TokenConfiguration::V0(v0) => v0.main_control_group_can_be_modified(), | ||
} | ||
} | ||
} | ||
|
||
/// Implementing TokenConfigurationV0Setters for TokenConfiguration | ||
impl TokenConfigurationV0Setters for TokenConfiguration { | ||
/// Sets the conventions. | ||
fn set_conventions(&mut self, conventions: TokenConfigurationConventionV0) { | ||
match self { | ||
TokenConfiguration::V0(v0) => v0.set_conventions(conventions), | ||
} | ||
} | ||
|
||
/// Sets the base supply. | ||
fn set_base_supply(&mut self, base_supply: u64) { | ||
match self { | ||
TokenConfiguration::V0(v0) => v0.set_base_supply(base_supply), | ||
} | ||
} | ||
|
||
/// Sets the maximum supply. | ||
fn set_max_supply(&mut self, max_supply: Option<u64>) { | ||
match self { | ||
TokenConfiguration::V0(v0) => v0.set_max_supply(max_supply), | ||
} | ||
} | ||
|
||
/// Sets the max supply change rules. | ||
fn set_max_supply_change_rules(&mut self, rules: ChangeControlRules) { | ||
match self { | ||
TokenConfiguration::V0(v0) => v0.set_max_supply_change_rules(rules), | ||
} | ||
} | ||
|
||
/// Sets the new tokens destination identity. | ||
fn set_new_tokens_destination_identity(&mut self, id: Option<Identifier>) { | ||
match self { | ||
TokenConfiguration::V0(v0) => v0.set_new_tokens_destination_identity(id), | ||
} | ||
} | ||
|
||
/// Sets the new tokens destination identity rules. | ||
fn set_new_tokens_destination_identity_rules(&mut self, rules: ChangeControlRules) { | ||
match self { | ||
TokenConfiguration::V0(v0) => v0.set_new_tokens_destination_identity_rules(rules), | ||
} | ||
} | ||
|
||
/// Sets the manual minting rules. | ||
fn set_manual_minting_rules(&mut self, rules: ChangeControlRules) { | ||
match self { | ||
TokenConfiguration::V0(v0) => v0.set_manual_minting_rules(rules), | ||
} | ||
} | ||
|
||
/// Sets the manual burning rules. | ||
fn set_manual_burning_rules(&mut self, rules: ChangeControlRules) { | ||
match self { | ||
TokenConfiguration::V0(v0) => v0.set_manual_burning_rules(rules), | ||
} | ||
} | ||
|
||
/// Sets the freeze rules. | ||
fn set_freeze_rules(&mut self, rules: ChangeControlRules) { | ||
match self { | ||
TokenConfiguration::V0(v0) => v0.set_freeze_rules(rules), | ||
} | ||
} | ||
|
||
/// Sets the unfreeze rules. | ||
fn set_unfreeze_rules(&mut self, rules: ChangeControlRules) { | ||
match self { | ||
TokenConfiguration::V0(v0) => v0.set_unfreeze_rules(rules), | ||
} | ||
} | ||
|
||
/// Sets the main control group. | ||
fn set_main_control_group(&mut self, group: Option<(BTreeSet<Identifier>, RequiredSigners)>) { | ||
match self { | ||
TokenConfiguration::V0(v0) => v0.set_main_control_group(group), | ||
} | ||
} | ||
|
||
/// Sets the main control group can be modified. | ||
fn set_main_control_group_can_be_modified(&mut self, action_takers: AuthorizedActionTakers) { | ||
match self { | ||
TokenConfiguration::V0(v0) => v0.set_main_control_group_can_be_modified(action_takers), | ||
} | ||
} | ||
} |
Oops, something went wrong.