Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove verify_output_amount_packable #1618

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions sdk/src/types/block/output/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -555,8 +554,6 @@ impl Packable for AccountOutput {
) -> Result<Self, UnpackError<Self::UnpackError, U::Error>> {
let amount = u64::unpack::<_, VERIFY>(unpacker, &()).coerce()?;

verify_output_amount_packable::<VERIFY>(&amount, visitor).map_err(UnpackError::Packable)?;

let mana = u64::unpack::<_, VERIFY>(unpacker, &()).coerce()?;

let native_tokens = NativeTokens::unpack::<_, VERIFY>(unpacker, &())?;
Expand Down
7 changes: 2 additions & 5 deletions sdk/src/types/block/output/anchor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -622,8 +621,6 @@ impl Packable for AnchorOutput {
) -> Result<Self, UnpackError<Self::UnpackError, U::Error>> {
let amount = u64::unpack::<_, VERIFY>(unpacker, &()).coerce()?;

verify_output_amount_packable::<VERIFY>(&amount, visitor).map_err(UnpackError::Packable)?;

let mana = u64::unpack::<_, VERIFY>(unpacker, &()).coerce()?;

let native_tokens = NativeTokens::unpack::<_, VERIFY>(unpacker, &())?;
Expand Down
7 changes: 3 additions & 4 deletions sdk/src/types/block/output/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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,
Expand All @@ -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,
}

Expand Down
5 changes: 2 additions & 3 deletions sdk/src/types/block/output/delegation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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,
Expand Down
7 changes: 2 additions & 5 deletions sdk/src/types/block/output/foundry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -624,8 +623,6 @@ impl Packable for FoundryOutput {
) -> Result<Self, UnpackError<Self::UnpackError, U::Error>> {
let amount = u64::unpack::<_, VERIFY>(unpacker, &()).coerce()?;

verify_output_amount_packable::<VERIFY>(&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, &())?;
Expand Down
10 changes: 0 additions & 10 deletions sdk/src/types/block/output/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<const VERIFY: bool>(
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 {
Expand Down
7 changes: 2 additions & 5 deletions sdk/src/types/block/output/nft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -541,8 +540,6 @@ impl Packable for NftOutput {
) -> Result<Self, UnpackError<Self::UnpackError, U::Error>> {
let amount = u64::unpack::<_, VERIFY>(unpacker, &()).coerce()?;

verify_output_amount_packable::<VERIFY>(&amount, visitor).map_err(UnpackError::Packable)?;

let mana = u64::unpack::<_, VERIFY>(unpacker, &()).coerce()?;

let native_tokens = NativeTokens::unpack::<_, VERIFY>(unpacker, &())?;
Expand Down
Loading