diff --git a/cli/src/wallet_cli/mod.rs b/cli/src/wallet_cli/mod.rs index 171a57981b..10f57a0795 100644 --- a/cli/src/wallet_cli/mod.rs +++ b/cli/src/wallet_cli/mod.rs @@ -731,7 +731,6 @@ pub async fn send_native_token_command( let transaction = if gift_storage_deposit.unwrap_or(false) { // Send native tokens together with the required storage deposit let storage_params = wallet.client().get_storage_score_parameters().await?; - let token_supply = wallet.client().get_token_supply().await?; wallet.client().bech32_hrp_matches(address.hrp()).await?; @@ -741,7 +740,7 @@ pub async fn send_native_token_command( TokenId::from_str(&token_id)?, U256::from_dec_str(&amount).map_err(|e| Error::Miscellaneous(e.to_string()))?, )?]) - .finish_output(token_supply)?]; + .finish_output()?]; wallet.send_outputs(outputs, None).await? } else { diff --git a/sdk/examples/client/output/build_account_output.rs b/sdk/examples/client/output/build_account_output.rs index afde4c23ff..b29486db14 100644 --- a/sdk/examples/client/output/build_account_output.rs +++ b/sdk/examples/client/output/build_account_output.rs @@ -34,7 +34,6 @@ async fn main() -> Result<()> { .finish() .await?; - let token_supply = client.get_token_supply().await?; let storage_score_params = client.get_storage_score_parameters().await?; let address = std::env::args() @@ -49,7 +48,7 @@ async fn main() -> Result<()> { .add_immutable_feature(IssuerFeature::new(address.clone())) .add_immutable_feature(MetadataFeature::new(metadata)?) .add_unlock_condition(AddressUnlockCondition::new(address)) - .finish_output(token_supply)?; + .finish_output()?; println!("{account_output:#?}"); diff --git a/sdk/examples/client/output/build_basic_output.rs b/sdk/examples/client/output/build_basic_output.rs index 489ae2bbe6..5f92114e56 100644 --- a/sdk/examples/client/output/build_basic_output.rs +++ b/sdk/examples/client/output/build_basic_output.rs @@ -48,12 +48,12 @@ async fn main() -> Result<()> { let outputs = [ // most simple output - basic_output_builder.clone().finish_output(token_supply)?, + basic_output_builder.clone().finish_output()?, // with metadata feature block basic_output_builder .clone() .add_feature(MetadataFeature::new(METADATA)?) - .finish_output(token_supply)?, + .finish_output()?, // with storage deposit return basic_output_builder .clone() @@ -62,26 +62,26 @@ async fn main() -> Result<()> { 1_000_000, token_supply, )?) - .finish_output(token_supply)?, + .finish_output()?, // with expiration basic_output_builder .clone() .add_unlock_condition(ExpirationUnlockCondition::new(address.clone(), 1)?) - .finish_output(token_supply)?, + .finish_output()?, // with timelock basic_output_builder .clone() .add_unlock_condition(TimelockUnlockCondition::new(1)?) - .finish_output(token_supply)?, + .finish_output()?, // with tag feature basic_output_builder .clone() .add_feature(TagFeature::new(METADATA)?) - .finish_output(token_supply)?, + .finish_output()?, // with sender feature basic_output_builder .add_feature(SenderFeature::new(address)) - .finish_output(token_supply)?, + .finish_output()?, ]; println!("{outputs:#?}"); diff --git a/sdk/examples/client/output/build_nft_output.rs b/sdk/examples/client/output/build_nft_output.rs index e72fa659d9..208f662a09 100644 --- a/sdk/examples/client/output/build_nft_output.rs +++ b/sdk/examples/client/output/build_nft_output.rs @@ -34,7 +34,6 @@ async fn main() -> Result<()> { .finish() .await?; - let token_supply = client.get_token_supply().await?; let storage_score_params = client.get_storage_score_parameters().await?; let address = std::env::args() @@ -63,7 +62,7 @@ async fn main() -> Result<()> { .add_feature(TagFeature::new(TAG)?) .add_immutable_feature(IssuerFeature::new(address)) .add_immutable_feature(MetadataFeature::new(tip_27_immutable_metadata)?) - .finish_output(token_supply)?; + .finish_output()?; println!("{nft_output:#?}"); diff --git a/sdk/examples/how_tos/accounts_and_addresses/check_balance.rs b/sdk/examples/how_tos/accounts_and_addresses/check_balance.rs index e9ec8f0095..ab200fa677 100644 --- a/sdk/examples/how_tos/accounts_and_addresses/check_balance.rs +++ b/sdk/examples/how_tos/accounts_and_addresses/check_balance.rs @@ -11,7 +11,7 @@ //! cargo run --release --all-features --example check_balance //! ``` -use iota_sdk::{types::block::address::ToBech32Ext, wallet::Result, Wallet}; +use iota_sdk::{wallet::Result, Wallet}; #[tokio::main] async fn main() -> Result<()> { diff --git a/sdk/examples/how_tos/advanced_transactions/advanced_transaction.rs b/sdk/examples/how_tos/advanced_transactions/advanced_transaction.rs index 17aa0c7792..7c9ba9c99a 100644 --- a/sdk/examples/how_tos/advanced_transactions/advanced_transaction.rs +++ b/sdk/examples/how_tos/advanced_transactions/advanced_transaction.rs @@ -48,7 +48,7 @@ async fn main() -> Result<()> { "rms1qpszqzadsym6wpppd6z037dvlejmjuke7s24hm95s9fg9vpua7vluaw60xu", )?)) .add_unlock_condition(TimelockUnlockCondition::new(slot_index)?) - .finish_output(wallet.client().get_token_supply().await?)?; + .finish_output()?; let transaction = wallet.send_outputs(vec![basic_output], None).await?; println!("Transaction sent: {}", transaction.transaction_id); diff --git a/sdk/examples/how_tos/nfts/mint_nft.rs b/sdk/examples/how_tos/nfts/mint_nft.rs index be2a795532..b1af051b4c 100644 --- a/sdk/examples/how_tos/nfts/mint_nft.rs +++ b/sdk/examples/how_tos/nfts/mint_nft.rs @@ -84,14 +84,13 @@ async fn main() -> Result<()> { println!("Minted NFT 1"); // Build an NFT manually by using the `NftOutputBuilder` - let token_supply = wallet.client().get_token_supply().await?; let outputs = [ // address of the owner of the NFT NftOutputBuilder::new_with_amount(NFT2_AMOUNT, NftId::null()) .add_unlock_condition(AddressUnlockCondition::new(sender_address.clone())) .add_feature(SenderFeature::new(sender_address.clone())) .add_immutable_feature(IssuerFeature::new(sender_address)) - .finish_output(token_supply)?, + .finish_output()?, ]; let transaction = wallet.send_outputs(outputs, None).await?; diff --git a/sdk/examples/how_tos/outputs/features.rs b/sdk/examples/how_tos/outputs/features.rs index 671b52d7b6..414ffe092e 100644 --- a/sdk/examples/how_tos/outputs/features.rs +++ b/sdk/examples/how_tos/outputs/features.rs @@ -31,7 +31,6 @@ async fn main() -> Result<()> { // Create a client instance. let client = Client::builder().with_node(&node_url)?.finish().await?; - let token_supply = client.get_token_supply().await?; let storage_score_params = client.get_storage_score_parameters().await?; let address = Address::try_from_bech32("rms1qpllaj0pyveqfkwxmnngz2c488hfdtmfrj3wfkgxtk4gtyrax0jaxzt70zy")?; @@ -44,26 +43,26 @@ async fn main() -> Result<()> { nft_output_builder .clone() .add_feature(SenderFeature::new(address.clone())) - .finish_output(token_supply)?, + .finish_output()?, // with issuer feature nft_output_builder .clone() .add_immutable_feature(IssuerFeature::new(address)) - .finish_output(token_supply)?, + .finish_output()?, // with metadata feature block nft_output_builder .clone() .add_feature(MetadataFeature::new("Hello, World!")?) - .finish_output(token_supply)?, + .finish_output()?, // with immutable metadata feature block nft_output_builder .clone() .add_immutable_feature(MetadataFeature::new("Hello, World!")?) - .finish_output(token_supply)?, + .finish_output()?, // with tag feature nft_output_builder .add_feature(TagFeature::new("Hello, World!")?) - .finish_output(token_supply)?, + .finish_output()?, ]; // Convert ouput array to json array diff --git a/sdk/examples/how_tos/outputs/unlock_conditions.rs b/sdk/examples/how_tos/outputs/unlock_conditions.rs index e022a15c6f..e926e9fde8 100644 --- a/sdk/examples/how_tos/outputs/unlock_conditions.rs +++ b/sdk/examples/how_tos/outputs/unlock_conditions.rs @@ -47,7 +47,7 @@ async fn main() -> Result<()> { let outputs = [ //// most simple output - basic_output_builder.clone().finish_output(token_supply)?, + basic_output_builder.clone().finish_output()?, // with storage deposit return unlock condition basic_output_builder .clone() @@ -56,22 +56,22 @@ async fn main() -> Result<()> { 1000000, token_supply, )?) - .finish_output(token_supply)?, + .finish_output()?, // with timeout unlock condition basic_output_builder .clone() .add_unlock_condition(TimelockUnlockCondition::new(1)?) - .finish_output(token_supply)?, + .finish_output()?, // with expiration unlock condition basic_output_builder .add_unlock_condition(ExpirationUnlockCondition::new(address.clone(), 1)?) - .finish_output(token_supply)?, + .finish_output()?, // with immutable account unlock condition foundry_output_builder .add_unlock_condition(ImmutableAccountAddressUnlockCondition::new( *account_address.as_account(), )) - .finish_output(token_supply)?, + .finish_output()?, ]; // Convert ouput array to json array diff --git a/sdk/examples/wallet/17_check_unlock_conditions.rs b/sdk/examples/wallet/17_check_unlock_conditions.rs index 6a40bd3cfc..f961427fb5 100644 --- a/sdk/examples/wallet/17_check_unlock_conditions.rs +++ b/sdk/examples/wallet/17_check_unlock_conditions.rs @@ -11,10 +11,7 @@ //! ``` use iota_sdk::{ - types::block::{ - address::Bech32Address, - output::{unlock_condition::AddressUnlockCondition, BasicOutputBuilder, UnlockCondition}, - }, + types::block::output::{unlock_condition::AddressUnlockCondition, BasicOutputBuilder, UnlockCondition}, wallet::Result, Wallet, }; @@ -38,7 +35,7 @@ async fn main() -> Result<()> { let output = BasicOutputBuilder::new_with_amount(AMOUNT) .add_unlock_condition(AddressUnlockCondition::new(wallet_address.clone())) - .finish_output(wallet.client().get_token_supply().await?)?; + .finish_output()?; let controlled_by_account = if let [UnlockCondition::Address(address_unlock_condition)] = output .unlock_conditions() diff --git a/sdk/examples/wallet/events.rs b/sdk/examples/wallet/events.rs index 9357ae6892..c2e2d99ec5 100644 --- a/sdk/examples/wallet/events.rs +++ b/sdk/examples/wallet/events.rs @@ -56,7 +56,7 @@ async fn main() -> Result<()> { // send transaction let outputs = [BasicOutputBuilder::new_with_amount(SEND_AMOUNT) .add_unlock_condition(AddressUnlockCondition::new(Address::try_from_bech32(RECV_ADDRESS)?)) - .finish_output(wallet.client().get_token_supply().await?)?]; + .finish_output()?]; let transaction = wallet.send_outputs(outputs, None).await?; println!("Transaction sent: {}", transaction.transaction_id); diff --git a/sdk/examples/wallet/offline_signing/0_generate_address.rs b/sdk/examples/wallet/offline_signing/0_generate_address.rs index bc5f4a8330..fa14f84112 100644 --- a/sdk/examples/wallet/offline_signing/0_generate_address.rs +++ b/sdk/examples/wallet/offline_signing/0_generate_address.rs @@ -10,7 +10,7 @@ use iota_sdk::{ client::{ - constants::{SHIMMER_BECH32_HRP, SHIMMER_COIN_TYPE}, + constants::SHIMMER_COIN_TYPE, secret::{stronghold::StrongholdSecretManager, SecretManager}, }, crypto::keys::{bip39::Mnemonic, bip44::Bip44}, diff --git a/sdk/src/client/api/block_builder/input_selection/remainder.rs b/sdk/src/client/api/block_builder/input_selection/remainder.rs index ca28c11548..0dae140a3e 100644 --- a/sdk/src/client/api/block_builder/input_selection/remainder.rs +++ b/sdk/src/client/api/block_builder/input_selection/remainder.rs @@ -75,12 +75,7 @@ impl InputSelection { remainder_builder = remainder_builder.with_native_tokens(native_tokens); } - Ok(( - remainder_builder - .finish_output(self.protocol_parameters.token_supply())? - .amount(), - native_tokens_remainder, - )) + Ok((remainder_builder.finish_output()?.amount(), native_tokens_remainder)) } pub(crate) fn remainder_and_storage_deposit_return_outputs( @@ -97,7 +92,7 @@ impl InputSelection { let diff = amount - output_sdr_amount; let srd_output = BasicOutputBuilder::new_with_amount(diff) .with_unlock_conditions([AddressUnlockCondition::new(address.clone())]) - .finish_output(self.protocol_parameters.token_supply())?; + .finish_output()?; // TODO verify_storage_deposit ? @@ -141,14 +136,11 @@ impl InputSelection { remainder_builder = remainder_builder.with_native_tokens(native_tokens); } - let remainder = remainder_builder.finish_output(self.protocol_parameters.token_supply())?; + let remainder = remainder_builder.finish_output()?; log::debug!("Created remainder output of {diff} for {remainder_address:?}"); - remainder.verify_storage_deposit( - self.protocol_parameters.storage_score_parameters(), - self.protocol_parameters.token_supply(), - )?; + remainder.verify_storage_deposit(self.protocol_parameters.storage_score_parameters())?; Ok(( Some(RemainderData { diff --git a/sdk/src/client/api/block_builder/input_selection/requirement/amount.rs b/sdk/src/client/api/block_builder/input_selection/requirement/amount.rs index e510cc082d..2e6f919a9f 100644 --- a/sdk/src/client/api/block_builder/input_selection/requirement/amount.rs +++ b/sdk/src/client/api/block_builder/input_selection/requirement/amount.rs @@ -253,13 +253,13 @@ impl InputSelection { let new_output = match output { Output::Account(output) => AccountOutputBuilder::from(&*output) .with_amount(new_amount) - .finish_output(self.protocol_parameters.token_supply())?, + .finish_output()?, Output::Foundry(output) => FoundryOutputBuilder::from(&*output) .with_amount(new_amount) - .finish_output(self.protocol_parameters.token_supply())?, + .finish_output()?, Output::Nft(output) => NftOutputBuilder::from(&*output) .with_amount(new_amount) - .finish_output(self.protocol_parameters.token_supply())?, + .finish_output()?, _ => panic!("only account, nft and foundry can be automatically created"), }; diff --git a/sdk/src/client/api/block_builder/input_selection/transition.rs b/sdk/src/client/api/block_builder/input_selection/transition.rs index 44141ff90c..18344028c6 100644 --- a/sdk/src/client/api/block_builder/input_selection/transition.rs +++ b/sdk/src/client/api/block_builder/input_selection/transition.rs @@ -60,7 +60,7 @@ impl InputSelection { .with_foundry_counter(u32::max(highest_foundry_serial_number, input.foundry_counter())) .with_features(features); - let output = builder.finish_output(self.protocol_parameters.token_supply())?; + let output = builder.finish_output()?; self.automatically_transitioned.insert(ChainId::from(account_id)); @@ -100,7 +100,7 @@ impl InputSelection { let output = NftOutputBuilder::from(input) .with_nft_id(nft_id) .with_features(features) - .finish_output(self.protocol_parameters.token_supply())?; + .finish_output()?; self.automatically_transitioned.insert(ChainId::from(nft_id)); @@ -138,7 +138,7 @@ impl InputSelection { return Ok(None); } - let output = FoundryOutputBuilder::from(input).finish_output(self.protocol_parameters.token_supply())?; + let output = FoundryOutputBuilder::from(input).finish_output()?; self.automatically_transitioned.insert(ChainId::from(foundry_id)); diff --git a/sdk/src/types/block/output/account.rs b/sdk/src/types/block/output/account.rs index 7d32d07562..5422d63aa7 100644 --- a/sdk/src/types/block/output/account.rs +++ b/sdk/src/types/block/output/account.rs @@ -19,9 +19,8 @@ use crate::types::{ unlock_condition::{ verify_allowed_unlock_conditions, UnlockCondition, UnlockConditionFlags, UnlockConditions, }, - verify_output_amount_packable, verify_output_amount_supply, ChainId, NativeToken, NativeTokens, Output, - OutputBuilderAmount, OutputId, StateTransitionError, StateTransitionVerifier, StorageScore, - StorageScoreParameters, + verify_output_amount_packable, ChainId, NativeToken, NativeTokens, Output, OutputBuilderAmount, OutputId, + StateTransitionError, StateTransitionVerifier, StorageScore, StorageScoreParameters, }, payload::signed_transaction::TransactionCapabilityFlag, protocol::ProtocolParameters, @@ -271,23 +270,9 @@ impl AccountOutputBuilder { Ok(output) } - /// - pub fn finish_with_params<'a>( - self, - params: impl Into> + Send, - ) -> Result { - let output = self.finish()?; - - if let Some(token_supply) = params.into().token_supply() { - verify_output_amount_supply(output.amount, token_supply)?; - } - - Ok(output) - } - /// Finishes the [`AccountOutputBuilder`] into an [`Output`]. - pub fn finish_output<'a>(self, params: impl Into> + Send) -> Result { - Ok(Output::Account(self.finish_with_params(params)?)) + pub fn finish_output(self) -> Result { + Ok(Output::Account(self.finish()?)) } } @@ -710,7 +695,7 @@ pub(crate) mod dto { builder = builder.add_unlock_condition(UnlockCondition::try_from_dto_with_params(u, ¶ms)?); } - builder.finish_with_params(params) + builder.finish() } } @@ -758,7 +743,7 @@ pub(crate) mod dto { builder = builder.with_immutable_features(immutable_features); } - builder.finish_with_params(params) + builder.finish() } } } @@ -824,7 +809,7 @@ mod tests { &protocol_parameters, ) .unwrap(); - assert_eq!(builder.finish_with_params(&protocol_parameters).unwrap(), output_split); + assert_eq!(builder.finish().unwrap(), output_split); }; let builder = AccountOutput::build_with_amount(100, account_id) diff --git a/sdk/src/types/block/output/anchor.rs b/sdk/src/types/block/output/anchor.rs index 80ae5ca4e5..7d1ea4f849 100644 --- a/sdk/src/types/block/output/anchor.rs +++ b/sdk/src/types/block/output/anchor.rs @@ -21,9 +21,8 @@ use crate::types::{ unlock_condition::{ verify_allowed_unlock_conditions, UnlockCondition, UnlockConditionFlags, UnlockConditions, }, - verify_output_amount_packable, verify_output_amount_supply, ChainId, NativeToken, NativeTokens, Output, - OutputBuilderAmount, OutputId, StateTransitionError, StateTransitionVerifier, StorageScore, - StorageScoreParameters, + verify_output_amount_packable, ChainId, NativeToken, NativeTokens, Output, OutputBuilderAmount, OutputId, + StateTransitionError, StateTransitionVerifier, StorageScore, StorageScoreParameters, }, payload::signed_transaction::TransactionCapabilityFlag, protocol::ProtocolParameters, @@ -315,20 +314,9 @@ impl AnchorOutputBuilder { Ok(output) } - /// - pub fn finish_with_params<'a>(self, params: impl Into> + Send) -> Result { - let output = self.finish()?; - - if let Some(token_supply) = params.into().token_supply() { - verify_output_amount_supply(output.amount, token_supply)?; - } - - Ok(output) - } - /// Finishes the [`AnchorOutputBuilder`] into an [`Output`]. - pub fn finish_output<'a>(self, params: impl Into> + Send) -> Result { - Ok(Output::Anchor(self.finish_with_params(params)?)) + pub fn finish_output(self) -> Result { + Ok(Output::Anchor(self.finish()?)) } } @@ -787,7 +775,7 @@ pub(crate) mod dto { builder = builder.add_unlock_condition(UnlockCondition::try_from_dto_with_params(u, ¶ms)?); } - builder.finish_with_params(params) + builder.finish() } } @@ -837,7 +825,7 @@ pub(crate) mod dto { builder = builder.with_immutable_features(immutable_features); } - builder.finish_with_params(params) + builder.finish() } } } @@ -904,7 +892,7 @@ mod tests { &protocol_parameters, ) .unwrap(); - assert_eq!(builder.finish_with_params(&protocol_parameters).unwrap(), output_split); + assert_eq!(builder.finish().unwrap(), output_split); }; let builder = AnchorOutput::build_with_amount(100, anchor_id) diff --git a/sdk/src/types/block/output/basic.rs b/sdk/src/types/block/output/basic.rs index 7bc396e836..6ca92bbd39 100644 --- a/sdk/src/types/block/output/basic.rs +++ b/sdk/src/types/block/output/basic.rs @@ -14,8 +14,8 @@ use crate::types::{ verify_allowed_unlock_conditions, AddressUnlockCondition, StorageDepositReturnUnlockCondition, UnlockCondition, UnlockConditionFlags, UnlockConditions, }, - verify_output_amount_packable, verify_output_amount_supply, NativeToken, NativeTokens, Output, - OutputBuilderAmount, OutputId, StorageScore, StorageScoreParameters, + verify_output_amount_packable, NativeToken, NativeTokens, Output, OutputBuilderAmount, OutputId, + StorageScore, StorageScoreParameters, }, protocol::ProtocolParameters, semantic::{SemanticValidationContext, TransactionFailureReason}, @@ -231,21 +231,9 @@ impl BasicOutputBuilder { Ok(output) } - /// - pub fn finish_with_params<'a>(self, params: impl Into> + Send) -> Result { - let output = self.finish()?; - let params = params.into(); - - if let Some(token_supply) = params.token_supply() { - verify_output_amount_supply(output.amount, token_supply)?; - } - - Ok(output) - } - /// Finishes the [`BasicOutputBuilder`] into an [`Output`]. - pub fn finish_output<'a>(self, params: impl Into> + Send) -> Result { - Ok(Output::Basic(self.finish_with_params(params)?)) + pub fn finish_output(self) -> Result { + Ok(Output::Basic(self.finish()?)) } } @@ -481,7 +469,7 @@ pub(crate) mod dto { builder = builder.add_unlock_condition(UnlockCondition::try_from_dto_with_params(u, ¶ms)?); } - builder.finish_with_params(params) + builder.finish() } } @@ -515,7 +503,7 @@ pub(crate) mod dto { builder = builder.with_features(features); } - builder.finish_with_params(params) + builder.finish() } } } @@ -573,10 +561,7 @@ mod tests { protocol_parameters.token_supply(), ) .unwrap(); - assert_eq!( - builder.finish_with_params(protocol_parameters.token_supply()).unwrap(), - output_split - ); + assert_eq!(builder.finish().unwrap(), output_split); }; let builder = BasicOutput::build_with_amount(100) diff --git a/sdk/src/types/block/output/delegation.rs b/sdk/src/types/block/output/delegation.rs index 48979de08e..fab44384be 100644 --- a/sdk/src/types/block/output/delegation.rs +++ b/sdk/src/types/block/output/delegation.rs @@ -13,8 +13,8 @@ use crate::types::{ unlock_condition::{ verify_allowed_unlock_conditions, UnlockCondition, UnlockConditionFlags, UnlockConditions, }, - verify_output_amount_packable, verify_output_amount_supply, Output, OutputBuilderAmount, OutputId, - StateTransitionError, StateTransitionVerifier, StorageScore, StorageScoreParameters, + verify_output_amount_packable, Output, OutputBuilderAmount, OutputId, StateTransitionError, + StateTransitionVerifier, StorageScore, StorageScoreParameters, }, protocol::ProtocolParameters, semantic::{SemanticValidationContext, TransactionFailureReason}, @@ -196,23 +196,9 @@ impl DelegationOutputBuilder { Ok(output) } - /// Finishes the builder into a [`DelegationOutput`] with parameters verification. - pub fn finish_with_params<'a>( - self, - params: impl Into> + Send, - ) -> Result { - let output = self.finish()?; - - if let Some(token_supply) = params.into().token_supply() { - verify_output_amount_supply(output.amount, token_supply)?; - } - - Ok(output) - } - /// Finishes the [`DelegationOutputBuilder`] into an [`Output`]. - pub fn finish_output(self, token_supply: u64) -> Result { - Ok(Output::Delegation(self.finish_with_params(token_supply)?)) + pub fn finish_output(self) -> Result { + Ok(Output::Delegation(self.finish()?)) } } @@ -514,7 +500,7 @@ pub(crate) mod dto { builder = builder.add_unlock_condition(UnlockCondition::try_from_dto_with_params(u, ¶ms)?); } - builder.finish_with_params(params) + builder.finish() } } @@ -554,7 +540,7 @@ pub(crate) mod dto { .collect::, Error>>()?; builder = builder.with_unlock_conditions(unlock_conditions); - builder.finish_with_params(params) + builder.finish() } } } diff --git a/sdk/src/types/block/output/foundry.rs b/sdk/src/types/block/output/foundry.rs index 1b8a448dac..addc999fdd 100644 --- a/sdk/src/types/block/output/foundry.rs +++ b/sdk/src/types/block/output/foundry.rs @@ -21,9 +21,8 @@ use crate::types::{ unlock_condition::{ verify_allowed_unlock_conditions, UnlockCondition, UnlockConditionFlags, UnlockConditions, }, - verify_output_amount_packable, verify_output_amount_supply, ChainId, NativeToken, NativeTokens, Output, - OutputBuilderAmount, OutputId, StateTransitionError, StateTransitionVerifier, StorageScore, - StorageScoreParameters, TokenId, TokenScheme, + verify_output_amount_packable, ChainId, NativeToken, NativeTokens, Output, OutputBuilderAmount, OutputId, + StateTransitionError, StateTransitionVerifier, StorageScore, StorageScoreParameters, TokenId, TokenScheme, }, payload::signed_transaction::{TransactionCapabilities, TransactionCapabilityFlag}, protocol::ProtocolParameters, @@ -288,23 +287,9 @@ impl FoundryOutputBuilder { Ok(output) } - /// - pub fn finish_with_params<'a>( - self, - params: impl Into> + Send, - ) -> Result { - let output = self.finish()?; - - if let Some(token_supply) = params.into().token_supply() { - verify_output_amount_supply(output.amount, token_supply)?; - } - - Ok(output) - } - /// Finishes the [`FoundryOutputBuilder`] into an [`Output`]. - pub fn finish_output<'a>(self, params: impl Into> + Send) -> Result { - Ok(Output::Foundry(self.finish_with_params(params)?)) + pub fn finish_output(self) -> Result { + Ok(Output::Foundry(self.finish()?)) } } @@ -757,7 +742,7 @@ pub(crate) mod dto { builder = builder.add_unlock_condition(UnlockCondition::try_from_dto_with_params(u, ¶ms)?); } - builder.finish_with_params(params) + builder.finish() } } @@ -802,7 +787,7 @@ pub(crate) mod dto { builder = builder.with_immutable_features(immutable_features); } - builder.finish_with_params(params) + builder.finish() } } } @@ -854,10 +839,7 @@ mod tests { protocol_parameters.clone(), ) .unwrap(); - assert_eq!( - builder.finish_with_params(protocol_parameters.clone()).unwrap(), - output_split - ); + assert_eq!(builder.finish().unwrap(), output_split); }; let builder = FoundryOutput::build_with_amount(100, 123, rand_token_scheme()) diff --git a/sdk/src/types/block/output/mod.rs b/sdk/src/types/block/output/mod.rs index 6fb37a815a..57a9541f6c 100644 --- a/sdk/src/types/block/output/mod.rs +++ b/sdk/src/types/block/output/mod.rs @@ -344,7 +344,7 @@ impl Output { /// byte cost, given by [`StorageScoreParameters`]. /// If there is a [`StorageDepositReturnUnlockCondition`](unlock_condition::StorageDepositReturnUnlockCondition), /// its amount is also checked. - pub fn verify_storage_deposit(&self, params: StorageScoreParameters, token_supply: u64) -> Result<(), Error> { + pub fn verify_storage_deposit(&self, params: StorageScoreParameters) -> Result<(), Error> { let required_output_amount = self.storage_cost(params); if self.amount() < required_output_amount { @@ -367,7 +367,7 @@ impl Output { }); } - let minimum_deposit = minimum_storage_deposit(return_condition.return_address(), params, token_supply); + let minimum_deposit = minimum_storage_deposit(return_condition.return_address(), params); // `Minimum Storage Deposit` ≤ `Return Amount` if return_condition.amount() < minimum_deposit { @@ -470,12 +470,12 @@ pub(crate) fn verify_output_amount_packable( /// Computes the minimum amount that a storage deposit has to match to allow creating a return [`Output`] back to the /// sender [`Address`]. -fn minimum_storage_deposit(address: &Address, params: StorageScoreParameters, token_supply: u64) -> u64 { +fn minimum_storage_deposit(address: &Address, params: StorageScoreParameters) -> u64 { // PANIC: This can never fail because the amount will always be within the valid range. Also, the actual value is // not important, we are only interested in the storage requirements of the type. BasicOutputBuilder::new_with_minimum_amount(params) .add_unlock_condition(AddressUnlockCondition::new(address.clone())) - .finish_with_params(token_supply) + .finish() .unwrap() .amount() } diff --git a/sdk/src/types/block/output/nft.rs b/sdk/src/types/block/output/nft.rs index 6cdbb24c8d..e3ab22cead 100644 --- a/sdk/src/types/block/output/nft.rs +++ b/sdk/src/types/block/output/nft.rs @@ -18,9 +18,8 @@ use crate::types::{ unlock_condition::{ verify_allowed_unlock_conditions, UnlockCondition, UnlockConditionFlags, UnlockConditions, }, - verify_output_amount_packable, verify_output_amount_supply, ChainId, NativeToken, NativeTokens, Output, - OutputBuilderAmount, OutputId, StateTransitionError, StateTransitionVerifier, StorageScore, - StorageScoreParameters, + verify_output_amount_packable, ChainId, NativeToken, NativeTokens, Output, OutputBuilderAmount, OutputId, + StateTransitionError, StateTransitionVerifier, StorageScore, StorageScoreParameters, }, payload::signed_transaction::TransactionCapabilityFlag, protocol::ProtocolParameters, @@ -253,20 +252,9 @@ impl NftOutputBuilder { Ok(output) } - /// - pub fn finish_with_params<'a>(self, params: impl Into> + Send) -> Result { - let output = self.finish()?; - - if let Some(token_supply) = params.into().token_supply() { - verify_output_amount_supply(output.amount, token_supply)?; - } - - Ok(output) - } - /// Finishes the [`NftOutputBuilder`] into an [`Output`]. - pub fn finish_output<'a>(self, params: impl Into> + Send) -> Result { - Ok(Output::Nft(self.finish_with_params(params)?)) + pub fn finish_output(self) -> Result { + Ok(Output::Nft(self.finish()?)) } } @@ -614,7 +602,7 @@ pub(crate) mod dto { builder = builder.add_unlock_condition(UnlockCondition::try_from_dto_with_params(u, ¶ms)?); } - builder.finish_with_params(params) + builder.finish() } } @@ -657,7 +645,7 @@ pub(crate) mod dto { builder = builder.with_immutable_features(immutable_features); } - builder.finish_with_params(params) + builder.finish() } } } @@ -718,7 +706,7 @@ mod tests { &protocol_parameters, ) .unwrap(); - assert_eq!(builder.finish_with_params(&protocol_parameters).unwrap(), output_split); + assert_eq!(builder.finish().unwrap(), output_split); }; let builder = NftOutput::build_with_amount(100, NftId::null()) diff --git a/sdk/src/types/block/payload/signed_transaction/transaction.rs b/sdk/src/types/block/payload/signed_transaction/transaction.rs index 5f044e2f6e..f211230ddf 100644 --- a/sdk/src/types/block/payload/signed_transaction/transaction.rs +++ b/sdk/src/types/block/payload/signed_transaction/transaction.rs @@ -463,7 +463,7 @@ fn verify_outputs(outputs: &[Output], visitor: &ProtocolPara } } - output.verify_storage_deposit(visitor.storage_score_parameters(), visitor.token_supply())?; + output.verify_storage_deposit(visitor.storage_score_parameters())?; } } diff --git a/sdk/src/types/block/protocol.rs b/sdk/src/types/block/protocol.rs index 6e6cce153a..1e6394edfc 100644 --- a/sdk/src/types/block/protocol.rs +++ b/sdk/src/types/block/protocol.rs @@ -126,7 +126,7 @@ impl ProtocolParameters { version: u8, network_name: impl Into, bech32_hrp: impl ConvertTo, - params: StorageScoreParameters, + storage_score_parameters: StorageScoreParameters, token_supply: u64, genesis_unix_timestamp: u64, slot_duration_in_seconds: u8, @@ -136,7 +136,7 @@ impl ProtocolParameters { version, network_name: >::try_from(network_name.into()).map_err(Error::InvalidStringPrefix)?, bech32_hrp: bech32_hrp.convert()?, - storage_score_parameters: params, + storage_score_parameters, token_supply, genesis_unix_timestamp, slot_duration_in_seconds, diff --git a/sdk/src/types/block/rand/output/mod.rs b/sdk/src/types/block/rand/output/mod.rs index 569052d27c..53b81781c7 100644 --- a/sdk/src/types/block/rand/output/mod.rs +++ b/sdk/src/types/block/rand/output/mod.rs @@ -45,7 +45,7 @@ pub fn rand_basic_output(token_supply: u64) -> BasicOutput { BasicOutput::build_with_amount(rand_number_range(0..token_supply)) .with_features(rand_allowed_features(BasicOutput::ALLOWED_FEATURES)) .add_unlock_condition(rand_address_unlock_condition()) - .finish_with_params(token_supply) + .finish() .unwrap() } @@ -67,7 +67,7 @@ pub fn rand_account_output(token_supply: u64) -> AccountOutput { AccountOutput::build_with_amount(rand_number_range(0..token_supply), account_id) .with_features(rand_allowed_features(AccountOutput::ALLOWED_FEATURES)) .add_unlock_condition(rand_address_unlock_condition_different_from_account_id(&account_id)) - .finish_with_params(token_supply) + .finish() .unwrap() } @@ -85,7 +85,7 @@ pub fn rand_anchor_output(token_supply: u64) -> AnchorOutput { .add_unlock_condition(rand_state_controller_address_unlock_condition_different_from( &anchor_id, )) - .finish_with_params(token_supply) + .finish() .unwrap() } @@ -103,7 +103,7 @@ pub fn rand_foundry_output(token_supply: u64) -> FoundryOutput { FoundryOutput::build_with_amount(rand_number_range(0..token_supply), rand_number(), rand_token_scheme()) .with_features(rand_allowed_features(FoundryOutput::ALLOWED_FEATURES)) .add_unlock_condition(ImmutableAccountAddressUnlockCondition::new(rand_account_address())) - .finish_with_params(token_supply) + .finish() .unwrap() } @@ -115,7 +115,7 @@ pub fn rand_nft_output(token_supply: u64) -> NftOutput { NftOutput::build_with_amount(rand_number_range(0..token_supply), nft_id) .with_features(rand_allowed_features(NftOutput::ALLOWED_FEATURES)) .add_unlock_condition(rand_address_unlock_condition_different_from(&nft_id)) - .finish_with_params(token_supply) + .finish() .unwrap() } diff --git a/sdk/src/wallet/core/mod.rs b/sdk/src/wallet/core/mod.rs index f682be86e7..a39f4516b0 100644 --- a/sdk/src/wallet/core/mod.rs +++ b/sdk/src/wallet/core/mod.rs @@ -708,7 +708,7 @@ mod test { let output = Output::Basic( BasicOutput::build_with_amount(amount) .add_unlock_condition(AddressUnlockCondition::new(address)) - .finish_with_params(protocol_parameters.clone()) + .finish() .unwrap(), ); let transaction = Transaction::builder(protocol_parameters.network_id()) diff --git a/sdk/src/wallet/operations/balance.rs b/sdk/src/wallet/operations/balance.rs index 5a205524ec..dd3d28f3ff 100644 --- a/sdk/src/wallet/operations/balance.rs +++ b/sdk/src/wallet/operations/balance.rs @@ -34,7 +34,7 @@ where wallet_data: &WalletData, ) -> Result { let network_id = self.client().get_network_id().await?; - let storage_params = self.client().get_storage_score_parameters().await?; + let storage_score_params = self.client().get_storage_score_parameters().await?; let mut balance = Balance::default(); let mut total_rent_amount = 0; let mut total_native_tokens = NativeTokensBuilder::default(); @@ -58,7 +58,7 @@ where } let output = &output_data.output; - let storage_cost = output.storage_cost(storage_params); + let storage_cost = output.storage_cost(storage_score_params); // Add account and foundry outputs here because they can't have a // [`StorageDepositReturnUnlockCondition`] or time related unlock conditions diff --git a/sdk/src/wallet/operations/output_claiming.rs b/sdk/src/wallet/operations/output_claiming.rs index 87f8e3c5d8..046ef5eb9d 100644 --- a/sdk/src/wallet/operations/output_claiming.rs +++ b/sdk/src/wallet/operations/output_claiming.rs @@ -280,7 +280,7 @@ where NftOutputBuilder::from(nft_output) .with_nft_id(nft_output.nft_id_non_null(&output_data.output_id)) .with_unlock_conditions([AddressUnlockCondition::new(wallet_address.clone())]) - .finish_output(token_supply)? + .finish_output()? } else { NftOutputBuilder::from(nft_output) .with_minimum_amount(storage_score_params) @@ -288,7 +288,7 @@ where .with_unlock_conditions([AddressUnlockCondition::new(wallet_address.clone())]) // Set native tokens empty, we will collect them from all inputs later .with_native_tokens([]) - .finish_output(token_supply)? + .finish_output()? }; // Add required amount for the new output @@ -375,7 +375,7 @@ where outputs_to_send.push( BasicOutputBuilder::new_with_amount(return_amount) .add_unlock_condition(AddressUnlockCondition::new(return_address)) - .finish_output(token_supply)?, + .finish_output()?, ); } @@ -385,7 +385,7 @@ where BasicOutputBuilder::new_with_amount(available_amount - required_amount_for_nfts) .add_unlock_condition(AddressUnlockCondition::new(wallet_address)) .with_native_tokens(new_native_tokens.finish()?) - .finish_output(token_supply)?, + .finish_output()?, ); } else if !new_native_tokens.finish()?.is_empty() { return Err(crate::client::api::input_selection::Error::InsufficientAmount { diff --git a/sdk/src/wallet/operations/output_consolidation.rs b/sdk/src/wallet/operations/output_consolidation.rs index c38522b6f6..b1854a12b0 100644 --- a/sdk/src/wallet/operations/output_consolidation.rs +++ b/sdk/src/wallet/operations/output_consolidation.rs @@ -128,7 +128,6 @@ where #[cfg(feature = "participation")] let voting_output = self.get_voting_output().await?; let slot_index = self.client().get_slot_index().await?; - let token_supply = self.client().get_token_supply().await?; let mut outputs_to_consolidate = Vec::new(); let wallet_data = self.data().await; @@ -258,7 +257,7 @@ where .unwrap_or_else(|| outputs_to_consolidate[0].address.clone()), )) .with_native_tokens(total_native_tokens.finish()?) - .finish_output(token_supply)?]; + .finish_output()?]; let options = Some(TransactionOptions { custom_inputs: Some(custom_inputs), diff --git a/sdk/src/wallet/operations/participation/voting.rs b/sdk/src/wallet/operations/participation/voting.rs index 3c16361609..cb6f097d1a 100644 --- a/sdk/src/wallet/operations/participation/voting.rs +++ b/sdk/src/wallet/operations/participation/voting.rs @@ -105,7 +105,7 @@ where Feature::Tag(TagFeature::new(PARTICIPATION_TAG)?), Feature::Metadata(MetadataFeature::new(participation_bytes.clone())?), ]) - .finish_output(self.client().get_token_supply().await?)?; + .finish_output()?; self.prepare_transaction( [new_output], @@ -177,7 +177,7 @@ where Feature::Tag(TagFeature::new(PARTICIPATION_TAG)?), Feature::Metadata(MetadataFeature::new(participation_bytes.clone())?), ]) - .finish_output(self.client().get_token_supply().await?)?; + .finish_output()?; self.prepare_transaction( [new_output], diff --git a/sdk/src/wallet/operations/participation/voting_power.rs b/sdk/src/wallet/operations/participation/voting_power.rs index 1d57151391..f2457cfe75 100644 --- a/sdk/src/wallet/operations/participation/voting_power.rs +++ b/sdk/src/wallet/operations/participation/voting_power.rs @@ -50,17 +50,14 @@ where /// Prepares the transaction for /// [Account::increase_voting_power()](crate::wallet::Account::increase_voting_power). pub async fn prepare_increase_voting_power(&self, amount: u64) -> Result { - let token_supply = self.client().get_token_supply().await?; - let (new_output, tx_options) = match self.get_voting_output().await? { Some(current_output_data) => { let output = current_output_data.output.as_basic(); let new_amount = output.amount().checked_add(amount).ok_or(Error::InvalidVotingPower)?; - let (new_output, tagged_data_payload) = self - .new_voting_output_and_tagged_data(output, new_amount, token_supply) - .await?; + let (new_output, tagged_data_payload) = + self.new_voting_output_and_tagged_data(output, new_amount).await?; ( new_output, @@ -76,7 +73,7 @@ where BasicOutputBuilder::new_with_amount(amount) .add_unlock_condition(AddressUnlockCondition::new(self.address().await)) .add_feature(TagFeature::new(PARTICIPATION_TAG)?) - .finish_output(token_supply)?, + .finish_output()?, None, ), }; @@ -102,7 +99,6 @@ where /// Prepares the transaction for /// [Account::decrease_voting_power()](crate::wallet::Account::decrease_voting_power). pub async fn prepare_decrease_voting_power(&self, amount: u64) -> Result { - let token_supply = self.client().get_token_supply().await?; let current_output_data = self .get_voting_output() .await? @@ -111,18 +107,11 @@ where // If the amount to decrease is the amount of the output, then we just remove the features. let (new_output, tagged_data_payload) = if amount == output.amount() { - ( - BasicOutputBuilder::from(output) - .clear_features() - .finish_output(token_supply)?, - None, - ) + (BasicOutputBuilder::from(output).clear_features().finish_output()?, None) } else { let new_amount = output.amount().checked_sub(amount).ok_or(Error::InvalidVotingPower)?; - let (new_output, tagged_data_payload) = self - .new_voting_output_and_tagged_data(output, new_amount, token_supply) - .await?; + let (new_output, tagged_data_payload) = self.new_voting_output_and_tagged_data(output, new_amount).await?; (new_output, Some(tagged_data_payload)) }; @@ -144,7 +133,6 @@ where &self, output: &BasicOutput, amount: u64, - token_supply: u64, ) -> Result<(Output, TaggedDataPayload)> { let mut output_builder = BasicOutputBuilder::from(output).with_amount(amount); let mut participation_bytes = output.features().metadata().map(|m| m.data()).unwrap_or(&[]); @@ -163,7 +151,7 @@ where }; Ok(( - output_builder.finish_output(token_supply)?, + output_builder.finish_output()?, TaggedDataPayload::new(PARTICIPATION_TAG.as_bytes().to_vec(), participation_bytes.to_vec())?, )) } diff --git a/sdk/src/wallet/operations/transaction/high_level/burning_melting/melt_native_token.rs b/sdk/src/wallet/operations/transaction/high_level/burning_melting/melt_native_token.rs index e17227e932..24f3963e2a 100644 --- a/sdk/src/wallet/operations/transaction/high_level/burning_melting/melt_native_token.rs +++ b/sdk/src/wallet/operations/transaction/high_level/burning_melting/melt_native_token.rs @@ -52,7 +52,6 @@ where let foundry_id = FoundryId::from(token_id); let account_id = *foundry_id.account_address().account_id(); - let token_supply = self.client().get_token_supply().await?; let (existing_account_output_data, existing_foundry_output) = self .find_account_and_foundry_output_data(account_id, foundry_id) @@ -66,7 +65,7 @@ where // Create the new account output with updated amount. let account_output = AccountOutputBuilder::from(account_output) .with_account_id(account_id) - .finish_output(token_supply)?; + .finish_output()?; let TokenScheme::Simple(token_scheme) = existing_foundry_output.token_scheme(); let outputs = [ @@ -77,7 +76,7 @@ where token_scheme.melted_tokens() + melt_amount, token_scheme.maximum_supply(), )?)) - .finish_output(token_supply)?, + .finish_output()?, ]; // Input selection will detect that we're melting native tokens and add the required inputs if available self.prepare_transaction(outputs, options).await diff --git a/sdk/src/wallet/operations/transaction/high_level/create_account.rs b/sdk/src/wallet/operations/transaction/high_level/create_account.rs index 4ca85270e0..bc8b1d5134 100644 --- a/sdk/src/wallet/operations/transaction/high_level/create_account.rs +++ b/sdk/src/wallet/operations/transaction/high_level/create_account.rs @@ -74,8 +74,7 @@ where options: impl Into> + Send, ) -> crate::wallet::Result { log::debug!("[TRANSACTION] prepare_create_account_output"); - let storage_params = self.client().get_storage_score_parameters().await?; - let token_supply = self.client().get_token_supply().await?; + let storage_score_params = self.client().get_storage_score_parameters().await?; let address = match params.as_ref().and_then(|options| options.address.as_ref()) { Some(bech32_address) => { @@ -86,7 +85,7 @@ where }; let mut account_output_builder = - AccountOutputBuilder::new_with_minimum_amount(storage_params, AccountId::null()) + AccountOutputBuilder::new_with_minimum_amount(storage_score_params, AccountId::null()) .with_foundry_counter(0) .add_unlock_condition(AddressUnlockCondition::new(address.clone())); if let Some(CreateAccountParams { @@ -104,7 +103,7 @@ where } } - let outputs = [account_output_builder.finish_output(token_supply)?]; + let outputs = [account_output_builder.finish_output()?]; self.prepare_transaction(outputs, options).await } diff --git a/sdk/src/wallet/operations/transaction/high_level/minting/create_native_token.rs b/sdk/src/wallet/operations/transaction/high_level/minting/create_native_token.rs index 63a994d190..479e291aaf 100644 --- a/sdk/src/wallet/operations/transaction/high_level/minting/create_native_token.rs +++ b/sdk/src/wallet/operations/transaction/high_level/minting/create_native_token.rs @@ -133,8 +133,7 @@ where options: impl Into> + Send, ) -> crate::wallet::Result { log::debug!("[TRANSACTION] create_native_token"); - let storage_params = self.client().get_storage_score_parameters().await?; - let token_supply = self.client().get_token_supply().await?; + let storage_score_params = self.client().get_storage_score_parameters().await?; let (account_id, account_output) = self .get_account_output(params.account_id) @@ -156,10 +155,10 @@ where let token_id = TokenId::from(foundry_id); let outputs = [ - new_account_output_builder.finish_output(token_supply)?, + new_account_output_builder.finish_output()?, { let mut foundry_builder = FoundryOutputBuilder::new_with_minimum_amount( - storage_params, + storage_score_params, account_output.foundry_counter() + 1, TokenScheme::Simple(SimpleTokenScheme::new( params.circulating_supply, @@ -175,7 +174,7 @@ where foundry_builder = foundry_builder.add_immutable_feature(MetadataFeature::new(foundry_metadata)?) } - foundry_builder.finish_output(token_supply)? + foundry_builder.finish_output()? }, // Native Tokens will be added automatically in the remainder output in try_select_inputs() ]; diff --git a/sdk/src/wallet/operations/transaction/high_level/minting/mint_native_token.rs b/sdk/src/wallet/operations/transaction/high_level/minting/mint_native_token.rs index 19627bb6c4..a3f7fa7076 100644 --- a/sdk/src/wallet/operations/transaction/high_level/minting/mint_native_token.rs +++ b/sdk/src/wallet/operations/transaction/high_level/minting/mint_native_token.rs @@ -58,7 +58,6 @@ where let mint_amount = mint_amount.into(); let wallet_data = self.data().await; - let token_supply = self.client().get_token_supply().await?; let existing_foundry_output = wallet_data.unspent_outputs.values().find(|output_data| { if let Output::Foundry(output) = &output_data.output { TokenId::new(*output.id()) == token_id @@ -126,8 +125,8 @@ where FoundryOutputBuilder::from(&foundry_output).with_token_scheme(updated_token_scheme); let outputs = [ - new_account_output_builder.finish_output(token_supply)?, - new_foundry_output_builder.finish_output(token_supply)?, + new_account_output_builder.finish_output()?, + new_foundry_output_builder.finish_output()?, // Native Tokens will be added automatically in the remainder output in try_select_inputs() ]; diff --git a/sdk/src/wallet/operations/transaction/high_level/minting/mint_nfts.rs b/sdk/src/wallet/operations/transaction/high_level/minting/mint_nfts.rs index 3fcd0ce917..03c0ab2fb9 100644 --- a/sdk/src/wallet/operations/transaction/high_level/minting/mint_nfts.rs +++ b/sdk/src/wallet/operations/transaction/high_level/minting/mint_nfts.rs @@ -161,8 +161,7 @@ where I::IntoIter: Send, { log::debug!("[TRANSACTION] prepare_mint_nfts"); - let storage_params = self.client().get_storage_score_parameters().await?; - let token_supply = self.client().get_token_supply().await?; + let storage_score_params = self.client().get_storage_score_parameters().await?; let wallet_address = self.address().await.into_inner(); let mut outputs = Vec::new(); @@ -184,7 +183,7 @@ where }; // NftId needs to be set to 0 for the creation - let mut nft_builder = NftOutputBuilder::new_with_minimum_amount(storage_params, NftId::null()) + let mut nft_builder = NftOutputBuilder::new_with_minimum_amount(storage_score_params, NftId::null()) // Address which will own the nft .add_unlock_condition(AddressUnlockCondition::new(address)); @@ -208,7 +207,7 @@ where nft_builder = nft_builder.add_immutable_feature(MetadataFeature::new(immutable_metadata)?); } - outputs.push(nft_builder.finish_output(token_supply)?); + outputs.push(nft_builder.finish_output()?); } self.prepare_transaction(outputs, options).await diff --git a/sdk/src/wallet/operations/transaction/high_level/send.rs b/sdk/src/wallet/operations/transaction/high_level/send.rs index 4d3459a853..cba400a43a 100644 --- a/sdk/src/wallet/operations/transaction/high_level/send.rs +++ b/sdk/src/wallet/operations/transaction/high_level/send.rs @@ -137,7 +137,7 @@ where { log::debug!("[TRANSACTION] prepare_send"); let options = options.into(); - let storage_params = self.client().get_storage_score_parameters().await?; + let storage_score_params = self.client().get_storage_score_parameters().await?; let token_supply = self.client().get_token_supply().await?; let wallet_address = self.address().await; @@ -173,7 +173,7 @@ where .add_unlock_condition(AddressUnlockCondition::new(address)) .finish()?; - if amount >= output.storage_cost(storage_params) { + if amount >= output.storage_cost(storage_score_params) { outputs.push(output.into()) } else { let expiration_slot_index = expiration @@ -187,8 +187,8 @@ where return_address.clone(), expiration_slot_index, )?) - .with_sufficient_storage_deposit(return_address, storage_params, token_supply)? - .finish_output(token_supply)?; + .with_sufficient_storage_deposit(return_address, storage_score_params, token_supply)? + .finish_output()?; if !options.as_ref().map(|o| o.allow_micro_amount).unwrap_or_default() { return Err(Error::InsufficientFunds { diff --git a/sdk/src/wallet/operations/transaction/high_level/send_native_tokens.rs b/sdk/src/wallet/operations/transaction/high_level/send_native_tokens.rs index d16265c4a5..59e3ec80f6 100644 --- a/sdk/src/wallet/operations/transaction/high_level/send_native_tokens.rs +++ b/sdk/src/wallet/operations/transaction/high_level/send_native_tokens.rs @@ -127,7 +127,7 @@ where I::IntoIter: Send, { log::debug!("[TRANSACTION] prepare_send_native_tokens"); - let storage_params = self.client().get_storage_score_parameters().await?; + let storage_score_params = self.client().get_storage_score_parameters().await?; let token_supply = self.client().get_token_supply().await?; let wallet_address = self.address().await; @@ -179,8 +179,8 @@ where return_address.clone(), expiration_slot_index, )?) - .with_sufficient_storage_deposit(return_address, storage_params, token_supply)? - .finish_output(token_supply)?, + .with_sufficient_storage_deposit(return_address, storage_score_params, token_supply)? + .finish_output()?, ) } diff --git a/sdk/src/wallet/operations/transaction/high_level/send_nft.rs b/sdk/src/wallet/operations/transaction/high_level/send_nft.rs index 11e045c813..1eb3dc31f6 100644 --- a/sdk/src/wallet/operations/transaction/high_level/send_nft.rs +++ b/sdk/src/wallet/operations/transaction/high_level/send_nft.rs @@ -96,7 +96,6 @@ where log::debug!("[TRANSACTION] prepare_send_nft"); let unspent_outputs = self.unspent_outputs(None).await; - let token_supply = self.client().get_token_supply().await?; let mut outputs = Vec::new(); @@ -116,7 +115,7 @@ where let nft_builder = NftOutputBuilder::from(nft_output) .with_nft_id(nft_id) .with_unlock_conditions([AddressUnlockCondition::new(address)]); - outputs.push(nft_builder.finish_output(token_supply)?); + outputs.push(nft_builder.finish_output()?); } } else { return Err(crate::wallet::Error::NftNotFoundInUnspentOutputs); diff --git a/sdk/src/wallet/operations/transaction/mod.rs b/sdk/src/wallet/operations/transaction/mod.rs index 2b45f2a686..78cfcdfbf7 100644 --- a/sdk/src/wallet/operations/transaction/mod.rs +++ b/sdk/src/wallet/operations/transaction/mod.rs @@ -73,10 +73,7 @@ where // Check if the outputs have enough amount to cover the storage deposit for output in &outputs { - output.verify_storage_deposit( - protocol_parameters.storage_score_parameters(), - protocol_parameters.token_supply(), - )?; + output.verify_storage_deposit(protocol_parameters.storage_score_parameters())?; } self.finish_transaction(outputs, options).await diff --git a/sdk/src/wallet/operations/transaction/prepare_output.rs b/sdk/src/wallet/operations/transaction/prepare_output.rs index 37234121e3..cf19662d7b 100644 --- a/sdk/src/wallet/operations/transaction/prepare_output.rs +++ b/sdk/src/wallet/operations/transaction/prepare_output.rs @@ -49,12 +49,12 @@ where self.client().bech32_hrp_matches(params.recipient_address.hrp()).await?; - let storage_params = self.client().get_storage_score_parameters().await?; + let storage_score_params = self.client().get_storage_score_parameters().await?; let nft_id = params.assets.as_ref().and_then(|a| a.nft_id); let (mut first_output_builder, existing_nft_output_data) = self - .create_initial_output_builder(params.recipient_address, nft_id, storage_params) + .create_initial_output_builder(params.recipient_address, nft_id, storage_score_params) .await?; if let Some(assets) = ¶ms.assets { @@ -105,7 +105,7 @@ where // Build output with minimum required storage deposit so we can use the amount in the next step let first_output = first_output_builder - .with_minimum_amount(storage_params) + .with_minimum_amount(storage_score_params) .finish_output(token_supply)?; let mut second_output_builder = if nft_id.is_some() { @@ -115,12 +115,12 @@ where }; // TODO: Probably not good to use ed25519 always here, even if technically it's the same for now.. - let min_storage_deposit_basic_output = BasicOutputBuilder::new_with_minimum_amount(storage_params) + let min_storage_deposit_basic_output = BasicOutputBuilder::new_with_minimum_amount(storage_score_params) .add_unlock_condition(AddressUnlockCondition::new(Ed25519Address::null())) .finish()? .amount(); - let min_required_storage_deposit = first_output.storage_cost(storage_params); + let min_required_storage_deposit = first_output.storage_cost(storage_score_params); if params.amount > min_required_storage_deposit { second_output_builder = second_output_builder.with_amount(params.amount); @@ -152,7 +152,7 @@ where // need to check the min required storage deposit again let min_storage_deposit_new_amount = second_output_builder .clone() - .with_minimum_amount(storage_params) + .with_minimum_amount(storage_score_params) .finish_output(token_supply)? .amount(); @@ -182,7 +182,7 @@ where // If we're sending an existing NFT, its minimum required storage deposit is not part of the available base_coin // balance, so we add it here if let Some(existing_nft_output_data) = existing_nft_output_data { - available_base_coin += existing_nft_output_data.output.storage_cost(storage_params); + available_base_coin += existing_nft_output_data.output.storage_cost(storage_score_params); } if final_amount > available_base_coin { @@ -437,8 +437,8 @@ impl OutputBuilder { } fn finish_output(self, token_supply: u64) -> Result { match self { - Self::Basic(b) => b.finish_output(token_supply), - Self::Nft(b) => b.finish_output(token_supply), + Self::Basic(b) => b.finish_output(), + Self::Nft(b) => b.finish_output(), } } } diff --git a/sdk/src/wallet/operations/transaction/prepare_transaction.rs b/sdk/src/wallet/operations/transaction/prepare_transaction.rs index 376d5a3b36..fcf9a1f96d 100644 --- a/sdk/src/wallet/operations/transaction/prepare_transaction.rs +++ b/sdk/src/wallet/operations/transaction/prepare_transaction.rs @@ -36,11 +36,10 @@ where let outputs = outputs.into(); let prepare_transaction_start_time = Instant::now(); let storage_score_params = self.client().get_storage_score_parameters().await?; - let token_supply = self.client().get_token_supply().await?; // Check if the outputs have enough amount to cover the storage deposit for output in &outputs { - output.verify_storage_deposit(storage_score_params, token_supply)?; + output.verify_storage_deposit(storage_score_params)?; } let is_burn_present = options.as_ref().map(|options| options.burn.is_some()).unwrap_or(false); diff --git a/sdk/tests/client/input_selection/account_outputs.rs b/sdk/tests/client/input_selection/account_outputs.rs index 3a550bfd2a..93469e6c4a 100644 --- a/sdk/tests/client/input_selection/account_outputs.rs +++ b/sdk/tests/client/input_selection/account_outputs.rs @@ -17,7 +17,7 @@ use crate::client::{ addresses, build_inputs, build_outputs, is_remainder_or_return, unsorted_eq, Build::{Account, Basic}, ACCOUNT_ID_0, ACCOUNT_ID_1, ACCOUNT_ID_2, BECH32_ADDRESS_ACCOUNT_1, BECH32_ADDRESS_ED25519_0, - BECH32_ADDRESS_ED25519_1, BECH32_ADDRESS_NFT_1, TOKEN_SUPPLY, + BECH32_ADDRESS_ED25519_1, BECH32_ADDRESS_NFT_1, }; #[test] @@ -495,7 +495,7 @@ fn account_in_output_and_sender() { Basic(1_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), ]); let account_output = AccountOutputBuilder::from(inputs[0].output.as_account()) - .finish_output(TOKEN_SUPPLY) + .finish_output() .unwrap(); let mut outputs = build_outputs([Basic( 1_000_000, diff --git a/sdk/tests/client/input_selection/foundry_outputs.rs b/sdk/tests/client/input_selection/foundry_outputs.rs index 2958c9dc76..2e0039f571 100644 --- a/sdk/tests/client/input_selection/foundry_outputs.rs +++ b/sdk/tests/client/input_selection/foundry_outputs.rs @@ -23,7 +23,7 @@ use pretty_assertions::assert_eq; use crate::client::{ addresses, build_inputs, build_outputs, is_remainder_or_return, unsorted_eq, Build::{Account, Basic, Foundry}, - ACCOUNT_ID_1, ACCOUNT_ID_2, BECH32_ADDRESS_ED25519_0, TOKEN_SUPPLY, + ACCOUNT_ID_1, ACCOUNT_ID_2, BECH32_ADDRESS_ED25519_0, }; #[test] @@ -224,7 +224,7 @@ fn melt_native_tokens() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), )) .with_foundry_counter(1) - .finish_output(protocol_parameters.token_supply()) + .finish_output() .unwrap(); inputs.push(InputSigningData { output: account_output, @@ -277,7 +277,7 @@ fn destroy_foundry_with_account_state_transition() { ]); let account_output = AccountOutputBuilder::from(inputs[0].output.as_account()) .with_amount(103_100) - .finish_output(TOKEN_SUPPLY) + .finish_output() .unwrap(); // Account output gets the amount from the foundry output added let outputs = [account_output]; @@ -429,7 +429,7 @@ fn simple_foundry_transition_basic_not_needed() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), )) .with_foundry_counter(1) - .finish_output(protocol_parameters.token_supply()) + .finish_output() .unwrap(); inputs.push(InputSigningData { output: account_output, @@ -496,7 +496,7 @@ fn simple_foundry_transition_basic_not_needed_with_remainder() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), )) .with_foundry_counter(1) - .finish_output(protocol_parameters.token_supply()) + .finish_output() .unwrap(); inputs.push(InputSigningData { output: account_output, @@ -638,7 +638,7 @@ fn mint_and_burn_at_the_same_time() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), )) .with_foundry_counter(1) - .finish_output(protocol_parameters.token_supply()) + .finish_output() .unwrap(); inputs.push(InputSigningData { output: account_output, @@ -691,7 +691,7 @@ fn take_amount_from_account_and_foundry_to_fund_basic() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), )) .with_foundry_counter(1) - .finish_output(protocol_parameters.token_supply()) + .finish_output() .unwrap(); inputs.push(InputSigningData { output: account_output, @@ -906,7 +906,7 @@ fn foundry_in_outputs_and_required() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), )) .with_foundry_counter(1) - .finish_output(protocol_parameters.token_supply()) + .finish_output() .unwrap(); inputs.push(InputSigningData { output: account_output, @@ -963,7 +963,7 @@ fn melt_and_burn_native_tokens() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), )) .with_foundry_counter(1) - .finish_output(protocol_parameters.token_supply()) + .finish_output() .unwrap(); inputs.push(InputSigningData { output: account_output, diff --git a/sdk/tests/client/input_selection/nft_outputs.rs b/sdk/tests/client/input_selection/nft_outputs.rs index 27e269aa5e..909024f6f2 100644 --- a/sdk/tests/client/input_selection/nft_outputs.rs +++ b/sdk/tests/client/input_selection/nft_outputs.rs @@ -1204,7 +1204,7 @@ fn changed_immutable_metadata() { .add_unlock_condition(AddressUnlockCondition::new( Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), )) - .finish_output(protocol_parameters.token_supply()) + .finish_output() .unwrap(); let inputs = [InputSigningData { @@ -1227,7 +1227,7 @@ fn changed_immutable_metadata() { let updated_nft_output = NftOutputBuilder::from(nft_output.as_nft()) .with_minimum_amount(protocol_parameters.storage_score_parameters()) .with_immutable_features(MetadataFeature::try_from(metadata)) - .finish_output(protocol_parameters.token_supply()) + .finish_output() .unwrap(); let outputs = [updated_nft_output]; diff --git a/sdk/tests/client/input_signing_data.rs b/sdk/tests/client/input_signing_data.rs index 956c1301f6..3af8a84422 100644 --- a/sdk/tests/client/input_signing_data.rs +++ b/sdk/tests/client/input_signing_data.rs @@ -33,7 +33,7 @@ fn input_signing_data_conversion() { .add_unlock_condition(AddressUnlockCondition::new( Address::try_from_bech32("rms1qpllaj0pyveqfkwxmnngz2c488hfdtmfrj3wfkgxtk4gtyrax0jaxzt70zy").unwrap(), )) - .finish_output(protocol_parameters.token_supply()) + .finish_output() .unwrap(); let input_signing_data = InputSigningData { diff --git a/sdk/tests/client/mod.rs b/sdk/tests/client/mod.rs index 44d55347f5..4d8db30740 100644 --- a/sdk/tests/client/mod.rs +++ b/sdk/tests/client/mod.rs @@ -131,7 +131,7 @@ fn build_basic_output( builder = builder.add_unlock_condition(ExpirationUnlockCondition::new(address, timestamp).unwrap()); } - builder.finish_output(TOKEN_SUPPLY).unwrap() + builder.finish_output().unwrap() } #[allow(clippy::too_many_arguments)] @@ -173,7 +173,7 @@ fn build_nft_output( builder = builder.add_unlock_condition(ExpirationUnlockCondition::new(address, timestamp).unwrap()); } - builder.finish_output(TOKEN_SUPPLY).unwrap() + builder.finish_output().unwrap() } #[allow(clippy::too_many_arguments)] @@ -204,7 +204,7 @@ fn build_account_output( builder = builder.add_immutable_feature(IssuerFeature::new(bech32_issuer)); } - builder.finish_output(TOKEN_SUPPLY).unwrap() + builder.finish_output().unwrap() } fn build_foundry_output( @@ -227,7 +227,7 @@ fn build_foundry_output( ); } - builder.finish_output(TOKEN_SUPPLY).unwrap() + builder.finish_output().unwrap() } fn build_output_inner(build: Build) -> (Output, Option) { diff --git a/sdk/tests/types/output/account.rs b/sdk/tests/types/output/account.rs index 46c846e8c2..8a2752ce53 100644 --- a/sdk/tests/types/output/account.rs +++ b/sdk/tests/types/output/account.rs @@ -1,18 +1,15 @@ // Copyright 2023 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -use iota_sdk::types::{ - block::{ - address::AccountAddress, - output::{AccountOutput, Feature, FoundryId, NativeToken, Output, SimpleTokenScheme, StorageScore, TokenId}, - protocol::protocol_parameters, - rand::output::{ - feature::{rand_issuer_feature, rand_metadata_feature, rand_sender_feature}, - rand_account_id, rand_account_output, - unlock_condition::rand_address_unlock_condition_different_from_account_id, - }, +use iota_sdk::types::block::{ + address::AccountAddress, + output::{AccountOutput, Feature, FoundryId, NativeToken, Output, SimpleTokenScheme, StorageScore, TokenId}, + protocol::protocol_parameters, + rand::output::{ + feature::{rand_issuer_feature, rand_metadata_feature, rand_sender_feature}, + rand_account_id, rand_account_output, + unlock_condition::rand_address_unlock_condition_different_from_account_id, }, - ValidationParams, }; use packable::PackableExt; use pretty_assertions::assert_eq; @@ -61,7 +58,7 @@ fn builder() { .add_unlock_condition(rand_address_unlock_condition_different_from_account_id(&account_id)) .with_features([Feature::from(metadata.clone()), sender_1.clone().into()]) .with_immutable_features([Feature::from(metadata.clone()), issuer_1.clone().into()]) - .finish_with_params(ValidationParams::default().with_protocol_parameters(protocol_parameters.clone())) + .finish() .unwrap(); assert_eq!( diff --git a/sdk/tests/types/output/basic.rs b/sdk/tests/types/output/basic.rs index 3f997fe929..bb8d9bffc7 100644 --- a/sdk/tests/types/output/basic.rs +++ b/sdk/tests/types/output/basic.rs @@ -1,20 +1,17 @@ // Copyright 2023 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -use iota_sdk::types::{ - block::{ - output::{BasicOutput, Feature, FoundryId, NativeToken, Output, SimpleTokenScheme, StorageScore, TokenId}, - protocol::protocol_parameters, - rand::{ - address::rand_account_address, - output::{ - feature::{rand_metadata_feature, rand_sender_feature}, - rand_basic_output, - unlock_condition::rand_address_unlock_condition, - }, +use iota_sdk::types::block::{ + output::{BasicOutput, Feature, FoundryId, NativeToken, Output, SimpleTokenScheme, StorageScore, TokenId}, + protocol::protocol_parameters, + rand::{ + address::rand_account_address, + output::{ + feature::{rand_metadata_feature, rand_sender_feature}, + rand_basic_output, + unlock_condition::rand_address_unlock_condition, }, }, - ValidationParams, }; use packable::PackableExt; use pretty_assertions::assert_eq; @@ -54,7 +51,7 @@ fn builder() { .with_minimum_amount(protocol_parameters.storage_score_parameters()) .add_unlock_condition(rand_address_unlock_condition()) .with_features([Feature::from(metadata.clone()), sender_1.clone().into()]) - .finish_with_params(ValidationParams::default().with_protocol_parameters(protocol_parameters.clone())) + .finish() .unwrap(); assert_eq!( diff --git a/sdk/tests/types/output/foundry.rs b/sdk/tests/types/output/foundry.rs index eaff2fd6c0..7ca59a680e 100644 --- a/sdk/tests/types/output/foundry.rs +++ b/sdk/tests/types/output/foundry.rs @@ -54,7 +54,7 @@ fn builder() { let output = builder .with_minimum_amount(protocol_parameters.storage_score_parameters()) .add_unlock_condition(ImmutableAccountAddressUnlockCondition::new(rand_account_address())) - .finish_with_params(&protocol_parameters) + .finish() .unwrap(); assert_eq!( diff --git a/sdk/tests/types/output/nft.rs b/sdk/tests/types/output/nft.rs index 9406a94399..be1dbbeddb 100644 --- a/sdk/tests/types/output/nft.rs +++ b/sdk/tests/types/output/nft.rs @@ -55,7 +55,7 @@ fn builder() { let output = builder .with_minimum_amount(protocol_parameters.storage_score_parameters()) .add_unlock_condition(rand_address_unlock_condition()) - .finish_with_params(protocol_parameters.token_supply()) + .finish() .unwrap(); assert_eq!( diff --git a/sdk/tests/types/payload.rs b/sdk/tests/types/payload.rs index 58e4e8a6ff..b8a2ddafee 100644 --- a/sdk/tests/types/payload.rs +++ b/sdk/tests/types/payload.rs @@ -34,7 +34,7 @@ fn transaction() { let output = Output::Basic( BasicOutput::build_with_amount(amount) .add_unlock_condition(AddressUnlockCondition::new(address)) - .finish_with_params(&protocol_parameters) + .finish() .unwrap(), ); let transaction = Transaction::builder(protocol_parameters.network_id()) diff --git a/sdk/tests/types/signed_transaction_payload.rs b/sdk/tests/types/signed_transaction_payload.rs index 09e4762cb7..eef9a27afb 100644 --- a/sdk/tests/types/signed_transaction_payload.rs +++ b/sdk/tests/types/signed_transaction_payload.rs @@ -39,7 +39,7 @@ fn builder_too_few_unlocks() { let output = Output::Basic( BasicOutput::build_with_amount(amount) .add_unlock_condition(AddressUnlockCondition::new(address)) - .finish_with_params(protocol_parameters.token_supply()) + .finish() .unwrap(), ); let transaction = Transaction::builder(protocol_parameters.network_id()) @@ -75,7 +75,7 @@ fn builder_too_many_unlocks() { let output = Output::Basic( BasicOutput::build_with_amount(amount) .add_unlock_condition(AddressUnlockCondition::new(address)) - .finish_with_params(protocol_parameters.token_supply()) + .finish() .unwrap(), ); let transaction = Transaction::builder(protocol_parameters.network_id()) @@ -114,7 +114,7 @@ fn pack_unpack_valid() { let output = Output::Basic( BasicOutput::build_with_amount(amount) .add_unlock_condition(AddressUnlockCondition::new(address)) - .finish_with_params(protocol_parameters.token_supply()) + .finish() .unwrap(), ); let transaction = Transaction::builder(protocol_parameters.network_id()) @@ -155,7 +155,7 @@ fn getters() { let output = Output::Basic( BasicOutput::build_with_amount(amount) .add_unlock_condition(AddressUnlockCondition::new(address)) - .finish_with_params(protocol_parameters.token_supply()) + .finish() .unwrap(), ); let transaction = Transaction::builder(protocol_parameters.network_id()) diff --git a/sdk/tests/types/transaction.rs b/sdk/tests/types/transaction.rs index 81f5e492a1..5e696ac391 100644 --- a/sdk/tests/types/transaction.rs +++ b/sdk/tests/types/transaction.rs @@ -42,7 +42,7 @@ fn build_valid() { let output = Output::Basic( BasicOutput::build_with_amount(amount) .add_unlock_condition(AddressUnlockCondition::new(address)) - .finish_with_params(protocol_parameters.token_supply()) + .finish() .unwrap(), ); @@ -67,7 +67,7 @@ fn build_valid_with_payload() { let output = Output::Basic( BasicOutput::build_with_amount(amount) .add_unlock_condition(AddressUnlockCondition::new(address)) - .finish_with_params(protocol_parameters.token_supply()) + .finish() .unwrap(), ); @@ -93,7 +93,7 @@ fn build_valid_add_inputs_outputs() { let output = Output::Basic( BasicOutput::build_with_amount(amount) .add_unlock_condition(AddressUnlockCondition::new(address)) - .finish_with_params(protocol_parameters.token_supply()) + .finish() .unwrap(), ); @@ -119,7 +119,7 @@ fn build_invalid_payload_kind() { let output = Output::Basic( BasicOutput::build_with_amount(amount) .add_unlock_condition(AddressUnlockCondition::new(address)) - .finish_with_params(protocol_parameters.token_supply()) + .finish() .unwrap(), ); let transaction = Transaction::builder(protocol_parameters.network_id()) @@ -158,7 +158,7 @@ fn build_invalid_input_count_low() { let output = Output::Basic( BasicOutput::build_with_amount(amount) .add_unlock_condition(AddressUnlockCondition::new(address)) - .finish_with_params(protocol_parameters.token_supply()) + .finish() .unwrap(), ); @@ -184,7 +184,7 @@ fn build_invalid_input_count_high() { let output = Output::Basic( BasicOutput::build_with_amount(amount) .add_unlock_condition(AddressUnlockCondition::new(address)) - .finish_with_params(protocol_parameters.token_supply()) + .finish() .unwrap(), ); @@ -228,7 +228,7 @@ fn build_invalid_output_count_high() { let output = Output::Basic( BasicOutput::build_with_amount(amount) .add_unlock_condition(AddressUnlockCondition::new(address)) - .finish_with_params(protocol_parameters.token_supply()) + .finish() .unwrap(), ); @@ -255,7 +255,7 @@ fn build_invalid_duplicate_utxo() { let output = Output::Basic( BasicOutput::build_with_amount(amount) .add_unlock_condition(AddressUnlockCondition::new(address)) - .finish_with_params(protocol_parameters.token_supply()) + .finish() .unwrap(), ); @@ -280,7 +280,7 @@ fn build_invalid_accumulated_output() { let output1 = Output::Basic( BasicOutput::build_with_amount(amount1) .add_unlock_condition(AddressUnlockCondition::new(address1)) - .finish_with_params(protocol_parameters.token_supply()) + .finish() .unwrap(), ); @@ -290,7 +290,7 @@ fn build_invalid_accumulated_output() { let output2 = Output::Basic( BasicOutput::build_with_amount(amount2) .add_unlock_condition(AddressUnlockCondition::new(address2)) - .finish_with_params(protocol_parameters.token_supply()) + .finish() .unwrap(), ); @@ -315,7 +315,7 @@ fn getters() { let outputs = [Output::Basic( BasicOutput::build_with_amount(amount) .add_unlock_condition(AddressUnlockCondition::new(address)) - .finish_with_params(protocol_parameters.token_supply()) + .finish() .unwrap(), )]; let payload = Payload::from(rand_tagged_data_payload()); @@ -343,12 +343,12 @@ fn duplicate_output_nft() { let amount = 1_000_000; let basic = BasicOutput::build_with_amount(amount) .add_unlock_condition(AddressUnlockCondition::new(address.clone())) - .finish_output(protocol_parameters.token_supply()) + .finish_output() .unwrap(); let nft_id = NftId::from(bytes); let nft = NftOutput::build_with_amount(1_000_000, nft_id) .add_unlock_condition(AddressUnlockCondition::new(address)) - .finish_output(protocol_parameters.token_supply()) + .finish_output() .unwrap(); let transaction = Transaction::builder(protocol_parameters.network_id()) @@ -374,12 +374,12 @@ fn duplicate_output_nft_null() { let amount = 1_000_000; let basic = BasicOutput::build_with_amount(amount) .add_unlock_condition(AddressUnlockCondition::new(address.clone())) - .finish_output(protocol_parameters.token_supply()) + .finish_output() .unwrap(); let nft_id = NftId::null(); let nft = NftOutput::build_with_amount(1_000_000, nft_id) .add_unlock_condition(AddressUnlockCondition::new(address)) - .finish_output(protocol_parameters.token_supply()) + .finish_output() .unwrap(); let transaction = Transaction::builder(protocol_parameters.network_id()) @@ -402,12 +402,12 @@ fn duplicate_output_account() { let amount = 1_000_000; let basic = BasicOutput::build_with_amount(amount) .add_unlock_condition(AddressUnlockCondition::new(address.clone())) - .finish_output(protocol_parameters.token_supply()) + .finish_output() .unwrap(); let account_id = AccountId::from(bytes); let account = AccountOutput::build_with_amount(1_000_000, account_id) .add_unlock_condition(AddressUnlockCondition::new(address.clone())) - .finish_output(protocol_parameters.token_supply()) + .finish_output() .unwrap(); let transaction = Transaction::builder(protocol_parameters.network_id()) @@ -433,7 +433,7 @@ fn duplicate_output_foundry() { let amount = 1_000_000; let basic = BasicOutput::build_with_amount(amount) .add_unlock_condition(AddressUnlockCondition::new(address)) - .finish_output(protocol_parameters.token_supply()) + .finish_output() .unwrap(); let account_id = AccountId::from(bytes); let token_scheme = TokenScheme::Simple(SimpleTokenScheme::new(70, 0, 100).unwrap()); @@ -444,7 +444,7 @@ fn duplicate_output_foundry() { .add_unlock_condition(ImmutableAccountAddressUnlockCondition::new(AccountAddress::from( account_id, ))) - .finish_output(protocol_parameters.token_supply()) + .finish_output() .unwrap(); let transaction = Transaction::builder(protocol_parameters.network_id()) @@ -470,7 +470,7 @@ fn transactions_capabilities() { let output = Output::Basic( BasicOutput::build_with_amount(amount) .add_unlock_condition(AddressUnlockCondition::new(address)) - .finish_with_params(&protocol_parameters) + .finish() .unwrap(), ); let transaction = Transaction::builder(protocol_parameters.network_id()) diff --git a/sdk/tests/wallet/balance.rs b/sdk/tests/wallet/balance.rs index 6a2c28310f..bc926936e7 100644 --- a/sdk/tests/wallet/balance.rs +++ b/sdk/tests/wallet/balance.rs @@ -2,13 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 use iota_sdk::{ - types::block::{ - address::Bech32Address, - output::{ - feature::SenderFeature, - unlock_condition::{AddressUnlockCondition, ExpirationUnlockCondition}, - BasicOutputBuilder, UnlockCondition, - }, + types::block::output::{ + feature::SenderFeature, + unlock_condition::{AddressUnlockCondition, ExpirationUnlockCondition}, + BasicOutputBuilder, UnlockCondition, }, wallet::{types::Balance, Result}, }; @@ -107,7 +104,6 @@ async fn balance_expiration() -> Result<()> { request_funds(&wallet_0).await?; let slots_until_expired = 20; - let token_supply = wallet_0.client().get_token_supply().await?; let outputs = [BasicOutputBuilder::new_with_amount(1_000_000) // Send to account 1 with expiration to account 2, both have no amount yet .with_unlock_conditions([ @@ -118,7 +114,7 @@ async fn balance_expiration() -> Result<()> { )?), ]) .with_features([SenderFeature::new(wallet_0.address().await)]) - .finish_output(token_supply)?]; + .finish_output()?]; let balance_before_tx = wallet_0.balance().await?; let tx = wallet_0.send_outputs(outputs, None).await?; @@ -166,7 +162,7 @@ async fn balance_expiration() -> Result<()> { let outputs = [BasicOutputBuilder::new_with_amount(1_000_000) // Send to wallet 1 with expiration to wallet 2, both have no amount yet .with_unlock_conditions([AddressUnlockCondition::new(wallet_1.address().await)]) - .finish_output(token_supply)?]; + .finish_output()?]; let _tx = wallet_2.send_outputs(outputs, None).await?; tear_down(storage_path_0)?; diff --git a/sdk/tests/wallet/burn_outputs.rs b/sdk/tests/wallet/burn_outputs.rs index 1517d73c10..dff9359506 100644 --- a/sdk/tests/wallet/burn_outputs.rs +++ b/sdk/tests/wallet/burn_outputs.rs @@ -64,8 +64,6 @@ async fn mint_and_burn_expired_nft() -> Result<()> { let wallet_1 = make_wallet(storage_path, None, None).await?; request_funds(&wallet_0).await?; - let token_supply = wallet_0.client().get_token_supply().await?; - let amount = 1_000_000; let outputs = [NftOutputBuilder::new_with_amount(amount, NftId::null()) .with_unlock_conditions([ @@ -73,7 +71,7 @@ async fn mint_and_burn_expired_nft() -> Result<()> { // immediately expired to account_1 UnlockCondition::Expiration(ExpirationUnlockCondition::new(wallet_1.address().await, 1)?), ]) - .finish_output(token_supply)?]; + .finish_output()?]; let transaction = wallet_0.send_outputs(outputs, None).await?; wallet_0 diff --git a/sdk/tests/wallet/claim_outputs.rs b/sdk/tests/wallet/claim_outputs.rs index b520eb1764..ae52af1961 100644 --- a/sdk/tests/wallet/claim_outputs.rs +++ b/sdk/tests/wallet/claim_outputs.rs @@ -140,7 +140,6 @@ async fn claim_2_basic_outputs_no_outputs_in_claim_account() -> Result<()> { request_funds(&wallet_0).await?; - let token_supply = wallet_0.client().get_token_supply().await?; let storage_score_params = wallet_0.client().get_storage_score_parameters().await?; // TODO more fitting value let expiration_slot = wallet_0.client().get_slot_index().await? + 86400; @@ -151,7 +150,7 @@ async fn claim_2_basic_outputs_no_outputs_in_claim_account() -> Result<()> { wallet_0.address().await, expiration_slot, )?) - .finish_output(token_supply)?; + .finish_output()?; let amount = output.amount(); let outputs = vec![output; 2]; @@ -338,7 +337,6 @@ async fn claim_2_native_tokens_no_outputs_in_claim_account() -> Result<()> { wallet_0.sync(None).await?; let storage_score_params = wallet_0.client().get_storage_score_parameters().await?; - let token_supply = wallet_0.client().get_token_supply().await?; let tx = wallet_0 .send_outputs( @@ -350,7 +348,7 @@ async fn claim_2_native_tokens_no_outputs_in_claim_account() -> Result<()> { wallet_0.client().get_slot_index().await? + 5000, )?) .add_native_token(NativeToken::new(create_tx_0.token_id, native_token_amount)?) - .finish_output(token_supply)?, + .finish_output()?, BasicOutputBuilder::new_with_minimum_amount(storage_score_params) .add_unlock_condition(AddressUnlockCondition::new(wallet_1.address().await)) .add_unlock_condition(ExpirationUnlockCondition::new( @@ -358,7 +356,7 @@ async fn claim_2_native_tokens_no_outputs_in_claim_account() -> Result<()> { wallet_0.client().get_slot_index().await? + 5000, )?) .add_native_token(NativeToken::new(create_tx_1.token_id, native_token_amount)?) - .finish_output(token_supply)?, + .finish_output()?, ], None, ) @@ -414,7 +412,6 @@ async fn claim_2_nft_outputs() -> Result<()> { request_funds(&wallet_0).await?; request_funds(&wallet_1).await?; - let token_supply = wallet_1.client().get_token_supply().await?; let outputs = [ // address of the owner of the NFT NftOutputBuilder::new_with_amount(1_000_000, NftId::null()) @@ -425,7 +422,7 @@ async fn claim_2_nft_outputs() -> Result<()> { wallet_1.client().get_slot_index().await? + 5000, )?), ]) - .finish_output(token_supply)?, + .finish_output()?, NftOutputBuilder::new_with_amount(1_000_000, NftId::null()) .with_unlock_conditions([ UnlockCondition::Address(AddressUnlockCondition::new(wallet_0.address().await)), @@ -434,7 +431,7 @@ async fn claim_2_nft_outputs() -> Result<()> { wallet_1.client().get_slot_index().await? + 5000, )?), ]) - .finish_output(token_supply)?, + .finish_output()?, ]; let tx = wallet_1.send_outputs(outputs, None).await?; @@ -476,7 +473,6 @@ async fn claim_2_nft_outputs_no_outputs_in_claim_account() -> Result<()> { request_funds(&wallet_0).await?; - let token_supply = wallet_0.client().get_token_supply().await?; let outputs = [ // address of the owner of the NFT NftOutputBuilder::new_with_amount(1_000_000, NftId::null()) @@ -487,7 +483,7 @@ async fn claim_2_nft_outputs_no_outputs_in_claim_account() -> Result<()> { wallet_0.client().get_slot_index().await? + 5000, )?), ]) - .finish_output(token_supply)?, + .finish_output()?, NftOutputBuilder::new_with_amount(1_000_000, NftId::null()) .with_unlock_conditions([ UnlockCondition::Address(AddressUnlockCondition::new(wallet_1.address().await)), @@ -496,7 +492,7 @@ async fn claim_2_nft_outputs_no_outputs_in_claim_account() -> Result<()> { wallet_0.client().get_slot_index().await? + 5000, )?), ]) - .finish_output(token_supply)?, + .finish_output()?, ]; let tx = wallet_0.send_outputs(outputs, None).await?; diff --git a/sdk/tests/wallet/events.rs b/sdk/tests/wallet/events.rs index 481d3ba105..41abdac43c 100644 --- a/sdk/tests/wallet/events.rs +++ b/sdk/tests/wallet/events.rs @@ -95,7 +95,7 @@ fn wallet_events_serde() { let output = Output::Basic( BasicOutput::build_with_amount(amount) .add_unlock_condition(AddressUnlockCondition::new(address)) - .finish_with_params(protocol_parameters.token_supply()) + .finish() .unwrap(), ); let transaction = Transaction::builder(protocol_parameters.network_id()) diff --git a/sdk/tests/wallet/output_preparation.rs b/sdk/tests/wallet/output_preparation.rs index b513175e9c..caf634f9a7 100644 --- a/sdk/tests/wallet/output_preparation.rs +++ b/sdk/tests/wallet/output_preparation.rs @@ -431,7 +431,6 @@ async fn output_preparation_sdr() -> Result<()> { request_funds(&wallet).await?; let storage_score_params = wallet.client().get_storage_score_parameters().await?; - let token_supply = wallet.client().get_token_supply().await?; let recipient_address_bech32 = String::from("rms1qpszqzadsym6wpppd6z037dvlejmjuke7s24hm95s9fg9vpua7vluaw60xu"); // Roundtrip to get the correct bech32 HRP @@ -452,7 +451,7 @@ async fn output_preparation_sdr() -> Result<()> { ) .await?; // Check if the output has enough amount to cover the storage deposit - output.verify_storage_deposit(storage_score_params, token_supply)?; + output.verify_storage_deposit(storage_score_params)?; assert_eq!(output.amount(), 50601); // address and sdr unlock condition assert_eq!(output.unlock_conditions().unwrap().len(), 2); @@ -473,7 +472,7 @@ async fn output_preparation_sdr() -> Result<()> { ) .await?; // Check if the output has enough amount to cover the storage deposit - output.verify_storage_deposit(storage_score_params, token_supply)?; + output.verify_storage_deposit(storage_score_params)?; assert_eq!(output.amount(), 85199); // address and sdr unlock condition assert_eq!(output.unlock_conditions().unwrap().len(), 2); @@ -498,7 +497,7 @@ async fn output_preparation_sdr() -> Result<()> { ) .await?; // Check if the output has enough amount to cover the storage deposit - output.verify_storage_deposit(storage_score_params, token_supply)?; + output.verify_storage_deposit(storage_score_params)?; assert_eq!(output.amount(), 85199); // address and sdr unlock condition assert_eq!(output.unlock_conditions().unwrap().len(), 2); @@ -523,7 +522,7 @@ async fn output_preparation_sdr() -> Result<()> { ) .await?; // Check if the output has enough amount to cover the storage deposit - output.verify_storage_deposit(storage_score_params, token_supply)?; + output.verify_storage_deposit(storage_score_params)?; // The additional 1 amount will be added, because the storage deposit should be gifted and not returned assert_eq!(output.amount(), 42600); // storage deposit gifted, only address unlock condition @@ -612,7 +611,6 @@ async fn prepare_output_remainder_dust() -> Result<()> { request_funds(&wallet_1).await?; let storage_score_params = wallet_0.client().get_storage_score_parameters().await?; - let token_supply = wallet_0.client().get_token_supply().await?; let balance = wallet_0.sync(None).await?; let minimum_required_storage_deposit = BasicOutputBuilder::new_with_amount(0) @@ -659,7 +657,7 @@ async fn prepare_output_remainder_dust() -> Result<()> { .await?; // Check if the output has enough amount to cover the storage deposit - output.verify_storage_deposit(storage_score_params, token_supply)?; + output.verify_storage_deposit(storage_score_params)?; // The left over 21299 is too small to keep, so we donate it assert_eq!(output.amount(), balance.base_coin().available()); // storage deposit gifted, only address unlock condition @@ -703,7 +701,7 @@ async fn prepare_output_remainder_dust() -> Result<()> { .await?; // Check if the output has enough amount to cover the storage deposit - output.verify_storage_deposit(storage_score_params, token_supply)?; + output.verify_storage_deposit(storage_score_params)?; // We use excess if leftover is too small, so amount == all available balance assert_eq!(output.amount(), 63900); // storage deposit gifted, only address unlock condition @@ -727,7 +725,7 @@ async fn prepare_output_remainder_dust() -> Result<()> { .await?; // Check if the output has enough amount to cover the storage deposit - output.verify_storage_deposit(storage_score_params, token_supply)?; + output.verify_storage_deposit(storage_score_params)?; // We use excess if leftover is too small, so amount == all available balance assert_eq!(output.amount(), 63900); // storage deposit returned, address and SDR unlock condition