From 7633aee140d9f4cd73ff5aaed3378a425d019f7e Mon Sep 17 00:00:00 2001 From: Ivan Shumkov Date: Mon, 27 Jan 2025 13:53:06 +0700 Subject: [PATCH] docs: add doc blocks --- .../rs-sdk/src/platform/transition/builder.rs | 42 ++++++++++ .../transition/fungible_tokens/burn.rs | 68 ++++++++++++++-- .../transition/fungible_tokens/destroy.rs | 66 +++++++++++++++- .../fungible_tokens/emergency_action.rs | 78 ++++++++++++++++++- .../transition/fungible_tokens/freeze.rs | 66 +++++++++++++++- .../transition/fungible_tokens/mint.rs | 75 +++++++++++++++++- .../transition/fungible_tokens/mod.rs | 2 + .../transition/fungible_tokens/transfer.rs | 76 +++++++++++++++++- .../transition/fungible_tokens/unfreeze.rs | 66 +++++++++++++++- 9 files changed, 526 insertions(+), 13 deletions(-) diff --git a/packages/rs-sdk/src/platform/transition/builder.rs b/packages/rs-sdk/src/platform/transition/builder.rs index cb2c58a67c..6c4549561d 100644 --- a/packages/rs-sdk/src/platform/transition/builder.rs +++ b/packages/rs-sdk/src/platform/transition/builder.rs @@ -8,9 +8,27 @@ use dpp::identity::IdentityPublicKey; use dpp::state_transition::StateTransition; use dpp::version::PlatformVersion; +/// Trait for building state transitions pub trait StateTransitionBuilder { + /// Returns the settings for the state transition + /// + /// # Returns + /// + /// * `Option` - The settings, if any fn settings(&self) -> Option; + /// Signs the state transition + /// + /// # Arguments + /// + /// * `sdk` - The SDK instance + /// * `identity_public_key` - The public key of the identity + /// * `signer` - The signer instance + /// * `platform_version` - The platform version + /// + /// # Returns + /// + /// * `Result` - The signed state transition or an error async fn sign( &self, sdk: &Sdk, @@ -19,6 +37,18 @@ pub trait StateTransitionBuilder { platform_version: &PlatformVersion, ) -> Result; + /// Broadcasts the state transition + /// + /// # Arguments + /// + /// * `sdk` - The SDK instance + /// * `identity_public_key` - The public key of the identity + /// * `signer` - The signer instance + /// * `platform_version` - The platform version + /// + /// # Returns + /// + /// * `Result` - The broadcasted state transition or an error async fn broadcast( &self, sdk: &Sdk, @@ -35,6 +65,18 @@ pub trait StateTransitionBuilder { Ok(state_transition) } + /// Broadcasts the state transition and waits for the result + /// + /// # Arguments + /// + /// * `sdk` - The SDK instance + /// * `identity_public_key` - The public key of the identity + /// * `signer` - The signer instance + /// * `platform_version` - The platform version + /// + /// # Returns + /// + /// * `Result<(Identifier, TokenAmount), Error>` - The result of the broadcasted state transition or an error async fn broadcast_and_wait_for_result( &self, sdk: &Sdk, diff --git a/packages/rs-sdk/src/platform/transition/fungible_tokens/burn.rs b/packages/rs-sdk/src/platform/transition/fungible_tokens/burn.rs index d533ec95f8..f0595d1841 100644 --- a/packages/rs-sdk/src/platform/transition/fungible_tokens/burn.rs +++ b/packages/rs-sdk/src/platform/transition/fungible_tokens/burn.rs @@ -15,7 +15,7 @@ use dpp::state_transition::StateTransition; use dpp::tokens::calculate_token_id; use dpp::version::PlatformVersion; -/// A builder to configure and broadcast burning tokens transition +/// A builder to configure and broadcast token burn transitions pub struct TokenBurnTransitionBuilder<'a> { data_contract: &'a DataContract, token_position: TokenContractPosition, @@ -28,14 +28,20 @@ pub struct TokenBurnTransitionBuilder<'a> { } impl<'a> TokenBurnTransitionBuilder<'a> { + /// Creates a new `TokenBurnTransitionBuilder` + /// + /// # Arguments + /// + /// * `data_contract` - A reference to the data contract + /// * `token_position` - The position of the token in the contract + /// * `owner_id` - The identifier of the token owner + /// * `amount` - The amount of tokens to burn pub fn new( data_contract: &'a DataContract, token_position: TokenContractPosition, owner_id: Identifier, amount: TokenAmount, ) -> Self { - // TODO: Validate token position - Self { data_contract, token_position, @@ -48,24 +54,57 @@ impl<'a> TokenBurnTransitionBuilder<'a> { } } + /// Adds a public note to the token burn transition + /// + /// # Arguments + /// + /// * `note` - The public note to add + /// + /// # Returns + /// + /// * `Self` - The updated builder pub fn with_public_note(mut self, note: String) -> Self { self.public_note = Some(note); self } + /// Adds a user fee increase to the token burn transition + /// + /// # Arguments + /// + /// * `user_fee_increase` - The user fee increase to add + /// + /// # Returns + /// + /// * `Self` - The updated builder pub fn with_user_fee_increase(mut self, user_fee_increase: UserFeeIncrease) -> Self { self.user_fee_increase = Some(user_fee_increase); self } + /// Adds group information to the token burn transition + /// + /// # Arguments + /// + /// * `group_info` - The group information to add + /// + /// # Returns + /// + /// * `Self` - The updated builder pub fn with_using_group_info(mut self, group_info: GroupStateTransitionInfoStatus) -> Self { self.using_group_info = Some(group_info); - - // TODO: Simplify group actions automatically find position if group action is required - self } + /// Adds settings to the token burn transition + /// + /// # Arguments + /// + /// * `settings` - The settings to add + /// + /// # Returns + /// + /// * `Self` - The updated builder pub fn with_settings(mut self, settings: PutSettings) -> Self { self.settings = Some(settings); self @@ -73,10 +112,27 @@ impl<'a> TokenBurnTransitionBuilder<'a> { } impl StateTransitionBuilder for TokenBurnTransitionBuilder<'_> { + /// Returns the settings for the token burn transition + /// + /// # Returns + /// + /// * `Option` - The settings, if any fn settings(&self) -> Option { self.settings } + /// Signs the token burn transition + /// + /// # Arguments + /// + /// * `sdk` - The SDK instance + /// * `identity_public_key` - The public key of the identity + /// * `signer` - The signer instance + /// * `platform_version` - The platform version + /// + /// # Returns + /// + /// * `Result` - The signed state transition or an error async fn sign( &self, sdk: &Sdk, diff --git a/packages/rs-sdk/src/platform/transition/fungible_tokens/destroy.rs b/packages/rs-sdk/src/platform/transition/fungible_tokens/destroy.rs index e771d29ff0..e82e4becbe 100644 --- a/packages/rs-sdk/src/platform/transition/fungible_tokens/destroy.rs +++ b/packages/rs-sdk/src/platform/transition/fungible_tokens/destroy.rs @@ -14,7 +14,7 @@ use dpp::state_transition::StateTransition; use dpp::tokens::calculate_token_id; use dpp::version::PlatformVersion; -/// A builder to configure minting tokens. +/// A builder to configure and broadcast token destroy funds transitions pub struct TokenDestroyFrozenFundsTransitionBuilder<'a> { data_contract: &'a DataContract, token_position: TokenContractPosition, @@ -28,6 +28,17 @@ pub struct TokenDestroyFrozenFundsTransitionBuilder<'a> { impl<'a> TokenDestroyFrozenFundsTransitionBuilder<'a> { /// Start building a mint tokens request for the provided DataContract. + /// + /// # Arguments + /// + /// * `data_contract` - A reference to the data contract + /// * `token_position` - The position of the token in the contract + /// * `actor_id` - The identifier of the actor + /// * `frozen_identity_id` - The identifier of the frozen identity + /// + /// # Returns + /// + /// * `Self` - The new builder instance pub fn new( data_contract: &'a DataContract, token_position: TokenContractPosition, @@ -48,16 +59,43 @@ impl<'a> TokenDestroyFrozenFundsTransitionBuilder<'a> { } } + /// Adds a public note to the token destroy transition + /// + /// # Arguments + /// + /// * `note` - The public note to add + /// + /// # Returns + /// + /// * `Self` - The updated builder pub fn with_public_note(mut self, note: String) -> Self { self.public_note = Some(note); self } + /// Adds a user fee increase to the token destroy transition + /// + /// # Arguments + /// + /// * `user_fee_increase` - The user fee increase to add + /// + /// # Returns + /// + /// * `Self` - The updated builder pub fn with_user_fee_increase(mut self, user_fee_increase: UserFeeIncrease) -> Self { self.user_fee_increase = Some(user_fee_increase); self } + /// Adds group information to the token destroy transition + /// + /// # Arguments + /// + /// * `group_info` - The group information to add + /// + /// # Returns + /// + /// * `Self` - The updated builder pub fn with_using_group_info(mut self, group_info: GroupStateTransitionInfoStatus) -> Self { self.using_group_info = Some(group_info); @@ -66,6 +104,15 @@ impl<'a> TokenDestroyFrozenFundsTransitionBuilder<'a> { self } + /// Adds settings to the token destroy transition + /// + /// # Arguments + /// + /// * `settings` - The settings to add + /// + /// # Returns + /// + /// * `Self` - The updated builder pub fn with_settings(mut self, settings: PutSettings) -> Self { self.settings = Some(settings); self @@ -73,10 +120,27 @@ impl<'a> TokenDestroyFrozenFundsTransitionBuilder<'a> { } impl StateTransitionBuilder for TokenDestroyFrozenFundsTransitionBuilder<'_> { + /// Returns the settings for the token destroy transition + /// + /// # Returns + /// + /// * `Option` - The settings, if any fn settings(&self) -> Option { self.settings } + /// Signs the token destroy transition + /// + /// # Arguments + /// + /// * `sdk` - The SDK instance + /// * `identity_public_key` - The public key of the identity + /// * `signer` - The signer instance + /// * `platform_version` - The platform version + /// + /// # Returns + /// + /// * `Result` - The signed state transition or an error async fn sign( &self, sdk: &Sdk, diff --git a/packages/rs-sdk/src/platform/transition/fungible_tokens/emergency_action.rs b/packages/rs-sdk/src/platform/transition/fungible_tokens/emergency_action.rs index ce54cb2d49..b8c45390cd 100644 --- a/packages/rs-sdk/src/platform/transition/fungible_tokens/emergency_action.rs +++ b/packages/rs-sdk/src/platform/transition/fungible_tokens/emergency_action.rs @@ -15,7 +15,7 @@ use dpp::tokens::calculate_token_id; use dpp::tokens::emergency_action::TokenEmergencyAction; use dpp::version::PlatformVersion; -/// A builder to configure minting tokens. +/// A builder to configure and broadcast emergency action transitions pub struct TokenEmergencyActionTransitionBuilder<'a> { data_contract: &'a DataContract, token_position: TokenContractPosition, @@ -28,7 +28,17 @@ pub struct TokenEmergencyActionTransitionBuilder<'a> { } impl<'a> TokenEmergencyActionTransitionBuilder<'a> { - /// Start building a mint tokens request for the provided DataContract. + /// Start building a pause tokens request for the provided DataContract. + /// + /// # Arguments + /// + /// * `data_contract` - A reference to the data contract + /// * `token_position` - The position of the token in the contract + /// * `actor_id` - The identifier of the actor + /// + /// # Returns + /// + /// * `Self` - The new builder instance pub fn pause( data_contract: &'a DataContract, token_position: TokenContractPosition, @@ -48,6 +58,17 @@ impl<'a> TokenEmergencyActionTransitionBuilder<'a> { } } + /// Start building a resume tokens request for the provided DataContract. + /// + /// # Arguments + /// + /// * `data_contract` - A reference to the data contract + /// * `token_position` - The position of the token in the contract + /// * `actor_id` - The identifier of the actor + /// + /// # Returns + /// + /// * `Self` - The new builder instance pub fn resume( data_contract: &'a DataContract, token_position: TokenContractPosition, @@ -67,16 +88,43 @@ impl<'a> TokenEmergencyActionTransitionBuilder<'a> { } } + /// Adds a public note to the token emergency action transition + /// + /// # Arguments + /// + /// * `note` - The public note to add + /// + /// # Returns + /// + /// * `Self` - The updated builder pub fn with_public_note(mut self, note: String) -> Self { self.public_note = Some(note); self } + /// Adds a user fee increase to the token emergency action transition + /// + /// # Arguments + /// + /// * `user_fee_increase` - The user fee increase to add + /// + /// # Returns + /// + /// * `Self` - The updated builder pub fn with_user_fee_increase(mut self, user_fee_increase: UserFeeIncrease) -> Self { self.user_fee_increase = Some(user_fee_increase); self } + /// Adds group information to the token emergency action transition + /// + /// # Arguments + /// + /// * `group_info` - The group information to add + /// + /// # Returns + /// + /// * `Self` - The updated builder pub fn with_using_group_info(mut self, group_info: GroupStateTransitionInfoStatus) -> Self { self.using_group_info = Some(group_info); @@ -85,6 +133,15 @@ impl<'a> TokenEmergencyActionTransitionBuilder<'a> { self } + /// Adds settings to the token emergency action transition + /// + /// # Arguments + /// + /// * `settings` - The settings to add + /// + /// # Returns + /// + /// * `Self` - The updated builder pub fn with_settings(mut self, settings: PutSettings) -> Self { self.settings = Some(settings); self @@ -92,10 +149,27 @@ impl<'a> TokenEmergencyActionTransitionBuilder<'a> { } impl StateTransitionBuilder for TokenEmergencyActionTransitionBuilder<'_> { + /// Returns the settings for the token emergency action transition + /// + /// # Returns + /// + /// * `Option` - The settings, if any fn settings(&self) -> Option { self.settings } + /// Signs the token emergency action transition + /// + /// # Arguments + /// + /// * `sdk` - The SDK instance + /// * `identity_public_key` - The public key of the identity + /// * `signer` - The signer instance + /// * `platform_version` - The platform version + /// + /// # Returns + /// + /// * `Result` - The signed state transition or an error async fn sign( &self, sdk: &Sdk, diff --git a/packages/rs-sdk/src/platform/transition/fungible_tokens/freeze.rs b/packages/rs-sdk/src/platform/transition/fungible_tokens/freeze.rs index d90ea52bde..0ac89e66c2 100644 --- a/packages/rs-sdk/src/platform/transition/fungible_tokens/freeze.rs +++ b/packages/rs-sdk/src/platform/transition/fungible_tokens/freeze.rs @@ -14,7 +14,7 @@ use dpp::state_transition::StateTransition; use dpp::tokens::calculate_token_id; use dpp::version::PlatformVersion; -/// A builder to configure minting tokens. +/// A builder to configure and broadcast token freeze transitions pub struct TokenFreezeTransitionBuilder<'a> { data_contract: &'a DataContract, token_position: TokenContractPosition, @@ -28,6 +28,17 @@ pub struct TokenFreezeTransitionBuilder<'a> { impl<'a> TokenFreezeTransitionBuilder<'a> { /// Start building a mint tokens request for the provided DataContract. + /// + /// # Arguments + /// + /// * `data_contract` - A reference to the data contract + /// * `token_position` - The position of the token in the contract + /// * `actor_id` - The identifier of the actor + /// * `freeze_identity_id` - The identifier of the frozen identity + /// + /// # Returns + /// + /// * `Self` - The new builder instance pub fn new( data_contract: &'a DataContract, token_position: TokenContractPosition, @@ -48,16 +59,43 @@ impl<'a> TokenFreezeTransitionBuilder<'a> { } } + /// Adds a public note to the token freeze transition + /// + /// # Arguments + /// + /// * `note` - The public note to add + /// + /// # Returns + /// + /// * `Self` - The updated builder pub fn with_public_note(mut self, note: String) -> Self { self.public_note = Some(note); self } + /// Adds a user fee increase to the token freeze transition + /// + /// # Arguments + /// + /// * `user_fee_increase` - The user fee increase to add + /// + /// # Returns + /// + /// * `Self` - The updated builder pub fn with_user_fee_increase(mut self, user_fee_increase: UserFeeIncrease) -> Self { self.user_fee_increase = Some(user_fee_increase); self } + /// Adds group information to the token freeze transition + /// + /// # Arguments + /// + /// * `group_info` - The group information to add + /// + /// # Returns + /// + /// * `Self` - The updated builder pub fn with_using_group_info(mut self, group_info: GroupStateTransitionInfoStatus) -> Self { self.using_group_info = Some(group_info); @@ -66,6 +104,15 @@ impl<'a> TokenFreezeTransitionBuilder<'a> { self } + /// Adds settings to the token freeze transition + /// + /// # Arguments + /// + /// * `settings` - The settings to add + /// + /// # Returns + /// + /// * `Self` - The updated builder pub fn with_settings(mut self, settings: PutSettings) -> Self { self.settings = Some(settings); self @@ -73,10 +120,27 @@ impl<'a> TokenFreezeTransitionBuilder<'a> { } impl StateTransitionBuilder for TokenFreezeTransitionBuilder<'_> { + /// Returns the settings for the token freeze transition + /// + /// # Returns + /// + /// * `Option` - The settings, if any fn settings(&self) -> Option { self.settings } + /// Signs the token freeze transition + /// + /// # Arguments + /// + /// * `sdk` - The SDK instance + /// * `identity_public_key` - The public key of the identity + /// * `signer` - The signer instance + /// * `platform_version` - The platform version + /// + /// # Returns + /// + /// * `Result` - The signed state transition or an error async fn sign( &self, sdk: &Sdk, diff --git a/packages/rs-sdk/src/platform/transition/fungible_tokens/mint.rs b/packages/rs-sdk/src/platform/transition/fungible_tokens/mint.rs index aca04c26ce..380f7cfe21 100644 --- a/packages/rs-sdk/src/platform/transition/fungible_tokens/mint.rs +++ b/packages/rs-sdk/src/platform/transition/fungible_tokens/mint.rs @@ -15,7 +15,7 @@ use dpp::state_transition::StateTransition; use dpp::tokens::calculate_token_id; use dpp::version::PlatformVersion; -/// A builder to configure minting tokens. +/// A builder to configure and broadcast token mint transitions pub struct TokenMintTransitionBuilder<'a> { data_contract: &'a DataContract, token_position: TokenContractPosition, @@ -30,6 +30,17 @@ pub struct TokenMintTransitionBuilder<'a> { impl<'a> TokenMintTransitionBuilder<'a> { /// Start building a mint tokens request for the provided DataContract. + /// + /// # Arguments + /// + /// * `data_contract` - A reference to the data contract + /// * `token_position` - The position of the token in the contract + /// * `issuer_id` - The identifier of the issuer + /// * `amount` - The amount of tokens to mint + /// + /// # Returns + /// + /// * `Self` - The new builder instance pub fn new( data_contract: &'a DataContract, token_position: TokenContractPosition, @@ -51,6 +62,15 @@ impl<'a> TokenMintTransitionBuilder<'a> { } } + /// Sets the recipient identity ID for the minted tokens + /// + /// # Arguments + /// + /// * `issued_to_id` - The identifier of the recipient + /// + /// # Returns + /// + /// * `Self` - The updated builder pub fn issued_to_identity_id(mut self, issued_to_id: Identifier) -> Self { self.recipient_id = Some(issued_to_id); @@ -59,16 +79,43 @@ impl<'a> TokenMintTransitionBuilder<'a> { self } + /// Adds a public note to the token mint transition + /// + /// # Arguments + /// + /// * `note` - The public note to add + /// + /// # Returns + /// + /// * `Self` - The updated builder pub fn with_public_note(mut self, note: String) -> Self { self.public_note = Some(note); self } + /// Adds a user fee increase to the token mint transition + /// + /// # Arguments + /// + /// * `user_fee_increase` - The user fee increase to add + /// + /// # Returns + /// + /// * `Self` - The updated builder pub fn with_user_fee_increase(mut self, user_fee_increase: UserFeeIncrease) -> Self { self.user_fee_increase = Some(user_fee_increase); self } + /// Adds group information to the token mint transition + /// + /// # Arguments + /// + /// * `group_info` - The group information to add + /// + /// # Returns + /// + /// * `Self` - The updated builder pub fn with_using_group_info(mut self, group_info: GroupStateTransitionInfoStatus) -> Self { self.using_group_info = Some(group_info); @@ -77,6 +124,15 @@ impl<'a> TokenMintTransitionBuilder<'a> { self } + /// Adds settings to the token mint transition + /// + /// # Arguments + /// + /// * `settings` - The settings to add + /// + /// # Returns + /// + /// * `Self` - The updated builder pub fn with_settings(mut self, settings: PutSettings) -> Self { self.settings = Some(settings); self @@ -84,10 +140,27 @@ impl<'a> TokenMintTransitionBuilder<'a> { } impl StateTransitionBuilder for TokenMintTransitionBuilder<'_> { + /// Returns the settings for the token mint transition + /// + /// # Returns + /// + /// * `Option` - The settings, if any fn settings(&self) -> Option { self.settings } + /// Signs the token mint transition + /// + /// # Arguments + /// + /// * `sdk` - The SDK instance + /// * `identity_public_key` - The public key of the identity + /// * `signer` - The signer instance + /// * `platform_version` - The platform version + /// + /// # Returns + /// + /// * `Result` - The signed state transition or an error async fn sign( &self, sdk: &Sdk, diff --git a/packages/rs-sdk/src/platform/transition/fungible_tokens/mod.rs b/packages/rs-sdk/src/platform/transition/fungible_tokens/mod.rs index 12770e7c1b..add8db703a 100644 --- a/packages/rs-sdk/src/platform/transition/fungible_tokens/mod.rs +++ b/packages/rs-sdk/src/platform/transition/fungible_tokens/mod.rs @@ -1,3 +1,5 @@ +//! Fungible token state transitions + pub mod burn; pub mod destroy; pub mod emergency_action; diff --git a/packages/rs-sdk/src/platform/transition/fungible_tokens/transfer.rs b/packages/rs-sdk/src/platform/transition/fungible_tokens/transfer.rs index 18086539a6..6908c8864d 100644 --- a/packages/rs-sdk/src/platform/transition/fungible_tokens/transfer.rs +++ b/packages/rs-sdk/src/platform/transition/fungible_tokens/transfer.rs @@ -17,7 +17,7 @@ use dpp::state_transition::StateTransition; use dpp::tokens::calculate_token_id; use dpp::version::PlatformVersion; -/// A builder to configure minting tokens. +/// A builder to configure and broadcast token transfer transitions pub struct TokenTransferTransitionBuilder<'a> { data_contract: &'a DataContract, token_position: TokenContractPosition, @@ -33,6 +33,18 @@ pub struct TokenTransferTransitionBuilder<'a> { impl<'a> TokenTransferTransitionBuilder<'a> { /// Start building a mint tokens request for the provided DataContract. + /// + /// # Arguments + /// + /// * `data_contract` - A reference to the data contract + /// * `token_position` - The position of the token in the contract + /// * `sender_id` - The identifier of the sender + /// * `recipient_id` - The identifier of the recipient + /// * `amount` - The amount of tokens to transfer + /// + /// # Returns + /// + /// * `Self` - The new builder instance pub fn new( data_contract: &'a DataContract, token_position: TokenContractPosition, @@ -56,6 +68,15 @@ impl<'a> TokenTransferTransitionBuilder<'a> { } } + /// Adds a shared encrypted note to the token transfer transition + /// + /// # Arguments + /// + /// * `shared_encrypted_note` - The shared encrypted note to add + /// + /// # Returns + /// + /// * `Self` - The updated builder pub fn with_shared_encrypted_note( mut self, shared_encrypted_note: SharedEncryptedNote, @@ -64,11 +85,29 @@ impl<'a> TokenTransferTransitionBuilder<'a> { self } + /// Adds a public note to the token transfer transition + /// + /// # Arguments + /// + /// * `note` - The public note to add + /// + /// # Returns + /// + /// * `Self` - The updated builder pub fn with_public_note(mut self, note: String) -> Self { self.public_note = Some(note); self } + /// Adds a private encrypted note to the token transfer transition + /// + /// # Arguments + /// + /// * `private_encrypted_note` - The private encrypted note to add + /// + /// # Returns + /// + /// * `Self` - The updated builder pub fn with_private_encrypted_note( mut self, private_encrypted_note: PrivateEncryptedNote, @@ -78,11 +117,29 @@ impl<'a> TokenTransferTransitionBuilder<'a> { self } + /// Adds a user fee increase to the token transfer transition + /// + /// # Arguments + /// + /// * `user_fee_increase` - The user fee increase to add + /// + /// # Returns + /// + /// * `Self` - The updated builder pub fn with_user_fee_increase(mut self, user_fee_increase: UserFeeIncrease) -> Self { self.user_fee_increase = Some(user_fee_increase); self } + /// Adds settings to the token transfer transition + /// + /// # Arguments + /// + /// * `settings` - The settings to add + /// + /// # Returns + /// + /// * `Self` - The updated builder pub fn with_settings(mut self, settings: PutSettings) -> Self { self.settings = Some(settings); self @@ -90,10 +147,27 @@ impl<'a> TokenTransferTransitionBuilder<'a> { } impl StateTransitionBuilder for TokenTransferTransitionBuilder<'_> { + /// Returns the settings for the token transfer transition + /// + /// # Returns + /// + /// * `Option` - The settings, if any fn settings(&self) -> Option { self.settings } + /// Signs the token transfer transition + /// + /// # Arguments + /// + /// * `sdk` - The SDK instance + /// * `identity_public_key` - The public key of the identity + /// * `signer` - The signer instance + /// * `platform_version` - The platform version + /// + /// # Returns + /// + /// * `Result` - The signed state transition or an error async fn sign( &self, sdk: &Sdk, diff --git a/packages/rs-sdk/src/platform/transition/fungible_tokens/unfreeze.rs b/packages/rs-sdk/src/platform/transition/fungible_tokens/unfreeze.rs index e9920339f6..6cb837a18e 100644 --- a/packages/rs-sdk/src/platform/transition/fungible_tokens/unfreeze.rs +++ b/packages/rs-sdk/src/platform/transition/fungible_tokens/unfreeze.rs @@ -14,7 +14,7 @@ use dpp::state_transition::StateTransition; use dpp::tokens::calculate_token_id; use dpp::version::PlatformVersion; -/// A builder to configure minting tokens. +/// A builder to configure and broadcast token unfreeze transitions pub struct TokenUnfreezeTransitionBuilder<'a> { data_contract: &'a DataContract, token_position: TokenContractPosition, @@ -28,6 +28,17 @@ pub struct TokenUnfreezeTransitionBuilder<'a> { impl<'a> TokenUnfreezeTransitionBuilder<'a> { /// Start building a mint tokens request for the provided DataContract. + /// + /// # Arguments + /// + /// * `data_contract` - A reference to the data contract + /// * `token_position` - The position of the token in the contract + /// * `actor_id` - The identifier of the actor + /// * `unfreeze_identity_id` - The identifier of the identity to unfreeze + /// + /// # Returns + /// + /// * `Self` - The new builder instance pub fn new( data_contract: &'a DataContract, token_position: TokenContractPosition, @@ -48,16 +59,43 @@ impl<'a> TokenUnfreezeTransitionBuilder<'a> { } } + /// Adds a public note to the token unfreeze transition + /// + /// # Arguments + /// + /// * `note` - The public note to add + /// + /// # Returns + /// + /// * `Self` - The updated builder pub fn with_public_note(mut self, note: String) -> Self { self.public_note = Some(note); self } + /// Adds a user fee increase to the token unfreeze transition + /// + /// # Arguments + /// + /// * `user_fee_increase` - The user fee increase to add + /// + /// # Returns + /// + /// * `Self` - The updated builder pub fn with_user_fee_increase(mut self, user_fee_increase: UserFeeIncrease) -> Self { self.user_fee_increase = Some(user_fee_increase); self } + /// Adds group information to the token unfreeze transition + /// + /// # Arguments + /// + /// * `group_info` - The group information to add + /// + /// # Returns + /// + /// * `Self` - The updated builder pub fn with_using_group_info(mut self, group_info: GroupStateTransitionInfoStatus) -> Self { self.using_group_info = Some(group_info); @@ -66,6 +104,15 @@ impl<'a> TokenUnfreezeTransitionBuilder<'a> { self } + /// Adds settings to the token unfreeze transition + /// + /// # Arguments + /// + /// * `settings` - The settings to add + /// + /// # Returns + /// + /// * `Self` - The updated builder pub fn with_settings(mut self, settings: PutSettings) -> Self { self.settings = Some(settings); self @@ -73,10 +120,27 @@ impl<'a> TokenUnfreezeTransitionBuilder<'a> { } impl StateTransitionBuilder for TokenUnfreezeTransitionBuilder<'_> { + /// Returns the settings for the token unfreeze transition + /// + /// # Returns + /// + /// * `Option` - The settings, if any fn settings(&self) -> Option { self.settings } + /// Signs the token unfreeze transition + /// + /// # Arguments + /// + /// * `sdk` - The SDK instance + /// * `identity_public_key` - The public key of the identity + /// * `signer` - The signer instance + /// * `platform_version` - The platform version + /// + /// # Returns + /// + /// * `Result` - The signed state transition or an error async fn sign( &self, sdk: &Sdk,