Skip to content

Commit

Permalink
Fix clippy warnings (#1646)
Browse files Browse the repository at this point in the history
* Fix clippy warnings

* Fix rand_tagged_data_payload test
  • Loading branch information
Thoralf-M authored Nov 20, 2023
1 parent 51d6e8e commit 543e065
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 23 deletions.
10 changes: 3 additions & 7 deletions bindings/core/src/method_handler/secret_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,9 @@ where
if let Some(secret_manager) = secret_manager.downcast::<StrongholdSecretManager>() {
secret_manager.store_mnemonic(mnemonic).await?;
Response::Ok
} else if let Some(secret_manager) = secret_manager.downcast::<SecretManager>() {
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::<SecretManager>() {
secret_manager.store_mnemonic(mnemonic).await?;
Response::Ok
} else {
return Err(iota_sdk::client::Error::SecretManagerMismatch.into());
}
Expand Down
2 changes: 1 addition & 1 deletion cli/src/wallet_cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(_) => {}
Expand Down
2 changes: 1 addition & 1 deletion sdk/examples/client/02_address_balance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
4 changes: 2 additions & 2 deletions sdk/src/client/api/block_builder/input_selection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(_) => {
Expand All @@ -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)?;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ pub(crate) fn get_native_tokens<'a>(outputs: impl Iterator<Item = &'a Output>) -
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)?;
}
}

Expand Down
2 changes: 1 addition & 1 deletion sdk/src/types/block/output/feature/native_token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}
}
Expand Down
6 changes: 5 additions & 1 deletion sdk/src/types/block/rand/payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
8 changes: 4 additions & 4 deletions sdk/src/wallet/operations/balance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)?;
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions sdk/src/wallet/operations/output_claiming.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/wallet/operations/output_consolidation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion sdk/src/wallet/operations/transaction/prepare_output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down

0 comments on commit 543e065

Please sign in to comment.