From e1b29b63f229ee95707b24e763255e04089f2d5f Mon Sep 17 00:00:00 2001 From: Thibault Martinez Date: Tue, 5 Dec 2023 13:09:29 +0100 Subject: [PATCH 1/2] Fix ISA for Restricted NFT/Account addresses --- .../api/block_builder/input_selection/mod.rs | 18 ++++++++++++------ .../client/input_selection/basic_outputs.rs | 2 +- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/sdk/src/client/api/block_builder/input_selection/mod.rs b/sdk/src/client/api/block_builder/input_selection/mod.rs index ba4ed047ab..67504bf51e 100644 --- a/sdk/src/client/api/block_builder/input_selection/mod.rs +++ b/sdk/src/client/api/block_builder/input_selection/mod.rs @@ -63,15 +63,16 @@ impl InputSelection { .output .required_and_unlocked_address(self.slot_index, input.output_id())? .0; + let required_address = if let Address::Restricted(restricted) = &required_address { + restricted.address() + } else { + &required_address + }; match required_address { - Address::Ed25519(_) => Ok(None), Address::Account(account_address) => Ok(Some(Requirement::Account(*account_address.account_id()))), Address::Nft(nft_address) => Ok(Some(Requirement::Nft(*nft_address.nft_id()))), - Address::Anchor(_) => Err(Error::UnsupportedAddressType(AnchorAddress::KIND)), - Address::ImplicitAccountCreation(_) => Ok(None), - Address::Restricted(_) => Ok(None), - _ => todo!("What do we do here?"), + _ => Ok(None), } } @@ -236,12 +237,17 @@ impl InputSelection { // PANIC: safe to unwrap as non basic/account/foundry/nft outputs are already filtered out. .unwrap() .0; + let required_address = if let Address::Restricted(restricted) = &required_address { + restricted.address() + } else { + &required_address + }; match required_address { + Address::Anchor(_) => false, Address::ImplicitAccountCreation(implicit_account_creation) => self .addresses .contains(&Address::from(*implicit_account_creation.ed25519_address())), - Address::Restricted(restricted) => self.addresses.contains(restricted.address()), _ => self.addresses.contains(&required_address), } }) diff --git a/sdk/tests/client/input_selection/basic_outputs.rs b/sdk/tests/client/input_selection/basic_outputs.rs index 10af45e799..4fac367de0 100644 --- a/sdk/tests/client/input_selection/basic_outputs.rs +++ b/sdk/tests/client/input_selection/basic_outputs.rs @@ -1853,7 +1853,7 @@ fn restricted_account() { let restricted = Address::from(RestrictedAddress::new(account_address.clone()).unwrap()); let inputs = build_inputs([ - Basic(2_000_000, restricted, None, None, None, None, None, None), + Basic(3_000_000, restricted, None, None, None, None, None, None), Account( 2_000_000, account_id_1, From eab86ba61a69e846ac1aa170304a6ee93ef49822 Mon Sep 17 00:00:00 2001 From: Thibault Martinez Date: Tue, 5 Dec 2023 13:13:51 +0100 Subject: [PATCH 2/2] Remove warning --- sdk/src/client/api/block_builder/input_selection/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/src/client/api/block_builder/input_selection/mod.rs b/sdk/src/client/api/block_builder/input_selection/mod.rs index 67504bf51e..dd4c60fd6f 100644 --- a/sdk/src/client/api/block_builder/input_selection/mod.rs +++ b/sdk/src/client/api/block_builder/input_selection/mod.rs @@ -19,7 +19,7 @@ pub use self::{burn::Burn, error::Error, requirement::Requirement}; use crate::{ client::{api::types::RemainderData, secret::types::InputSigningData}, types::block::{ - address::{AccountAddress, Address, AnchorAddress, NftAddress}, + address::{AccountAddress, Address, NftAddress}, input::INPUT_COUNT_RANGE, output::{ AccountOutput, ChainId, FoundryOutput, NativeTokensBuilder, NftOutput, Output, OutputId, OUTPUT_COUNT_RANGE,