From c43c804ecd91dc873d1ea01d04bde59d59754efb Mon Sep 17 00:00:00 2001 From: Thoralf-M <46689931+Thoralf-M@users.noreply.github.com> Date: Wed, 28 Feb 2024 15:38:18 +0100 Subject: [PATCH] Add missing #[serde(with = "string")], clippy (#2088) Co-authored-by: Thibault Martinez --- sdk/src/client/api/block_builder/transaction.rs | 2 +- sdk/src/types/block/core/block.rs | 2 +- sdk/src/types/block/semantic/mod.rs | 4 +--- .../operations/transaction/high_level/delegation/create.rs | 2 ++ .../wallet/operations/transaction/high_level/staking/begin.rs | 3 +++ 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/sdk/src/client/api/block_builder/transaction.rs b/sdk/src/client/api/block_builder/transaction.rs index e886255f96..a0db364fd2 100644 --- a/sdk/src/client/api/block_builder/transaction.rs +++ b/sdk/src/client/api/block_builder/transaction.rs @@ -47,7 +47,7 @@ pub fn verify_semantic( protocol_parameters, ); - Ok(context.validate()?) + context.validate() } /// Verifies that the signed transaction payload doesn't exceed the block size limit with 8 parents. diff --git a/sdk/src/types/block/core/block.rs b/sdk/src/types/block/core/block.rs index 8d36326579..aca6943614 100644 --- a/sdk/src/types/block/core/block.rs +++ b/sdk/src/types/block/core/block.rs @@ -296,7 +296,7 @@ impl Packable for Block { }; if let Some(protocol_params) = protocol_params { - verify_block_slot(&block.header, &block.body, &protocol_params).map_err(UnpackError::Packable)?; + verify_block_slot(&block.header, &block.body, protocol_params).map_err(UnpackError::Packable)?; let block_len = if let (Some(start), Some(end)) = (start_opt, unpacker.read_bytes()) { end - start diff --git a/sdk/src/types/block/semantic/mod.rs b/sdk/src/types/block/semantic/mod.rs index 236e9efbf6..4bbf203458 100644 --- a/sdk/src/types/block/semantic/mod.rs +++ b/sdk/src/types/block/semantic/mod.rs @@ -261,9 +261,7 @@ impl<'a> SemanticValidationContext<'a> { return Err(TransactionFailureReason::SemanticValidationFailed); } - if let Err(conflict) = self.output_unlock(consumed_output, output_id, &unlocks[index]) { - return Err(conflict); - } + self.output_unlock(consumed_output, output_id, &unlocks[index])? } } diff --git a/sdk/src/wallet/operations/transaction/high_level/delegation/create.rs b/sdk/src/wallet/operations/transaction/high_level/delegation/create.rs index 46aa8eace6..e2b91ee592 100644 --- a/sdk/src/wallet/operations/transaction/high_level/delegation/create.rs +++ b/sdk/src/wallet/operations/transaction/high_level/delegation/create.rs @@ -9,6 +9,7 @@ use crate::{ address::{AccountAddress, Bech32Address}, output::{unlock_condition::AddressUnlockCondition, DelegationId, DelegationOutputBuilder}, }, + utils::serde::string, wallet::{operations::transaction::TransactionOptions, types::TransactionWithMetadata, Wallet}, }; @@ -21,6 +22,7 @@ pub struct CreateDelegationParams { // TODO: https://github.com/iotaledger/iota-sdk/issues/1888 pub address: Option, /// The amount to delegate. + #[serde(with = "string")] pub delegated_amount: u64, /// The Account Address of the validator to which this output will delegate. pub validator_address: AccountAddress, diff --git a/sdk/src/wallet/operations/transaction/high_level/staking/begin.rs b/sdk/src/wallet/operations/transaction/high_level/staking/begin.rs index e8f70dc5a0..1adbd1d2b3 100644 --- a/sdk/src/wallet/operations/transaction/high_level/staking/begin.rs +++ b/sdk/src/wallet/operations/transaction/high_level/staking/begin.rs @@ -9,6 +9,7 @@ use crate::{ output::{feature::StakingFeature, AccountId, AccountOutputBuilder}, slot::EpochIndex, }, + utils::serde::string, wallet::{types::TransactionWithMetadata, TransactionOptions, Wallet}, }; @@ -19,8 +20,10 @@ pub struct BeginStakingParams { /// The account id which will begin staking. pub account_id: AccountId, /// The amount of tokens to stake. + #[serde(with = "string")] pub staked_amount: u64, /// The fixed cost of the validator, which it receives as part of its Mana rewards. + #[serde(with = "string")] pub fixed_cost: u64, /// The staking period (in epochs). Will default to the staking unbonding period. pub staking_period: Option,