diff --git a/packages/rs-dpp/src/document/document_factory/v0/mod.rs b/packages/rs-dpp/src/document/document_factory/v0/mod.rs index 2fe4f9d922c..fdfe9bc248d 100644 --- a/packages/rs-dpp/src/document/document_factory/v0/mod.rs +++ b/packages/rs-dpp/src/document/document_factory/v0/mod.rs @@ -237,6 +237,7 @@ impl DocumentFactoryV0 { Ok(DocumentsBatchTransitionV0 { owner_id, transitions, + user_fee_increase: 0, signature_public_key_id: 0, signature: Default::default(), } diff --git a/packages/rs-dpp/src/document/specialized_document_factory/v0/mod.rs b/packages/rs-dpp/src/document/specialized_document_factory/v0/mod.rs index c3fc31defb2..0d844c6ba62 100644 --- a/packages/rs-dpp/src/document/specialized_document_factory/v0/mod.rs +++ b/packages/rs-dpp/src/document/specialized_document_factory/v0/mod.rs @@ -246,6 +246,7 @@ impl SpecializedDocumentFactoryV0 { Ok(DocumentsBatchTransitionV0 { owner_id, transitions, + user_fee_increase: 0, signature_public_key_id: 0, signature: Default::default(), } diff --git a/packages/rs-dpp/src/fee/default_costs/constants.rs b/packages/rs-dpp/src/fee/default_costs/constants.rs index f93be480f1c..a3afb06691e 100644 --- a/packages/rs-dpp/src/fee/default_costs/constants.rs +++ b/packages/rs-dpp/src/fee/default_costs/constants.rs @@ -1,7 +1,7 @@ use crate::fee::Credits; pub const BASE_ST_PROCESSING_FEE: Credits = 10000; // 84000 -pub const FEE_MULTIPLIER: Credits = 2; +pub const DEFAULT_SYSTEM_FEE_MULTIPLIER: Credits = 2; pub const DEFAULT_USER_TIP: Credits = 0; pub const STORAGE_CREDIT_PER_BYTE: Credits = 5000; pub const PROCESSING_CREDIT_PER_BYTE: Credits = 12; diff --git a/packages/rs-dpp/src/fee/fee_result/mod.rs b/packages/rs-dpp/src/fee/fee_result/mod.rs index 1956719049c..c58e7b97c25 100644 --- a/packages/rs-dpp/src/fee/fee_result/mod.rs +++ b/packages/rs-dpp/src/fee/fee_result/mod.rs @@ -41,6 +41,7 @@ use crate::consensus::fee::fee_error::FeeError; use crate::fee::fee_result::refunds::FeeRefunds; use crate::fee::fee_result::BalanceChange::{AddToBalance, NoBalanceChange, RemoveFromBalance}; use crate::fee::Credits; +use crate::prelude::UserFeeIncrease; use crate::ProtocolError; use platform_value::Identifier; use std::cmp::Ordering; @@ -192,6 +193,21 @@ impl FeeResult { removed_bytes_from_system: 0, } } + + /// Apply a fee multiplier to a fee result + pub fn apply_user_fee_increase(&mut self, add_fee_percentage_multiplier: UserFeeIncrease) { + let additional_processing_fee = (self.processing_fee as u128) + .saturating_mul(add_fee_percentage_multiplier as u128) + .saturating_div(100); + if additional_processing_fee > u64::MAX as u128 { + self.processing_fee = u64::MAX; + } else { + self.processing_fee = self + .processing_fee + .saturating_add(additional_processing_fee as u64); + } + } + /// Convenience method to get total fee pub fn total_base_fee(&self) -> Credits { self.storage_fee + self.processing_fee diff --git a/packages/rs-dpp/src/lib.rs b/packages/rs-dpp/src/lib.rs index e06eb659e91..1ebf54d0a79 100644 --- a/packages/rs-dpp/src/lib.rs +++ b/packages/rs-dpp/src/lib.rs @@ -65,6 +65,10 @@ pub mod prelude { pub type TimestampMillis = u64; pub type Revision = u64; pub type IdentityNonce = u64; + + /// UserFeeIncrease is the additional percentage of the processing fee. + /// A 1 here means we pay 1% more in processing fees. A 100 means we pay 100% more. + pub type UserFeeIncrease = u16; } pub use bincode; diff --git a/packages/rs-dpp/src/state_transition/mod.rs b/packages/rs-dpp/src/state_transition/mod.rs index b9dadd68e3d..2f079353f4b 100644 --- a/packages/rs-dpp/src/state_transition/mod.rs +++ b/packages/rs-dpp/src/state_transition/mod.rs @@ -63,7 +63,7 @@ use crate::identity::state_transition::OptionallyAssetLockProved; ))] use crate::identity::{IdentityPublicKey, KeyType, Purpose}; use crate::identity::{KeyID, SecurityLevel}; -use crate::prelude::AssetLockProof; +use crate::prelude::{AssetLockProof, UserFeeIncrease}; pub use state_transitions::*; use crate::serialization::Signable; @@ -315,6 +315,11 @@ impl StateTransition { call_method!(self, signature) } + /// returns the fee_increase additional percentage multiplier, it affects only processing costs + pub fn user_fee_increase(&self) -> UserFeeIncrease { + call_method!(self, user_fee_increase) + } + /// The transaction id is a single hash of the data with the signature pub fn transaction_id(&self) -> Result<[u8; 32], ProtocolError> { Ok(hash_single( @@ -347,6 +352,11 @@ impl StateTransition { call_method!(self, set_signature, signature) } + /// set fee multiplier + pub fn set_user_fee_increase(&mut self, fee_multiplier: UserFeeIncrease) { + call_method!(self, set_user_fee_increase, fee_multiplier) + } + /// set a new signature pub fn set_signature_public_key_id(&mut self, public_key_id: KeyID) { call_method_identity_signed!(self, set_signature_public_key_id, public_key_id) diff --git a/packages/rs-dpp/src/state_transition/serialization.rs b/packages/rs-dpp/src/state_transition/serialization.rs index 76889fe459b..5757fd76c3b 100644 --- a/packages/rs-dpp/src/state_transition/serialization.rs +++ b/packages/rs-dpp/src/state_transition/serialization.rs @@ -88,6 +88,7 @@ mod tests { let identity_topup_transition = IdentityTopUpTransitionV0 { asset_lock_proof: AssetLockProof::Instant(asset_lock_proof), identity_id: identity.id(), + user_fee_increase: 0, signature: [1u8; 65].to_vec().into(), }; let state_transition: StateTransition = identity_topup_transition.into(); @@ -125,6 +126,7 @@ mod tests { add_public_keys: add_public_keys_in_creation, disable_public_keys: vec![], public_keys_disabled_at: None, + user_fee_increase: 0, }; let key_signable_bytes = identity_update_transition @@ -192,6 +194,7 @@ mod tests { add_public_keys: add_public_keys_in_creation, disable_public_keys: vec![3, 4, 5], public_keys_disabled_at: Some(15), + user_fee_increase: 0, }; let key_signable_bytes = identity_update_transition @@ -246,6 +249,7 @@ mod tests { pooling: Pooling::Standard, output_script: CoreScript::from_bytes((0..23).collect::>()), nonce: 1, + user_fee_increase: 0, signature_public_key_id: 0, signature: [1u8; 65].to_vec().into(), }; @@ -296,6 +300,7 @@ mod tests { .data_contract_owned() .try_into_platform_versioned(platform_version) .expect("expected a data contract"), + user_fee_increase: 0, signature_public_key_id: 0, signature: [1u8; 65].to_vec().into(), }); diff --git a/packages/rs-dpp/src/state_transition/state_transitions/common_fields.rs b/packages/rs-dpp/src/state_transition/state_transitions/common_fields.rs index 9080f26523e..fc9a770f231 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/common_fields.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/common_fields.rs @@ -2,6 +2,8 @@ pub mod property_names { pub const STATE_TRANSITION_PROTOCOL_VERSION: &str = "$version"; pub const IDENTITY_CONTRACT_NONCE: &str = "identityContractNonce"; pub const IDENTITY_NONCE: &str = "identityNonce"; + + pub const USER_FEE_INCREASE: &str = "userFeeIncrease"; pub const SIGNATURE_PUBLIC_KEY_ID: &str = "signaturePublicKeyId"; pub const SIGNATURE: &str = "signature"; pub const TRANSITION_TYPE: &str = "type"; diff --git a/packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_create_transition/state_transition_like.rs b/packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_create_transition/state_transition_like.rs index 4c629619aba..e8c7765558b 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_create_transition/state_transition_like.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_create_transition/state_transition_like.rs @@ -1,3 +1,4 @@ +use crate::prelude::UserFeeIncrease; use crate::state_transition::data_contract_create_transition::DataContractCreateTransition; use crate::state_transition::{StateTransitionLike, StateTransitionType}; use crate::version::FeatureVersion; @@ -35,6 +36,21 @@ impl StateTransitionLike for DataContractCreateTransition { } } + /// returns the fee multiplier + fn user_fee_increase(&self) -> UserFeeIncrease { + match self { + DataContractCreateTransition::V0(transition) => transition.user_fee_increase(), + } + } + /// set a fee multiplier + fn set_user_fee_increase(&mut self, fee_multiplier: UserFeeIncrease) { + match self { + DataContractCreateTransition::V0(transition) => { + transition.set_user_fee_increase(fee_multiplier) + } + } + } + fn set_signature_bytes(&mut self, signature: Vec) { match self { DataContractCreateTransition::V0(transition) => { diff --git a/packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_create_transition/v0/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_create_transition/v0/mod.rs index 973d127f172..054004a6dc5 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_create_transition/v0/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_create_transition/v0/mod.rs @@ -18,7 +18,7 @@ use crate::{data_contract::DataContract, identity::KeyID, ProtocolError}; use crate::data_contract::created_data_contract::CreatedDataContract; use crate::data_contract::serialized_version::DataContractInSerializationFormat; -use crate::prelude::IdentityNonce; +use crate::prelude::{IdentityNonce, UserFeeIncrease}; use crate::state_transition::data_contract_create_transition::DataContractCreateTransition; use bincode::{Decode, Encode}; use platform_version::{TryFromPlatformVersioned, TryIntoPlatformVersioned}; @@ -37,6 +37,7 @@ use crate::version::PlatformVersion; pub struct DataContractCreateTransitionV0 { pub data_contract: DataContractInSerializationFormat, pub identity_nonce: IdentityNonce, + pub user_fee_increase: UserFeeIncrease, #[platform_signable(exclude_from_sig_hash)] pub signature_public_key_id: KeyID, #[platform_signable(exclude_from_sig_hash)] @@ -67,6 +68,7 @@ impl TryFromPlatformVersioned for DataContractCreateTransitionV0 { Ok(DataContractCreateTransitionV0 { data_contract: value.try_into_platform_versioned(platform_version)?, identity_nonce: Default::default(), + user_fee_increase: 0, signature_public_key_id: 0, signature: Default::default(), }) @@ -84,6 +86,7 @@ impl TryFromPlatformVersioned for DataContractCreateTransit Ok(DataContractCreateTransitionV0 { data_contract: data_contract.try_into_platform_versioned(platform_version)?, identity_nonce, + user_fee_increase: 0, signature_public_key_id: 0, signature: Default::default(), }) diff --git a/packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_create_transition/v0/state_transition_like.rs b/packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_create_transition/v0/state_transition_like.rs index d92fb6ec4e6..6f879c2b7e8 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_create_transition/v0/state_transition_like.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_create_transition/v0/state_transition_like.rs @@ -1,5 +1,6 @@ use platform_value::BinaryData; +use crate::prelude::UserFeeIncrease; use crate::{ prelude::Identifier, state_transition::{StateTransitionLike, StateTransitionType}, @@ -48,4 +49,12 @@ impl StateTransitionLike for DataContractCreateTransitionV0 { self.data_contract.id() )] } + + fn user_fee_increase(&self) -> UserFeeIncrease { + self.user_fee_increase + } + + fn set_user_fee_increase(&mut self, fee_multiplier: UserFeeIncrease) { + self.user_fee_increase = fee_multiplier + } } diff --git a/packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_create_transition/v0/v0_methods.rs b/packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_create_transition/v0/v0_methods.rs index 20eb5f00e90..ddf987f5a5e 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_create_transition/v0/v0_methods.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_create_transition/v0/v0_methods.rs @@ -38,6 +38,7 @@ impl DataContractCreateTransitionMethodsV0 for DataContractCreateTransitionV0 { let transition = DataContractCreateTransition::V0(DataContractCreateTransitionV0 { data_contract: data_contract.try_into_platform_versioned(platform_version)?, identity_nonce, + user_fee_increase: 0, signature_public_key_id: key_id, signature: Default::default(), }); diff --git a/packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_create_transition/v0/value_conversion.rs b/packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_create_transition/v0/value_conversion.rs index 64af95bf2c4..f79c2f765fd 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_create_transition/v0/value_conversion.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_create_transition/v0/value_conversion.rs @@ -11,6 +11,7 @@ use crate::data_contract::conversion::value::v0::DataContractValueConversionMeth use crate::state_transition::{StateTransitionFieldTypes, StateTransitionValueConvert}; use crate::state_transition::data_contract_create_transition::{DataContractCreateTransitionV0}; use crate::state_transition::data_contract_create_transition::fields::*; +use crate::state_transition::state_transitions::common_fields::property_names::USER_FEE_INCREASE; use crate::state_transition::state_transitions::contract::data_contract_create_transition::fields::{BINARY_FIELDS, IDENTIFIER_FIELDS, U32_FIELDS}; impl<'a> StateTransitionValueConvert<'a> for DataContractCreateTransitionV0 { @@ -41,6 +42,10 @@ impl<'a> StateTransitionValueConvert<'a> for DataContractCreateTransitionV0 { platform_version, )? .try_into_platform_versioned(platform_version)?, + user_fee_increase: raw_object + .get_optional_integer(USER_FEE_INCREASE) + .map_err(ProtocolError::ValueError)? + .unwrap_or_default(), }) } @@ -71,6 +76,10 @@ impl<'a> StateTransitionValueConvert<'a> for DataContractCreateTransitionV0 { platform_version, )? .try_into_platform_versioned(platform_version)?, + user_fee_increase: raw_value_map + .remove_optional_integer(USER_FEE_INCREASE) + .map_err(ProtocolError::ValueError)? + .unwrap_or_default(), }) } diff --git a/packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_update_transition/methods/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_update_transition/methods/mod.rs index 6f7196258e4..98522c59720 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_update_transition/methods/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_update_transition/methods/mod.rs @@ -12,7 +12,7 @@ use crate::state_transition::StateTransition; use crate::version::FeatureVersion; use crate::ProtocolError; -use crate::prelude::IdentityNonce; +use crate::prelude::{IdentityNonce, UserFeeIncrease}; use platform_version::version::PlatformVersion; impl DataContractUpdateTransitionMethodsV0 for DataContractUpdateTransition { @@ -21,6 +21,7 @@ impl DataContractUpdateTransitionMethodsV0 for DataContractUpdateTransition { identity: &PartialIdentity, key_id: KeyID, identity_contract_nonce: IdentityNonce, + user_fee_increase: UserFeeIncrease, signer: &S, platform_version: &PlatformVersion, feature_version: Option, @@ -37,6 +38,7 @@ impl DataContractUpdateTransitionMethodsV0 for DataContractUpdateTransition { identity, key_id, identity_contract_nonce, + user_fee_increase, signer, platform_version, feature_version, diff --git a/packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_update_transition/methods/v0/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_update_transition/methods/v0/mod.rs index eacbc8925da..1dd2d579b34 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_update_transition/methods/v0/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_update_transition/methods/v0/mod.rs @@ -2,7 +2,7 @@ use crate::data_contract::DataContract; use crate::identity::signer::Signer; use crate::identity::{KeyID, PartialIdentity}; -use crate::prelude::IdentityNonce; +use crate::prelude::{IdentityNonce, UserFeeIncrease}; use crate::state_transition::StateTransition; use crate::version::FeatureVersion; use crate::ProtocolError; @@ -27,6 +27,7 @@ pub trait DataContractUpdateTransitionMethodsV0 { identity: &PartialIdentity, key_id: KeyID, identity_contract_nonce: IdentityNonce, + user_fee_increase: UserFeeIncrease, signer: &S, platform_version: &PlatformVersion, feature_version: Option, diff --git a/packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_update_transition/state_transition_like.rs b/packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_update_transition/state_transition_like.rs index 64cd37651d8..7c03a33becc 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_update_transition/state_transition_like.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_update_transition/state_transition_like.rs @@ -1,3 +1,4 @@ +use crate::prelude::UserFeeIncrease; use crate::state_transition::data_contract_update_transition::DataContractUpdateTransition; use crate::state_transition::{StateTransitionLike, StateTransitionType}; use crate::version::FeatureVersion; @@ -54,4 +55,19 @@ impl StateTransitionLike for DataContractUpdateTransition { DataContractUpdateTransition::V0(transition) => transition.unique_identifiers(), } } + + /// returns the fee increase multiplier + fn user_fee_increase(&self) -> UserFeeIncrease { + match self { + DataContractUpdateTransition::V0(transition) => transition.user_fee_increase(), + } + } + /// set a fee increase multiplier + fn set_user_fee_increase(&mut self, user_fee_increase: UserFeeIncrease) { + match self { + DataContractUpdateTransition::V0(transition) => { + transition.set_user_fee_increase(user_fee_increase) + } + } + } } diff --git a/packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_update_transition/v0/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_update_transition/v0/mod.rs index 51b74438c6a..144d706ecca 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_update_transition/v0/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_update_transition/v0/mod.rs @@ -18,7 +18,7 @@ use platform_version::version::PlatformVersion; use platform_version::{TryFromPlatformVersioned, TryIntoPlatformVersioned}; use crate::data_contract::serialized_version::DataContractInSerializationFormat; -use crate::prelude::IdentityNonce; +use crate::prelude::{IdentityNonce, UserFeeIncrease}; use crate::state_transition::data_contract_update_transition::DataContractUpdateTransition; use crate::state_transition::StateTransition; use crate::{data_contract::DataContract, identity::KeyID, ProtocolError}; @@ -37,6 +37,7 @@ pub struct DataContractUpdateTransitionV0 { )] pub identity_contract_nonce: IdentityNonce, pub data_contract: DataContractInSerializationFormat, + pub user_fee_increase: UserFeeIncrease, #[platform_signable(exclude_from_sig_hash)] pub signature_public_key_id: KeyID, #[platform_signable(exclude_from_sig_hash)] @@ -53,6 +54,7 @@ impl TryFromPlatformVersioned<(DataContract, IdentityNonce)> for DataContractUpd Ok(DataContractUpdateTransitionV0 { identity_contract_nonce: value.1, data_contract: value.0.try_into_platform_versioned(platform_version)?, + user_fee_increase: 0, signature_public_key_id: 0, signature: Default::default(), }) diff --git a/packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_update_transition/v0/state_transition_like.rs b/packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_update_transition/v0/state_transition_like.rs index 54e7e1e452e..5ada17858d9 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_update_transition/v0/state_transition_like.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_update_transition/v0/state_transition_like.rs @@ -1,5 +1,6 @@ use platform_value::BinaryData; +use crate::prelude::UserFeeIncrease; use crate::{ prelude::Identifier, state_transition::{StateTransitionLike, StateTransitionType}, @@ -49,4 +50,12 @@ impl StateTransitionLike for DataContractUpdateTransitionV0 { self.identity_contract_nonce )] } + + fn user_fee_increase(&self) -> UserFeeIncrease { + self.user_fee_increase + } + + fn set_user_fee_increase(&mut self, fee_multiplier: UserFeeIncrease) { + self.user_fee_increase = fee_multiplier + } } diff --git a/packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_update_transition/v0/v0_methods.rs b/packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_update_transition/v0/v0_methods.rs index 00793419858..732b684b7ac 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_update_transition/v0/v0_methods.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_update_transition/v0/v0_methods.rs @@ -3,7 +3,7 @@ use crate::identity::signer::Signer; use crate::identity::{KeyID, PartialIdentity}; use crate::serialization::Signable; -use crate::prelude::IdentityNonce; +use crate::prelude::{IdentityNonce, UserFeeIncrease}; use crate::state_transition::data_contract_update_transition::methods::DataContractUpdateTransitionMethodsV0; use crate::state_transition::data_contract_update_transition::{ DataContractUpdateTransition, DataContractUpdateTransitionV0, @@ -20,6 +20,7 @@ impl DataContractUpdateTransitionMethodsV0 for DataContractUpdateTransitionV0 { identity: &PartialIdentity, key_id: KeyID, identity_contract_nonce: IdentityNonce, + user_fee_increase: UserFeeIncrease, signer: &S, platform_version: &PlatformVersion, _feature_version: Option, @@ -27,6 +28,7 @@ impl DataContractUpdateTransitionMethodsV0 for DataContractUpdateTransitionV0 { let transition = DataContractUpdateTransition::V0(DataContractUpdateTransitionV0 { identity_contract_nonce, data_contract: data_contract.try_into_platform_versioned(platform_version)?, + user_fee_increase, signature_public_key_id: key_id, signature: Default::default(), }); diff --git a/packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_update_transition/v0/value_conversion.rs b/packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_update_transition/v0/value_conversion.rs index 25d7cf90988..9759ab775b4 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_update_transition/v0/value_conversion.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_update_transition/v0/value_conversion.rs @@ -4,7 +4,9 @@ use crate::state_transition::data_contract_update_transition::fields::*; use crate::state_transition::data_contract_update_transition::{ DataContractUpdateTransitionV0, BINARY_FIELDS, IDENTIFIER_FIELDS, U32_FIELDS, }; -use crate::state_transition::state_transitions::common_fields::property_names::IDENTITY_CONTRACT_NONCE; +use crate::state_transition::state_transitions::common_fields::property_names::{ + IDENTITY_CONTRACT_NONCE, USER_FEE_INCREASE, +}; use crate::state_transition::StateTransitionFieldTypes; use crate::state_transition::StateTransitionValueConvert; use crate::ProtocolError; @@ -76,6 +78,10 @@ impl<'a> StateTransitionValueConvert<'a> for DataContractUpdateTransitionV0 { platform_version, )? .try_into_platform_versioned(platform_version)?, + user_fee_increase: raw_object + .get_optional_integer(USER_FEE_INCREASE) + .map_err(ProtocolError::ValueError)? + .unwrap_or_default(), }) } @@ -110,6 +116,10 @@ impl<'a> StateTransitionValueConvert<'a> for DataContractUpdateTransitionV0 { platform_version, )? .try_into_platform_versioned(platform_version)?, + user_fee_increase: raw_value_map + .remove_optional_integer(USER_FEE_INCREASE) + .map_err(ProtocolError::ValueError)? + .unwrap_or_default(), }) } diff --git a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/methods/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/methods/mod.rs index 034c61c6bf1..c44b929bc47 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/methods/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/methods/mod.rs @@ -6,7 +6,7 @@ use crate::document::Document; use crate::identity::signer::Signer; #[cfg(feature = "state-transition-signing")] use crate::identity::IdentityPublicKey; -use crate::prelude::IdentityNonce; +use crate::prelude::{IdentityNonce, UserFeeIncrease}; use crate::state_transition::documents_batch_transition::document_transition::DocumentTransition; use crate::state_transition::documents_batch_transition::methods::v0::DocumentsBatchTransitionMethodsV0; use crate::state_transition::documents_batch_transition::DocumentsBatchTransition; @@ -43,6 +43,7 @@ impl DocumentsBatchTransitionMethodsV0 for DocumentsBatchTransition { entropy: [u8; 32], identity_public_key: &IdentityPublicKey, identity_contract_nonce: IdentityNonce, + user_fee_increase: UserFeeIncrease, signer: &S, platform_version: &PlatformVersion, batch_feature_version: Option, @@ -63,6 +64,7 @@ impl DocumentsBatchTransitionMethodsV0 for DocumentsBatchTransition { entropy, identity_public_key, identity_contract_nonce, + user_fee_increase, signer, platform_version, batch_feature_version, @@ -84,6 +86,7 @@ impl DocumentsBatchTransitionMethodsV0 for DocumentsBatchTransition { document_type: DocumentTypeRef, identity_public_key: &IdentityPublicKey, identity_contract_nonce: IdentityNonce, + user_fee_increase: UserFeeIncrease, signer: &S, platform_version: &PlatformVersion, batch_feature_version: Option, @@ -103,6 +106,7 @@ impl DocumentsBatchTransitionMethodsV0 for DocumentsBatchTransition { document_type, identity_public_key, identity_contract_nonce, + user_fee_increase, signer, platform_version, batch_feature_version, diff --git a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/methods/v0/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/methods/v0/mod.rs index 38a3fdf9115..ef36e3ce411 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/methods/v0/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/methods/v0/mod.rs @@ -7,7 +7,7 @@ use crate::identity::signer::Signer; #[cfg(feature = "state-transition-signing")] use crate::identity::IdentityPublicKey; use crate::identity::SecurityLevel; -use crate::prelude::IdentityNonce; +use crate::prelude::{IdentityNonce, UserFeeIncrease}; use crate::state_transition::documents_batch_transition::accessors::DocumentsBatchTransitionAccessorsV0; use crate::state_transition::documents_batch_transition::document_base_transition::v0::v0_methods::DocumentBaseTransitionV0Methods; use crate::state_transition::documents_batch_transition::document_transition::{ @@ -29,6 +29,7 @@ pub trait DocumentsBatchTransitionMethodsV0: DocumentsBatchTransitionAccessorsV0 entropy: [u8; 32], identity_public_key: &IdentityPublicKey, identity_contract_nonce: IdentityNonce, + user_fee_increase: UserFeeIncrease, signer: &S, platform_version: &PlatformVersion, batch_feature_version: Option, @@ -42,6 +43,7 @@ pub trait DocumentsBatchTransitionMethodsV0: DocumentsBatchTransitionAccessorsV0 document_type: DocumentTypeRef, identity_public_key: &IdentityPublicKey, identity_contract_nonce: IdentityNonce, + user_fee_increase: UserFeeIncrease, signer: &S, platform_version: &PlatformVersion, _batch_feature_version: Option, diff --git a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/state_transition_like.rs b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/state_transition_like.rs index 463df4ab97d..40f051e36a4 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/state_transition_like.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/state_transition_like.rs @@ -1,3 +1,4 @@ +use crate::prelude::UserFeeIncrease; use crate::state_transition::documents_batch_transition::DocumentsBatchTransition; use crate::state_transition::{StateTransitionLike, StateTransitionType}; use crate::version::FeatureVersion; @@ -41,6 +42,21 @@ impl StateTransitionLike for DocumentsBatchTransition { } } + /// returns the fee multiplier + fn user_fee_increase(&self) -> UserFeeIncrease { + match self { + DocumentsBatchTransition::V0(transition) => transition.user_fee_increase(), + } + } + /// set a fee multiplier + fn set_user_fee_increase(&mut self, fee_multiplier: UserFeeIncrease) { + match self { + DocumentsBatchTransition::V0(transition) => { + transition.set_user_fee_increase(fee_multiplier) + } + } + } + fn owner_id(&self) -> Identifier { match self { DocumentsBatchTransition::V0(transition) => transition.owner_id(), diff --git a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/v0/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/v0/mod.rs index 47a8917eda8..4f301bb4520 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/v0/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/v0/mod.rs @@ -15,6 +15,7 @@ use crate::ProtocolError; use bincode::{Decode, Encode}; use platform_serialization_derive::PlatformSignable; +use crate::prelude::UserFeeIncrease; use platform_value::{BinaryData, Identifier}; #[cfg(feature = "state-transition-serde-conversion")] use serde::{Deserialize, Serialize}; @@ -28,6 +29,7 @@ use serde::{Deserialize, Serialize}; pub struct DocumentsBatchTransitionV0 { pub owner_id: Identifier, pub transitions: Vec, + pub user_fee_increase: UserFeeIncrease, #[platform_signable(exclude_from_sig_hash)] pub signature_public_key_id: KeyID, #[platform_signable(exclude_from_sig_hash)] diff --git a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/v0/state_transition_like.rs b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/v0/state_transition_like.rs index a3b21412746..4e7f896ef79 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/v0/state_transition_like.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/v0/state_transition_like.rs @@ -1,3 +1,4 @@ +use crate::prelude::UserFeeIncrease; use crate::state_transition::documents_batch_transition::document_base_transition::v0::v0_methods::DocumentBaseTransitionV0Methods; use crate::state_transition::documents_batch_transition::document_transition::DocumentTransitionV0Methods; use crate::state_transition::documents_batch_transition::{ @@ -60,4 +61,12 @@ impl StateTransitionLike for DocumentsBatchTransitionV0 { }) .collect() } + + fn user_fee_increase(&self) -> UserFeeIncrease { + self.user_fee_increase + } + + fn set_user_fee_increase(&mut self, fee_multiplier: UserFeeIncrease) { + self.user_fee_increase = fee_multiplier + } } diff --git a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/v0/v0_methods.rs b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/v0/v0_methods.rs index dac57e51977..7711326a0e3 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/v0/v0_methods.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/v0/v0_methods.rs @@ -6,10 +6,9 @@ use crate::document::{Document, DocumentV0Getters}; use crate::identity::signer::Signer; #[cfg(feature = "state-transition-signing")] use crate::identity::SecurityLevel; -use crate::prelude::IdentityNonce; #[cfg(feature = "state-transition-signing")] use crate::prelude::IdentityPublicKey; - +use crate::prelude::{IdentityNonce, UserFeeIncrease}; use crate::state_transition::documents_batch_transition::accessors::DocumentsBatchTransitionAccessorsV0; #[cfg(feature = "state-transition-signing")] use crate::state_transition::documents_batch_transition::document_create_transition::DocumentCreateTransition; @@ -47,6 +46,7 @@ impl DocumentsBatchTransitionMethodsV0 for DocumentsBatchTransitionV0 { entropy: [u8; 32], identity_public_key: &IdentityPublicKey, identity_contract_nonce: IdentityNonce, + user_fee_increase: UserFeeIncrease, signer: &S, platform_version: &PlatformVersion, _batch_feature_version: Option, @@ -66,6 +66,7 @@ impl DocumentsBatchTransitionMethodsV0 for DocumentsBatchTransitionV0 { let documents_batch_transition: DocumentsBatchTransition = DocumentsBatchTransitionV0 { owner_id, transitions: vec![create_transition.into()], + user_fee_increase, signature_public_key_id: 0, signature: Default::default(), } @@ -85,6 +86,7 @@ impl DocumentsBatchTransitionMethodsV0 for DocumentsBatchTransitionV0 { document_type: DocumentTypeRef, identity_public_key: &IdentityPublicKey, identity_contract_nonce: IdentityNonce, + user_fee_increase: UserFeeIncrease, signer: &S, platform_version: &PlatformVersion, _batch_feature_version: Option, @@ -103,6 +105,7 @@ impl DocumentsBatchTransitionMethodsV0 for DocumentsBatchTransitionV0 { let documents_batch_transition: DocumentsBatchTransition = DocumentsBatchTransitionV0 { owner_id, transitions: vec![replace_transition.into()], + user_fee_increase, signature_public_key_id: 0, signature: Default::default(), } diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_create_transition/state_transition_like.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_create_transition/state_transition_like.rs index 6ef7dc800be..4c4c51d055b 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_create_transition/state_transition_like.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_create_transition/state_transition_like.rs @@ -1,3 +1,4 @@ +use crate::prelude::UserFeeIncrease; use crate::state_transition::identity_create_transition::IdentityCreateTransition; use crate::state_transition::{StateTransitionLike, StateTransitionType}; use crate::version::FeatureVersion; @@ -41,6 +42,21 @@ impl StateTransitionLike for IdentityCreateTransition { } } + /// returns the fee multiplier + fn user_fee_increase(&self) -> UserFeeIncrease { + match self { + IdentityCreateTransition::V0(transition) => transition.user_fee_increase(), + } + } + /// set a fee multiplier + fn set_user_fee_increase(&mut self, fee_multiplier: UserFeeIncrease) { + match self { + IdentityCreateTransition::V0(transition) => { + transition.set_user_fee_increase(fee_multiplier) + } + } + } + fn owner_id(&self) -> Identifier { match self { IdentityCreateTransition::V0(transition) => transition.owner_id(), diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_create_transition/v0/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_create_transition/v0/mod.rs index 70dba1ee7dd..36fba74378f 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_create_transition/v0/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_create_transition/v0/mod.rs @@ -19,7 +19,7 @@ use serde::{Deserialize, Serialize}; use crate::identity::state_transition::asset_lock_proof::AssetLockProof; use crate::identity::Identity; -use crate::prelude::Identifier; +use crate::prelude::{Identifier, UserFeeIncrease}; use crate::identity::accessors::IdentityGettersV0; use crate::identity::state_transition::AssetLockProved; @@ -46,6 +46,7 @@ pub struct IdentityCreateTransitionV0 { #[platform_signable(into = "Vec")] pub public_keys: Vec, pub asset_lock_proof: AssetLockProof, + pub user_fee_increase: UserFeeIncrease, #[platform_signable(exclude_from_sig_hash)] pub signature: BinaryData, #[cfg_attr(feature = "state-transition-serde-conversion", serde(skip))] @@ -63,7 +64,7 @@ struct IdentityCreateTransitionV0Inner { public_keys: Vec, asset_lock_proof: AssetLockProof, // Generic identity ST fields - // protocol_version: u32, + user_fee_increase: UserFeeIncrease, signature: BinaryData, } @@ -74,12 +75,14 @@ impl TryFrom for IdentityCreateTransitionV0 { let IdentityCreateTransitionV0Inner { public_keys, asset_lock_proof, + user_fee_increase, signature, } = value; let identity_id = asset_lock_proof.create_identifier()?; Ok(Self { public_keys, asset_lock_proof, + user_fee_increase, signature, identity_id, }) diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_create_transition/v0/state_transition_like.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_create_transition/v0/state_transition_like.rs index 98564128516..9aa5ee38a6c 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_create_transition/v0/state_transition_like.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_create_transition/v0/state_transition_like.rs @@ -1,5 +1,6 @@ use platform_value::BinaryData; +use crate::prelude::UserFeeIncrease; use crate::state_transition::identity_create_transition::IdentityCreateTransition; use crate::{ prelude::Identifier, @@ -54,4 +55,12 @@ impl StateTransitionLike for IdentityCreateTransitionV0 { fn unique_identifiers(&self) -> Vec { vec![base64::encode(self.identity_id)] } + + fn user_fee_increase(&self) -> UserFeeIncrease { + self.user_fee_increase + } + + fn set_user_fee_increase(&mut self, fee_multiplier: UserFeeIncrease) { + self.user_fee_increase = fee_multiplier + } } diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_transfer_transition/state_transition_like.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_transfer_transition/state_transition_like.rs index 4ed8e142ad8..dd5cede96be 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_transfer_transition/state_transition_like.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_transfer_transition/state_transition_like.rs @@ -1,3 +1,4 @@ +use crate::prelude::UserFeeIncrease; use crate::state_transition::identity_credit_transfer_transition::IdentityCreditTransferTransition; use crate::state_transition::{StateTransitionLike, StateTransitionType}; use crate::version::FeatureVersion; @@ -43,6 +44,21 @@ impl StateTransitionLike for IdentityCreditTransferTransition { } } + /// returns the fee multiplier + fn user_fee_increase(&self) -> UserFeeIncrease { + match self { + IdentityCreditTransferTransition::V0(transition) => transition.user_fee_increase(), + } + } + /// set a fee multiplier + fn set_user_fee_increase(&mut self, fee_multiplier: UserFeeIncrease) { + match self { + IdentityCreditTransferTransition::V0(transition) => { + transition.set_user_fee_increase(fee_multiplier) + } + } + } + fn owner_id(&self) -> Identifier { match self { IdentityCreditTransferTransition::V0(transition) => transition.owner_id(), diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_transfer_transition/v0/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_transfer_transition/v0/mod.rs index 3537591658f..b04b6f3f761 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_transfer_transition/v0/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_transfer_transition/v0/mod.rs @@ -10,7 +10,7 @@ mod version; use crate::identity::KeyID; -use crate::prelude::{Identifier, IdentityNonce}; +use crate::prelude::{Identifier, IdentityNonce, UserFeeIncrease}; use crate::ProtocolError; use bincode::{Decode, Encode}; @@ -42,6 +42,7 @@ pub struct IdentityCreditTransferTransitionV0 { pub recipient_id: Identifier, pub amount: u64, pub nonce: IdentityNonce, + pub user_fee_increase: UserFeeIncrease, #[platform_signable(exclude_from_sig_hash)] pub signature_public_key_id: KeyID, #[platform_signable(exclude_from_sig_hash)] @@ -79,6 +80,7 @@ mod test { recipient_id: Identifier::random(), amount: rng.gen(), nonce: 1, + user_fee_increase: 0, signature_public_key_id: rng.gen(), signature: [0; 65].to_vec().into(), }; diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_transfer_transition/v0/state_transition_like.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_transfer_transition/v0/state_transition_like.rs index dcff4645868..95133643c2b 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_transfer_transition/v0/state_transition_like.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_transfer_transition/v0/state_transition_like.rs @@ -1,5 +1,6 @@ use platform_value::BinaryData; +use crate::prelude::UserFeeIncrease; use crate::{ prelude::Identifier, state_transition::{StateTransitionLike, StateTransitionType}, @@ -58,4 +59,12 @@ impl StateTransitionLike for IdentityCreditTransferTransitionV0 { self.nonce )] } + + fn user_fee_increase(&self) -> UserFeeIncrease { + self.user_fee_increase + } + + fn set_user_fee_increase(&mut self, fee_multiplier: UserFeeIncrease) { + self.user_fee_increase = fee_multiplier + } } diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_withdrawal_transition/methods/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_withdrawal_transition/methods/mod.rs index 5eba3ea31ff..3aaef91f3c4 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_withdrawal_transition/methods/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_withdrawal_transition/methods/mod.rs @@ -13,7 +13,7 @@ use crate::identity::Identity; #[cfg(feature = "state-transition-signing")] use crate::identity::core_script::CoreScript; #[cfg(feature = "state-transition-signing")] -use crate::prelude::IdentityNonce; +use crate::prelude::{IdentityNonce, UserFeeIncrease}; #[cfg(feature = "state-transition-signing")] use crate::state_transition::identity_credit_withdrawal_transition::v0::IdentityCreditWithdrawalTransitionV0; #[cfg(feature = "state-transition-signing")] @@ -33,6 +33,7 @@ impl IdentityCreditWithdrawalTransitionMethodsV0 for IdentityCreditWithdrawalTra amount: u64, pooling: Pooling, core_fee_per_byte: u32, + user_fee_increase: UserFeeIncrease, signer: S, nonce: IdentityNonce, platform_version: &PlatformVersion, @@ -50,6 +51,7 @@ impl IdentityCreditWithdrawalTransitionMethodsV0 for IdentityCreditWithdrawalTra amount, pooling, core_fee_per_byte, + user_fee_increase, signer, nonce, platform_version, diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_withdrawal_transition/methods/v0/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_withdrawal_transition/methods/v0/mod.rs index 9ed7e264efa..c739eadb0eb 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_withdrawal_transition/methods/v0/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_withdrawal_transition/methods/v0/mod.rs @@ -5,7 +5,7 @@ use crate::identity::signer::Signer; #[cfg(feature = "state-transition-signing")] use crate::identity::Identity; #[cfg(feature = "state-transition-signing")] -use crate::prelude::IdentityNonce; +use crate::prelude::{IdentityNonce, UserFeeIncrease}; #[cfg(feature = "state-transition-signing")] use crate::state_transition::StateTransition; use crate::state_transition::StateTransitionType; @@ -24,6 +24,7 @@ pub trait IdentityCreditWithdrawalTransitionMethodsV0 { amount: u64, pooling: Pooling, core_fee_per_byte: u32, + user_fee_increase: UserFeeIncrease, signer: S, nonce: IdentityNonce, _platform_version: &PlatformVersion, diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_withdrawal_transition/state_transition_like.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_withdrawal_transition/state_transition_like.rs index 2710ba1ab1d..dc21b8c52db 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_withdrawal_transition/state_transition_like.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_withdrawal_transition/state_transition_like.rs @@ -1,3 +1,4 @@ +use crate::prelude::UserFeeIncrease; use crate::state_transition::identity_credit_withdrawal_transition::IdentityCreditWithdrawalTransition; use crate::state_transition::{StateTransitionLike, StateTransitionType}; use crate::version::FeatureVersion; @@ -39,6 +40,21 @@ impl StateTransitionLike for IdentityCreditWithdrawalTransition { } } + /// returns the fee multiplier + fn user_fee_increase(&self) -> UserFeeIncrease { + match self { + IdentityCreditWithdrawalTransition::V0(transition) => transition.user_fee_increase(), + } + } + /// set a fee multiplier + fn set_user_fee_increase(&mut self, fee_multiplier: UserFeeIncrease) { + match self { + IdentityCreditWithdrawalTransition::V0(transition) => { + transition.set_user_fee_increase(fee_multiplier) + } + } + } + fn set_signature_bytes(&mut self, signature: Vec) { match self { IdentityCreditWithdrawalTransition::V0(transition) => { diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_withdrawal_transition/v0/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_withdrawal_transition/v0/mod.rs index f2eceacdfc0..2a5246b9ab7 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_withdrawal_transition/v0/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_withdrawal_transition/v0/mod.rs @@ -16,7 +16,7 @@ use platform_value::BinaryData; use serde::{Deserialize, Serialize}; use crate::balances::credits::CREDITS_PER_DUFF; -use crate::prelude::IdentityNonce; +use crate::prelude::{IdentityNonce, UserFeeIncrease}; use crate::{ identity::{core_script::CoreScript, KeyID}, prelude::Identifier, @@ -46,6 +46,7 @@ pub struct IdentityCreditWithdrawalTransitionV0 { pub pooling: Pooling, pub output_script: CoreScript, pub nonce: IdentityNonce, + pub user_fee_increase: UserFeeIncrease, #[platform_signable(exclude_from_sig_hash)] pub signature_public_key_id: KeyID, #[platform_signable(exclude_from_sig_hash)] diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_withdrawal_transition/v0/state_transition_like.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_withdrawal_transition/v0/state_transition_like.rs index d9fce1286e3..15c9358967e 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_withdrawal_transition/v0/state_transition_like.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_withdrawal_transition/v0/state_transition_like.rs @@ -1,5 +1,6 @@ use platform_value::BinaryData; +use crate::prelude::UserFeeIncrease; use crate::{ prelude::Identifier, state_transition::{StateTransitionLike, StateTransitionType}, @@ -59,4 +60,12 @@ impl StateTransitionLike for IdentityCreditWithdrawalTransitionV0 { self.nonce )] } + + fn user_fee_increase(&self) -> UserFeeIncrease { + self.user_fee_increase + } + + fn set_user_fee_increase(&mut self, fee_multiplier: UserFeeIncrease) { + self.user_fee_increase = fee_multiplier + } } diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_withdrawal_transition/v0/v0_methods.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_withdrawal_transition/v0/v0_methods.rs index 4e5ab951c34..8824c15498b 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_withdrawal_transition/v0/v0_methods.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_withdrawal_transition/v0/v0_methods.rs @@ -7,7 +7,7 @@ use crate::identity::signer::Signer; #[cfg(feature = "state-transition-signing")] use crate::identity::{Identity, KeyType, Purpose, SecurityLevel}; #[cfg(feature = "state-transition-signing")] -use crate::prelude::IdentityNonce; +use crate::prelude::{IdentityNonce, UserFeeIncrease}; #[cfg(feature = "state-transition-signing")] use crate::ProtocolError; #[cfg(feature = "state-transition-signing")] @@ -28,6 +28,7 @@ impl IdentityCreditWithdrawalTransitionMethodsV0 for IdentityCreditWithdrawalTra amount: u64, pooling: Pooling, core_fee_per_byte: u32, + user_fee_increase: UserFeeIncrease, signer: S, nonce: IdentityNonce, _platform_version: &PlatformVersion, @@ -40,6 +41,7 @@ impl IdentityCreditWithdrawalTransitionMethodsV0 for IdentityCreditWithdrawalTra pooling, output_script, nonce, + user_fee_increase, signature_public_key_id: 0, signature: Default::default(), } diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_topup_transition/methods/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_topup_transition/methods/mod.rs index 32f59f9e4ad..243117c2945 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_topup_transition/methods/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_topup_transition/methods/mod.rs @@ -5,7 +5,7 @@ pub use v0::*; #[cfg(feature = "state-transition-signing")] use crate::identity::Identity; #[cfg(feature = "state-transition-signing")] -use crate::prelude::AssetLockProof; +use crate::prelude::{AssetLockProof, UserFeeIncrease}; #[cfg(feature = "state-transition-signing")] use crate::state_transition::identity_topup_transition::v0::IdentityTopUpTransitionV0; use crate::state_transition::identity_topup_transition::IdentityTopUpTransition; @@ -25,6 +25,7 @@ impl IdentityTopUpTransitionMethodsV0 for IdentityTopUpTransition { identity: &Identity, asset_lock_proof: AssetLockProof, asset_lock_proof_private_key: &[u8], + user_fee_increase: UserFeeIncrease, platform_version: &PlatformVersion, version: Option, ) -> Result { @@ -38,6 +39,7 @@ impl IdentityTopUpTransitionMethodsV0 for IdentityTopUpTransition { identity, asset_lock_proof, asset_lock_proof_private_key, + user_fee_increase, platform_version, version, )?), diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_topup_transition/methods/v0/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_topup_transition/methods/v0/mod.rs index 4f25e0e4071..d314b9325a7 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_topup_transition/methods/v0/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_topup_transition/methods/v0/mod.rs @@ -1,7 +1,7 @@ #[cfg(feature = "state-transition-signing")] use crate::identity::Identity; #[cfg(feature = "state-transition-signing")] -use crate::prelude::AssetLockProof; +use crate::prelude::{AssetLockProof, UserFeeIncrease}; #[cfg(feature = "state-transition-signing")] use crate::state_transition::StateTransition; use crate::state_transition::StateTransitionType; @@ -16,6 +16,7 @@ pub trait IdentityTopUpTransitionMethodsV0 { identity: &Identity, asset_lock_proof: AssetLockProof, asset_lock_proof_private_key: &[u8], + user_fee_increase: UserFeeIncrease, platform_version: &PlatformVersion, version: Option, ) -> Result; diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_topup_transition/state_transition_like.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_topup_transition/state_transition_like.rs index 6f8ef71baa0..ced05743a77 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_topup_transition/state_transition_like.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_topup_transition/state_transition_like.rs @@ -1,3 +1,4 @@ +use crate::prelude::UserFeeIncrease; use crate::state_transition::identity_topup_transition::IdentityTopUpTransition; use crate::state_transition::{StateTransitionLike, StateTransitionType}; use crate::version::FeatureVersion; @@ -41,6 +42,21 @@ impl StateTransitionLike for IdentityTopUpTransition { } } + /// returns the fee multiplier + fn user_fee_increase(&self) -> UserFeeIncrease { + match self { + IdentityTopUpTransition::V0(transition) => transition.user_fee_increase(), + } + } + /// set a fee multiplier + fn set_user_fee_increase(&mut self, fee_multiplier: UserFeeIncrease) { + match self { + IdentityTopUpTransition::V0(transition) => { + transition.set_user_fee_increase(fee_multiplier) + } + } + } + fn owner_id(&self) -> Identifier { match self { IdentityTopUpTransition::V0(transition) => transition.owner_id(), diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_topup_transition/v0/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_topup_transition/v0/mod.rs index 673eb859e55..8541ad0e7b8 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_topup_transition/v0/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_topup_transition/v0/mod.rs @@ -18,7 +18,7 @@ use serde::{Deserialize, Serialize}; use crate::identity::state_transition::asset_lock_proof::AssetLockProof; -use crate::prelude::Identifier; +use crate::prelude::{Identifier, UserFeeIncrease}; use crate::ProtocolError; @@ -41,6 +41,7 @@ pub struct IdentityTopUpTransitionV0 { // Own ST fields pub asset_lock_proof: AssetLockProof, pub identity_id: Identifier, + pub user_fee_increase: UserFeeIncrease, #[platform_signable(exclude_from_sig_hash)] pub signature: BinaryData, } diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_topup_transition/v0/state_transition_like.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_topup_transition/v0/state_transition_like.rs index 4c36f94ec1b..a04e462f90c 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_topup_transition/v0/state_transition_like.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_topup_transition/v0/state_transition_like.rs @@ -1,5 +1,6 @@ use platform_value::BinaryData; +use crate::prelude::UserFeeIncrease; use crate::state_transition::identity_topup_transition::IdentityTopUpTransition; use crate::{ prelude::Identifier, @@ -65,4 +66,12 @@ impl StateTransitionLike for IdentityTopUpTransitionV0 { } } } + + fn user_fee_increase(&self) -> UserFeeIncrease { + self.user_fee_increase + } + + fn set_user_fee_increase(&mut self, fee_multiplier: UserFeeIncrease) { + self.user_fee_increase = fee_multiplier + } } diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_topup_transition/v0/v0_methods.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_topup_transition/v0/v0_methods.rs index 3814262abbe..da2b8f680b3 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_topup_transition/v0/v0_methods.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_topup_transition/v0/v0_methods.rs @@ -2,10 +2,10 @@ use crate::identity::accessors::IdentityGettersV0; #[cfg(feature = "state-transition-signing")] use crate::identity::Identity; -#[cfg(feature = "state-transition-signing")] -use crate::prelude::AssetLockProof; use crate::prelude::Identifier; #[cfg(feature = "state-transition-signing")] +use crate::prelude::{AssetLockProof, UserFeeIncrease}; +#[cfg(feature = "state-transition-signing")] use crate::ProtocolError; #[cfg(feature = "state-transition-signing")] use dashcore::signer; @@ -30,12 +30,14 @@ impl IdentityTopUpTransitionMethodsV0 for IdentityTopUpTransitionV0 { identity: &Identity, asset_lock_proof: AssetLockProof, asset_lock_proof_private_key: &[u8], + user_fee_increase: UserFeeIncrease, _platform_version: &PlatformVersion, _version: Option, ) -> Result { let identity_top_up_transition = IdentityTopUpTransitionV0 { asset_lock_proof, identity_id: identity.id(), + user_fee_increase, signature: Default::default(), }; diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_topup_transition/v0/value_conversion.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_topup_transition/v0/value_conversion.rs index d1dd35f4c4e..46ba75bd23a 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_topup_transition/v0/value_conversion.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_topup_transition/v0/value_conversion.rs @@ -11,6 +11,7 @@ use crate::state_transition::identity_topup_transition::fields::*; use crate::state_transition::identity_topup_transition::v0::IdentityTopUpTransitionV0; use crate::state_transition::StateTransitionValueConvert; +use crate::state_transition::state_transitions::common_fields::property_names::USER_FEE_INCREASE; use platform_version::version::PlatformVersion; impl<'a> StateTransitionValueConvert<'a> for IdentityTopUpTransitionV0 { @@ -33,10 +34,16 @@ impl<'a> StateTransitionValueConvert<'a> for IdentityTopUpTransitionV0 { .map_err(ProtocolError::ValueError)?; let asset_lock_proof = AssetLockProof::try_from(raw_asset_lock_proof)?; + let user_fee_increase = raw_object + .get_optional_integer(USER_FEE_INCREASE) + .map_err(ProtocolError::ValueError)? + .unwrap_or_default(); + Ok(IdentityTopUpTransitionV0 { signature, identity_id, asset_lock_proof, + user_fee_increase, }) } diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_update_transition/methods/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_update_transition/methods/mod.rs index ebc2d1af964..7b5b482cb63 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_update_transition/methods/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_update_transition/methods/mod.rs @@ -18,7 +18,7 @@ use crate::version::FeatureVersion; use crate::ProtocolError; #[cfg(feature = "state-transition-signing")] -use crate::prelude::IdentityNonce; +use crate::prelude::{IdentityNonce, UserFeeIncrease}; #[cfg(feature = "state-transition-signing")] use platform_version::version::PlatformVersion; @@ -31,6 +31,7 @@ impl IdentityUpdateTransitionMethodsV0 for IdentityUpdateTransition { disable_public_keys: Vec, public_keys_disabled_at: Option, nonce: IdentityNonce, + user_fee_increase: UserFeeIncrease, signer: &S, platform_version: &PlatformVersion, version: Option, @@ -49,6 +50,7 @@ impl IdentityUpdateTransitionMethodsV0 for IdentityUpdateTransition { disable_public_keys, public_keys_disabled_at, nonce, + user_fee_increase, signer, platform_version, version, diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_update_transition/methods/v0/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_update_transition/methods/v0/mod.rs index 93c8adc3d05..82bbceb7f1f 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_update_transition/methods/v0/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_update_transition/methods/v0/mod.rs @@ -3,7 +3,7 @@ use crate::identity::signer::Signer; #[cfg(feature = "state-transition-signing")] use crate::identity::{Identity, IdentityPublicKey}; #[cfg(feature = "state-transition-signing")] -use crate::prelude::IdentityNonce; +use crate::prelude::{IdentityNonce, UserFeeIncrease}; #[cfg(feature = "state-transition-signing")] use crate::state_transition::StateTransition; use crate::state_transition::StateTransitionType; @@ -23,6 +23,7 @@ pub trait IdentityUpdateTransitionMethodsV0 { disable_public_keys: Vec, public_keys_disabled_at: Option, nonce: IdentityNonce, + user_fee_increase: UserFeeIncrease, signer: &S, platform_version: &PlatformVersion, version: Option, diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_update_transition/state_transition_like.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_update_transition/state_transition_like.rs index 7b8aaef35b1..ccd82e9af96 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_update_transition/state_transition_like.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_update_transition/state_transition_like.rs @@ -1,3 +1,4 @@ +use crate::prelude::UserFeeIncrease; use crate::state_transition::identity_update_transition::IdentityUpdateTransition; use crate::state_transition::{StateTransitionLike, StateTransitionType}; use crate::version::FeatureVersion; @@ -41,6 +42,21 @@ impl StateTransitionLike for IdentityUpdateTransition { } } + /// returns the fee multiplier + fn user_fee_increase(&self) -> UserFeeIncrease { + match self { + IdentityUpdateTransition::V0(transition) => transition.user_fee_increase(), + } + } + /// set a fee multiplier + fn set_user_fee_increase(&mut self, fee_multiplier: UserFeeIncrease) { + match self { + IdentityUpdateTransition::V0(transition) => { + transition.set_user_fee_increase(fee_multiplier) + } + } + } + fn owner_id(&self) -> Identifier { match self { IdentityUpdateTransition::V0(transition) => transition.owner_id(), diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_update_transition/v0/json_conversion.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_update_transition/v0/json_conversion.rs index 2cdaa09100a..6ecab17352c 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_update_transition/v0/json_conversion.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_update_transition/v0/json_conversion.rs @@ -29,6 +29,7 @@ mod test { add_public_keys: vec![public_key.into()], disable_public_keys: vec![], public_keys_disabled_at: None, + user_fee_increase: 0, signature_public_key_id: 0, signature: BinaryData::new(buffer.to_vec()), } diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_update_transition/v0/mod.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_update_transition/v0/mod.rs index c1aa3c0e85f..1a00215f53a 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_update_transition/v0/mod.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_update_transition/v0/mod.rs @@ -19,7 +19,7 @@ use std::convert::{TryFrom, TryInto}; use crate::state_transition::public_key_in_creation::IdentityPublicKeyInCreation; use crate::state_transition::public_key_in_creation::IdentityPublicKeyInCreationSignable; -use crate::prelude::IdentityNonce; +use crate::prelude::{IdentityNonce, UserFeeIncrease}; use crate::{ identity::KeyID, prelude::{Identifier, Revision, TimestampMillis}, @@ -60,6 +60,9 @@ pub struct IdentityUpdateTransitionV0 { /// Timestamp when keys were disabled pub public_keys_disabled_at: Option, + /// The fee multiplier + pub user_fee_increase: UserFeeIncrease, + /// The ID of the public key used to sing the State Transition #[platform_signable(exclude_from_sig_hash)] pub signature_public_key_id: KeyID, diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_update_transition/v0/state_transition_like.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_update_transition/v0/state_transition_like.rs index 12e38921b12..8145e1d385a 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_update_transition/v0/state_transition_like.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_update_transition/v0/state_transition_like.rs @@ -1,5 +1,6 @@ use platform_value::BinaryData; +use crate::prelude::UserFeeIncrease; use crate::{ prelude::Identifier, state_transition::{StateTransitionLike, StateTransitionType}, @@ -58,4 +59,12 @@ impl StateTransitionLike for IdentityUpdateTransitionV0 { self.nonce )] } + + fn user_fee_increase(&self) -> UserFeeIncrease { + self.user_fee_increase + } + + fn set_user_fee_increase(&mut self, fee_multiplier: UserFeeIncrease) { + self.user_fee_increase = fee_multiplier + } } diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_update_transition/v0/v0_methods.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_update_transition/v0/v0_methods.rs index 87c7c261c94..9d58fafe151 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_update_transition/v0/v0_methods.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_update_transition/v0/v0_methods.rs @@ -19,7 +19,7 @@ use crate::identity::{Identity, IdentityPublicKey}; use crate::identity::accessors::IdentityGettersV0; #[cfg(feature = "state-transition-signing")] use crate::identity::identity_public_key::accessors::v0::IdentityPublicKeyGettersV0; -use crate::prelude::IdentityNonce; +use crate::prelude::{IdentityNonce, UserFeeIncrease}; use crate::state_transition::identity_update_transition::accessors::IdentityUpdateTransitionAccessorsV0; use crate::state_transition::identity_update_transition::methods::IdentityUpdateTransitionMethodsV0; use crate::state_transition::identity_update_transition::v0::IdentityUpdateTransitionV0; @@ -45,6 +45,7 @@ impl IdentityUpdateTransitionMethodsV0 for IdentityUpdateTransitionV0 { disable_public_keys: Vec, public_keys_disabled_at: Option, nonce: IdentityNonce, + user_fee_increase: UserFeeIncrease, signer: &S, _platform_version: &PlatformVersion, _version: Option, @@ -63,6 +64,7 @@ impl IdentityUpdateTransitionMethodsV0 for IdentityUpdateTransitionV0 { add_public_keys: add_public_keys_in_creation, disable_public_keys, public_keys_disabled_at, + user_fee_increase, }; let state_transition: StateTransition = identity_update_transition.clone().into(); diff --git a/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_update_transition/v0/value_conversion.rs b/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_update_transition/v0/value_conversion.rs index abe58de381f..2af88151d87 100644 --- a/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_update_transition/v0/value_conversion.rs +++ b/packages/rs-dpp/src/state_transition/state_transitions/identity/identity_update_transition/v0/value_conversion.rs @@ -9,7 +9,9 @@ use crate::state_transition::identity_update_transition::v0::{ use crate::state_transition::public_key_in_creation::IdentityPublicKeyInCreation; use crate::state_transition::StateTransitionValueConvert; -use crate::state_transition::state_transitions::common_fields::property_names::NONCE; +use crate::state_transition::state_transitions::common_fields::property_names::{ + NONCE, USER_FEE_INCREASE, +}; use platform_version::version::PlatformVersion; impl<'a> StateTransitionValueConvert<'a> for IdentityUpdateTransitionV0 { @@ -33,6 +35,10 @@ impl<'a> StateTransitionValueConvert<'a> for IdentityUpdateTransitionV0 { let nonce = raw_object .get_integer(NONCE) .map_err(ProtocolError::ValueError)?; + let user_fee_increase = raw_object + .get_optional_integer(USER_FEE_INCREASE) + .map_err(ProtocolError::ValueError)? + .unwrap_or_default(); let add_public_keys = raw_object .remove_optional_array(property_names::ADD_PUBLIC_KEYS) .map_err(ProtocolError::ValueError)? @@ -55,6 +61,7 @@ impl<'a> StateTransitionValueConvert<'a> for IdentityUpdateTransitionV0 { add_public_keys, disable_public_keys, public_keys_disabled_at, + user_fee_increase, }) } diff --git a/packages/rs-dpp/src/state_transition/traits/state_transition_like.rs b/packages/rs-dpp/src/state_transition/traits/state_transition_like.rs index efed047cd47..a1d78449bee 100644 --- a/packages/rs-dpp/src/state_transition/traits/state_transition_like.rs +++ b/packages/rs-dpp/src/state_transition/traits/state_transition_like.rs @@ -2,7 +2,7 @@ use std::fmt::Debug; use platform_value::BinaryData; -use crate::prelude::Identifier; +use crate::prelude::{Identifier, UserFeeIncrease}; use crate::version::FeatureVersion; use crate::state_transition::StateTransitionType; @@ -37,6 +37,10 @@ pub trait StateTransitionLike: fn signature(&self) -> &BinaryData; /// set a new signature fn set_signature(&mut self, signature: BinaryData); + /// returns the fee multiplier + fn user_fee_increase(&self) -> UserFeeIncrease; + /// set a fee multiplier + fn set_user_fee_increase(&mut self, fee_multiplier: UserFeeIncrease); /// get modified ids list fn modified_data_ids(&self) -> Vec; diff --git a/packages/rs-drive-abci/src/abci/handler/check_tx.rs b/packages/rs-drive-abci/src/abci/handler/check_tx.rs index 93de3035775..da8dfff55d4 100644 --- a/packages/rs-drive-abci/src/abci/handler/check_tx.rs +++ b/packages/rs-drive-abci/src/abci/handler/check_tx.rs @@ -60,7 +60,7 @@ where gas_wanted: gas_wanted as SignedCredits, codespace: "".to_string(), sender: first_unique_identifier, - priority: 0, + priority: check_tx_result.priority as i64, }) } Err(error) => { diff --git a/packages/rs-drive-abci/src/execution/check_tx/mod.rs b/packages/rs-drive-abci/src/execution/check_tx/mod.rs index 73d1bf379de..354fed2eab9 100644 --- a/packages/rs-drive-abci/src/execution/check_tx/mod.rs +++ b/packages/rs-drive-abci/src/execution/check_tx/mod.rs @@ -64,6 +64,9 @@ pub struct CheckTxResult { /// reject the transition. All transitions return only 1 unique identifier except the documents /// batch transition that returns 1 for each document transition pub unique_identifiers: Vec, + /// Priority to return to tenderdash. State Transitions with higher priority take precedence + /// over state transitions with lower priority + pub priority: u32, } impl Platform diff --git a/packages/rs-drive-abci/src/execution/check_tx/v0/mod.rs b/packages/rs-drive-abci/src/execution/check_tx/v0/mod.rs index bdda71fac88..4ad51c685e7 100644 --- a/packages/rs-drive-abci/src/execution/check_tx/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/check_tx/v0/mod.rs @@ -109,6 +109,8 @@ where let unique_identifiers = state_transition.unique_identifiers(); + let priority = state_transition.user_fee_increase() as u32 * 100; + let validation_result = state_transition_to_execution_event_for_check_tx( &platform_ref, state_transition, @@ -129,6 +131,7 @@ where level: check_tx_level, fee_result: Some(fee_result), unique_identifiers, + priority, }) }) } else { @@ -136,6 +139,7 @@ where level: check_tx_level, fee_result: None, unique_identifiers, + priority, })) } }) @@ -376,7 +380,140 @@ mod tests { let transaction = platform.drive.grove.start_transaction(); + let processing_result = platform + .platform + .process_raw_state_transitions( + &vec![serialized.clone()], + &platform_state, + &BlockInfo::default(), + &transaction, + platform_version, + ) + .expect("expected to process state transition"); + + assert_eq!(processing_result.aggregated_fees().processing_fee, 2604790); + + let check_result = platform + .check_tx( + serialized.as_slice(), + Recheck, + &platform_state, + platform_version, + ) + .expect("expected to check tx"); + + assert!(check_result.is_valid()); // it should still be valid, because we didn't commit the transaction + + platform + .drive + .grove + .commit_transaction(transaction) + .unwrap() + .expect("expected to commit"); + + let check_result = platform + .check_tx( + serialized.as_slice(), + Recheck, + &platform_state, + platform_version, + ) + .expect("expected to check tx"); + + assert!(check_result.is_valid()); // it should still be valid, because we don't validate state + } + + #[test] + fn data_contract_create_check_tx_priority() { + let mut platform = TestPlatformBuilder::new() + .with_config(PlatformConfig::default()) + .build_with_mock_rpc(); + platform + .core_rpc + .expect_verify_instant_lock() + .returning(|_, _| Ok(true)); + + let platform_state = platform.state.load(); + let protocol_version = platform_state.current_protocol_version_in_consensus(); + let platform_version = PlatformVersion::get(protocol_version).unwrap(); + + let (key, private_key) = IdentityPublicKey::random_ecdsa_critical_level_authentication_key( + 1, + Some(1), + platform_version, + ) + .expect("expected to get key pair"); + + platform + .drive + .create_initial_state_structure(None, platform_version) + .expect("expected to create state structure"); + let identity: Identity = IdentityV0 { + id: Identifier::new([ + 158, 113, 180, 126, 91, 83, 62, 44, 83, 54, 97, 88, 240, 215, 84, 139, 167, 156, + 166, 203, 222, 4, 64, 31, 215, 199, 149, 151, 190, 246, 251, 44, + ]), + public_keys: BTreeMap::from([(1, key.clone())]), + balance: 1000000000, + revision: 0, + } + .into(); + + let dashpay = get_dashpay_contract_fixture(Some(identity.id()), 1, protocol_version); + let mut create_contract_state_transition: StateTransition = dashpay + .try_into_platform_versioned(platform_version) + .expect("expected a state transition"); + + create_contract_state_transition.set_user_fee_increase(100); // This means that things will be twice as expensive + + create_contract_state_transition + .sign(&key, private_key.as_slice(), &NativeBlsModule) + .expect("expected to sign transition"); + let serialized = create_contract_state_transition + .serialize_to_bytes() + .expect("serialized state transition"); + platform + .drive + .add_new_identity( + identity, + false, + &BlockInfo::default(), + true, + None, + platform_version, + ) + .expect("expected to insert identity"); + + let validation_result = platform + .check_tx( + serialized.as_slice(), + FirstTimeCheck, + &platform_state, + platform_version, + ) + .expect("expected to check tx"); + + assert!(validation_result.errors.is_empty()); + + assert_eq!(validation_result.data.unwrap().priority, 10000); + + let check_result = platform + .check_tx( + serialized.as_slice(), + Recheck, + &platform_state, + platform_version, + ) + .expect("expected to check tx"); + + assert!(check_result.is_valid()); + + assert_eq!(check_result.data.unwrap().priority, 10000); + + let transaction = platform.drive.grove.start_transaction(); + + let processing_result = platform .platform .process_raw_state_transitions( &vec![serialized.clone()], @@ -387,6 +524,13 @@ mod tests { ) .expect("expected to process state transition"); + // The processing fees should be twice as much as a fee multiplier of 0, + // since a fee multiplier of 100 means 100% more of 1 (gives 2) + assert_eq!( + processing_result.aggregated_fees().processing_fee, + 2604790 * 2 + ); + let check_result = platform .check_tx( serialized.as_slice(), @@ -398,6 +542,8 @@ mod tests { assert!(check_result.is_valid()); // it should still be valid, because we didn't commit the transaction + assert_eq!(check_result.data.unwrap().priority, 10000); + platform .drive .grove @@ -415,6 +561,8 @@ mod tests { .expect("expected to check tx"); assert!(check_result.is_valid()); // it should still be valid, because we don't validate state + + assert_eq!(check_result.data.unwrap().priority, 10000); } #[test] @@ -649,6 +797,7 @@ mod tests { entropy.0, &key, 1, + 0, &signer, platform_version, None, @@ -667,6 +816,7 @@ mod tests { profile, &key, 2, + 0, &signer, platform_version, None, @@ -813,6 +963,7 @@ mod tests { &identity, asset_lock_proof_top_up, pk.as_slice(), + 0, platform_version, None, ) @@ -942,6 +1093,7 @@ mod tests { &identity, asset_lock_proof_top_up, pk.as_slice(), + 0, platform_version, None, ) @@ -1074,6 +1226,7 @@ mod tests { &identity, asset_lock_proof_top_up, pk.as_slice(), + 0, platform_version, None, ) @@ -1194,6 +1347,7 @@ mod tests { &identity, asset_lock_proof_top_up.clone(), pk.as_slice(), + 0, platform_version, None, ) @@ -1380,6 +1534,7 @@ mod tests { add_public_keys: vec![IdentityPublicKeyInCreation::V0(new_key)], disable_public_keys: vec![], public_keys_disabled_at: None, + user_fee_increase: 0, signature_public_key_id: 1, signature: Default::default(), } @@ -1492,6 +1647,7 @@ mod tests { add_public_keys: vec![IdentityPublicKeyInCreation::V0(new_key.clone())], disable_public_keys: vec![], public_keys_disabled_at: None, + user_fee_increase: 0, signature_public_key_id: 0, signature: Default::default(), } @@ -1516,6 +1672,7 @@ mod tests { add_public_keys: vec![IdentityPublicKeyInCreation::V0(new_key)], disable_public_keys: vec![], public_keys_disabled_at: None, + user_fee_increase: 0, signature_public_key_id: 0, signature: Default::default(), } diff --git a/packages/rs-drive-abci/src/execution/platform_events/block_start/clear_drive_block_cache/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/block_start/clear_drive_block_cache/v0/mod.rs index d988eb34c7e..06750ab6e0d 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/block_start/clear_drive_block_cache/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/block_start/clear_drive_block_cache/v0/mod.rs @@ -11,8 +11,7 @@ where pub(super) fn clear_drive_block_cache_v0(&self) { self.drive.cache.data_contracts.clear_block_cache(); - let mut protocol_versions_counter = - self.drive.cache.protocol_versions_counter.write(); + let mut protocol_versions_counter = self.drive.cache.protocol_versions_counter.write(); protocol_versions_counter.clear_block_cache() } diff --git a/packages/rs-drive-abci/src/execution/platform_events/state_transition_processing/execute_event/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/state_transition_processing/execute_event/v0/mod.rs index c5cc4e1a01b..929fff2092d 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/state_transition_processing/execute_event/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/state_transition_processing/execute_event/v0/mod.rs @@ -56,12 +56,14 @@ where identity, operations, execution_operations, + user_fee_increase, .. } | ExecutionEvent::PaidDriveEvent { identity, operations, execution_operations, + user_fee_increase, .. } => { if fee_validation_result.is_valid_with_data() { @@ -84,6 +86,8 @@ where platform_version, )?; + individual_fee_result.apply_user_fee_increase(user_fee_increase); + let balance_change = individual_fee_result.into_balance_change(identity.id); let outcome = self.drive.apply_balance_change_from_fee_to_identity( diff --git a/packages/rs-drive-abci/src/execution/platform_events/state_transition_processing/validate_fees_of_event/v0/mod.rs b/packages/rs-drive-abci/src/execution/platform_events/state_transition_processing/validate_fees_of_event/v0/mod.rs index be0d150f59f..f1e4106fea1 100644 --- a/packages/rs-drive-abci/src/execution/platform_events/state_transition_processing/validate_fees_of_event/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/platform_events/state_transition_processing/validate_fees_of_event/v0/mod.rs @@ -48,6 +48,7 @@ where added_balance, operations, execution_operations, + user_fee_increase, } => { let previous_balance = identity.balance.ok_or(Error::Execution( ExecutionError::CorruptedCodeExecution("partial identity info with no balance"), @@ -71,6 +72,8 @@ where platform_version, )?; + estimated_fee_result.apply_user_fee_increase(*user_fee_increase); + // TODO: Should take into account refunds as well let total_fee = estimated_fee_result.total_base_fee(); if previous_balance_with_top_up >= total_fee { @@ -96,6 +99,7 @@ where removed_balance, operations, execution_operations, + user_fee_increase, } => { let balance = identity.balance.ok_or(Error::Execution( ExecutionError::CorruptedCodeExecution("partial identity info with no balance"), @@ -120,6 +124,8 @@ where platform_version, )?; + estimated_fee_result.apply_user_fee_increase(*user_fee_increase); + // TODO: Should take into account refunds as well let required_balance = estimated_fee_result.total_base_fee(); if balance_after_principal_operation >= required_balance { diff --git a/packages/rs-drive-abci/src/execution/types/execution_event/mod.rs b/packages/rs-drive-abci/src/execution/types/execution_event/mod.rs index 6ff45363d5f..f09a669c309 100644 --- a/packages/rs-drive-abci/src/execution/types/execution_event/mod.rs +++ b/packages/rs-drive-abci/src/execution/types/execution_event/mod.rs @@ -9,6 +9,7 @@ use dpp::block::epoch::Epoch; use dpp::fee::Credits; use dpp::identity::PartialIdentity; +use dpp::prelude::UserFeeIncrease; use dpp::version::PlatformVersion; use drive::state_transition_action::StateTransitionAction; @@ -33,6 +34,8 @@ pub(in crate::execution) enum ExecutionEvent<'a> { operations: Vec>, /// the execution operations that we must also pay for execution_operations: Vec, + /// the fee multiplier that the user agreed to, 0 means 100% of the base fee, 1 means 101% + user_fee_increase: UserFeeIncrease, }, /// A drive event that is paid from an asset lock PaidFromAssetLockDriveEvent { @@ -44,6 +47,8 @@ pub(in crate::execution) enum ExecutionEvent<'a> { operations: Vec>, /// the execution operations that we must also pay for execution_operations: Vec, + /// the fee multiplier that the user agreed to, 0 means 100% of the base fee, 1 means 101% + user_fee_increase: UserFeeIncrease, }, /// A drive event that is free FreeDriveEvent { @@ -62,6 +67,7 @@ impl<'a> ExecutionEvent<'a> { ) -> Result { match &action { StateTransitionAction::IdentityCreateAction(identity_create_action) => { + let user_fee_increase = identity_create_action.user_fee_increase(); let identity = identity_create_action.into(); let operations = action.into_high_level_drive_operations(epoch, platform_version)?; @@ -70,9 +76,11 @@ impl<'a> ExecutionEvent<'a> { added_balance: 0, operations, execution_operations: execution_context.operations_consume(), + user_fee_increase, }) } StateTransitionAction::IdentityTopUpAction(identity_top_up_action) => { + let user_fee_increase = identity_top_up_action.user_fee_increase(); let added_balance = identity_top_up_action.top_up_balance_amount(); let operations = action.into_high_level_drive_operations(epoch, platform_version)?; @@ -82,6 +90,7 @@ impl<'a> ExecutionEvent<'a> { added_balance, operations, execution_operations: execution_context.operations_consume(), + user_fee_increase, }) } else { Err(Error::Execution(ExecutionError::CorruptedCodeExecution( @@ -90,6 +99,7 @@ impl<'a> ExecutionEvent<'a> { } } StateTransitionAction::IdentityCreditWithdrawalAction(identity_credit_withdrawal) => { + let user_fee_increase = identity_credit_withdrawal.user_fee_increase(); let removed_balance = identity_credit_withdrawal.amount(); let operations = action.into_high_level_drive_operations(epoch, platform_version)?; @@ -99,6 +109,7 @@ impl<'a> ExecutionEvent<'a> { removed_balance: Some(removed_balance), operations, execution_operations: execution_context.operations_consume(), + user_fee_increase, }) } else { Err(Error::Execution(ExecutionError::CorruptedCodeExecution( @@ -107,6 +118,7 @@ impl<'a> ExecutionEvent<'a> { } } StateTransitionAction::IdentityCreditTransferAction(identity_credit_transfer) => { + let user_fee_increase = identity_credit_transfer.user_fee_increase(); let removed_balance = identity_credit_transfer.transfer_amount(); let operations = action.into_high_level_drive_operations(epoch, platform_version)?; @@ -116,6 +128,7 @@ impl<'a> ExecutionEvent<'a> { removed_balance: Some(removed_balance), operations, execution_operations: execution_context.operations_consume(), + user_fee_increase, }) } else { Err(Error::Execution(ExecutionError::CorruptedCodeExecution( @@ -124,6 +137,7 @@ impl<'a> ExecutionEvent<'a> { } } _ => { + let user_fee_increase = action.user_fee_increase(); let operations = action.into_high_level_drive_operations(epoch, platform_version)?; if let Some(identity) = identity { @@ -132,6 +146,7 @@ impl<'a> ExecutionEvent<'a> { removed_balance: None, operations, execution_operations: execution_context.operations_consume(), + user_fee_increase, }) } else { Err(Error::Execution(ExecutionError::CorruptedCodeExecution( diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_update/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_update/mod.rs index 9ce2c7c2e3b..008e292a09f 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_update/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/data_contract_update/mod.rs @@ -178,6 +178,7 @@ mod tests { platform_version, ) .expect("to be able to convert data contract to serialization format"), + user_fee_increase: 0, signature: BinaryData::new(vec![0; 65]), signature_public_key_id: 0, }; @@ -258,6 +259,7 @@ mod tests { platform_version, ) .expect("to be able to convert data contract to serialization format"), + user_fee_increase: 0, signature: BinaryData::new(vec![0; 65]), signature_public_key_id: 0, }; diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/state/v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/state/v0/mod.rs index 1652427b3d2..ac3ccabd4be 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/state/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/state/v0/mod.rs @@ -91,6 +91,7 @@ impl DocumentsBatchStateTransitionStateValidationV0 for DocumentsBatchTransition ), ))?, owner_id, + state_transition_action.user_fee_increase(), )?, ), ); @@ -131,6 +132,7 @@ impl DocumentsBatchStateTransitionStateValidationV0 for DocumentsBatchTransition ), ))?, owner_id, + state_transition_action.user_fee_increase(), )?, )); } else { diff --git a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/transformer/v0/mod.rs b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/transformer/v0/mod.rs index 06dab8e8938..8ba97782e98 100644 --- a/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/transformer/v0/mod.rs +++ b/packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/documents_batch/transformer/v0/mod.rs @@ -103,6 +103,7 @@ impl DocumentsBatchTransitionTransformerV0 for DocumentsBatchTransition { execution_context: &mut StateTransitionExecutionContext, ) -> Result, Error> { let owner_id = self.owner_id(); + let user_fee_increase = self.user_fee_increase(); let platform_version = platform.state.current_platform_version()?; let mut transitions_by_contracts_and_types: BTreeMap< &Identifier, @@ -155,6 +156,7 @@ impl DocumentsBatchTransitionTransformerV0 for DocumentsBatchTransition { let batch_transition_action = DocumentsBatchTransitionActionV0 { owner_id, transitions: validation_result.into_data()?, + user_fee_increase, } .into(); Ok(ConsensusValidationResult::new_with_data( diff --git a/packages/rs-drive-abci/tests/strategy_tests/strategy.rs b/packages/rs-drive-abci/tests/strategy_tests/strategy.rs index b223aa35524..b4196374955 100644 --- a/packages/rs-drive-abci/tests/strategy_tests/strategy.rs +++ b/packages/rs-drive-abci/tests/strategy_tests/strategy.rs @@ -484,6 +484,7 @@ impl NetworkStrategy { &identity, 1, //key id 1 should always be a high or critical auth key in these tests *identity_contract_nonce, + 0, signer, platform_version, None, @@ -572,6 +573,7 @@ impl NetworkStrategy { DocumentsBatchTransitionV0 { owner_id: identity.id(), transitions: vec![document_create_transition.into()], + user_fee_increase: 0, signature_public_key_id: 0, signature: BinaryData::default(), } @@ -686,6 +688,7 @@ impl NetworkStrategy { DocumentsBatchTransitionV0 { owner_id: identity.id(), transitions: vec![document_create_transition.into()], + user_fee_increase: 0, signature_public_key_id: 0, signature: BinaryData::default(), } @@ -784,6 +787,7 @@ impl NetworkStrategy { DocumentsBatchTransitionV0 { owner_id: identity.id, transitions: vec![document_delete_transition.into()], + user_fee_increase: 0, signature_public_key_id: 0, signature: BinaryData::default(), } @@ -884,6 +888,7 @@ impl NetworkStrategy { DocumentsBatchTransitionV0 { owner_id: identity.id, transitions: vec![document_replace_transition.into()], + user_fee_increase: 0, signature_public_key_id: 0, signature: BinaryData::default(), } @@ -1126,6 +1131,7 @@ impl NetworkStrategy { identity, asset_lock_proof, secret_key.as_ref(), + 0, platform_version, None, ) diff --git a/packages/rs-drive/src/state_transition_action/contract/data_contract_create/mod.rs b/packages/rs-drive/src/state_transition_action/contract/data_contract_create/mod.rs index 8cd87549918..f34eca7070f 100644 --- a/packages/rs-drive/src/state_transition_action/contract/data_contract_create/mod.rs +++ b/packages/rs-drive/src/state_transition_action/contract/data_contract_create/mod.rs @@ -6,7 +6,7 @@ pub mod v0; use crate::state_transition_action::contract::data_contract_create::v0::DataContractCreateTransitionActionV0; use derive_more::From; use dpp::data_contract::DataContract; -use dpp::prelude::IdentityNonce; +use dpp::prelude::{IdentityNonce, UserFeeIncrease}; /// data contract create transition action #[derive(Debug, Clone, From)] @@ -35,4 +35,11 @@ impl DataContractCreateTransitionAction { DataContractCreateTransitionAction::V0(transition) => transition.identity_nonce, } } + + /// fee multiplier + pub fn user_fee_increase(&self) -> UserFeeIncrease { + match self { + DataContractCreateTransitionAction::V0(transition) => transition.user_fee_increase, + } + } } diff --git a/packages/rs-drive/src/state_transition_action/contract/data_contract_create/v0/mod.rs b/packages/rs-drive/src/state_transition_action/contract/data_contract_create/v0/mod.rs index 955583b9134..2bcde179d62 100644 --- a/packages/rs-drive/src/state_transition_action/contract/data_contract_create/v0/mod.rs +++ b/packages/rs-drive/src/state_transition_action/contract/data_contract_create/v0/mod.rs @@ -2,7 +2,7 @@ pub mod transformer; use dpp::data_contract::DataContract; -use dpp::prelude::IdentityNonce; +use dpp::prelude::{IdentityNonce, UserFeeIncrease}; /// data contract create transition action v0 #[derive(Debug, Clone)] @@ -11,4 +11,6 @@ pub struct DataContractCreateTransitionActionV0 { pub data_contract: DataContract, /// identity nonce pub identity_nonce: IdentityNonce, + /// fee multiplier + pub user_fee_increase: UserFeeIncrease, } diff --git a/packages/rs-drive/src/state_transition_action/contract/data_contract_create/v0/transformer.rs b/packages/rs-drive/src/state_transition_action/contract/data_contract_create/v0/transformer.rs index 01851b398be..9291d787372 100644 --- a/packages/rs-drive/src/state_transition_action/contract/data_contract_create/v0/transformer.rs +++ b/packages/rs-drive/src/state_transition_action/contract/data_contract_create/v0/transformer.rs @@ -21,6 +21,7 @@ impl TryFromPlatformVersioned platform_version, )?, identity_nonce: value.identity_nonce, + user_fee_increase: value.user_fee_increase, }) } } @@ -41,6 +42,7 @@ impl TryFromPlatformVersioned<&DataContractCreateTransitionV0> platform_version, )?, identity_nonce: value.identity_nonce, + user_fee_increase: value.user_fee_increase, }) } } diff --git a/packages/rs-drive/src/state_transition_action/contract/data_contract_update/mod.rs b/packages/rs-drive/src/state_transition_action/contract/data_contract_update/mod.rs index 525bb128331..3ea424e0e62 100644 --- a/packages/rs-drive/src/state_transition_action/contract/data_contract_update/mod.rs +++ b/packages/rs-drive/src/state_transition_action/contract/data_contract_update/mod.rs @@ -6,7 +6,7 @@ pub mod v0; use crate::state_transition_action::contract::data_contract_update::v0::DataContractUpdateTransitionActionV0; use derive_more::From; use dpp::data_contract::DataContract; -use dpp::prelude::IdentityNonce; +use dpp::prelude::{IdentityNonce, UserFeeIncrease}; /// data contract update transition action #[derive(Debug, Clone, From)] @@ -37,4 +37,11 @@ impl DataContractUpdateTransitionAction { } } } + + /// fee multiplier + pub fn user_fee_increase(&self) -> UserFeeIncrease { + match self { + DataContractUpdateTransitionAction::V0(transition) => transition.user_fee_increase, + } + } } diff --git a/packages/rs-drive/src/state_transition_action/contract/data_contract_update/v0/mod.rs b/packages/rs-drive/src/state_transition_action/contract/data_contract_update/v0/mod.rs index 84e8bce987b..5b3bfca097a 100644 --- a/packages/rs-drive/src/state_transition_action/contract/data_contract_update/v0/mod.rs +++ b/packages/rs-drive/src/state_transition_action/contract/data_contract_update/v0/mod.rs @@ -2,7 +2,7 @@ pub mod transformer; use dpp::data_contract::DataContract; -use dpp::prelude::IdentityNonce; +use dpp::prelude::{IdentityNonce, UserFeeIncrease}; /// data contract update transition action v0 #[derive(Debug, Clone)] @@ -11,4 +11,6 @@ pub struct DataContractUpdateTransitionActionV0 { pub data_contract: DataContract, /// identity contract nonce pub identity_contract_nonce: IdentityNonce, + /// fee multiplier + pub user_fee_increase: UserFeeIncrease, } diff --git a/packages/rs-drive/src/state_transition_action/contract/data_contract_update/v0/transformer.rs b/packages/rs-drive/src/state_transition_action/contract/data_contract_update/v0/transformer.rs index ecbad8494fb..009da92b40e 100644 --- a/packages/rs-drive/src/state_transition_action/contract/data_contract_update/v0/transformer.rs +++ b/packages/rs-drive/src/state_transition_action/contract/data_contract_update/v0/transformer.rs @@ -21,6 +21,7 @@ impl TryFromPlatformVersioned platform_version, )?, identity_contract_nonce: value.identity_contract_nonce, + user_fee_increase: value.user_fee_increase, }) } } @@ -41,6 +42,7 @@ impl TryFromPlatformVersioned<&DataContractUpdateTransitionV0> platform_version, )?, identity_contract_nonce: value.identity_contract_nonce, + user_fee_increase: value.user_fee_increase, }) } } diff --git a/packages/rs-drive/src/state_transition_action/document/documents_batch/mod.rs b/packages/rs-drive/src/state_transition_action/document/documents_batch/mod.rs index db1ff2017ba..d6581cd9d1e 100644 --- a/packages/rs-drive/src/state_transition_action/document/documents_batch/mod.rs +++ b/packages/rs-drive/src/state_transition_action/document/documents_batch/mod.rs @@ -5,6 +5,7 @@ use dpp::data_contract::accessors::v0::DataContractV0Getters; use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; use dpp::identity::SecurityLevel; use dpp::platform_value::Identifier; +use dpp::prelude::UserFeeIncrease; use dpp::ProtocolError; use crate::state_transition_action::document::documents_batch::document_transition::document_base_transition_action::DocumentBaseTransitionActionAccessorsV0; @@ -62,6 +63,13 @@ impl DocumentsBatchTransitionAction { DocumentsBatchTransitionAction::V0(v0) => v0.transitions = transitions, } } + + /// fee multiplier + pub fn user_fee_increase(&self) -> UserFeeIncrease { + match self { + DocumentsBatchTransitionAction::V0(transition) => transition.user_fee_increase, + } + } } impl DocumentsBatchTransitionAction { diff --git a/packages/rs-drive/src/state_transition_action/document/documents_batch/v0/mod.rs b/packages/rs-drive/src/state_transition_action/document/documents_batch/v0/mod.rs index 62689f8607d..6fef9bd8537 100644 --- a/packages/rs-drive/src/state_transition_action/document/documents_batch/v0/mod.rs +++ b/packages/rs-drive/src/state_transition_action/document/documents_batch/v0/mod.rs @@ -1,5 +1,6 @@ use crate::state_transition_action::document::documents_batch::document_transition::DocumentTransitionAction; use dpp::identifier::Identifier; +use dpp::prelude::UserFeeIncrease; /// action v0 #[derive(Default, Debug, Clone)] @@ -8,4 +9,6 @@ pub struct DocumentsBatchTransitionActionV0 { pub owner_id: Identifier, /// The inner transitions pub transitions: Vec, + /// fee multiplier + pub user_fee_increase: UserFeeIncrease, } diff --git a/packages/rs-drive/src/state_transition_action/identity/identity_create/mod.rs b/packages/rs-drive/src/state_transition_action/identity/identity_create/mod.rs index bafaaeca538..c2c978ca99c 100644 --- a/packages/rs-drive/src/state_transition_action/identity/identity_create/mod.rs +++ b/packages/rs-drive/src/state_transition_action/identity/identity_create/mod.rs @@ -9,6 +9,7 @@ use crate::state_transition_action::identity::identity_create::v0::{ use derive_more::From; use dpp::identity::{Identity, IdentityPublicKey, PartialIdentity}; use dpp::platform_value::{Bytes36, Identifier}; +use dpp::prelude::UserFeeIncrease; use dpp::version::PlatformVersion; use dpp::ProtocolError; @@ -48,6 +49,13 @@ impl IdentityCreateTransitionAction { IdentityCreateTransitionAction::V0(action) => action.asset_lock_outpoint, } } + + /// fee multiplier + pub fn user_fee_increase(&self) -> UserFeeIncrease { + match self { + IdentityCreateTransitionAction::V0(transition) => transition.user_fee_increase, + } + } } impl From for PartialIdentity { diff --git a/packages/rs-drive/src/state_transition_action/identity/identity_create/v0/mod.rs b/packages/rs-drive/src/state_transition_action/identity/identity_create/v0/mod.rs index e3b71152936..4abd643ff98 100644 --- a/packages/rs-drive/src/state_transition_action/identity/identity_create/v0/mod.rs +++ b/packages/rs-drive/src/state_transition_action/identity/identity_create/v0/mod.rs @@ -7,6 +7,7 @@ use dpp::identity::{IdentityPublicKey, IdentityV0, PartialIdentity}; use dpp::identity::identity_public_key::accessors::v0::IdentityPublicKeyGettersV0; use dpp::identity::Identity; use dpp::platform_value::Bytes36; +use dpp::prelude::UserFeeIncrease; use dpp::version::PlatformVersion; use dpp::ProtocolError; use serde::{Deserialize, Serialize}; @@ -23,6 +24,8 @@ pub struct IdentityCreateTransitionActionV0 { pub identity_id: Identifier, /// asset lock outpoint pub asset_lock_outpoint: Bytes36, + /// fee multiplier + pub user_fee_increase: UserFeeIncrease, } impl From for PartialIdentity { diff --git a/packages/rs-drive/src/state_transition_action/identity/identity_create/v0/transformer.rs b/packages/rs-drive/src/state_transition_action/identity/identity_create/v0/transformer.rs index c41f188bbc4..5a7880a477b 100644 --- a/packages/rs-drive/src/state_transition_action/identity/identity_create/v0/transformer.rs +++ b/packages/rs-drive/src/state_transition_action/identity/identity_create/v0/transformer.rs @@ -36,6 +36,7 @@ impl IdentityCreateTransitionActionV0 { initial_balance_amount, identity_id, asset_lock_outpoint: Bytes36::new(outpoint_bytes), + user_fee_increase: value.user_fee_increase, }) } @@ -66,6 +67,7 @@ impl IdentityCreateTransitionActionV0 { initial_balance_amount, identity_id: *identity_id, asset_lock_outpoint: Bytes36::new(outpoint_bytes), + user_fee_increase: value.user_fee_increase, }) } } diff --git a/packages/rs-drive/src/state_transition_action/identity/identity_credit_transfer/mod.rs b/packages/rs-drive/src/state_transition_action/identity/identity_credit_transfer/mod.rs index 44bb92d031a..01dabf088d7 100644 --- a/packages/rs-drive/src/state_transition_action/identity/identity_credit_transfer/mod.rs +++ b/packages/rs-drive/src/state_transition_action/identity/identity_credit_transfer/mod.rs @@ -7,7 +7,7 @@ use crate::state_transition_action::identity::identity_credit_transfer::v0::Iden use derive_more::From; use dpp::fee::Credits; use dpp::platform_value::Identifier; -use dpp::prelude::IdentityNonce; +use dpp::prelude::{IdentityNonce, UserFeeIncrease}; /// action #[derive(Debug, Clone, From)] @@ -44,4 +44,11 @@ impl IdentityCreditTransferTransitionAction { IdentityCreditTransferTransitionAction::V0(transition) => transition.recipient_id, } } + + /// fee multiplier + pub fn user_fee_increase(&self) -> UserFeeIncrease { + match self { + IdentityCreditTransferTransitionAction::V0(transition) => transition.user_fee_increase, + } + } } diff --git a/packages/rs-drive/src/state_transition_action/identity/identity_credit_transfer/v0/mod.rs b/packages/rs-drive/src/state_transition_action/identity/identity_credit_transfer/v0/mod.rs index b850805b35f..9ee87543cb2 100644 --- a/packages/rs-drive/src/state_transition_action/identity/identity_credit_transfer/v0/mod.rs +++ b/packages/rs-drive/src/state_transition_action/identity/identity_credit_transfer/v0/mod.rs @@ -2,7 +2,7 @@ mod transformer; use dpp::fee::Credits; use dpp::platform_value::Identifier; -use dpp::prelude::IdentityNonce; +use dpp::prelude::{IdentityNonce, UserFeeIncrease}; use serde::{Deserialize, Serialize}; /// action v0 @@ -17,4 +17,6 @@ pub struct IdentityCreditTransferTransitionActionV0 { pub identity_id: Identifier, /// nonce pub nonce: IdentityNonce, + /// fee multiplier + pub user_fee_increase: UserFeeIncrease, } diff --git a/packages/rs-drive/src/state_transition_action/identity/identity_credit_transfer/v0/transformer.rs b/packages/rs-drive/src/state_transition_action/identity/identity_credit_transfer/v0/transformer.rs index 356147f1f55..72f79a34d68 100644 --- a/packages/rs-drive/src/state_transition_action/identity/identity_credit_transfer/v0/transformer.rs +++ b/packages/rs-drive/src/state_transition_action/identity/identity_credit_transfer/v0/transformer.rs @@ -8,6 +8,7 @@ impl From for IdentityCreditTransferTransiti recipient_id, amount, nonce, + user_fee_increase, .. } = value; IdentityCreditTransferTransitionActionV0 { @@ -15,6 +16,7 @@ impl From for IdentityCreditTransferTransiti recipient_id, transfer_amount: amount, nonce, + user_fee_increase, } } } @@ -26,6 +28,7 @@ impl From<&IdentityCreditTransferTransitionV0> for IdentityCreditTransferTransit recipient_id, amount, nonce, + user_fee_increase, .. } = value; IdentityCreditTransferTransitionActionV0 { @@ -33,6 +36,7 @@ impl From<&IdentityCreditTransferTransitionV0> for IdentityCreditTransferTransit recipient_id: *recipient_id, transfer_amount: *amount, nonce: *nonce, + user_fee_increase: *user_fee_increase, } } } diff --git a/packages/rs-drive/src/state_transition_action/identity/identity_credit_withdrawal/mod.rs b/packages/rs-drive/src/state_transition_action/identity/identity_credit_withdrawal/mod.rs index 08f4a46eff1..ef579b4d5cf 100644 --- a/packages/rs-drive/src/state_transition_action/identity/identity_credit_withdrawal/mod.rs +++ b/packages/rs-drive/src/state_transition_action/identity/identity_credit_withdrawal/mod.rs @@ -8,7 +8,7 @@ use derive_more::From; use dpp::document::Document; use dpp::platform_value::Identifier; -use dpp::prelude::IdentityNonce; +use dpp::prelude::{IdentityNonce, UserFeeIncrease}; /// action #[derive(Debug, Clone, From)] @@ -56,4 +56,13 @@ impl IdentityCreditWithdrawalTransitionAction { } } } + + /// fee multiplier + pub fn user_fee_increase(&self) -> UserFeeIncrease { + match self { + IdentityCreditWithdrawalTransitionAction::V0(transition) => { + transition.user_fee_increase + } + } + } } diff --git a/packages/rs-drive/src/state_transition_action/identity/identity_credit_withdrawal/v0/mod.rs b/packages/rs-drive/src/state_transition_action/identity/identity_credit_withdrawal/v0/mod.rs index 858a08122dc..0e1be9120cb 100644 --- a/packages/rs-drive/src/state_transition_action/identity/identity_credit_withdrawal/v0/mod.rs +++ b/packages/rs-drive/src/state_transition_action/identity/identity_credit_withdrawal/v0/mod.rs @@ -2,7 +2,7 @@ mod transformer; use dpp::document::Document; use dpp::identifier::Identifier; -use dpp::prelude::IdentityNonce; +use dpp::prelude::{IdentityNonce, UserFeeIncrease}; use serde::{Deserialize, Serialize}; @@ -18,4 +18,6 @@ pub struct IdentityCreditWithdrawalTransitionActionV0 { pub prepared_withdrawal_document: Document, /// amount pub amount: u64, + /// fee multiplier + pub user_fee_increase: UserFeeIncrease, } diff --git a/packages/rs-drive/src/state_transition_action/identity/identity_credit_withdrawal/v0/transformer.rs b/packages/rs-drive/src/state_transition_action/identity/identity_credit_withdrawal/v0/transformer.rs index 90ec624839c..b1d352b97e4 100644 --- a/packages/rs-drive/src/state_transition_action/identity/identity_credit_withdrawal/v0/transformer.rs +++ b/packages/rs-drive/src/state_transition_action/identity/identity_credit_withdrawal/v0/transformer.rs @@ -47,6 +47,7 @@ impl IdentityCreditWithdrawalTransitionActionV0 { nonce: identity_credit_withdrawal.nonce, prepared_withdrawal_document: withdrawal_document, amount: identity_credit_withdrawal.amount, + user_fee_increase: identity_credit_withdrawal.user_fee_increase, } } } diff --git a/packages/rs-drive/src/state_transition_action/identity/identity_topup/mod.rs b/packages/rs-drive/src/state_transition_action/identity/identity_topup/mod.rs index 0743a68fb08..b9900811c49 100644 --- a/packages/rs-drive/src/state_transition_action/identity/identity_topup/mod.rs +++ b/packages/rs-drive/src/state_transition_action/identity/identity_topup/mod.rs @@ -7,6 +7,7 @@ use crate::state_transition_action::identity::identity_topup::v0::IdentityTopUpT use derive_more::From; use dpp::platform_value::{Bytes36, Identifier}; +use dpp::prelude::UserFeeIncrease; /// action #[derive(Debug, Clone, From)] @@ -36,4 +37,11 @@ impl IdentityTopUpTransitionAction { IdentityTopUpTransitionAction::V0(action) => action.asset_lock_outpoint, } } + + /// fee multiplier + pub fn user_fee_increase(&self) -> UserFeeIncrease { + match self { + IdentityTopUpTransitionAction::V0(transition) => transition.user_fee_increase, + } + } } diff --git a/packages/rs-drive/src/state_transition_action/identity/identity_topup/v0/mod.rs b/packages/rs-drive/src/state_transition_action/identity/identity_topup/v0/mod.rs index 2c718c420b0..98d6b5ad7d2 100644 --- a/packages/rs-drive/src/state_transition_action/identity/identity_topup/v0/mod.rs +++ b/packages/rs-drive/src/state_transition_action/identity/identity_topup/v0/mod.rs @@ -3,6 +3,7 @@ mod transformer; use dpp::identifier::Identifier; use dpp::platform_value::Bytes36; +use dpp::prelude::UserFeeIncrease; use serde::{Deserialize, Serialize}; /// action v0 @@ -15,4 +16,6 @@ pub struct IdentityTopUpTransitionActionV0 { pub identity_id: Identifier, /// asset lock outpoint pub asset_lock_outpoint: Bytes36, + /// fee multiplier + pub user_fee_increase: UserFeeIncrease, } diff --git a/packages/rs-drive/src/state_transition_action/identity/identity_topup/v0/transformer.rs b/packages/rs-drive/src/state_transition_action/identity/identity_topup/v0/transformer.rs index d14579d294a..75516f4fd63 100644 --- a/packages/rs-drive/src/state_transition_action/identity/identity_topup/v0/transformer.rs +++ b/packages/rs-drive/src/state_transition_action/identity/identity_topup/v0/transformer.rs @@ -17,6 +17,7 @@ impl IdentityTopUpTransitionActionV0 { let IdentityTopUpTransitionV0 { identity_id, asset_lock_proof, + user_fee_increase, .. } = value; @@ -34,6 +35,7 @@ impl IdentityTopUpTransitionActionV0 { top_up_balance_amount, identity_id, asset_lock_outpoint: Bytes36::new(outpoint_bytes), + user_fee_increase, }) } @@ -45,6 +47,7 @@ impl IdentityTopUpTransitionActionV0 { let IdentityTopUpTransitionV0 { identity_id, asset_lock_proof, + user_fee_increase, .. } = value; @@ -62,6 +65,7 @@ impl IdentityTopUpTransitionActionV0 { top_up_balance_amount, identity_id: *identity_id, asset_lock_outpoint: Bytes36::new(outpoint_bytes), + user_fee_increase: *user_fee_increase, }) } } diff --git a/packages/rs-drive/src/state_transition_action/identity/identity_update/mod.rs b/packages/rs-drive/src/state_transition_action/identity/identity_update/mod.rs index 564fa1a141d..51e22249889 100644 --- a/packages/rs-drive/src/state_transition_action/identity/identity_update/mod.rs +++ b/packages/rs-drive/src/state_transition_action/identity/identity_update/mod.rs @@ -3,11 +3,12 @@ pub mod transformer; /// v0 pub mod v0; +use crate::state_transition_action::identity::identity_credit_withdrawal::IdentityCreditWithdrawalTransitionAction; use crate::state_transition_action::identity::identity_update::v0::IdentityUpdateTransitionActionV0; use derive_more::From; use dpp::identity::{IdentityPublicKey, KeyID, TimestampMillis}; use dpp::platform_value::Identifier; -use dpp::prelude::Revision; +use dpp::prelude::{Revision, UserFeeIncrease}; /// action #[derive(Debug, Clone, From)] @@ -59,4 +60,11 @@ impl IdentityUpdateTransitionAction { IdentityUpdateTransitionAction::V0(transition) => transition.revision, } } + + /// fee multiplier + pub fn user_fee_increase(&self) -> UserFeeIncrease { + match self { + IdentityUpdateTransitionAction::V0(transition) => transition.user_fee_increase, + } + } } diff --git a/packages/rs-drive/src/state_transition_action/identity/identity_update/v0/mod.rs b/packages/rs-drive/src/state_transition_action/identity/identity_update/v0/mod.rs index c85f4d09f37..7c1f947b30b 100644 --- a/packages/rs-drive/src/state_transition_action/identity/identity_update/v0/mod.rs +++ b/packages/rs-drive/src/state_transition_action/identity/identity_update/v0/mod.rs @@ -2,7 +2,7 @@ mod transformer; use dpp::identifier::Identifier; use dpp::identity::{IdentityPublicKey, KeyID, TimestampMillis}; -use dpp::prelude::{IdentityNonce, Revision}; +use dpp::prelude::{IdentityNonce, Revision, UserFeeIncrease}; use serde::{Deserialize, Serialize}; /// action v0 @@ -21,4 +21,6 @@ pub struct IdentityUpdateTransitionActionV0 { pub revision: Revision, /// nonce used to prevent replay attacks pub nonce: IdentityNonce, + /// fee multiplier + pub user_fee_increase: UserFeeIncrease, } diff --git a/packages/rs-drive/src/state_transition_action/identity/identity_update/v0/transformer.rs b/packages/rs-drive/src/state_transition_action/identity/identity_update/v0/transformer.rs index 4400b10ed6e..6b96f281fd2 100644 --- a/packages/rs-drive/src/state_transition_action/identity/identity_update/v0/transformer.rs +++ b/packages/rs-drive/src/state_transition_action/identity/identity_update/v0/transformer.rs @@ -10,6 +10,7 @@ impl From for IdentityUpdateTransitionActionV0 { public_keys_disabled_at, revision, nonce, + user_fee_increase, .. } = value; IdentityUpdateTransitionActionV0 { @@ -19,6 +20,7 @@ impl From for IdentityUpdateTransitionActionV0 { identity_id, revision, nonce, + user_fee_increase, } } } @@ -32,6 +34,7 @@ impl From<&IdentityUpdateTransitionV0> for IdentityUpdateTransitionActionV0 { public_keys_disabled_at, revision, nonce, + user_fee_increase, .. } = value; IdentityUpdateTransitionActionV0 { @@ -44,6 +47,7 @@ impl From<&IdentityUpdateTransitionV0> for IdentityUpdateTransitionActionV0 { identity_id: *identity_id, revision: *revision, nonce: *nonce, + user_fee_increase: *user_fee_increase, } } } diff --git a/packages/rs-drive/src/state_transition_action/mod.rs b/packages/rs-drive/src/state_transition_action/mod.rs index c0385bbef1f..f3f90a1c6aa 100644 --- a/packages/rs-drive/src/state_transition_action/mod.rs +++ b/packages/rs-drive/src/state_transition_action/mod.rs @@ -16,9 +16,14 @@ use crate::state_transition_action::identity::identity_credit_transfer::Identity use crate::state_transition_action::identity::identity_credit_withdrawal::IdentityCreditWithdrawalTransitionAction; use crate::state_transition_action::identity::identity_topup::IdentityTopUpTransitionAction; use crate::state_transition_action::identity::identity_update::IdentityUpdateTransitionAction; -use crate::state_transition_action::system::bump_identity_data_contract_nonce_action::BumpIdentityDataContractNonceAction; -use crate::state_transition_action::system::bump_identity_nonce_action::BumpIdentityNonceAction; +use crate::state_transition_action::system::bump_identity_data_contract_nonce_action::{ + BumpIdentityDataContractNonceAction, BumpIdentityDataContractNonceActionAccessorsV0, +}; +use crate::state_transition_action::system::bump_identity_nonce_action::{ + BumpIdentityNonceAction, BumpIdentityNonceActionAccessorsV0, +}; use derive_more::From; +use dpp::prelude::UserFeeIncrease; /// ST action #[derive(Debug, Clone, From)] @@ -48,3 +53,27 @@ pub enum StateTransitionAction { /// it will also only happen if the state validation fails BumpIdentityDataContractNonceAction(BumpIdentityDataContractNonceAction), } + +impl StateTransitionAction { + /// The fee multiplier for the action + pub fn user_fee_increase(&self) -> UserFeeIncrease { + match self { + StateTransitionAction::DataContractCreateAction(action) => action.user_fee_increase(), + StateTransitionAction::DataContractUpdateAction(action) => action.user_fee_increase(), + StateTransitionAction::DocumentsBatchAction(action) => action.user_fee_increase(), + StateTransitionAction::IdentityCreateAction(action) => action.user_fee_increase(), + StateTransitionAction::IdentityTopUpAction(action) => action.user_fee_increase(), + StateTransitionAction::IdentityCreditWithdrawalAction(action) => { + action.user_fee_increase() + } + StateTransitionAction::IdentityUpdateAction(action) => action.user_fee_increase(), + StateTransitionAction::IdentityCreditTransferAction(action) => { + action.user_fee_increase() + } + StateTransitionAction::BumpIdentityNonceAction(action) => action.user_fee_increase(), + StateTransitionAction::BumpIdentityDataContractNonceAction(action) => { + action.user_fee_increase() + } + } + } +} diff --git a/packages/rs-drive/src/state_transition_action/system/bump_identity_data_contract_nonce_action/mod.rs b/packages/rs-drive/src/state_transition_action/system/bump_identity_data_contract_nonce_action/mod.rs index 68be72fc6be..bcd59379b31 100644 --- a/packages/rs-drive/src/state_transition_action/system/bump_identity_data_contract_nonce_action/mod.rs +++ b/packages/rs-drive/src/state_transition_action/system/bump_identity_data_contract_nonce_action/mod.rs @@ -1,7 +1,7 @@ use derive_more::From; use dpp::platform_value::Identifier; -use dpp::prelude::IdentityNonce; +use dpp::prelude::{IdentityNonce, UserFeeIncrease}; /// transformer module pub mod transformer; @@ -34,4 +34,10 @@ impl BumpIdentityDataContractNonceActionAccessorsV0 for BumpIdentityDataContract BumpIdentityDataContractNonceAction::V0(v0) => v0.identity_contract_nonce, } } + + fn user_fee_increase(&self) -> UserFeeIncrease { + match self { + BumpIdentityDataContractNonceAction::V0(transition) => transition.user_fee_increase, + } + } } diff --git a/packages/rs-drive/src/state_transition_action/system/bump_identity_data_contract_nonce_action/transformer.rs b/packages/rs-drive/src/state_transition_action/system/bump_identity_data_contract_nonce_action/transformer.rs index 10f46f6f141..ec98eb4d651 100644 --- a/packages/rs-drive/src/state_transition_action/system/bump_identity_data_contract_nonce_action/transformer.rs +++ b/packages/rs-drive/src/state_transition_action/system/bump_identity_data_contract_nonce_action/transformer.rs @@ -1,4 +1,5 @@ use dpp::platform_value::Identifier; +use dpp::prelude::UserFeeIncrease; use dpp::ProtocolError; use dpp::state_transition::data_contract_update_transition::DataContractUpdateTransition; @@ -12,11 +13,16 @@ impl BumpIdentityDataContractNonceAction { pub fn from_document_base_transition( value: DocumentBaseTransition, identity_id: Identifier, + user_fee_increase: UserFeeIncrease, ) -> Result { match value { DocumentBaseTransition::V0(v0) => Ok( - BumpIdentityDataContractNonceActionV0::try_from_base_transition(v0, identity_id)? - .into(), + BumpIdentityDataContractNonceActionV0::try_from_base_transition( + v0, + identity_id, + user_fee_increase, + )? + .into(), ), } } @@ -25,12 +31,14 @@ impl BumpIdentityDataContractNonceAction { pub fn from_borrowed_document_base_transition( value: &DocumentBaseTransition, identity_id: Identifier, + user_fee_increase: UserFeeIncrease, ) -> Result { match value { DocumentBaseTransition::V0(v0) => Ok( BumpIdentityDataContractNonceActionV0::try_from_borrowed_base_transition( v0, identity_id, + user_fee_increase, )? .into(), ), @@ -41,12 +49,14 @@ impl BumpIdentityDataContractNonceAction { pub fn from_document_base_transition_action( value: DocumentBaseTransitionAction, identity_id: Identifier, + user_fee_increase: UserFeeIncrease, ) -> Result { match value { DocumentBaseTransitionAction::V0(v0) => Ok( BumpIdentityDataContractNonceActionV0::try_from_base_transition_action( v0, identity_id, + user_fee_increase, )? .into(), ), @@ -57,12 +67,14 @@ impl BumpIdentityDataContractNonceAction { pub fn from_document_borrowed_base_transition_action( value: &DocumentBaseTransitionAction, identity_id: Identifier, + user_fee_increase: UserFeeIncrease, ) -> Result { match value { DocumentBaseTransitionAction::V0(v0) => Ok( BumpIdentityDataContractNonceActionV0::try_from_borrowed_base_transition_action( v0, identity_id, + user_fee_increase, )? .into(), ), diff --git a/packages/rs-drive/src/state_transition_action/system/bump_identity_data_contract_nonce_action/v0/mod.rs b/packages/rs-drive/src/state_transition_action/system/bump_identity_data_contract_nonce_action/v0/mod.rs index 4d812bb703b..52780ee2b4b 100644 --- a/packages/rs-drive/src/state_transition_action/system/bump_identity_data_contract_nonce_action/v0/mod.rs +++ b/packages/rs-drive/src/state_transition_action/system/bump_identity_data_contract_nonce_action/v0/mod.rs @@ -2,7 +2,7 @@ pub mod transformer; use dpp::identifier::Identifier; -use dpp::prelude::IdentityNonce; +use dpp::prelude::{IdentityNonce, UserFeeIncrease}; #[derive(Debug, Clone)] /// Version 0 of the bump identity data contract nonce action @@ -14,6 +14,8 @@ pub struct BumpIdentityDataContractNonceActionV0 { pub data_contract_id: Identifier, /// The identity contract nonce, this is used to stop replay attacks pub identity_contract_nonce: IdentityNonce, + /// fee multiplier + pub user_fee_increase: UserFeeIncrease, } /// document base transition action accessors v0 @@ -24,4 +26,6 @@ pub trait BumpIdentityDataContractNonceActionAccessorsV0 { fn data_contract_id(&self) -> Identifier; /// Identity contract nonce fn identity_contract_nonce(&self) -> IdentityNonce; + /// Fee multiplier + fn user_fee_increase(&self) -> UserFeeIncrease; } diff --git a/packages/rs-drive/src/state_transition_action/system/bump_identity_data_contract_nonce_action/v0/transformer.rs b/packages/rs-drive/src/state_transition_action/system/bump_identity_data_contract_nonce_action/v0/transformer.rs index f7219d1f594..6a338e35c41 100644 --- a/packages/rs-drive/src/state_transition_action/system/bump_identity_data_contract_nonce_action/v0/transformer.rs +++ b/packages/rs-drive/src/state_transition_action/system/bump_identity_data_contract_nonce_action/v0/transformer.rs @@ -1,5 +1,6 @@ use dpp::data_contract::accessors::v0::DataContractV0Getters; use dpp::platform_value::Identifier; +use dpp::prelude::UserFeeIncrease; use dpp::ProtocolError; use dpp::state_transition::data_contract_update_transition::DataContractUpdateTransitionV0; @@ -13,6 +14,7 @@ impl BumpIdentityDataContractNonceActionV0 { pub fn try_from_base_transition( value: DocumentBaseTransitionV0, identity_id: Identifier, + user_fee_increase: UserFeeIncrease, ) -> Result { let DocumentBaseTransitionV0 { data_contract_id, @@ -23,6 +25,7 @@ impl BumpIdentityDataContractNonceActionV0 { identity_id, data_contract_id, identity_contract_nonce, + user_fee_increase, }) } @@ -30,6 +33,7 @@ impl BumpIdentityDataContractNonceActionV0 { pub fn try_from_borrowed_base_transition( value: &DocumentBaseTransitionV0, identity_id: Identifier, + user_fee_increase: UserFeeIncrease, ) -> Result { let DocumentBaseTransitionV0 { data_contract_id, @@ -40,6 +44,7 @@ impl BumpIdentityDataContractNonceActionV0 { identity_id, data_contract_id: *data_contract_id, identity_contract_nonce: *identity_contract_nonce, + user_fee_increase, }) } @@ -47,6 +52,7 @@ impl BumpIdentityDataContractNonceActionV0 { pub fn try_from_base_transition_action( value: DocumentBaseTransitionActionV0, identity_id: Identifier, + user_fee_increase: UserFeeIncrease, ) -> Result { let DocumentBaseTransitionActionV0 { data_contract, @@ -57,6 +63,7 @@ impl BumpIdentityDataContractNonceActionV0 { identity_id, data_contract_id: data_contract.contract.id(), identity_contract_nonce, + user_fee_increase, }) } @@ -64,6 +71,7 @@ impl BumpIdentityDataContractNonceActionV0 { pub fn try_from_borrowed_base_transition_action( value: &DocumentBaseTransitionActionV0, identity_id: Identifier, + user_fee_increase: UserFeeIncrease, ) -> Result { let DocumentBaseTransitionActionV0 { data_contract, @@ -74,6 +82,7 @@ impl BumpIdentityDataContractNonceActionV0 { identity_id, data_contract_id: data_contract.contract.id(), identity_contract_nonce: *identity_contract_nonce, + user_fee_increase, }) } @@ -84,12 +93,14 @@ impl BumpIdentityDataContractNonceActionV0 { let DataContractUpdateTransitionV0 { data_contract, identity_contract_nonce, + user_fee_increase, .. } = value; Ok(BumpIdentityDataContractNonceActionV0 { identity_id: data_contract.owner_id(), data_contract_id: data_contract.id(), identity_contract_nonce, + user_fee_increase, }) } @@ -100,12 +111,14 @@ impl BumpIdentityDataContractNonceActionV0 { let DataContractUpdateTransitionV0 { data_contract, identity_contract_nonce, + user_fee_increase, .. } = value; Ok(BumpIdentityDataContractNonceActionV0 { identity_id: data_contract.owner_id(), data_contract_id: data_contract.id(), identity_contract_nonce: *identity_contract_nonce, + user_fee_increase: *user_fee_increase, }) } @@ -116,12 +129,14 @@ impl BumpIdentityDataContractNonceActionV0 { let DataContractUpdateTransitionActionV0 { data_contract, identity_contract_nonce, + user_fee_increase, .. } = value; Ok(BumpIdentityDataContractNonceActionV0 { identity_id: data_contract.owner_id(), data_contract_id: data_contract.id(), identity_contract_nonce, + user_fee_increase, }) } @@ -132,12 +147,14 @@ impl BumpIdentityDataContractNonceActionV0 { let DataContractUpdateTransitionActionV0 { data_contract, identity_contract_nonce, + user_fee_increase, .. } = value; Ok(BumpIdentityDataContractNonceActionV0 { identity_id: data_contract.owner_id(), data_contract_id: data_contract.id(), identity_contract_nonce: *identity_contract_nonce, + user_fee_increase: *user_fee_increase, }) } } diff --git a/packages/rs-drive/src/state_transition_action/system/bump_identity_nonce_action/mod.rs b/packages/rs-drive/src/state_transition_action/system/bump_identity_nonce_action/mod.rs index c586a02020e..c66be8b36a3 100644 --- a/packages/rs-drive/src/state_transition_action/system/bump_identity_nonce_action/mod.rs +++ b/packages/rs-drive/src/state_transition_action/system/bump_identity_nonce_action/mod.rs @@ -1,7 +1,7 @@ use derive_more::From; use dpp::platform_value::Identifier; -use dpp::prelude::IdentityNonce; +use dpp::prelude::{IdentityNonce, UserFeeIncrease}; /// transformer module pub mod transformer; @@ -28,4 +28,10 @@ impl BumpIdentityNonceActionAccessorsV0 for BumpIdentityNonceAction { BumpIdentityNonceAction::V0(v0) => v0.identity_nonce, } } + + fn user_fee_increase(&self) -> UserFeeIncrease { + match self { + BumpIdentityNonceAction::V0(transition) => transition.user_fee_increase, + } + } } diff --git a/packages/rs-drive/src/state_transition_action/system/bump_identity_nonce_action/v0/mod.rs b/packages/rs-drive/src/state_transition_action/system/bump_identity_nonce_action/v0/mod.rs index 17e36375712..8437a51f704 100644 --- a/packages/rs-drive/src/state_transition_action/system/bump_identity_nonce_action/v0/mod.rs +++ b/packages/rs-drive/src/state_transition_action/system/bump_identity_nonce_action/v0/mod.rs @@ -2,7 +2,7 @@ pub mod transformer; use dpp::identifier::Identifier; -use dpp::prelude::IdentityNonce; +use dpp::prelude::{IdentityNonce, UserFeeIncrease}; #[derive(Debug, Clone)] /// Version 0 of the bump identity nonce action @@ -13,6 +13,8 @@ pub struct BumpIdentityNonceActionV0 { pub identity_id: Identifier, /// The identity contract nonce, this is used to stop replay attacks pub identity_nonce: IdentityNonce, + /// fee multiplier + pub user_fee_increase: UserFeeIncrease, } /// document base transition action accessors v0 @@ -21,4 +23,7 @@ pub trait BumpIdentityNonceActionAccessorsV0 { fn identity_id(&self) -> Identifier; /// Identity contract nonce fn identity_nonce(&self) -> IdentityNonce; + + /// fee multiplier + fn user_fee_increase(&self) -> UserFeeIncrease; } diff --git a/packages/rs-drive/src/state_transition_action/system/bump_identity_nonce_action/v0/transformer.rs b/packages/rs-drive/src/state_transition_action/system/bump_identity_nonce_action/v0/transformer.rs index ee46bc58659..9c99de49239 100644 --- a/packages/rs-drive/src/state_transition_action/system/bump_identity_nonce_action/v0/transformer.rs +++ b/packages/rs-drive/src/state_transition_action/system/bump_identity_nonce_action/v0/transformer.rs @@ -13,11 +13,15 @@ impl BumpIdentityNonceActionV0 { value: IdentityUpdateTransitionV0, ) -> Result { let IdentityUpdateTransitionV0 { - identity_id, nonce, .. + identity_id, + nonce, + user_fee_increase, + .. } = value; Ok(BumpIdentityNonceActionV0 { identity_id, identity_nonce: nonce, + user_fee_increase, }) } @@ -26,11 +30,15 @@ impl BumpIdentityNonceActionV0 { value: &IdentityUpdateTransitionV0, ) -> Result { let IdentityUpdateTransitionV0 { - identity_id, nonce, .. + identity_id, + nonce, + user_fee_increase, + .. } = value; Ok(BumpIdentityNonceActionV0 { identity_id: *identity_id, identity_nonce: *nonce, + user_fee_increase: *user_fee_increase, }) } @@ -39,11 +47,15 @@ impl BumpIdentityNonceActionV0 { value: IdentityUpdateTransitionActionV0, ) -> Result { let IdentityUpdateTransitionActionV0 { - identity_id, nonce, .. + identity_id, + nonce, + user_fee_increase, + .. } = value; Ok(BumpIdentityNonceActionV0 { identity_id, identity_nonce: nonce, + user_fee_increase, }) } @@ -52,11 +64,15 @@ impl BumpIdentityNonceActionV0 { value: &IdentityUpdateTransitionActionV0, ) -> Result { let IdentityUpdateTransitionActionV0 { - identity_id, nonce, .. + identity_id, + nonce, + user_fee_increase, + .. } = value; Ok(BumpIdentityNonceActionV0 { identity_id: *identity_id, identity_nonce: *nonce, + user_fee_increase: *user_fee_increase, }) } @@ -65,11 +81,15 @@ impl BumpIdentityNonceActionV0 { value: IdentityCreditTransferTransitionV0, ) -> Result { let IdentityCreditTransferTransitionV0 { - identity_id, nonce, .. + identity_id, + nonce, + user_fee_increase, + .. } = value; Ok(BumpIdentityNonceActionV0 { identity_id, identity_nonce: nonce, + user_fee_increase, }) } @@ -78,11 +98,15 @@ impl BumpIdentityNonceActionV0 { value: &IdentityCreditTransferTransitionV0, ) -> Result { let IdentityCreditTransferTransitionV0 { - identity_id, nonce, .. + identity_id, + nonce, + user_fee_increase, + .. } = value; Ok(BumpIdentityNonceActionV0 { identity_id: *identity_id, identity_nonce: *nonce, + user_fee_increase: *user_fee_increase, }) } @@ -91,11 +115,15 @@ impl BumpIdentityNonceActionV0 { value: IdentityCreditTransferTransitionActionV0, ) -> Result { let IdentityCreditTransferTransitionActionV0 { - identity_id, nonce, .. + identity_id, + nonce, + user_fee_increase, + .. } = value; Ok(BumpIdentityNonceActionV0 { identity_id, identity_nonce: nonce, + user_fee_increase, }) } @@ -104,11 +132,15 @@ impl BumpIdentityNonceActionV0 { value: &IdentityCreditTransferTransitionActionV0, ) -> Result { let IdentityCreditTransferTransitionActionV0 { - identity_id, nonce, .. + identity_id, + nonce, + user_fee_increase, + .. } = value; Ok(BumpIdentityNonceActionV0 { identity_id: *identity_id, identity_nonce: *nonce, + user_fee_increase: *user_fee_increase, }) } @@ -117,11 +149,15 @@ impl BumpIdentityNonceActionV0 { value: IdentityCreditWithdrawalTransitionV0, ) -> Result { let IdentityCreditWithdrawalTransitionV0 { - identity_id, nonce, .. + identity_id, + nonce, + user_fee_increase, + .. } = value; Ok(BumpIdentityNonceActionV0 { identity_id, identity_nonce: nonce, + user_fee_increase, }) } @@ -130,11 +166,15 @@ impl BumpIdentityNonceActionV0 { value: &IdentityCreditWithdrawalTransitionV0, ) -> Result { let IdentityCreditWithdrawalTransitionV0 { - identity_id, nonce, .. + identity_id, + nonce, + user_fee_increase, + .. } = value; Ok(BumpIdentityNonceActionV0 { identity_id: *identity_id, identity_nonce: *nonce, + user_fee_increase: *user_fee_increase, }) } @@ -143,11 +183,15 @@ impl BumpIdentityNonceActionV0 { value: IdentityCreditWithdrawalTransitionActionV0, ) -> Result { let IdentityCreditWithdrawalTransitionActionV0 { - identity_id, nonce, .. + identity_id, + nonce, + user_fee_increase, + .. } = value; Ok(BumpIdentityNonceActionV0 { identity_id, identity_nonce: nonce, + user_fee_increase, }) } @@ -156,11 +200,15 @@ impl BumpIdentityNonceActionV0 { value: &IdentityCreditWithdrawalTransitionActionV0, ) -> Result { let IdentityCreditWithdrawalTransitionActionV0 { - identity_id, nonce, .. + identity_id, + nonce, + user_fee_increase, + .. } = value; Ok(BumpIdentityNonceActionV0 { identity_id: *identity_id, identity_nonce: *nonce, + user_fee_increase: *user_fee_increase, }) } } diff --git a/packages/rs-sdk/src/platform/transition/put_document.rs b/packages/rs-sdk/src/platform/transition/put_document.rs index e4a88ec9943..8c9edfd70bb 100644 --- a/packages/rs-sdk/src/platform/transition/put_document.rs +++ b/packages/rs-sdk/src/platform/transition/put_document.rs @@ -72,12 +72,16 @@ impl PutDocument for Document { settings, ) .await?; + + let settings = settings.unwrap_or_default(); + let transition = DocumentsBatchTransition::new_document_creation_transition_from_document( self.clone(), document_type.as_ref(), document_state_transition_entropy, &identity_public_key, new_identity_contract_nonce, + settings.user_fee_increase.unwrap_or_default(), signer, sdk.version(), None, @@ -89,7 +93,7 @@ impl PutDocument for Document { request .clone() - .execute(sdk, settings.unwrap_or_default().request_settings) + .execute(sdk, settings.request_settings) .await?; // response is empty for a broadcast, result comes from the stream wait for state transition result diff --git a/packages/rs-sdk/src/platform/transition/put_settings.rs b/packages/rs-sdk/src/platform/transition/put_settings.rs index d6544132d92..7ddaef7a687 100644 --- a/packages/rs-sdk/src/platform/transition/put_settings.rs +++ b/packages/rs-sdk/src/platform/transition/put_settings.rs @@ -1,3 +1,4 @@ +use dpp::prelude::UserFeeIncrease; use rs_dapi_client::RequestSettings; /// The options when putting something to platform @@ -5,4 +6,5 @@ use rs_dapi_client::RequestSettings; pub struct PutSettings { pub request_settings: RequestSettings, pub identity_nonce_stale_time_s: Option, + pub user_fee_increase: Option, } diff --git a/packages/rs-sdk/src/platform/transition/top_up_identity.rs b/packages/rs-sdk/src/platform/transition/top_up_identity.rs index eadf5396398..2aa5eb3b942 100644 --- a/packages/rs-sdk/src/platform/transition/top_up_identity.rs +++ b/packages/rs-sdk/src/platform/transition/top_up_identity.rs @@ -3,7 +3,7 @@ use crate::{Error, Sdk}; use dapi_grpc::platform::VersionedGrpcResponse; use dpp::dashcore::PrivateKey; use dpp::identity::Identity; -use dpp::prelude::AssetLockProof; +use dpp::prelude::{AssetLockProof, UserFeeIncrease}; use dpp::state_transition::identity_topup_transition::methods::IdentityTopUpTransitionMethodsV0; use dpp::state_transition::identity_topup_transition::IdentityTopUpTransition; use dpp::state_transition::proof_result::StateTransitionProofResult; @@ -17,6 +17,7 @@ pub trait TopUpIdentity { sdk: &Sdk, asset_lock_proof: AssetLockProof, asset_lock_proof_private_key: &PrivateKey, + user_fee_increase: Option, ) -> Result; } @@ -27,11 +28,13 @@ impl TopUpIdentity for Identity { sdk: &Sdk, asset_lock_proof: AssetLockProof, asset_lock_proof_private_key: &PrivateKey, + user_fee_increase: Option, ) -> Result { let state_transition = IdentityTopUpTransition::try_from_identity( self, asset_lock_proof, asset_lock_proof_private_key.inner.as_ref(), + user_fee_increase.unwrap_or_default(), sdk.version(), None, )?; diff --git a/packages/rs-sdk/src/platform/transition/withdraw_from_identity.rs b/packages/rs-sdk/src/platform/transition/withdraw_from_identity.rs index 72c1a579b96..093c182e43f 100644 --- a/packages/rs-sdk/src/platform/transition/withdraw_from_identity.rs +++ b/packages/rs-sdk/src/platform/transition/withdraw_from_identity.rs @@ -5,6 +5,7 @@ use dpp::identity::accessors::IdentityGettersV0; use dpp::identity::core_script::CoreScript; use dpp::identity::signer::Signer; use dpp::identity::Identity; +use dpp::prelude::UserFeeIncrease; use dpp::state_transition::identity_credit_withdrawal_transition::IdentityCreditWithdrawalTransition; @@ -26,6 +27,7 @@ pub trait WithdrawFromIdentity { address: Address, amount: u64, core_fee_per_byte: Option, + user_fee_increase: Option, signer: S, settings: Option, ) -> Result; @@ -39,6 +41,7 @@ impl WithdrawFromIdentity for Identity { address: Address, amount: u64, core_fee_per_byte: Option, + user_fee_increase: Option, signer: S, settings: Option, ) -> Result { @@ -49,6 +52,7 @@ impl WithdrawFromIdentity for Identity { amount, Pooling::Never, core_fee_per_byte.unwrap_or(1), + user_fee_increase.unwrap_or_default(), signer, new_identity_nonce, sdk.version(), diff --git a/packages/strategy-tests/src/lib.rs b/packages/strategy-tests/src/lib.rs index b62761bfb4c..0b1e155b3af 100644 --- a/packages/strategy-tests/src/lib.rs +++ b/packages/strategy-tests/src/lib.rs @@ -523,6 +523,7 @@ impl Strategy { &identity_info, 2, // Assuming key id 2 is a high or critical auth key *nonce, + 0, signer, platform_version, None, @@ -666,6 +667,7 @@ impl Strategy { DocumentsBatchTransitionV0 { owner_id: identity.id(), transitions: vec![document_create_transition.into()], + user_fee_increase: 0, signature_public_key_id: 2, signature: BinaryData::default(), } @@ -779,6 +781,7 @@ impl Strategy { DocumentsBatchTransitionV0 { owner_id: identity.id(), transitions: vec![document_create_transition.into()], + user_fee_increase: 0, signature_public_key_id: 1, signature: BinaryData::default(), } @@ -881,6 +884,7 @@ impl Strategy { DocumentsBatchTransitionV0 { owner_id: identity.id, transitions: vec![document_delete_transition.into()], + user_fee_increase: 0, signature_public_key_id: 1, signature: BinaryData::default(), } @@ -986,6 +990,7 @@ impl Strategy { DocumentsBatchTransitionV0 { owner_id: identity.id, transitions: vec![document_replace_transition.into()], + user_fee_increase: 0, signature_public_key_id: 1, signature: BinaryData::default(), } diff --git a/packages/strategy-tests/src/transitions.rs b/packages/strategy-tests/src/transitions.rs index 5a47e6f1c38..b0c57dae6bf 100644 --- a/packages/strategy-tests/src/transitions.rs +++ b/packages/strategy-tests/src/transitions.rs @@ -236,6 +236,7 @@ pub fn create_identity_top_up_transition( identity, asset_lock_proof, pk_bytes.as_ref(), + 0, platform_version, None, ) @@ -315,6 +316,7 @@ pub fn create_identity_update_transition_add_keys( vec![], None, *identity_nonce, + 0, signer, platform_version, None, @@ -423,6 +425,7 @@ pub fn create_identity_update_transition_disable_keys( key_ids_to_disable, Some(block_time), *identity_nonce, + 0, signer, platform_version, None, @@ -476,6 +479,7 @@ pub fn create_identity_withdrawal_transition( pooling: Pooling::Never, output_script: CoreScript::random_p2sh(rng), nonce: *nonce, + user_fee_increase: 0, signature_public_key_id: 0, signature: Default::default(), } @@ -546,6 +550,7 @@ pub fn create_identity_credit_transfer_transition( recipient_id: recipient.id(), amount, nonce: *nonce, + user_fee_increase: 0, signature_public_key_id: 0, signature: Default::default(), } diff --git a/packages/wasm-dpp/src/data_contract_factory/data_contract_factory.rs b/packages/wasm-dpp/src/data_contract_factory/data_contract_factory.rs index 3036b9d8497..4d1d87166b4 100644 --- a/packages/wasm-dpp/src/data_contract_factory/data_contract_factory.rs +++ b/packages/wasm-dpp/src/data_contract_factory/data_contract_factory.rs @@ -28,9 +28,7 @@ impl From for DataContractFactory { #[wasm_bindgen(js_class=DataContractFactory)] impl DataContractFactoryWasm { #[wasm_bindgen(constructor)] - pub fn new( - protocol_version: u32, - ) -> DataContractFactoryWasm { + pub fn new(protocol_version: u32) -> DataContractFactoryWasm { DataContractFactory::new(protocol_version) .with_js_error() .expect("should create a factory") diff --git a/packages/wasm-dpp/src/identity/state_transition/identity_topup_transition/identity_topup_transition.rs b/packages/wasm-dpp/src/identity/state_transition/identity_topup_transition/identity_topup_transition.rs index 0de70583fa1..bbe6315614c 100644 --- a/packages/wasm-dpp/src/identity/state_transition/identity_topup_transition/identity_topup_transition.rs +++ b/packages/wasm-dpp/src/identity/state_transition/identity_topup_transition/identity_topup_transition.rs @@ -66,7 +66,9 @@ impl IdentityTopUpTransitionWasm { pub fn set_asset_lock_proof(&mut self, asset_lock_proof: JsValue) -> Result<(), JsValue> { let asset_lock_proof = create_asset_lock_proof_from_wasm_instance(&asset_lock_proof)?; - self.0.set_asset_lock_proof(asset_lock_proof).map_err(from_dpp_err) + self.0 + .set_asset_lock_proof(asset_lock_proof) + .map_err(from_dpp_err) } #[wasm_bindgen(getter, js_name=assetLockProof)] diff --git a/packages/wasm-dpp/test/unit/dataContract/stateTransition/DataContractCreateTransition/DataContractCreateTransition.spec.js b/packages/wasm-dpp/test/unit/dataContract/stateTransition/DataContractCreateTransition/DataContractCreateTransition.spec.js index c1d94c84843..973c2f90e31 100644 --- a/packages/wasm-dpp/test/unit/dataContract/stateTransition/DataContractCreateTransition/DataContractCreateTransition.spec.js +++ b/packages/wasm-dpp/test/unit/dataContract/stateTransition/DataContractCreateTransition/DataContractCreateTransition.spec.js @@ -66,7 +66,7 @@ describe('DataContractCreateTransition', () => { it('should return serialized State Transition', () => { const result = stateTransition.toBuffer(); expect(result).to.be.instanceOf(Buffer); - expect(result).to.have.lengthOf(2357); + expect(result).to.have.lengthOf(2358); }); it('should be able to restore contract config from bytes', () => { diff --git a/packages/wasm-dpp/test/unit/dataContract/stateTransition/DataContractUpdateTransition/DataContractUpdateTransition.spec.js b/packages/wasm-dpp/test/unit/dataContract/stateTransition/DataContractUpdateTransition/DataContractUpdateTransition.spec.js index 074e375d90d..dd2cda514c3 100644 --- a/packages/wasm-dpp/test/unit/dataContract/stateTransition/DataContractUpdateTransition/DataContractUpdateTransition.spec.js +++ b/packages/wasm-dpp/test/unit/dataContract/stateTransition/DataContractUpdateTransition/DataContractUpdateTransition.spec.js @@ -65,7 +65,7 @@ describe('DataContractUpdateTransition', () => { it('should return serialized State Transition', () => { const result = stateTransition.toBuffer(); expect(result).to.be.instanceOf(Buffer); - expect(result).to.have.lengthOf(2357); + expect(result).to.have.lengthOf(2358); }); it('should be able to restore contract config from bytes', () => {