From 14819c6ee00e38f6b5282073dde581b04a240e6d Mon Sep 17 00:00:00 2001 From: Thibault Martinez Date: Wed, 15 Nov 2023 09:22:01 +0100 Subject: [PATCH] Remove verify_output_amount_packable --- sdk/src/types/block/output/account.rs | 7 ++----- sdk/src/types/block/output/anchor.rs | 7 ++----- sdk/src/types/block/output/basic.rs | 7 +++---- sdk/src/types/block/output/delegation.rs | 5 ++--- sdk/src/types/block/output/foundry.rs | 7 ++----- sdk/src/types/block/output/mod.rs | 10 ---------- sdk/src/types/block/output/nft.rs | 7 ++----- 7 files changed, 13 insertions(+), 37 deletions(-) diff --git a/sdk/src/types/block/output/account.rs b/sdk/src/types/block/output/account.rs index 1a65c4f833..ddb2ec9501 100644 --- a/sdk/src/types/block/output/account.rs +++ b/sdk/src/types/block/output/account.rs @@ -16,9 +16,8 @@ use crate::types::block::{ output::{ feature::{verify_allowed_features, Feature, FeatureFlags, Features}, unlock_condition::{verify_allowed_unlock_conditions, UnlockCondition, UnlockConditionFlags, UnlockConditions}, - verify_output_amount_packable, ChainId, MinimumOutputAmount, NativeToken, NativeTokens, Output, - OutputBuilderAmount, OutputId, StateTransitionError, StateTransitionVerifier, StorageScore, - StorageScoreParameters, + ChainId, MinimumOutputAmount, NativeToken, NativeTokens, Output, OutputBuilderAmount, OutputId, + StateTransitionError, StateTransitionVerifier, StorageScore, StorageScoreParameters, }, payload::signed_transaction::TransactionCapabilityFlag, protocol::ProtocolParameters, @@ -555,8 +554,6 @@ impl Packable for AccountOutput { ) -> Result> { let amount = u64::unpack::<_, VERIFY>(unpacker, &()).coerce()?; - verify_output_amount_packable::(&amount, visitor).map_err(UnpackError::Packable)?; - let mana = u64::unpack::<_, VERIFY>(unpacker, &()).coerce()?; let native_tokens = NativeTokens::unpack::<_, VERIFY>(unpacker, &())?; diff --git a/sdk/src/types/block/output/anchor.rs b/sdk/src/types/block/output/anchor.rs index 3646ea4e32..60ae4bada5 100644 --- a/sdk/src/types/block/output/anchor.rs +++ b/sdk/src/types/block/output/anchor.rs @@ -18,9 +18,8 @@ use crate::types::block::{ output::{ feature::{verify_allowed_features, Feature, FeatureFlags, Features}, unlock_condition::{verify_allowed_unlock_conditions, UnlockCondition, UnlockConditionFlags, UnlockConditions}, - verify_output_amount_packable, ChainId, MinimumOutputAmount, NativeToken, NativeTokens, Output, - OutputBuilderAmount, OutputId, StateTransitionError, StateTransitionVerifier, StorageScore, - StorageScoreParameters, + ChainId, MinimumOutputAmount, NativeToken, NativeTokens, Output, OutputBuilderAmount, OutputId, + StateTransitionError, StateTransitionVerifier, StorageScore, StorageScoreParameters, }, payload::signed_transaction::TransactionCapabilityFlag, protocol::ProtocolParameters, @@ -622,8 +621,6 @@ impl Packable for AnchorOutput { ) -> Result> { let amount = u64::unpack::<_, VERIFY>(unpacker, &()).coerce()?; - verify_output_amount_packable::(&amount, visitor).map_err(UnpackError::Packable)?; - let mana = u64::unpack::<_, VERIFY>(unpacker, &()).coerce()?; let native_tokens = NativeTokens::unpack::<_, VERIFY>(unpacker, &())?; diff --git a/sdk/src/types/block/output/basic.rs b/sdk/src/types/block/output/basic.rs index 6290dbd9e4..4407b942d7 100644 --- a/sdk/src/types/block/output/basic.rs +++ b/sdk/src/types/block/output/basic.rs @@ -13,8 +13,8 @@ use crate::types::block::{ verify_allowed_unlock_conditions, AddressUnlockCondition, StorageDepositReturnUnlockCondition, UnlockCondition, UnlockConditionFlags, UnlockConditions, }, - verify_output_amount_packable, MinimumOutputAmount, NativeToken, NativeTokens, Output, OutputBuilderAmount, - OutputId, StorageScore, StorageScoreParameters, + MinimumOutputAmount, NativeToken, NativeTokens, Output, OutputBuilderAmount, OutputId, StorageScore, + StorageScoreParameters, }, protocol::ProtocolParameters, semantic::{SemanticValidationContext, TransactionFailureReason}, @@ -252,7 +252,6 @@ impl From<&BasicOutput> for BasicOutputBuilder { #[packable(unpack_visitor = ProtocolParameters)] pub struct BasicOutput { /// Amount of IOTA coins to deposit with this output. - #[packable(verify_with = verify_output_amount_packable)] amount: u64, /// Amount of stored Mana held by this output. mana: u64, @@ -261,8 +260,8 @@ pub struct BasicOutput { /// Define how the output can be unlocked in a transaction. #[packable(verify_with = verify_unlock_conditions_packable)] unlock_conditions: UnlockConditions, - #[packable(verify_with = verify_features_packable)] /// Features of the output. + #[packable(verify_with = verify_features_packable)] features: Features, } diff --git a/sdk/src/types/block/output/delegation.rs b/sdk/src/types/block/output/delegation.rs index ad3c765150..b4683aa063 100644 --- a/sdk/src/types/block/output/delegation.rs +++ b/sdk/src/types/block/output/delegation.rs @@ -10,8 +10,8 @@ use crate::types::block::{ output::{ chain_id::ChainId, unlock_condition::{verify_allowed_unlock_conditions, UnlockCondition, UnlockConditionFlags, UnlockConditions}, - verify_output_amount_packable, MinimumOutputAmount, Output, OutputBuilderAmount, OutputId, - StateTransitionError, StateTransitionVerifier, StorageScore, StorageScoreParameters, + MinimumOutputAmount, Output, OutputBuilderAmount, OutputId, StateTransitionError, StateTransitionVerifier, + StorageScore, StorageScoreParameters, }, protocol::ProtocolParameters, semantic::{SemanticValidationContext, TransactionFailureReason}, @@ -217,7 +217,6 @@ impl From<&DelegationOutput> for DelegationOutputBuilder { #[packable(unpack_visitor = ProtocolParameters)] pub struct DelegationOutput { /// Amount of IOTA coins to deposit with this output. - #[packable(verify_with = verify_output_amount_packable)] amount: u64, /// Amount of delegated IOTA coins. delegated_amount: u64, diff --git a/sdk/src/types/block/output/foundry.rs b/sdk/src/types/block/output/foundry.rs index da514eb580..cc4f9b59d9 100644 --- a/sdk/src/types/block/output/foundry.rs +++ b/sdk/src/types/block/output/foundry.rs @@ -18,9 +18,8 @@ use crate::types::block::{ account::AccountId, feature::{verify_allowed_features, Feature, FeatureFlags, Features}, unlock_condition::{verify_allowed_unlock_conditions, UnlockCondition, UnlockConditionFlags, UnlockConditions}, - verify_output_amount_packable, ChainId, MinimumOutputAmount, NativeToken, NativeTokens, Output, - OutputBuilderAmount, OutputId, StateTransitionError, StateTransitionVerifier, StorageScore, - StorageScoreParameters, TokenId, TokenScheme, + ChainId, MinimumOutputAmount, NativeToken, NativeTokens, Output, OutputBuilderAmount, OutputId, + StateTransitionError, StateTransitionVerifier, StorageScore, StorageScoreParameters, TokenId, TokenScheme, }, payload::signed_transaction::{TransactionCapabilities, TransactionCapabilityFlag}, protocol::ProtocolParameters, @@ -624,8 +623,6 @@ impl Packable for FoundryOutput { ) -> Result> { let amount = u64::unpack::<_, VERIFY>(unpacker, &()).coerce()?; - verify_output_amount_packable::(&amount, visitor).map_err(UnpackError::Packable)?; - let native_tokens = NativeTokens::unpack::<_, VERIFY>(unpacker, &())?; let serial_number = u32::unpack::<_, VERIFY>(unpacker, &()).coerce()?; let token_scheme = TokenScheme::unpack::<_, VERIFY>(unpacker, &())?; diff --git a/sdk/src/types/block/output/mod.rs b/sdk/src/types/block/output/mod.rs index a44416d268..53095f9ee5 100644 --- a/sdk/src/types/block/output/mod.rs +++ b/sdk/src/types/block/output/mod.rs @@ -460,16 +460,6 @@ pub(crate) fn verify_output_amount(amount: u64, token_supply: u64) -> Result<(), verify_output_amount_supply(amount, token_supply) } -pub(crate) fn verify_output_amount_packable( - amount: &u64, - protocol_parameters: &ProtocolParameters, -) -> Result<(), Error> { - if VERIFY { - verify_output_amount(*amount, protocol_parameters.token_supply())?; - } - Ok(()) -} - /// A trait that is shared by all output types, which is used to calculate the minimum amount the output /// must contain to satisfy its storage cost. pub trait MinimumOutputAmount: StorageScore { diff --git a/sdk/src/types/block/output/nft.rs b/sdk/src/types/block/output/nft.rs index 1a1656df4f..11b758d456 100644 --- a/sdk/src/types/block/output/nft.rs +++ b/sdk/src/types/block/output/nft.rs @@ -18,9 +18,8 @@ use crate::types::block::{ verify_allowed_unlock_conditions, AddressUnlockCondition, StorageDepositReturnUnlockCondition, UnlockCondition, UnlockConditionFlags, UnlockConditions, }, - verify_output_amount_packable, BasicOutputBuilder, ChainId, MinimumOutputAmount, NativeToken, NativeTokens, - Output, OutputBuilderAmount, OutputId, StateTransitionError, StateTransitionVerifier, StorageScore, - StorageScoreParameters, + BasicOutputBuilder, ChainId, MinimumOutputAmount, NativeToken, NativeTokens, Output, OutputBuilderAmount, + OutputId, StateTransitionError, StateTransitionVerifier, StorageScore, StorageScoreParameters, }, payload::signed_transaction::TransactionCapabilityFlag, protocol::ProtocolParameters, @@ -541,8 +540,6 @@ impl Packable for NftOutput { ) -> Result> { let amount = u64::unpack::<_, VERIFY>(unpacker, &()).coerce()?; - verify_output_amount_packable::(&amount, visitor).map_err(UnpackError::Packable)?; - let mana = u64::unpack::<_, VERIFY>(unpacker, &()).coerce()?; let native_tokens = NativeTokens::unpack::<_, VERIFY>(unpacker, &())?;