From 544311a9143a0e24188717e8f225807ca0721388 Mon Sep 17 00:00:00 2001 From: Thibault Martinez Date: Wed, 8 Nov 2023 16:00:09 +0100 Subject: [PATCH] Remove output token supply check (#1599) * Remove output token supply check * Remove unneeded lifetimes --- cli/src/wallet_cli/mod.rs | 3 +- .../client/output/build_account_output.rs | 3 +- .../client/output/build_basic_output.rs | 14 +++---- .../client/output/build_nft_output.rs | 3 +- .../accounts_and_addresses/check_balance.rs | 2 +- .../advanced_transaction.rs | 2 +- sdk/examples/how_tos/nfts/mint_nft.rs | 3 +- sdk/examples/how_tos/outputs/features.rs | 11 +++-- .../how_tos/outputs/unlock_conditions.rs | 10 ++--- .../wallet/17_check_unlock_conditions.rs | 7 +--- sdk/examples/wallet/events.rs | 2 +- .../offline_signing/0_generate_address.rs | 2 +- .../input_selection/remainder.rs | 16 ++------ .../input_selection/requirement/amount.rs | 6 +-- .../input_selection/transition.rs | 6 +-- sdk/src/types/block/output/account.rs | 29 ++++---------- sdk/src/types/block/output/anchor.rs | 26 ++++-------- sdk/src/types/block/output/basic.rs | 28 ++++--------- sdk/src/types/block/output/delegation.rs | 26 +++--------- sdk/src/types/block/output/foundry.rs | 33 ++++----------- sdk/src/types/block/output/mod.rs | 9 ++--- sdk/src/types/block/output/nft.rs | 26 ++++-------- sdk/src/types/block/output/rent.rs | 2 +- .../payload/signed_transaction/transaction.rs | 2 +- sdk/src/types/block/rand/output/mod.rs | 10 ++--- sdk/src/wallet/core/mod.rs | 2 +- sdk/src/wallet/operations/output_claiming.rs | 8 ++-- .../wallet/operations/output_consolidation.rs | 3 +- .../wallet/operations/participation/voting.rs | 4 +- .../operations/participation/voting_power.rs | 24 +++-------- .../burning_melting/melt_native_token.rs | 5 +-- .../transaction/high_level/create_account.rs | 3 +- .../high_level/minting/create_native_token.rs | 5 +-- .../high_level/minting/mint_native_token.rs | 5 +-- .../high_level/minting/mint_nfts.rs | 3 +- .../operations/transaction/high_level/send.rs | 6 +-- .../high_level/send_native_tokens.rs | 2 +- .../transaction/high_level/send_nft.rs | 3 +- sdk/src/wallet/operations/transaction/mod.rs | 2 +- .../operations/transaction/prepare_output.rs | 4 +- .../transaction/prepare_transaction.rs | 3 +- .../client/input_selection/account_outputs.rs | 4 +- .../client/input_selection/foundry_outputs.rs | 18 ++++----- .../client/input_selection/nft_outputs.rs | 4 +- sdk/tests/client/input_signing_data.rs | 2 +- sdk/tests/client/mod.rs | 8 ++-- sdk/tests/types/output/account.rs | 21 +++++----- sdk/tests/types/output/basic.rs | 23 +++++------ sdk/tests/types/output/foundry.rs | 2 +- sdk/tests/types/output/nft.rs | 2 +- sdk/tests/types/payload.rs | 2 +- sdk/tests/types/signed_transaction_payload.rs | 8 ++-- sdk/tests/types/transaction.rs | 40 +++++++++---------- sdk/tests/wallet/balance.rs | 16 +++----- sdk/tests/wallet/burn_outputs.rs | 4 +- sdk/tests/wallet/claim_outputs.rs | 18 ++++----- sdk/tests/wallet/events.rs | 2 +- sdk/tests/wallet/output_preparation.rs | 15 ++++--- 58 files changed, 207 insertions(+), 345 deletions(-) diff --git a/cli/src/wallet_cli/mod.rs b/cli/src/wallet_cli/mod.rs index 87720cf67d..62dfbaec12 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 rent_structure = wallet.client().get_rent_structure().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 3f6631f41a..6e5f8ed133 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 rent_structure = client.get_rent_structure().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 5dfafd8772..149ee6c284 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 rent_structure = client.get_rent_structure().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 97ae44ceb9..95a7b2284d 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 rent_structure = client.get_rent_structure().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 ae74660100..60f566af70 100644 --- a/sdk/examples/how_tos/outputs/unlock_conditions.rs +++ b/sdk/examples/how_tos/outputs/unlock_conditions.rs @@ -48,7 +48,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() @@ -57,22 +57,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 f9bb877585..e7442dcdd0 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.rent_structure(), - self.protocol_parameters.token_supply(), - )?; + remainder.verify_storage_deposit(self.protocol_parameters.rent_structure())?; 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 c3a4d097a9..de78c4aaa9 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 @@ -249,13 +249,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 de27285b41..3dee4b05f3 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_min, verify_output_amount_packable, verify_output_amount_supply, ChainId, NativeToken, - NativeTokens, Output, OutputBuilderAmount, OutputId, Rent, RentStructure, StateTransitionError, - StateTransitionVerifier, + verify_output_amount_min, verify_output_amount_packable, ChainId, NativeToken, NativeTokens, Output, + OutputBuilderAmount, OutputId, Rent, RentStructure, StateTransitionError, StateTransitionVerifier, }, 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()?)) } } @@ -702,7 +687,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() } } @@ -750,7 +735,7 @@ pub(crate) mod dto { builder = builder.with_immutable_features(immutable_features); } - builder.finish_with_params(params) + builder.finish() } } } @@ -816,7 +801,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 c54fd11901..8dccff6276 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_min, verify_output_amount_packable, verify_output_amount_supply, ChainId, NativeToken, - NativeTokens, Output, OutputBuilderAmount, OutputId, Rent, RentStructure, StateTransitionError, - StateTransitionVerifier, + verify_output_amount_min, verify_output_amount_packable, ChainId, NativeToken, NativeTokens, Output, + OutputBuilderAmount, OutputId, Rent, RentStructure, StateTransitionError, StateTransitionVerifier, }, payload::signed_transaction::TransactionCapabilityFlag, protocol::ProtocolParameters, @@ -320,20 +319,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()?)) } } @@ -785,7 +773,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() } } @@ -838,7 +826,7 @@ pub(crate) mod dto { builder = builder.with_immutable_features(immutable_features); } - builder.finish_with_params(params) + builder.finish() } } } @@ -905,7 +893,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 42a3787eb2..7b99c1c574 100644 --- a/sdk/src/types/block/output/basic.rs +++ b/sdk/src/types/block/output/basic.rs @@ -13,8 +13,8 @@ use crate::types::{ unlock_condition::{ verify_allowed_unlock_conditions, UnlockCondition, UnlockConditionFlags, UnlockConditions, }, - verify_output_amount_min, verify_output_amount_packable, verify_output_amount_supply, NativeToken, - NativeTokens, Output, OutputBuilderAmount, OutputId, Rent, RentStructure, + verify_output_amount_min, verify_output_amount_packable, NativeToken, NativeTokens, Output, + OutputBuilderAmount, OutputId, Rent, RentStructure, }, protocol::ProtocolParameters, semantic::{SemanticValidationContext, TransactionFailureReason}, @@ -181,20 +181,9 @@ impl BasicOutputBuilder { 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 [`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()?)) } } @@ -420,7 +409,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() } } @@ -456,7 +445,7 @@ pub(crate) mod dto { builder = builder.with_features(features); } - builder.finish_with_params(params) + builder.finish() } } } @@ -514,10 +503,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 93550da76a..0097d54dc4 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_min, verify_output_amount_packable, verify_output_amount_supply, Output, - OutputBuilderAmount, OutputId, Rent, RentStructure, StateTransitionError, StateTransitionVerifier, + verify_output_amount_min, verify_output_amount_packable, Output, OutputBuilderAmount, OutputId, Rent, + RentStructure, StateTransitionError, StateTransitionVerifier, }, protocol::ProtocolParameters, semantic::{SemanticValidationContext, TransactionFailureReason}, @@ -200,23 +200,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()?)) } } @@ -513,7 +499,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() } } @@ -555,7 +541,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 e39f8053f9..f979bc1a5d 100644 --- a/sdk/src/types/block/output/foundry.rs +++ b/sdk/src/types/block/output/foundry.rs @@ -21,9 +21,9 @@ use crate::types::{ unlock_condition::{ verify_allowed_unlock_conditions, UnlockCondition, UnlockConditionFlags, UnlockConditions, }, - verify_output_amount_min, verify_output_amount_packable, verify_output_amount_supply, ChainId, NativeToken, - NativeTokens, Output, OutputBuilderAmount, OutputId, Rent, RentStructure, StateTransitionError, - StateTransitionVerifier, TokenId, TokenScheme, + verify_output_amount_min, verify_output_amount_packable, ChainId, NativeToken, NativeTokens, Output, + OutputBuilderAmount, OutputId, Rent, RentStructure, StateTransitionError, StateTransitionVerifier, TokenId, + TokenScheme, }, payload::signed_transaction::{TransactionCapabilities, TransactionCapabilityFlag}, protocol::ProtocolParameters, @@ -296,23 +296,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()?)) } } @@ -754,7 +740,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() } } @@ -799,7 +785,7 @@ pub(crate) mod dto { builder = builder.with_immutable_features(immutable_features); } - builder.finish_with_params(params) + builder.finish() } } } @@ -851,10 +837,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 cf3621c937..74e285bba3 100644 --- a/sdk/src/types/block/output/mod.rs +++ b/sdk/src/types/block/output/mod.rs @@ -347,7 +347,7 @@ impl Output { /// byte cost, given by [`RentStructure`]. /// If there is a [`StorageDepositReturnUnlockCondition`](unlock_condition::StorageDepositReturnUnlockCondition), /// its amount is also checked. - pub fn verify_storage_deposit(&self, rent_structure: RentStructure, token_supply: u64) -> Result<(), Error> { + pub fn verify_storage_deposit(&self, rent_structure: RentStructure) -> Result<(), Error> { let required_output_amount = self.rent_cost(rent_structure); if self.amount() < required_output_amount { @@ -370,8 +370,7 @@ impl Output { }); } - let minimum_deposit = - minimum_storage_deposit(return_condition.return_address(), rent_structure, token_supply); + let minimum_deposit = minimum_storage_deposit(return_condition.return_address(), rent_structure); // `Minimum Storage Deposit` ≤ `Return Amount` if return_condition.amount() < minimum_deposit { @@ -476,12 +475,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, rent_structure: RentStructure, token_supply: u64) -> u64 { +fn minimum_storage_deposit(address: &Address, rent_structure: RentStructure) -> 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_storage_deposit(rent_structure) .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 3f5224a52f..28c32ff138 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_min, verify_output_amount_packable, verify_output_amount_supply, ChainId, NativeToken, - NativeTokens, Output, OutputBuilderAmount, OutputId, Rent, RentStructure, StateTransitionError, - StateTransitionVerifier, + verify_output_amount_min, verify_output_amount_packable, ChainId, NativeToken, NativeTokens, Output, + OutputBuilderAmount, OutputId, Rent, RentStructure, StateTransitionError, StateTransitionVerifier, }, payload::signed_transaction::TransactionCapabilityFlag, protocol::ProtocolParameters, @@ -257,20 +256,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()?)) } } @@ -607,7 +595,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() } } @@ -650,7 +638,7 @@ pub(crate) mod dto { builder = builder.with_immutable_features(immutable_features); } - builder.finish_with_params(params) + builder.finish() } } } @@ -711,7 +699,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/output/rent.rs b/sdk/src/types/block/output/rent.rs index a68346e76e..f3df1617ac 100644 --- a/sdk/src/types/block/output/rent.rs +++ b/sdk/src/types/block/output/rent.rs @@ -219,6 +219,6 @@ impl MinimumStorageDepositBasicOutput { } pub fn finish(self) -> Result { - Ok(self.builder.finish_output(self.token_supply)?.rent_cost(self.config)) + Ok(self.builder.finish_output()?.rent_cost(self.config)) } } diff --git a/sdk/src/types/block/payload/signed_transaction/transaction.rs b/sdk/src/types/block/payload/signed_transaction/transaction.rs index 8770ad47a7..e8b05e5565 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.rent_structure(), visitor.token_supply())?; + output.verify_storage_deposit(visitor.rent_structure())?; } } diff --git a/sdk/src/types/block/rand/output/mod.rs b/sdk/src/types/block/rand/output/mod.rs index f4d613f8ad..71f8a2a934 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(Output::AMOUNT_MIN..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(Output::AMOUNT_MIN..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() } @@ -107,7 +107,7 @@ pub fn rand_foundry_output(token_supply: u64) -> FoundryOutput { ) .with_features(rand_allowed_features(FoundryOutput::ALLOWED_FEATURES)) .add_unlock_condition(ImmutableAccountAddressUnlockCondition::new(rand_account_address())) - .finish_with_params(token_supply) + .finish() .unwrap() } @@ -119,7 +119,7 @@ pub fn rand_nft_output(token_supply: u64) -> NftOutput { NftOutput::build_with_amount(rand_number_range(Output::AMOUNT_MIN..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 3569f1981c..d594b63ba4 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/output_claiming.rs b/sdk/src/wallet/operations/output_claiming.rs index c36c37535a..b6db006558 100644 --- a/sdk/src/wallet/operations/output_claiming.rs +++ b/sdk/src/wallet/operations/output_claiming.rs @@ -278,7 +278,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_storage_deposit(rent_structure) @@ -286,7 +286,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 @@ -367,7 +367,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()?, ); } @@ -377,7 +377,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 4b9b318f20..9a9f69355c 100644 --- a/sdk/src/wallet/operations/transaction/high_level/create_account.rs +++ b/sdk/src/wallet/operations/transaction/high_level/create_account.rs @@ -75,7 +75,6 @@ where ) -> crate::wallet::Result { log::debug!("[TRANSACTION] prepare_create_account_output"); let rent_structure = self.client().get_rent_structure().await?; - let token_supply = self.client().get_token_supply().await?; let address = match params.as_ref().and_then(|options| options.address.as_ref()) { Some(bech32_address) => { @@ -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 9c08563832..93e2bb89f6 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 @@ -134,7 +134,6 @@ where ) -> crate::wallet::Result { log::debug!("[TRANSACTION] create_native_token"); let rent_structure = self.client().get_rent_structure().await?; - let token_supply = self.client().get_token_supply().await?; let (account_id, account_output) = self .get_account_output(params.account_id) @@ -156,7 +155,7 @@ 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_storage_deposit( rent_structure, @@ -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 acd9b6807b..c9c4400023 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 @@ -162,7 +162,6 @@ where { log::debug!("[TRANSACTION] prepare_mint_nfts"); let rent_structure = self.client().get_rent_structure().await?; - let token_supply = self.client().get_token_supply().await?; let wallet_address = self.address().await.into_inner(); let mut outputs = Vec::new(); @@ -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 dc055c1c06..235572f0e7 100644 --- a/sdk/src/wallet/operations/transaction/high_level/send.rs +++ b/sdk/src/wallet/operations/transaction/high_level/send.rs @@ -173,13 +173,13 @@ where // Get the minimum required amount for an output assuming it does not need a storage deposit. let output = BasicOutputBuilder::new_with_minimum_storage_deposit(rent_structure) .add_unlock_condition(AddressUnlockCondition::new(address)) - .finish_output(token_supply)?; + .finish_output()?; if amount >= output.amount() { outputs.push( BasicOutputBuilder::from(output.as_basic()) .with_amount(amount) - .finish_output(token_supply)?, + .finish_output()?, ) } else { let expiration_slot_index = expiration @@ -215,7 +215,7 @@ where )?, ) .add_unlock_condition(ExpirationUnlockCondition::new(return_address, expiration_slot_index)?) - .finish_output(token_supply)?, + .finish_output()?, ) } } 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 55ef81733a..bf02fd7797 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 @@ -196,7 +196,7 @@ where )?, ) .add_unlock_condition(ExpirationUnlockCondition::new(return_address, expiration_slot_index)?) - .finish_output(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 8d00c142de..b3d49d954a 100644 --- a/sdk/src/wallet/operations/transaction/mod.rs +++ b/sdk/src/wallet/operations/transaction/mod.rs @@ -73,7 +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.rent_structure(), protocol_parameters.token_supply())?; + output.verify_storage_deposit(protocol_parameters.rent_structure())?; } 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 3c0507d4c5..95c04aa37d 100644 --- a/sdk/src/wallet/operations/transaction/prepare_output.rs +++ b/sdk/src/wallet/operations/transaction/prepare_output.rs @@ -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 833657c311..0b1906eddf 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 rent_structure = self.client().get_rent_structure().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(rent_structure, token_supply)?; + output.verify_storage_deposit(rent_structure)?; } 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 f09ce99f55..5212407e81 100644 --- a/sdk/tests/client/input_selection/nft_outputs.rs +++ b/sdk/tests/client/input_selection/nft_outputs.rs @@ -1203,7 +1203,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 { @@ -1226,7 +1226,7 @@ fn changed_immutable_metadata() { let updated_nft_output = NftOutputBuilder::from(nft_output.as_nft()) .with_minimum_storage_deposit(protocol_parameters.rent_structure()) .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 a8cc3b34a2..2b6f7e84f0 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, Rent, SimpleTokenScheme, 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, Rent, SimpleTokenScheme, 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 d2dd05e845..24f81e4051 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, Rent, SimpleTokenScheme, 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, Rent, SimpleTokenScheme, 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_storage_deposit(protocol_parameters.rent_structure()) .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 03e6b364fe..66859d0da2 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_storage_deposit(protocol_parameters.rent_structure()) .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 f07ad91442..437ae9fcf0 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_storage_deposit(protocol_parameters.rent_structure()) .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 271737075f..bc0366cff0 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 rent_structure = wallet_0.client().get_rent_structure().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 rent_structure = wallet_0.client().get_rent_structure().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_storage_deposit(rent_structure) .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 38063b95db..314d3558fa 100644 --- a/sdk/tests/wallet/output_preparation.rs +++ b/sdk/tests/wallet/output_preparation.rs @@ -429,7 +429,6 @@ async fn output_preparation_sdr() -> Result<()> { request_funds(&wallet).await?; let rent_structure = wallet.client().get_rent_structure().await?; - let token_supply = wallet.client().get_token_supply().await?; let recipient_address_bech32 = String::from("rms1qpszqzadsym6wpppd6z037dvlejmjuke7s24hm95s9fg9vpua7vluaw60xu"); // Roundtrip to get the correct bech32 HRP @@ -450,7 +449,7 @@ async fn output_preparation_sdr() -> Result<()> { ) .await?; // Check if the output has enough amount to cover the storage deposit - output.verify_storage_deposit(rent_structure, token_supply)?; + output.verify_storage_deposit(rent_structure)?; assert_eq!(output.amount(), 50601); // address and sdr unlock condition assert_eq!(output.unlock_conditions().unwrap().len(), 2); @@ -471,7 +470,7 @@ async fn output_preparation_sdr() -> Result<()> { ) .await?; // Check if the output has enough amount to cover the storage deposit - output.verify_storage_deposit(rent_structure, token_supply)?; + output.verify_storage_deposit(rent_structure)?; assert_eq!(output.amount(), 85199); // address and sdr unlock condition assert_eq!(output.unlock_conditions().unwrap().len(), 2); @@ -496,7 +495,7 @@ async fn output_preparation_sdr() -> Result<()> { ) .await?; // Check if the output has enough amount to cover the storage deposit - output.verify_storage_deposit(rent_structure, token_supply)?; + output.verify_storage_deposit(rent_structure)?; assert_eq!(output.amount(), 85199); // address and sdr unlock condition assert_eq!(output.unlock_conditions().unwrap().len(), 2); @@ -521,7 +520,7 @@ async fn output_preparation_sdr() -> Result<()> { ) .await?; // Check if the output has enough amount to cover the storage deposit - output.verify_storage_deposit(rent_structure, token_supply)?; + output.verify_storage_deposit(rent_structure)?; // 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 @@ -655,7 +654,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(rent_structure, token_supply)?; + output.verify_storage_deposit(rent_structure)?; // 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 @@ -699,7 +698,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(rent_structure, token_supply)?; + output.verify_storage_deposit(rent_structure)?; // 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 @@ -723,7 +722,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(rent_structure, token_supply)?; + output.verify_storage_deposit(rent_structure)?; // 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