diff --git a/bindings/core/src/method_handler/secret_manager.rs b/bindings/core/src/method_handler/secret_manager.rs index 928a9ad795..3e3ac2ec34 100644 --- a/bindings/core/src/method_handler/secret_manager.rs +++ b/bindings/core/src/method_handler/secret_manager.rs @@ -124,13 +124,9 @@ where if let Some(secret_manager) = secret_manager.downcast::() { secret_manager.store_mnemonic(mnemonic).await?; Response::Ok - } else if let Some(secret_manager) = secret_manager.downcast::() { - if let SecretManager::Stronghold(secret_manager) = secret_manager { - secret_manager.store_mnemonic(mnemonic).await?; - Response::Ok - } else { - return Err(iota_sdk::client::Error::SecretManagerMismatch.into()); - } + } else if let Some(SecretManager::Stronghold(secret_manager)) = secret_manager.downcast::() { + secret_manager.store_mnemonic(mnemonic).await?; + Response::Ok } else { return Err(iota_sdk::client::Error::SecretManagerMismatch.into()); } diff --git a/cli/src/wallet_cli/mod.rs b/cli/src/wallet_cli/mod.rs index dba658b975..9a47485e53 100644 --- a/cli/src/wallet_cli/mod.rs +++ b/cli/src/wallet_cli/mod.rs @@ -954,7 +954,7 @@ async fn print_wallet_address(wallet: &Wallet) -> Result<(), Error> { if address.inner() == required_address { if let Some(nt) = output_data.output.native_token() { - native_tokens.add_native_token(nt.clone())?; + native_tokens.add_native_token(*nt)?; } match &output_data.output { Output::Basic(_) => {} diff --git a/sdk/examples/client/02_address_balance.rs b/sdk/examples/client/02_address_balance.rs index fc9cc522cd..edea187d1a 100644 --- a/sdk/examples/client/02_address_balance.rs +++ b/sdk/examples/client/02_address_balance.rs @@ -56,7 +56,7 @@ async fn main() -> Result<()> { let mut total_native_tokens = NativeTokensBuilder::new(); for output in outputs { if let Some(native_token) = output.native_token() { - total_native_tokens.add_native_token(native_token.clone())?; + total_native_tokens.add_native_token(*native_token)?; } total_amount += output.amount(); } diff --git a/sdk/src/client/api/block_builder/input_selection/mod.rs b/sdk/src/client/api/block_builder/input_selection/mod.rs index c8f8d742f5..e9efec2740 100644 --- a/sdk/src/client/api/block_builder/input_selection/mod.rs +++ b/sdk/src/client/api/block_builder/input_selection/mod.rs @@ -398,7 +398,7 @@ impl InputSelection { for input in &self.selected_inputs { if let Some(native_token) = input.output.native_token() { - input_native_tokens_builder.add_native_token(native_token.clone())?; + input_native_tokens_builder.add_native_token(*native_token)?; } match &input.output { Output::Account(_) => { @@ -417,7 +417,7 @@ impl InputSelection { for output in self.outputs.iter() { if let Some(native_token) = output.native_token() { - output_native_tokens_builder.add_native_token(native_token.clone())?; + output_native_tokens_builder.add_native_token(*native_token)?; } } diff --git a/sdk/src/client/api/block_builder/input_selection/requirement/native_tokens.rs b/sdk/src/client/api/block_builder/input_selection/requirement/native_tokens.rs index 02b2818cc8..e355d74dbd 100644 --- a/sdk/src/client/api/block_builder/input_selection/requirement/native_tokens.rs +++ b/sdk/src/client/api/block_builder/input_selection/requirement/native_tokens.rs @@ -15,8 +15,8 @@ pub(crate) fn get_native_tokens<'a>(outputs: impl Iterator) - let mut required_native_tokens = NativeTokensBuilder::new(); for output in outputs { - if let Some(output_native_token) = output.native_token() { - required_native_tokens.add_native_token(output_native_token.clone())?; + if let Some(native_token) = output.native_token() { + required_native_tokens.add_native_token(*native_token)?; } } diff --git a/sdk/src/types/block/output/feature/native_token.rs b/sdk/src/types/block/output/feature/native_token.rs index 7bb52a0275..52e298edff 100644 --- a/sdk/src/types/block/output/feature/native_token.rs +++ b/sdk/src/types/block/output/feature/native_token.rs @@ -46,7 +46,7 @@ mod dto { fn from(value: &NativeTokenFeature) -> Self { Self { kind: NativeTokenFeature::KIND, - token_id: value.token_id().clone(), + token_id: *value.token_id(), amount: value.amount(), } } diff --git a/sdk/src/types/block/rand/payload.rs b/sdk/src/types/block/rand/payload.rs index 9df77731e5..f016f21b16 100644 --- a/sdk/src/types/block/rand/payload.rs +++ b/sdk/src/types/block/rand/payload.rs @@ -10,7 +10,11 @@ use crate::types::block::{ pub fn rand_tagged_data_payload() -> TaggedDataPayload { TaggedDataPayload::new( rand_bytes(rand_number_range(TaggedDataPayload::TAG_LENGTH_RANGE).into()), - rand_bytes(rand_number_range(0..10000)), + rand_bytes( + rand_number_range(TaggedDataPayload::DATA_LENGTH_RANGE) + .try_into() + .unwrap(), + ), ) .unwrap() } diff --git a/sdk/src/wallet/operations/balance.rs b/sdk/src/wallet/operations/balance.rs index 374e74cc90..707c1d448e 100644 --- a/sdk/src/wallet/operations/balance.rs +++ b/sdk/src/wallet/operations/balance.rs @@ -88,7 +88,7 @@ where // Add native token if let Some(native_token) = output.native_token() { - total_native_tokens.add_native_token(native_token.clone())?; + total_native_tokens.add_native_token(*native_token)?; } balance.foundries.push(output.id()); @@ -125,7 +125,7 @@ where // Add native token if let Some(native_token) = output.native_token() { - total_native_tokens.add_native_token(native_token.clone())?; + total_native_tokens.add_native_token(*native_token)?; } } else { // if we have multiple unlock conditions for basic or nft outputs, then we can't @@ -199,7 +199,7 @@ where // Add native token if let Some(native_token) = output.native_token() { - total_native_tokens.add_native_token(native_token.clone())?; + total_native_tokens.add_native_token(*native_token)?; } } else { // only add outputs that can't be locked now and at any point in the future @@ -260,7 +260,7 @@ where if output_data.network_id == network_id { locked_amount += output_data.output.amount(); if let Some(native_token) = output_data.output.native_token() { - locked_native_tokens.add_native_token(native_token.clone())?; + locked_native_tokens.add_native_token(*native_token)?; } } } diff --git a/sdk/src/wallet/operations/output_claiming.rs b/sdk/src/wallet/operations/output_claiming.rs index 2db2b94d41..7d2af9e8e8 100644 --- a/sdk/src/wallet/operations/output_claiming.rs +++ b/sdk/src/wallet/operations/output_claiming.rs @@ -248,7 +248,7 @@ where // check native tokens for output_data in &outputs_to_claim { if let Some(native_token) = output_data.output.native_token() { - new_native_tokens.add_native_token(native_token.clone())?; + new_native_tokens.add_native_token(*native_token)?; } if let Some(sdr) = sdr_not_expired(&output_data.output, slot_index) { // for own output subtract the return amount @@ -333,7 +333,7 @@ where if available_amount < required_amount { if !additional_inputs_used.contains(&output_data.output_id) { if let Some(native_token) = output_data.output.native_token() { - new_native_tokens.add_native_token(native_token.clone())?; + new_native_tokens.add_native_token(*native_token)?; } available_amount += output_data.output.amount(); additional_inputs.push(output_data.output_id); diff --git a/sdk/src/wallet/operations/output_consolidation.rs b/sdk/src/wallet/operations/output_consolidation.rs index 1e8a3c8d97..51047cc692 100644 --- a/sdk/src/wallet/operations/output_consolidation.rs +++ b/sdk/src/wallet/operations/output_consolidation.rs @@ -232,7 +232,7 @@ where for output_data in outputs_to_consolidate.iter().take(max_inputs.into()) { if let Some(native_token) = output_data.output.native_token() { - total_native_tokens.add_native_token(native_token.clone())?; + total_native_tokens.add_native_token(*native_token)?; }; total_amount += output_data.output.amount(); diff --git a/sdk/src/wallet/operations/transaction/prepare_output.rs b/sdk/src/wallet/operations/transaction/prepare_output.rs index d34d8c1aa7..d47eaa764b 100644 --- a/sdk/src/wallet/operations/transaction/prepare_output.rs +++ b/sdk/src/wallet/operations/transaction/prepare_output.rs @@ -81,7 +81,7 @@ where } if let Some(native_token) = &features.native_token { - first_output_builder = first_output_builder.with_native_token(native_token.clone()); + first_output_builder = first_output_builder.with_native_token(*native_token); } }