diff --git a/bindings/nodejs/lib/types/block/output/output.ts b/bindings/nodejs/lib/types/block/output/output.ts index 95bfdd45af..fb2fe10cb1 100644 --- a/bindings/nodejs/lib/types/block/output/output.ts +++ b/bindings/nodejs/lib/types/block/output/output.ts @@ -25,14 +25,14 @@ enum OutputType { Basic = 0, /** An Account output. */ Account = 1, + /** An Anchor output. */ + Anchor = 2, /** A Foundry output. */ - Foundry = 2, + Foundry = 3, /** An NFT output. */ - Nft = 3, + Nft = 4, /** A Delegation output. */ - Delegation = 4, - /** An Anchor output. */ - Anchor = 5, + Delegation = 5, } /** @@ -74,6 +74,8 @@ abstract class Output { return plainToInstance(BasicOutput, data) as any as BasicOutput; } else if (data.type == OutputType.Account) { return plainToInstance(AccountOutput, data) as any as AccountOutput; + } else if (data.type == OutputType.Anchor) { + return plainToInstance(AnchorOutput, data) as any as AnchorOutput; } else if (data.type == OutputType.Foundry) { return plainToInstance(FoundryOutput, data) as any as FoundryOutput; } else if (data.type == OutputType.Nft) { @@ -83,8 +85,6 @@ abstract class Output { DelegationOutput, data, ) as any as DelegationOutput; - } else if (data.type == OutputType.Anchor) { - return plainToInstance(AnchorOutput, data) as any as AnchorOutput; } throw new Error('Invalid JSON'); } @@ -144,6 +144,7 @@ abstract class CommonOutput extends Output { return this.nativeTokens; } } + /** * A Basic output. */ @@ -272,71 +273,73 @@ class AnchorOutput extends ImmutableFeaturesOutput { } /** - * An NFT output. + * A Foundry output. */ -class NftOutput extends ImmutableFeaturesOutput { +class FoundryOutput extends ImmutableFeaturesOutput { /** - * Unique identifier of the NFT, which is the BLAKE2b-256 hash of the Output ID that created it. - * Unless its newly minted, then the id is zeroed. + * The serial number of the Foundry with respect to the controlling alias. */ - readonly nftId: NftId; + readonly serialNumber: number; /** - * The amount of (stored) Mana held by the output. + * The token scheme for the Foundry. */ - readonly mana: u64; + @Type(() => TokenScheme, { + discriminator: TokenSchemeDiscriminator, + }) + readonly tokenScheme: TokenScheme; /** * @param amount The amount of the output. - * @param mana The amount of stored mana. - * @param nftId The NFT ID as hex-encoded string. + * @param serialNumber The serial number of the Foundry with respect to the controlling alias. * @param unlockConditions The unlock conditions of the output. + * @param tokenScheme The token scheme for the Foundry. */ constructor( amount: u64, - mana: u64, - nftId: NftId, + serialNumber: number, unlockConditions: UnlockCondition[], + tokenScheme: TokenScheme, ) { - super(OutputType.Nft, amount, unlockConditions); - this.nftId = nftId; - this.mana = mana; + super(OutputType.Foundry, amount, unlockConditions); + this.serialNumber = serialNumber; + this.tokenScheme = tokenScheme; } } + /** - * A Foundry output. + * An NFT output. */ -class FoundryOutput extends ImmutableFeaturesOutput { +class NftOutput extends ImmutableFeaturesOutput { /** - * The serial number of the Foundry with respect to the controlling alias. + * Unique identifier of the NFT, which is the BLAKE2b-256 hash of the Output ID that created it. + * Unless its newly minted, then the id is zeroed. */ - readonly serialNumber: number; + readonly nftId: NftId; /** - * The token scheme for the Foundry. + * The amount of (stored) Mana held by the output. */ - @Type(() => TokenScheme, { - discriminator: TokenSchemeDiscriminator, - }) - readonly tokenScheme: TokenScheme; + readonly mana: u64; /** * @param amount The amount of the output. - * @param serialNumber The serial number of the Foundry with respect to the controlling alias. + * @param mana The amount of stored mana. + * @param nftId The NFT ID as hex-encoded string. * @param unlockConditions The unlock conditions of the output. - * @param tokenScheme The token scheme for the Foundry. */ constructor( amount: u64, - serialNumber: number, + mana: u64, + nftId: NftId, unlockConditions: UnlockCondition[], - tokenScheme: TokenScheme, ) { - super(OutputType.Foundry, amount, unlockConditions); - this.serialNumber = serialNumber; - this.tokenScheme = tokenScheme; + super(OutputType.Nft, amount, unlockConditions); + this.nftId = nftId; + this.mana = mana; } } + /** * A Delegation output. */ @@ -402,8 +405,9 @@ const OutputDiscriminator = { subTypes: [ { value: BasicOutput, name: OutputType.Basic as any }, { value: AccountOutput, name: OutputType.Account as any }, - { value: NftOutput, name: OutputType.Nft as any }, + { value: AnchorOutput, name: OutputType.Anchor as any }, { value: FoundryOutput, name: OutputType.Foundry as any }, + { value: NftOutput, name: OutputType.Nft as any }, { value: DelegationOutput, name: OutputType.Delegation as any }, ], }; @@ -416,7 +420,7 @@ export { BasicOutput, AccountOutput, AnchorOutput, - NftOutput, FoundryOutput, + NftOutput, DelegationOutput, }; diff --git a/bindings/python/iota_sdk/types/output.py b/bindings/python/iota_sdk/types/output.py index 1208b47534..92769c780a 100644 --- a/bindings/python/iota_sdk/types/output.py +++ b/bindings/python/iota_sdk/types/output.py @@ -19,17 +19,18 @@ class OutputType(IntEnum): Attributes: Basic (0): A basic output. Account (1): An account output. - Foundry (2): A foundry output. - Nft (3): An NFT output. - Delegation (4): A delegation output. - Anchor (5): An anchor output. + Anchor (2): An anchor output. + Foundry (3): A foundry output. + Nft (4): An NFT output. + Delegation (5): A delegation output. + """ Basic = 0 Account = 1 - Foundry = 2 - Nft = 3 - Delegation = 4 - Anchor = 5 + Anchor = 2 + Foundry = 3 + Nft = 4 + Delegation = 5 @json @@ -304,8 +305,12 @@ class DelegationOutput: OutputType.Delegation), init=False) -Output: TypeAlias = Union[BasicOutput, AccountOutput, - FoundryOutput, NftOutput, DelegationOutput, AnchorOutput] +Output: TypeAlias = Union[BasicOutput, + AccountOutput, + AnchorOutput, + FoundryOutput, + NftOutput, + DelegationOutput] def deserialize_output(d: Dict[str, Any]) -> Output: @@ -320,14 +325,14 @@ def deserialize_output(d: Dict[str, Any]) -> Output: return BasicOutput.from_dict(d) if output_type == OutputType.Account: return AccountOutput.from_dict(d) + if output_type == OutputType.Anchor: + return AnchorOutput.from_dict(d) if output_type == OutputType.Foundry: return FoundryOutput.from_dict(d) if output_type == OutputType.Nft: return NftOutput.from_dict(d) if output_type == OutputType.Delegation: return DelegationOutput.from_dict(d) - if output_type == OutputType.Anchor: - return AnchorOutput.from_dict(d) raise Exception(f'invalid output type: {output_type}') diff --git a/sdk/src/client/api/block_builder/input_selection/requirement/amount.rs b/sdk/src/client/api/block_builder/input_selection/requirement/amount.rs index 65daa9618a..c3a4d097a9 100644 --- a/sdk/src/client/api/block_builder/input_selection/requirement/amount.rs +++ b/sdk/src/client/api/block_builder/input_selection/requirement/amount.rs @@ -250,10 +250,10 @@ impl InputSelection { Output::Account(output) => AccountOutputBuilder::from(&*output) .with_amount(new_amount) .finish_output(self.protocol_parameters.token_supply())?, - Output::Nft(output) => NftOutputBuilder::from(&*output) + Output::Foundry(output) => FoundryOutputBuilder::from(&*output) .with_amount(new_amount) .finish_output(self.protocol_parameters.token_supply())?, - Output::Foundry(output) => FoundryOutputBuilder::from(&*output) + Output::Nft(output) => NftOutputBuilder::from(&*output) .with_amount(new_amount) .finish_output(self.protocol_parameters.token_supply())?, _ => panic!("only account, nft and foundry can be automatically created"), diff --git a/sdk/src/client/api/block_builder/input_selection/requirement/mod.rs b/sdk/src/client/api/block_builder/input_selection/requirement/mod.rs index 599e713b22..9da2517062 100644 --- a/sdk/src/client/api/block_builder/input_selection/requirement/mod.rs +++ b/sdk/src/client/api/block_builder/input_selection/requirement/mod.rs @@ -78,18 +78,6 @@ impl InputSelection { is_created } - // Add an nft requirement if the nft output is transitioning and then required in the inputs. - Output::Nft(nft_output) => { - let is_created = nft_output.nft_id().is_null(); - - if !is_created { - let requirement = Requirement::Nft(*nft_output.nft_id()); - log::debug!("Adding {requirement:?} from output"); - self.requirements.push(requirement); - } - - is_created - } // Add a foundry requirement if the foundry output is transitioning and then required in the inputs. // Also add an account requirement since the associated account output needs to be transitioned. Output::Foundry(foundry_output) => { @@ -114,6 +102,18 @@ impl InputSelection { is_created } + // Add an nft requirement if the nft output is transitioning and then required in the inputs. + Output::Nft(nft_output) => { + let is_created = nft_output.nft_id().is_null(); + + if !is_created { + let requirement = Requirement::Nft(*nft_output.nft_id()); + log::debug!("Adding {requirement:?} from output"); + self.requirements.push(requirement); + } + + is_created + } _ => false, }; diff --git a/sdk/src/client/api/block_builder/input_selection/transition.rs b/sdk/src/client/api/block_builder/input_selection/transition.rs index 84213bb246..44141ff90c 100644 --- a/sdk/src/client/api/block_builder/input_selection/transition.rs +++ b/sdk/src/client/api/block_builder/input_selection/transition.rs @@ -152,8 +152,8 @@ impl InputSelection { pub(crate) fn transition_input(&mut self, input: &InputSigningData) -> Result, Error> { match &input.output { Output::Account(account_input) => self.transition_account_input(account_input, input.output_id()), - Output::Nft(nft_input) => self.transition_nft_input(nft_input, input.output_id()), Output::Foundry(foundry_input) => self.transition_foundry_input(foundry_input, input.output_id()), + Output::Nft(nft_input) => self.transition_nft_input(nft_input, input.output_id()), _ => Ok(None), } } diff --git a/sdk/src/types/block/output/anchor.rs b/sdk/src/types/block/output/anchor.rs index 21f363386f..c54fd11901 100644 --- a/sdk/src/types/block/output/anchor.rs +++ b/sdk/src/types/block/output/anchor.rs @@ -379,8 +379,7 @@ pub struct AnchorOutput { impl AnchorOutput { /// The [`Output`](crate::types::block::output::Output) kind of an [`AnchorOutput`]. - /// TODO - pub const KIND: u8 = 255; + pub const KIND: u8 = 2; /// Maximum possible length in bytes of the state metadata. pub const STATE_METADATA_LENGTH_MAX: u16 = 8192; /// The set of allowed [`UnlockCondition`]s for an [`AnchorOutput`]. diff --git a/sdk/src/types/block/output/delegation.rs b/sdk/src/types/block/output/delegation.rs index 0e40245870..8a90cff520 100644 --- a/sdk/src/types/block/output/delegation.rs +++ b/sdk/src/types/block/output/delegation.rs @@ -262,7 +262,7 @@ pub struct DelegationOutput { impl DelegationOutput { /// The [`Output`](crate::types::block::output::Output) kind of a [`DelegationOutput`]. - pub const KIND: u8 = 4; + pub const KIND: u8 = 5; /// The set of allowed [`UnlockCondition`]s for a [`DelegationOutput`]. pub const ALLOWED_UNLOCK_CONDITIONS: UnlockConditionFlags = UnlockConditionFlags::ADDRESS; diff --git a/sdk/src/types/block/output/foundry.rs b/sdk/src/types/block/output/foundry.rs index 56c2782e14..e39f8053f9 100644 --- a/sdk/src/types/block/output/foundry.rs +++ b/sdk/src/types/block/output/foundry.rs @@ -351,7 +351,7 @@ pub struct FoundryOutput { impl FoundryOutput { /// The [`Output`](crate::types::block::output::Output) kind of a [`FoundryOutput`]. - pub const KIND: u8 = 2; + pub const KIND: u8 = 3; /// The set of allowed [`UnlockCondition`]s for a [`FoundryOutput`]. pub const ALLOWED_UNLOCK_CONDITIONS: UnlockConditionFlags = UnlockConditionFlags::IMMUTABLE_ACCOUNT_ADDRESS; /// The set of allowed [`Feature`]s for a [`FoundryOutput`]. diff --git a/sdk/src/types/block/output/mod.rs b/sdk/src/types/block/output/mod.rs index 840819c7a2..38cb152b7c 100644 --- a/sdk/src/types/block/output/mod.rs +++ b/sdk/src/types/block/output/mod.rs @@ -132,10 +132,10 @@ impl core::fmt::Debug for Output { match self { Self::Basic(output) => output.fmt(f), Self::Account(output) => output.fmt(f), + Self::Anchor(output) => output.fmt(f), Self::Foundry(output) => output.fmt(f), Self::Nft(output) => output.fmt(f), Self::Delegation(output) => output.fmt(f), - Self::Anchor(output) => output.fmt(f), } } } @@ -149,10 +149,10 @@ impl Output { match self { Self::Basic(_) => BasicOutput::KIND, Self::Account(_) => AccountOutput::KIND, + Self::Anchor(_) => AnchorOutput::KIND, Self::Foundry(_) => FoundryOutput::KIND, Self::Nft(_) => NftOutput::KIND, Self::Delegation(_) => DelegationOutput::KIND, - Self::Anchor(_) => AnchorOutput::KIND, } } @@ -161,10 +161,10 @@ impl Output { match self { Self::Basic(_) => "Basic", Self::Account(_) => "Account", + Self::Anchor(_) => "Anchor", Self::Foundry(_) => "Foundry", Self::Nft(_) => "Nft", Self::Delegation(_) => "Delegation", - Self::Anchor(_) => "Anchor", } } @@ -173,10 +173,10 @@ impl Output { match self { Self::Basic(output) => output.amount(), Self::Account(output) => output.amount(), + Self::Anchor(output) => output.amount(), Self::Foundry(output) => output.amount(), Self::Nft(output) => output.amount(), Self::Delegation(output) => output.amount(), - Self::Anchor(output) => output.amount(), } } @@ -185,10 +185,10 @@ impl Output { match self { Self::Basic(output) => output.mana(), Self::Account(output) => output.mana(), + Self::Anchor(output) => output.mana(), Self::Foundry(_) => 0, Self::Nft(output) => output.mana(), Self::Delegation(_) => 0, - Self::Anchor(output) => output.mana(), } } @@ -197,10 +197,10 @@ impl Output { match self { Self::Basic(output) => Some(output.native_tokens()), Self::Account(output) => Some(output.native_tokens()), + Self::Anchor(output) => Some(output.native_tokens()), Self::Foundry(output) => Some(output.native_tokens()), Self::Nft(output) => Some(output.native_tokens()), Self::Delegation(_) => None, - Self::Anchor(output) => Some(output.native_tokens()), } } @@ -209,10 +209,10 @@ impl Output { match self { Self::Basic(output) => Some(output.unlock_conditions()), Self::Account(output) => Some(output.unlock_conditions()), + Self::Anchor(output) => Some(output.unlock_conditions()), Self::Foundry(output) => Some(output.unlock_conditions()), Self::Nft(output) => Some(output.unlock_conditions()), Self::Delegation(output) => Some(output.unlock_conditions()), - Self::Anchor(output) => Some(output.unlock_conditions()), } } @@ -221,10 +221,10 @@ impl Output { match self { Self::Basic(output) => Some(output.features()), Self::Account(output) => Some(output.features()), + Self::Anchor(output) => Some(output.features()), Self::Foundry(output) => Some(output.features()), Self::Nft(output) => Some(output.features()), Self::Delegation(_) => None, - Self::Anchor(output) => Some(output.features()), } } @@ -233,10 +233,10 @@ impl Output { match self { Self::Basic(_) => None, Self::Account(output) => Some(output.immutable_features()), + Self::Anchor(output) => Some(output.immutable_features()), Self::Foundry(output) => Some(output.immutable_features()), Self::Nft(output) => Some(output.immutable_features()), Self::Delegation(_) => None, - Self::Anchor(output) => Some(output.immutable_features()), } } @@ -245,10 +245,10 @@ impl Output { match self { Self::Basic(_) => None, Self::Account(output) => Some(output.chain_id()), + Self::Anchor(output) => Some(output.chain_id()), Self::Foundry(output) => Some(output.chain_id()), Self::Nft(output) => Some(output.chain_id()), Self::Delegation(_) => None, - Self::Anchor(output) => Some(output.chain_id()), } } @@ -277,6 +277,7 @@ impl Output { .clone(), Some(Address::Account(output.account_address(output_id))), )), + Self::Anchor(_) => Err(Error::UnsupportedOutputKind(AnchorOutput::KIND)), Self::Foundry(output) => Ok((Address::Account(*output.account_address()), None)), Self::Nft(output) => Ok(( output @@ -292,7 +293,6 @@ impl Output { .clone(), None, )), - Self::Anchor(_) => Err(Error::UnsupportedOutputKind(AnchorOutput::KIND)), } } @@ -391,6 +391,10 @@ impl Packable for Output { AccountOutput::KIND.pack(packer)?; output.pack(packer) } + Self::Anchor(output) => { + AnchorOutput::KIND.pack(packer)?; + output.pack(packer) + } Self::Foundry(output) => { FoundryOutput::KIND.pack(packer)?; output.pack(packer) @@ -403,10 +407,6 @@ impl Packable for Output { DelegationOutput::KIND.pack(packer)?; output.pack(packer) } - Self::Anchor(output) => { - AnchorOutput::KIND.pack(packer)?; - output.pack(packer) - } }?; Ok(()) @@ -419,10 +419,10 @@ impl Packable for Output { Ok(match u8::unpack::<_, VERIFY>(unpacker, &()).coerce()? { BasicOutput::KIND => Self::from(BasicOutput::unpack::<_, VERIFY>(unpacker, visitor).coerce()?), AccountOutput::KIND => Self::from(AccountOutput::unpack::<_, VERIFY>(unpacker, visitor).coerce()?), + AnchorOutput::KIND => Self::from(AnchorOutput::unpack::<_, VERIFY>(unpacker, visitor).coerce()?), FoundryOutput::KIND => Self::from(FoundryOutput::unpack::<_, VERIFY>(unpacker, visitor).coerce()?), NftOutput::KIND => Self::from(NftOutput::unpack::<_, VERIFY>(unpacker, visitor).coerce()?), DelegationOutput::KIND => Self::from(DelegationOutput::unpack::<_, VERIFY>(unpacker, visitor).coerce()?), - AnchorOutput::KIND => Self::from(AnchorOutput::unpack::<_, VERIFY>(unpacker, visitor).coerce()?), k => return Err(UnpackError::Packable(Error::InvalidOutputKind(k))), }) } @@ -496,10 +496,10 @@ pub mod dto { pub enum OutputDto { Basic(BasicOutputDto), Account(AccountOutputDto), + Anchor(AnchorOutputDto), Foundry(FoundryOutputDto), Nft(NftOutputDto), Delegation(DelegationOutputDto), - Anchor(AnchorOutputDto), } impl From<&Output> for OutputDto { @@ -507,10 +507,10 @@ pub mod dto { match value { Output::Basic(o) => Self::Basic(o.into()), Output::Account(o) => Self::Account(o.into()), + Output::Anchor(o) => Self::Anchor(o.into()), Output::Foundry(o) => Self::Foundry(o.into()), Output::Nft(o) => Self::Nft(o.into()), Output::Delegation(o) => Self::Delegation(o.into()), - Output::Anchor(o) => Self::Anchor(o.into()), } } } @@ -523,12 +523,12 @@ pub mod dto { Ok(match dto { OutputDto::Basic(o) => Self::Basic(BasicOutput::try_from_dto_with_params_inner(o, params)?), OutputDto::Account(o) => Self::Account(AccountOutput::try_from_dto_with_params_inner(o, params)?), + OutputDto::Anchor(o) => Self::Anchor(AnchorOutput::try_from_dto_with_params_inner(o, params)?), OutputDto::Foundry(o) => Self::Foundry(FoundryOutput::try_from_dto_with_params_inner(o, params)?), OutputDto::Nft(o) => Self::Nft(NftOutput::try_from_dto_with_params_inner(o, params)?), OutputDto::Delegation(o) => { Self::Delegation(DelegationOutput::try_from_dto_with_params_inner(o, params)?) } - OutputDto::Anchor(o) => Self::Anchor(AnchorOutput::try_from_dto_with_params_inner(o, params)?), }) } } @@ -550,6 +550,10 @@ pub mod dto { AccountOutputDto::deserialize(value) .map_err(|e| serde::de::Error::custom(format!("cannot deserialize account output: {e}")))?, ), + AnchorOutput::KIND => Self::Anchor( + AnchorOutputDto::deserialize(value) + .map_err(|e| serde::de::Error::custom(format!("cannot deserialize anchor output: {e}")))?, + ), FoundryOutput::KIND => Self::Foundry( FoundryOutputDto::deserialize(value) .map_err(|e| serde::de::Error::custom(format!("cannot deserialize foundry output: {e}")))?, @@ -563,10 +567,6 @@ pub mod dto { serde::de::Error::custom(format!("cannot deserialize delegation output: {e}")) })?) } - AnchorOutput::KIND => Self::Anchor( - AnchorOutputDto::deserialize(value) - .map_err(|e| serde::de::Error::custom(format!("cannot deserialize anchor output: {e}")))?, - ), _ => return Err(serde::de::Error::custom("invalid output type")), }, ) @@ -583,10 +583,10 @@ pub mod dto { enum OutputDto_<'a> { T0(&'a BasicOutputDto), T1(&'a AccountOutputDto), - T2(&'a FoundryOutputDto), - T3(&'a NftOutputDto), - T4(&'a DelegationOutputDto), - T5(&'a AnchorOutputDto), + T2(&'a AnchorOutputDto), + T3(&'a FoundryOutputDto), + T4(&'a NftOutputDto), + T5(&'a DelegationOutputDto), } #[derive(Serialize)] struct TypedOutput<'a> { @@ -600,16 +600,16 @@ pub mod dto { Self::Account(o) => TypedOutput { output: OutputDto_::T1(o), }, - Self::Foundry(o) => TypedOutput { + Self::Anchor(o) => TypedOutput { output: OutputDto_::T2(o), }, - Self::Nft(o) => TypedOutput { + Self::Foundry(o) => TypedOutput { output: OutputDto_::T3(o), }, - Self::Delegation(o) => TypedOutput { + Self::Nft(o) => TypedOutput { output: OutputDto_::T4(o), }, - Self::Anchor(o) => TypedOutput { + Self::Delegation(o) => TypedOutput { output: OutputDto_::T5(o), }, }; diff --git a/sdk/src/types/block/output/nft.rs b/sdk/src/types/block/output/nft.rs index 3b8b397888..3f5224a52f 100644 --- a/sdk/src/types/block/output/nft.rs +++ b/sdk/src/types/block/output/nft.rs @@ -309,7 +309,7 @@ pub struct NftOutput { impl NftOutput { /// The [`Output`](crate::types::block::output::Output) kind of an [`NftOutput`]. - pub const KIND: u8 = 3; + pub const KIND: u8 = 4; /// The set of allowed [`UnlockCondition`]s for an [`NftOutput`]. pub const ALLOWED_UNLOCK_CONDITIONS: UnlockConditionFlags = UnlockConditionFlags::ADDRESS .union(UnlockConditionFlags::STORAGE_DEPOSIT_RETURN) diff --git a/sdk/src/types/block/payload/signed_transaction/transaction.rs b/sdk/src/types/block/payload/signed_transaction/transaction.rs index a02b2e3629..ea8ced1379 100644 --- a/sdk/src/types/block/payload/signed_transaction/transaction.rs +++ b/sdk/src/types/block/payload/signed_transaction/transaction.rs @@ -432,10 +432,10 @@ fn verify_outputs(outputs: &[Output], visitor: &ProtocolPara let (amount, native_tokens, chain_id) = match output { Output::Basic(output) => (output.amount(), Some(output.native_tokens()), None), Output::Account(output) => (output.amount(), Some(output.native_tokens()), Some(output.chain_id())), + Output::Anchor(output) => (output.amount(), None, Some(output.chain_id())), Output::Foundry(output) => (output.amount(), Some(output.native_tokens()), Some(output.chain_id())), Output::Nft(output) => (output.amount(), Some(output.native_tokens()), Some(output.chain_id())), Output::Delegation(output) => (output.amount(), None, Some(output.chain_id())), - Output::Anchor(output) => (output.amount(), None, Some(output.chain_id())), }; amount_sum = amount_sum diff --git a/sdk/src/types/block/semantic.rs b/sdk/src/types/block/semantic.rs index 8edeacaebb..6359cee8e7 100644 --- a/sdk/src/types/block/semantic.rs +++ b/sdk/src/types/block/semantic.rs @@ -273,6 +273,7 @@ impl<'a> SemanticValidationContext<'a> { Some(output.native_tokens()), output.unlock_conditions(), ), + Output::Anchor(_) => return Err(Error::UnsupportedOutputKind(AnchorOutput::KIND)), Output::Foundry(output) => ( output.unlock(output_id, unlock, &mut self), output.amount(), @@ -294,7 +295,6 @@ impl<'a> SemanticValidationContext<'a> { None, output.unlock_conditions(), ), - Output::Anchor(_) => return Err(Error::UnsupportedOutputKind(AnchorOutput::KIND)), }; if let Err(conflict) = conflict { @@ -361,6 +361,7 @@ impl<'a> SemanticValidationContext<'a> { Some(output.native_tokens()), Some(output.features()), ), + Output::Anchor(_) => return Err(Error::UnsupportedOutputKind(AnchorOutput::KIND)), Output::Foundry(output) => ( output.amount(), 0, @@ -374,7 +375,6 @@ impl<'a> SemanticValidationContext<'a> { Some(output.features()), ), Output::Delegation(output) => (output.amount(), 0, None, None), - Output::Anchor(_) => return Err(Error::UnsupportedOutputKind(AnchorOutput::KIND)), }; if let Some(unlock_conditions) = created_output.unlock_conditions() { @@ -425,9 +425,9 @@ impl<'a> SemanticValidationContext<'a> { if match &created_output { Output::Account(_) => !address.has_capability(AddressCapabilityFlag::AccountOutputs), + Output::Anchor(_) => !address.has_capability(AddressCapabilityFlag::AnchorOutputs), Output::Nft(_) => !address.has_capability(AddressCapabilityFlag::NftOutputs), Output::Delegation(_) => !address.has_capability(AddressCapabilityFlag::DelegationOutputs), - Output::Anchor(_) => !address.has_capability(AddressCapabilityFlag::AnchorOutputs), _ => false, } { // TODO: add a variant https://github.com/iotaledger/iota-sdk/issues/1430