Skip to content

Commit e23bcda

Browse files
a lot more work
1 parent 40316c0 commit e23bcda

File tree

65 files changed

+1526
-270
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1526
-270
lines changed

packages/data-contracts/src/error.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,4 +136,3 @@ impl From<token_history_contract::Error> for Error {
136136
}
137137
}
138138
}
139-

packages/data-contracts/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ pub use feature_flags_contract;
99
pub use masternode_reward_shares_contract;
1010
use platform_value::Identifier;
1111
use platform_version::version::PlatformVersion;
12+
pub use token_history_contract;
1213
pub use wallet_utils_contract;
1314
pub use withdrawals_contract;
14-
pub use token_history_contract;
1515

1616
#[repr(u8)]
1717
#[derive(PartialEq, Eq, Clone, Copy, Debug, Ord, PartialOrd, Hash)]

packages/rs-dpp/src/data_contract/accessors/v1/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ use crate::data_contract::accessors::v0::{DataContractV0Getters, DataContractV0S
22
use crate::data_contract::associated_token::token_configuration::TokenConfiguration;
33
use crate::data_contract::group::{Group, GroupName};
44
use crate::data_contract::TokenContractPosition;
5-
use std::collections::BTreeMap;
65
use platform_value::Identifier;
6+
use std::collections::BTreeMap;
77

88
pub trait DataContractV1Getters: DataContractV0Getters {
99
/// Returns a reference to the groups map.
@@ -17,7 +17,7 @@ pub trait DataContractV1Getters: DataContractV0Getters {
1717

1818
/// Returns a mutable reference to the tokens map.
1919
fn tokens_mut(&mut self) -> Option<&mut BTreeMap<TokenContractPosition, TokenConfiguration>>;
20-
20+
2121
/// Returns the token id at a certain position
2222
fn token_id(&self, position: TokenContractPosition) -> Option<Identifier>;
2323
}

packages/rs-dpp/src/data_contract/associated_token/token_configuration/accessors/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ impl TokenConfigurationV0Getters for TokenConfiguration {
3434
}
3535
}
3636

37+
/// Returns if we keep history.
38+
fn keeps_history(&self) -> bool {
39+
match self {
40+
TokenConfiguration::V0(v0) => v0.keeps_history(),
41+
}
42+
}
43+
3744
/// Returns the maximum supply.
3845
fn max_supply(&self) -> Option<u64> {
3946
match self {

packages/rs-dpp/src/data_contract/associated_token/token_configuration/accessors/v0/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::data_contract::associated_token::token_configuration::v0::TokenConfigurationConventionV0;
2+
use crate::data_contract::associated_token::token_configuration::TokenConfiguration;
23
use crate::data_contract::change_control_rules::authorized_action_takers::AuthorizedActionTakers;
34
use crate::data_contract::change_control_rules::ChangeControlRules;
45
use crate::data_contract::group::RequiredSigners;
@@ -15,6 +16,8 @@ pub trait TokenConfigurationV0Getters {
1516

1617
/// Returns the base supply.
1718
fn base_supply(&self) -> u64;
19+
/// Returns the base supply.
20+
fn keeps_history(&self) -> bool;
1821

1922
/// Returns the maximum supply.
2023
fn max_supply(&self) -> Option<u64>;

packages/rs-dpp/src/data_contract/associated_token/token_configuration/v0/accessors.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ impl TokenConfigurationV0Getters for TokenConfigurationV0 {
2727
self.base_supply
2828
}
2929

30+
/// Returns if we keep history.
31+
fn keeps_history(&self) -> bool {
32+
self.keeps_history
33+
}
34+
3035
/// Returns the maximum supply.
3136
fn max_supply(&self) -> Option<u64> {
3237
self.max_supply

packages/rs-dpp/src/data_contract/associated_token/token_configuration/v0/mod.rs

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
mod accessors;
22

33
use crate::data_contract::change_control_rules::authorized_action_takers::AuthorizedActionTakers;
4+
use crate::data_contract::change_control_rules::v0::ChangeControlRulesV0;
45
use crate::data_contract::change_control_rules::ChangeControlRules;
56
use crate::data_contract::group::RequiredSigners;
67
use crate::identity::state_transition::asset_lock_proof::{Decode, Encode};
78
use platform_value::Identifier;
89
use serde::{Deserialize, Serialize};
910
use std::collections::{BTreeMap, BTreeSet};
1011
use std::fmt;
11-
use crate::data_contract::change_control_rules::v0::ChangeControlRulesV0;
1212

1313
#[derive(Serialize, Deserialize, Decode, Encode, Debug, Clone, PartialEq, Eq)]
1414
#[serde(rename_all = "camelCase")]
@@ -33,6 +33,8 @@ pub struct TokenConfigurationV0 {
3333
pub base_supply: u64,
3434
/// The maximum supply the token can ever have
3535
pub max_supply: Option<u64>,
36+
/// Do we keep history, default is true.
37+
pub keeps_history: bool,
3638
/// Who can change the max supply
3739
/// Even if set no one can ever change this under the base supply
3840
pub max_supply_change_rules: ChangeControlRules,
@@ -71,46 +73,56 @@ impl fmt::Display for TokenConfigurationV0 {
7173
impl TokenConfigurationV0 {
7274
pub fn default_most_restrictive() -> Self {
7375
Self {
74-
conventions: TokenConfigurationConventionV0 { localizations: Default::default(), decimals: 8 },
76+
conventions: TokenConfigurationConventionV0 {
77+
localizations: Default::default(),
78+
decimals: 8,
79+
},
7580
base_supply: 100000,
7681
max_supply: None,
82+
keeps_history: true,
7783
max_supply_change_rules: ChangeControlRulesV0 {
7884
authorized_to_make_change: AuthorizedActionTakers::NoOne,
7985
authorized_to_change_authorized_action_takers: AuthorizedActionTakers::NoOne,
8086
changing_authorized_action_takers_to_no_one_allowed: false,
8187
changing_authorized_action_takers_to_contract_owner_allowed: false,
82-
}.into(),
88+
}
89+
.into(),
8390
new_tokens_destination_identity: None,
8491
new_tokens_destination_identity_rules: ChangeControlRulesV0 {
8592
authorized_to_make_change: AuthorizedActionTakers::NoOne,
8693
authorized_to_change_authorized_action_takers: AuthorizedActionTakers::NoOne,
8794
changing_authorized_action_takers_to_no_one_allowed: false,
8895
changing_authorized_action_takers_to_contract_owner_allowed: false,
89-
}.into(),
96+
}
97+
.into(),
9098
manual_minting_rules: ChangeControlRulesV0 {
9199
authorized_to_make_change: AuthorizedActionTakers::NoOne,
92100
authorized_to_change_authorized_action_takers: AuthorizedActionTakers::NoOne,
93101
changing_authorized_action_takers_to_no_one_allowed: false,
94102
changing_authorized_action_takers_to_contract_owner_allowed: false,
95-
}.into(),
103+
}
104+
.into(),
96105
manual_burning_rules: ChangeControlRulesV0 {
97106
authorized_to_make_change: AuthorizedActionTakers::NoOne,
98107
authorized_to_change_authorized_action_takers: AuthorizedActionTakers::NoOne,
99108
changing_authorized_action_takers_to_no_one_allowed: false,
100109
changing_authorized_action_takers_to_contract_owner_allowed: false,
101-
}.into(),
110+
}
111+
.into(),
102112
freeze_rules: ChangeControlRulesV0 {
103113
authorized_to_make_change: AuthorizedActionTakers::NoOne,
104114
authorized_to_change_authorized_action_takers: AuthorizedActionTakers::NoOne,
105115
changing_authorized_action_takers_to_no_one_allowed: false,
106116
changing_authorized_action_takers_to_contract_owner_allowed: false,
107-
}.into(),
117+
}
118+
.into(),
108119
unfreeze_rules: ChangeControlRulesV0 {
109120
authorized_to_make_change: AuthorizedActionTakers::NoOne,
110121
authorized_to_change_authorized_action_takers: AuthorizedActionTakers::NoOne,
111122
changing_authorized_action_takers_to_no_one_allowed: false,
112123
changing_authorized_action_takers_to_contract_owner_allowed: false,
113-
}.into(),
124+
}
125+
.into(),
114126
main_control_group: None,
115127
main_control_group_can_be_modified: AuthorizedActionTakers::NoOne,
116128
}

packages/rs-dpp/src/data_contract/v1/accessors/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ use crate::data_contract::accessors::v1::{DataContractV1Getters, DataContractV1S
1111
use crate::data_contract::associated_token::token_configuration::TokenConfiguration;
1212
use crate::data_contract::document_type::accessors::DocumentTypeV0Getters;
1313
use crate::data_contract::group::{Group, GroupName};
14+
use crate::util::hash::hash_double;
1415
use platform_value::Identifier;
1516
use std::collections::BTreeMap;
16-
use crate::util::hash::hash_double;
1717

1818
impl DataContractV0Getters for DataContractV1 {
1919
fn id(&self) -> Identifier {

packages/rs-dpp/src/document/generate_document_id.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::document::Document;
2+
use crate::prelude::IdentityNonce;
23
use crate::{prelude::Identifier, util::hash::hash_double_to_vec};
34

45
impl Document {

packages/rs-dpp/src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,15 @@ pub mod prelude {
8888
pub type Revision = u64;
8989
pub type IdentityNonce = u64;
9090

91+
pub type SenderKeyIndex = u32;
92+
pub type RecipientKeyIndex = u32;
93+
94+
/// The index of the user's key that is used to derive keys that will be used to encrypt the contact's user id in encToUserId and the private data.
95+
pub type RootEncryptionKeyIndex = u32;
96+
97+
/// The index at which to derive the root encryption key.
98+
pub type DerivationEncryptionKeyIndex = u32;
99+
91100
/// UserFeeIncrease is the additional percentage of the processing fee.
92101
/// A 1 here means we pay 1% more in processing fees. A 100 means we pay 100% more.
93102
pub type UserFeeIncrease = u16;

0 commit comments

Comments
 (0)