diff --git a/cli/src/cli.rs b/cli/src/cli.rs index f074dd77eb..44e1cbacad 100644 --- a/cli/src/cli.rs +++ b/cli/src/cli.rs @@ -64,7 +64,7 @@ pub struct InitParameters { #[arg(short, long, value_name = "URL", env = "NODE_URL", default_value = DEFAULT_NODE_URL)] pub node_url: String, /// Set the BIP path, `4219/0/0/0` if not provided. - #[arg(short, long, value_parser = parse_bip_path)] + #[arg(short, long, value_parser = parse_bip_path, default_value = "4219/0/0/0")] pub bip_path: Option, /// Set the Bech32-encoded wallet address. #[arg(short, long)] 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 ef13ae2fa1..dc5b8f27b1 100644 --- a/sdk/src/client/api/block_builder/input_selection/mod.rs +++ b/sdk/src/client/api/block_builder/input_selection/mod.rs @@ -155,6 +155,7 @@ impl InputSelection { available_inputs: impl Into>, outputs: impl Into>, addresses: impl IntoIterator, + slot_index: impl Into, protocol_parameters: ProtocolParameters, ) -> Self { let available_inputs = available_inputs.into(); @@ -189,9 +190,8 @@ impl InputSelection { burn: None, remainder_address: None, protocol_parameters, - // TODO may want to make this mandatory at some point // Should be set from a commitment context input - slot_index: SlotIndex::from(0), + slot_index: slot_index.into(), requirements: Vec::new(), automatically_transitioned: HashSet::new(), mana_allotments: 0, @@ -222,12 +222,6 @@ impl InputSelection { self } - /// Sets the slot index of an [`InputSelection`]. - pub fn with_slot_index(mut self, slot_index: impl Into) -> Self { - self.slot_index = slot_index.into(); - self - } - /// Sets the mana allotments sum of an [`InputSelection`]. pub fn with_mana_allotments<'a>(mut self, mana_allotments: impl Iterator) -> Self { self.mana_allotments = mana_allotments.map(ManaAllotment::mana).sum(); diff --git a/sdk/src/client/api/block_builder/input_selection/remainder.rs b/sdk/src/client/api/block_builder/input_selection/remainder.rs index 3f3c06adfb..e572fc1ad8 100644 --- a/sdk/src/client/api/block_builder/input_selection/remainder.rs +++ b/sdk/src/client/api/block_builder/input_selection/remainder.rs @@ -14,7 +14,11 @@ use crate::{ client::api::RemainderData, types::block::{ address::{Address, Ed25519Address}, - output::{unlock_condition::AddressUnlockCondition, BasicOutputBuilder, NativeTokensBuilder, Output}, + output::{ + unlock_condition::AddressUnlockCondition, AccountOutputBuilder, BasicOutputBuilder, NativeTokensBuilder, + NftOutputBuilder, Output, + }, + Error as BlockError, }, }; @@ -73,17 +77,18 @@ impl InputSelection { )))); // TODO https://github.com/iotaledger/iota-sdk/issues/1631 - // if let Some(native_tokens) = native_tokens_diff { - // remainder_builder = remainder_builder.with_native_tokens(native_tokens); - // } + // TODO Only putting one in remainder atm so we can at least create foundries + if let Some(native_tokens) = native_tokens_diff { + remainder_builder = remainder_builder.with_native_token(*native_tokens.first().unwrap()); + } Ok((remainder_builder.finish_output()?.amount(), native_tokens_remainder)) } pub(crate) fn remainder_and_storage_deposit_return_outputs( - &self, + &mut self, ) -> Result<(Option, Vec), Error> { - let (inputs_sum, outputs_sum, inputs_sdr, outputs_sdr) = + let (input_amount, output_amount, inputs_sdr, outputs_sdr) = amount_sums(&self.selected_inputs, &self.outputs, self.slot_index); let mut storage_deposit_returns = Vec::new(); @@ -118,30 +123,82 @@ impl InputSelection { let native_tokens_diff = get_native_tokens_diff(&input_native_tokens, &output_native_tokens)?; - if inputs_sum == outputs_sum && native_tokens_diff.is_none() { + let mut input_mana = 0; + + for input in &self.selected_inputs { + input_mana += input.output.available_mana( + &self.protocol_parameters, + input.output_id().transaction_id().slot_index(), + self.slot_index, + )?; + // TODO rewards https://github.com/iotaledger/iota-sdk/issues/1310 + } + + let output_mana = self.outputs.iter().map(|o| o.mana()).sum::() + self.mana_allotments; + + if input_amount == output_amount && input_mana == output_mana && native_tokens_diff.is_none() { log::debug!("No remainder required"); return Ok((None, storage_deposit_returns)); } + let amount_diff = input_amount + .checked_sub(output_amount) + .ok_or(BlockError::ConsumedAmountOverflow)?; + let mana_diff = input_mana + .checked_sub(output_mana) + .ok_or(BlockError::ConsumedManaOverflow)?; + + // If there is only a mana remainder, try to fit it in an automatically transitioned output. + if input_amount == output_amount && input_mana != output_mana && native_tokens_diff.is_none() { + let filter = |output: &Output| { + output + .chain_id() + .as_ref() + .map(|chain_id| self.automatically_transitioned.contains(chain_id)) + .unwrap_or(false) + // Foundries can't hold mana so they are not considered here. + && !output.is_foundry() + }; + let index = self + .outputs + .iter() + .position(|output| filter(output) && output.is_account()) + .or_else(|| self.outputs.iter().position(filter)); + + if let Some(index) = index { + self.outputs[index] = match &self.outputs[index] { + Output::Account(output) => AccountOutputBuilder::from(&*output) + .with_mana(output.mana() + mana_diff) + .finish_output()?, + Output::Nft(output) => NftOutputBuilder::from(&*output) + .with_mana(output.mana() + mana_diff) + .finish_output()?, + _ => panic!("only account, nft can be automatically created and can hold mana"), + }; + + return Ok((None, storage_deposit_returns)); + } + } + let Some((remainder_address, chain)) = self.get_remainder_address()? else { return Err(Error::MissingInputWithEd25519Address); }; - let diff = inputs_sum - outputs_sum; - let mut remainder_builder = BasicOutputBuilder::new_with_amount(diff); + let mut remainder_builder = BasicOutputBuilder::new_with_amount(amount_diff).with_mana(mana_diff); remainder_builder = remainder_builder.add_unlock_condition(AddressUnlockCondition::new(remainder_address.clone())); // TODO https://github.com/iotaledger/iota-sdk/issues/1631 - // if let Some(native_tokens) = native_tokens_diff { - // log::debug!("Adding {native_tokens:?} to remainder output for {remainder_address:?}"); - // remainder_builder = remainder_builder.with_native_tokens(native_tokens); - // } + // TODO Only putting one in remainder atm so we can at least create foundries + if let Some(native_tokens) = native_tokens_diff { + log::debug!("Adding {native_tokens:?} to remainder output for {remainder_address:?}"); + remainder_builder = remainder_builder.with_native_token(*native_tokens.first().unwrap()); + } let remainder = remainder_builder.finish_output()?; - log::debug!("Created remainder output of {diff} for {remainder_address:?}"); + log::debug!("Created remainder output of amount {amount_diff} and mana {mana_diff} for {remainder_address:?}"); remainder.verify_storage_deposit(self.protocol_parameters.storage_score_parameters())?; diff --git a/sdk/src/client/api/high_level.rs b/sdk/src/client/api/high_level.rs index 55a67e4194..da1b275537 100644 --- a/sdk/src/client/api/high_level.rs +++ b/sdk/src/client/api/high_level.rs @@ -111,23 +111,23 @@ impl Client { // Returns the slot index corresponding to the current timestamp. pub async fn get_slot_index(&self) -> Result { - let current_time = unix_timestamp_now().as_nanos() as u64; + let unix_timestamp = unix_timestamp_now(); + let current_time_nanos = unix_timestamp.as_nanos() as u64; let network_info = self.get_network_info().await?; if let Some(tangle_time) = network_info.tangle_time { // Check the local time is in the range of +-5 minutes of the node to prevent locking funds by accident if !(tangle_time - FIVE_MINUTES_IN_NANOSECONDS..tangle_time + FIVE_MINUTES_IN_NANOSECONDS) - .contains(¤t_time) + .contains(¤t_time_nanos) { return Err(Error::TimeNotSynced { - current_time, + current_time: current_time_nanos, tangle_time, }); } } - // TODO double check with TIP if this should be seconds or nanoseconds - Ok(network_info.protocol_parameters.slot_index(current_time)) + Ok(network_info.protocol_parameters.slot_index(unix_timestamp.as_secs())) } } diff --git a/sdk/src/types/block/output/mod.rs b/sdk/src/types/block/output/mod.rs index 196986c4bc..3faf18b62a 100644 --- a/sdk/src/types/block/output/mod.rs +++ b/sdk/src/types/block/output/mod.rs @@ -217,6 +217,33 @@ impl Output { } } + /// Returns all the mana held by the output, which is potential + stored, all decayed. + pub fn available_mana( + &self, + protocol_parameters: &ProtocolParameters, + creation_index: SlotIndex, + target_index: SlotIndex, + ) -> Result { + let (amount, mana) = match self { + Self::Basic(output) => (output.amount(), output.mana()), + Self::Account(output) => (output.amount(), output.mana()), + Self::Anchor(output) => (output.amount(), output.mana()), + Self::Foundry(output) => (output.amount(), 0), + Self::Nft(output) => (output.amount(), output.mana()), + Self::Delegation(output) => (output.amount(), 0), + }; + + let min_deposit = self.minimum_amount(protocol_parameters.storage_score_parameters()); + let generation_amount = amount.saturating_sub(min_deposit); + let potential_mana = + protocol_parameters.generate_mana_with_decay(generation_amount, creation_index, target_index)?; + let stored_mana = protocol_parameters.mana_with_decay(mana, creation_index, target_index)?; + + Ok(potential_mana + .checked_add(stored_mana) + .ok_or(Error::ConsumedManaOverflow)?) + } + /// Returns the unlock conditions of an [`Output`], if any. pub fn unlock_conditions(&self) -> Option<&UnlockConditions> { match self { diff --git a/sdk/src/types/block/payload/signed_transaction/transaction.rs b/sdk/src/types/block/payload/signed_transaction/transaction.rs index b97e42c954..d0ca90259e 100644 --- a/sdk/src/types/block/payload/signed_transaction/transaction.rs +++ b/sdk/src/types/block/payload/signed_transaction/transaction.rs @@ -61,8 +61,8 @@ impl TransactionBuilder { } /// Sets the context inputs of a [`TransactionBuilder`]. - pub fn with_context_inputs(mut self, context_inputs: impl Into>) -> Self { - self.context_inputs = context_inputs.into(); + pub fn with_context_inputs(mut self, context_inputs: impl IntoIterator) -> Self { + self.context_inputs = context_inputs.into_iter().collect(); self } @@ -164,6 +164,8 @@ impl TransactionBuilder { .try_into() .map_err(Error::InvalidContextInputCount)?; + verify_context_inputs(&context_inputs)?; + let inputs: BoxedSlicePrefix = self .inputs .into_boxed_slice() diff --git a/sdk/src/types/block/rand/output/mod.rs b/sdk/src/types/block/rand/output/mod.rs index 8dc8ad3231..604eec7e5f 100644 --- a/sdk/src/types/block/rand/output/mod.rs +++ b/sdk/src/types/block/rand/output/mod.rs @@ -35,13 +35,22 @@ use crate::types::block::{ rand_state_controller_address_unlock_condition_different_from, }, }, - transaction::rand_transaction_id, + transaction::rand_transaction_id_with_slot_index, }, + slot::SlotIndex, }; +/// Generates a random output id with a given slot index. +pub fn rand_output_id_with_slot_index(slot_index: impl Into) -> OutputId { + OutputId::new( + rand_transaction_id_with_slot_index(slot_index), + rand_number_range(OUTPUT_INDEX_RANGE), + ) +} + /// Generates a random [`OutputId`]. pub fn rand_output_id() -> OutputId { - OutputId::new(rand_transaction_id(), rand_number_range(OUTPUT_INDEX_RANGE)) + rand_output_id_with_slot_index(rand_number::()) } /// Generates a random [`BasicOutput`]. diff --git a/sdk/src/types/block/semantic/mod.rs b/sdk/src/types/block/semantic/mod.rs index 0c7a7e8c11..c6ce5aea43 100644 --- a/sdk/src/types/block/semantic/mod.rs +++ b/sdk/src/types/block/semantic/mod.rs @@ -16,9 +16,7 @@ pub use self::{ }; use crate::types::block::{ address::Address, - output::{ - AccountId, AnchorOutput, ChainId, FoundryId, MinimumOutputAmount, NativeTokens, Output, OutputId, TokenId, - }, + output::{AccountId, AnchorOutput, ChainId, FoundryId, NativeTokens, Output, OutputId, TokenId}, payload::signed_transaction::{Transaction, TransactionCapabilityFlag, TransactionSigningHash}, protocol::ProtocolParameters, unlock::Unlock, @@ -104,18 +102,13 @@ impl<'a> SemanticValidationContext<'a> { pub fn validate(mut self) -> Result, Error> { // Validation of inputs. for (index, (output_id, consumed_output)) in self.inputs.iter().enumerate() { - let (amount, mana, consumed_native_token, unlock_conditions) = match consumed_output { - Output::Basic(output) => ( - output.amount(), - output.mana(), - output.native_token(), - output.unlock_conditions(), - ), - Output::Account(output) => (output.amount(), output.mana(), None, output.unlock_conditions()), + let (amount, consumed_native_token, unlock_conditions) = match consumed_output { + Output::Basic(output) => (output.amount(), output.native_token(), output.unlock_conditions()), + Output::Account(output) => (output.amount(), None, output.unlock_conditions()), Output::Anchor(_) => return Err(Error::UnsupportedOutputKind(AnchorOutput::KIND)), - Output::Foundry(output) => (output.amount(), 0, output.native_token(), output.unlock_conditions()), - Output::Nft(output) => (output.amount(), output.mana(), None, output.unlock_conditions()), - Output::Delegation(output) => (output.amount(), 0, None, output.unlock_conditions()), + Output::Foundry(output) => (output.amount(), output.native_token(), output.unlock_conditions()), + Output::Nft(output) => (output.amount(), None, output.unlock_conditions()), + Output::Delegation(output) => (output.amount(), None, output.unlock_conditions()), }; let commitment_slot_index = self @@ -162,34 +155,13 @@ impl<'a> SemanticValidationContext<'a> { .checked_add(amount) .ok_or(Error::ConsumedAmountOverflow)?; - let potential_mana = { - // Deposit amount doesn't generate mana - let min_deposit = consumed_output.minimum_amount(self.protocol_parameters.storage_score_parameters()); - let generation_amount = consumed_output.amount().saturating_sub(min_deposit); - - self.protocol_parameters.generate_mana_with_decay( - generation_amount, - output_id.transaction_id().slot_index(), - self.transaction.creation_slot(), - ) - }?; - - // Add potential mana - self.input_mana = self - .input_mana - .checked_add(potential_mana) - .ok_or(Error::ConsumedManaOverflow)?; - - let stored_mana = self.protocol_parameters.mana_with_decay( - mana, - output_id.transaction_id().slot_index(), - self.transaction.creation_slot(), - )?; - - // Add stored mana self.input_mana = self .input_mana - .checked_add(stored_mana) + .checked_add(consumed_output.available_mana( + &self.protocol_parameters, + output_id.transaction_id().slot_index(), + self.transaction.creation_slot(), + )?) .ok_or(Error::ConsumedManaOverflow)?; // TODO: Add reward mana https://github.com/iotaledger/iota-sdk/issues/1310 diff --git a/sdk/src/wallet/operations/transaction/account.rs b/sdk/src/wallet/operations/transaction/account.rs index 81d64777a3..c95a826b17 100644 --- a/sdk/src/wallet/operations/transaction/account.rs +++ b/sdk/src/wallet/operations/transaction/account.rs @@ -51,18 +51,6 @@ where where crate::wallet::Error: From, { - let implicit_account_data = self.data().await.unspent_outputs.get(output_id).cloned(); - - let implicit_account = if let Some(implicit_account_data) = &implicit_account_data { - if implicit_account_data.output.is_implicit_account() { - implicit_account_data.output.as_basic() - } else { - return Err(Error::ImplicitAccountNotFound); - } - } else { - return Err(Error::ImplicitAccountNotFound); - }; - let key_source = match key_source.map(Into::into) { Some(key_source) => key_source, None => self.bip_path().await.ok_or(Error::MissingBipPath)?.into(), @@ -84,9 +72,24 @@ where } }; + let wallet_data = self.data().await; + let implicit_account_data = wallet_data + .unspent_outputs + .get(output_id) + .ok_or(Error::ImplicitAccountNotFound)?; + let implicit_account = if implicit_account_data.output.is_implicit_account() { + implicit_account_data.output.as_basic() + } else { + return Err(Error::ImplicitAccountNotFound); + }; + let account_id = AccountId::from(output_id); let account = AccountOutput::build_with_amount(implicit_account.amount(), account_id) - .with_mana(implicit_account.mana()) + .with_mana(implicit_account_data.output.available_mana( + &self.client().get_protocol_parameters().await?, + implicit_account_data.output_id.transaction_id().slot_index(), + self.client().get_slot_index().await?, + )?) .with_unlock_conditions([AddressUnlockCondition::from(Address::from( *implicit_account .address() @@ -99,6 +102,8 @@ where )?]) .finish_output()?; + drop(wallet_data); + // TODO https://github.com/iotaledger/iota-sdk/issues/1740 let issuance = self.client().get_issuance().await?; diff --git a/sdk/src/wallet/operations/transaction/build_transaction.rs b/sdk/src/wallet/operations/transaction/build_transaction.rs index 079ceb3f35..cff7dcd261 100644 --- a/sdk/src/wallet/operations/transaction/build_transaction.rs +++ b/sdk/src/wallet/operations/transaction/build_transaction.rs @@ -1,6 +1,8 @@ // Copyright 2021 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 +use std::collections::HashSet; + use instant::Instant; use crate::{ @@ -9,8 +11,10 @@ use crate::{ secret::{types::InputSigningData, SecretManage}, }, types::block::{ + context_input::{BlockIssuanceCreditContextInput, ContextInput}, input::{Input, UtxoInput}, - payload::signed_transaction::{Transaction, TransactionCapabilities, TransactionCapabilityFlag}, + output::Output, + payload::signed_transaction::Transaction, }, wallet::{operations::transaction::TransactionOptions, Wallet}, }; @@ -32,11 +36,20 @@ where let mut inputs: Vec = Vec::new(); let mut inputs_for_signing: Vec = Vec::new(); + let mut context_inputs = HashSet::new(); + + for input in &selected_transaction_data.inputs { + // Transitioning an issuer account requires a BlockIssuanceCreditContextInput. + if let Output::Account(account) = &input.output { + if account.features().block_issuer().is_some() { + context_inputs.insert(ContextInput::from(BlockIssuanceCreditContextInput::from( + account.account_id_non_null(input.output_id()), + ))); + } + } - for utxo in &selected_transaction_data.inputs { - let input = Input::Utxo(UtxoInput::from(*utxo.output_id())); - inputs.push(input.clone()); - inputs_for_signing.push(utxo.clone()); + inputs.push(Input::Utxo(UtxoInput::from(*input.output_id()))); + inputs_for_signing.push(input.clone()); } // Build transaction @@ -46,24 +59,12 @@ where .with_inputs(inputs) .with_outputs(selected_transaction_data.outputs); - if let Some(mut options) = options.into() { + if let Some(options) = options.into() { // Optional add a tagged payload builder = builder.with_payload(options.tagged_data_payload); - if let Some(context_inputs) = options.context_inputs { - builder = builder.with_context_inputs(context_inputs); - } - - // TODO remove when https://github.com/iotaledger/iota-sdk/issues/1744 is done - match options.capabilities.as_mut() { - Some(capabilities) => { - capabilities.add_capability(TransactionCapabilityFlag::BurnMana); - } - None => { - let mut capabilities = TransactionCapabilities::default(); - capabilities.add_capability(TransactionCapabilityFlag::BurnMana); - options.capabilities = Some(capabilities); - } + if let Some(context_inputs_opt) = options.context_inputs { + context_inputs.extend(context_inputs_opt); } if let Some(capabilities) = options.capabilities { @@ -75,7 +76,9 @@ where } } - let transaction = builder.finish_with_params(&protocol_parameters)?; + let transaction = builder + .with_context_inputs(context_inputs) + .finish_with_params(&protocol_parameters)?; validate_transaction_length(&transaction)?; diff --git a/sdk/src/wallet/operations/transaction/input_selection.rs b/sdk/src/wallet/operations/transaction/input_selection.rs index 0460ad4f4f..9b06159ed9 100644 --- a/sdk/src/wallet/operations/transaction/input_selection.rs +++ b/sdk/src/wallet/operations/transaction/input_selection.rs @@ -94,6 +94,7 @@ where available_outputs_signing_data, outputs, Some(wallet_data.address.clone().into_inner()), + slot_index, protocol_parameters.clone(), ) .with_required_inputs(custom_inputs) @@ -133,6 +134,7 @@ where available_outputs_signing_data, outputs, Some(wallet_data.address.clone().into_inner()), + slot_index, protocol_parameters.clone(), ) .with_required_inputs(mandatory_inputs) @@ -169,6 +171,7 @@ where available_outputs_signing_data, outputs, Some(wallet_data.address.clone().into_inner()), + slot_index, protocol_parameters.clone(), ) .with_forbidden_inputs(forbidden_inputs); diff --git a/sdk/tests/client/input_selection/account_outputs.rs b/sdk/tests/client/input_selection/account_outputs.rs index ade83ef47a..d798619e03 100644 --- a/sdk/tests/client/input_selection/account_outputs.rs +++ b/sdk/tests/client/input_selection/account_outputs.rs @@ -17,7 +17,7 @@ use crate::client::{ build_inputs, build_outputs, is_remainder_or_return, unsorted_eq, Build::{Account, Basic}, ACCOUNT_ID_0, ACCOUNT_ID_1, ACCOUNT_ID_2, BECH32_ADDRESS_ACCOUNT_1, BECH32_ADDRESS_ED25519_0, - BECH32_ADDRESS_ED25519_1, BECH32_ADDRESS_NFT_1, + BECH32_ADDRESS_ED25519_1, BECH32_ADDRESS_NFT_1, SLOT_INDEX, }; #[test] @@ -34,7 +34,7 @@ fn input_account_eq_output_account() { None, None, )], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Account( 1_000_000, @@ -49,6 +49,7 @@ fn input_account_eq_output_account() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select() @@ -72,7 +73,7 @@ fn transition_account_id_zero() { None, None, )], - None, + Some(SLOT_INDEX), ); let account_id = AccountId::from(inputs[0].output_id()); let outputs = build_outputs([Account( @@ -88,6 +89,7 @@ fn transition_account_id_zero() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select() @@ -128,7 +130,7 @@ fn transition_account_id_zero() { // inputs, // outputs, // [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], -// protocol_parameters, +// SLOT_INDEX+1, protocol_parameters, // ) // .select(); @@ -176,7 +178,7 @@ fn transition_account_id_zero() { // inputs, // outputs, // [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], -// protocol_parameters, +// SLOT_INDEX+1, protocol_parameters, // ) // .select(); @@ -221,7 +223,7 @@ fn transition_account_id_zero() { // inputs.clone(), // outputs, // [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], -// protocol_parameters, +// SLOT_INDEX+1, protocol_parameters, // ) // .select() // .unwrap(); @@ -247,7 +249,7 @@ fn create_account() { None, None, )], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Account( 1_000_000, @@ -262,6 +264,7 @@ fn create_account() { inputs.clone(), outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select() @@ -294,7 +297,7 @@ fn burn_account() { None, None, )], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 2_000_000, @@ -311,6 +314,7 @@ fn burn_account() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .with_burn(Burn::new().add_account(account_id_2)) @@ -353,7 +357,7 @@ fn burn_account() { // inputs, // outputs, // [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], -// protocol_parameters, +// SLOT_INDEX+1, protocol_parameters, // ) // .select(); @@ -397,6 +401,7 @@ fn missing_input_for_account_output() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select(); @@ -449,6 +454,7 @@ fn missing_input_for_account_output_2() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select(); @@ -475,7 +481,7 @@ fn missing_input_for_account_output_but_created() { None, None, )], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Account( 1_000_000, @@ -490,6 +496,7 @@ fn missing_input_for_account_output_but_created() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select(); @@ -523,7 +530,7 @@ fn account_in_output_and_sender() { None, ), ], - None, + Some(SLOT_INDEX), ); let account_output = AccountOutputBuilder::from(inputs[0].output.as_account()) .finish_output() @@ -544,6 +551,7 @@ fn account_in_output_and_sender() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select() @@ -582,6 +590,7 @@ fn missing_ed25519_sender() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select(); @@ -623,6 +632,7 @@ fn missing_ed25519_issuer_created() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select(); @@ -647,7 +657,7 @@ fn missing_ed25519_issuer_transition() { Some(Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()), None, )], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Account( 1_000_000, @@ -662,6 +672,7 @@ fn missing_ed25519_issuer_transition() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select(); @@ -698,6 +709,7 @@ fn missing_account_sender() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select(); @@ -739,6 +751,7 @@ fn missing_account_issuer_created() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select(); @@ -763,7 +776,7 @@ fn missing_account_issuer_transition() { Some(Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap()), None, )], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Account( 1_000_000, @@ -778,6 +791,7 @@ fn missing_account_issuer_transition() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select(); @@ -814,6 +828,7 @@ fn missing_nft_sender() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select(); @@ -855,6 +870,7 @@ fn missing_nft_issuer_created() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select(); @@ -879,7 +895,7 @@ fn missing_nft_issuer_transition() { Some(Address::try_from_bech32(BECH32_ADDRESS_NFT_1).unwrap()), None, )], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Account( 1_000_000, @@ -894,6 +910,7 @@ fn missing_nft_issuer_transition() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select(); @@ -927,7 +944,7 @@ fn increase_account_amount() { None, ), ], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Account( 3_000_000, @@ -942,6 +959,7 @@ fn increase_account_amount() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select() @@ -977,7 +995,7 @@ fn decrease_account_amount() { None, ), ], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Account( 1_000_000, @@ -992,6 +1010,7 @@ fn decrease_account_amount() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select() @@ -1039,7 +1058,7 @@ fn prefer_basic_to_account() { None, ), ], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 1_000_000, @@ -1056,6 +1075,7 @@ fn prefer_basic_to_account() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select() @@ -1092,7 +1112,7 @@ fn take_amount_from_account_to_fund_basic() { None, ), ], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 1_200_000, @@ -1109,6 +1129,7 @@ fn take_amount_from_account_to_fund_basic() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select() @@ -1159,7 +1180,7 @@ fn account_burn_should_validate_account_sender() { None, ), ], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 2_000_000, @@ -1176,6 +1197,7 @@ fn account_burn_should_validate_account_sender() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .with_burn(Burn::new().add_account(account_id_1)) @@ -1224,7 +1246,7 @@ fn account_burn_should_validate_account_address() { None, ), ], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 2_000_000, @@ -1241,6 +1263,7 @@ fn account_burn_should_validate_account_address() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .with_burn(Burn::new().add_account(account_id_1)) @@ -1277,7 +1300,7 @@ fn transitioned_zero_account_id_no_longer_is_zero() { None, None, )], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 1_000_000, @@ -1294,6 +1317,7 @@ fn transitioned_zero_account_id_no_longer_is_zero() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select() @@ -1343,7 +1367,7 @@ fn two_accounts_required() { None, ), ], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 3_000_000, @@ -1360,6 +1384,7 @@ fn two_accounts_required() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select() @@ -1404,7 +1429,7 @@ fn state_controller_sender_required() { None, None, )], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 1_000_000, @@ -1421,6 +1446,7 @@ fn state_controller_sender_required() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select() @@ -1445,7 +1471,7 @@ fn state_controller_sender_required_already_selected() { None, None, )], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([ Account( @@ -1472,6 +1498,7 @@ fn state_controller_sender_required_already_selected() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .with_required_inputs([*inputs[0].output_id()]) @@ -1496,7 +1523,7 @@ fn state_transition_and_required() { None, None, )], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Account( 2_000_000, @@ -1511,6 +1538,7 @@ fn state_transition_and_required() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .with_required_inputs([*inputs[0].output_id()]) @@ -1535,7 +1563,7 @@ fn remainder_address_in_state_controller() { None, None, )], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Account( 1_000_000, @@ -1550,6 +1578,7 @@ fn remainder_address_in_state_controller() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select() diff --git a/sdk/tests/client/input_selection/basic_outputs.rs b/sdk/tests/client/input_selection/basic_outputs.rs index f20d862c8b..5689848353 100644 --- a/sdk/tests/client/input_selection/basic_outputs.rs +++ b/sdk/tests/client/input_selection/basic_outputs.rs @@ -17,7 +17,7 @@ use crate::client::{ build_inputs, build_outputs, is_remainder_or_return, unsorted_eq, Build::{Account, Basic, Nft}, ACCOUNT_ID_0, ACCOUNT_ID_1, BECH32_ADDRESS_ACCOUNT_1, BECH32_ADDRESS_ED25519_0, BECH32_ADDRESS_ED25519_1, - BECH32_ADDRESS_ED25519_2, BECH32_ADDRESS_NFT_1, BECH32_ADDRESS_REMAINDER, NFT_ID_0, NFT_ID_1, + BECH32_ADDRESS_ED25519_2, BECH32_ADDRESS_NFT_1, BECH32_ADDRESS_REMAINDER, NFT_ID_0, NFT_ID_1, SLOT_INDEX, }; #[test] @@ -35,7 +35,7 @@ fn input_amount_equal_output_amount() { None, None, )], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 1_000_000, @@ -52,6 +52,7 @@ fn input_amount_equal_output_amount() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select() @@ -76,7 +77,7 @@ fn input_amount_lower_than_output_amount() { None, None, )], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 2_000_000, @@ -93,6 +94,7 @@ fn input_amount_lower_than_output_amount() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select(); @@ -133,7 +135,7 @@ fn input_amount_lower_than_output_amount_2() { None, ), ], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 3_500_000, @@ -150,6 +152,7 @@ fn input_amount_lower_than_output_amount_2() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select(); @@ -178,7 +181,7 @@ fn input_amount_greater_than_output_amount() { None, None, )], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 500_000, @@ -195,6 +198,7 @@ fn input_amount_greater_than_output_amount() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select() @@ -232,7 +236,7 @@ fn input_amount_greater_than_output_amount_with_remainder_address() { None, None, )], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 500_000, @@ -249,6 +253,7 @@ fn input_amount_greater_than_output_amount_with_remainder_address() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .with_remainder_address(remainder_address) @@ -298,7 +303,7 @@ fn two_same_inputs_one_needed() { None, ), ], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 500_000, @@ -315,6 +320,7 @@ fn two_same_inputs_one_needed() { inputs, outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select() @@ -364,7 +370,7 @@ fn two_inputs_one_needed() { None, ), ], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 1_000_000, @@ -381,6 +387,7 @@ fn two_inputs_one_needed() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select() @@ -417,7 +424,7 @@ fn two_inputs_one_needed_reversed() { None, ), ], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 1_000_000, @@ -434,6 +441,7 @@ fn two_inputs_one_needed_reversed() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select() @@ -470,7 +478,7 @@ fn two_inputs_both_needed() { None, ), ], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 3_000_000, @@ -487,6 +495,7 @@ fn two_inputs_both_needed() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select() @@ -523,7 +532,7 @@ fn two_inputs_remainder() { None, ), ], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 2_500_000, @@ -540,6 +549,7 @@ fn two_inputs_remainder() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select() @@ -590,7 +600,7 @@ fn two_inputs_remainder() { // inputs, // outputs, // [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], -// protocol_parameters, +// SLOT_INDEX+1,protocol_parameters, // ) // .select(); @@ -661,7 +671,7 @@ fn ed25519_sender() { None, ), ], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 2_000_000, @@ -681,6 +691,7 @@ fn ed25519_sender() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), ], + SLOT_INDEX, protocol_parameters, ) .select() @@ -713,7 +724,7 @@ fn missing_ed25519_sender() { None, None, )], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 1_000_000, @@ -730,6 +741,7 @@ fn missing_ed25519_sender() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select(); @@ -796,7 +808,7 @@ fn account_sender() { None, ), ], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 2_000_000, @@ -813,6 +825,7 @@ fn account_sender() { inputs, outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select() @@ -857,7 +870,7 @@ fn account_sender_zero_id() { None, ), ], - None, + Some(SLOT_INDEX), ); let account_id = AccountId::from(inputs[1].output_id()); let outputs = build_outputs([Basic( @@ -875,6 +888,7 @@ fn account_sender_zero_id() { inputs.clone(), outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select() @@ -905,7 +919,7 @@ fn missing_account_sender() { None, None, )], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 1_000_000, @@ -922,6 +936,7 @@ fn missing_account_sender() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select(); @@ -990,7 +1005,7 @@ fn nft_sender() { None, ), ], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 2_000_000, @@ -1007,6 +1022,7 @@ fn nft_sender() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select() @@ -1054,7 +1070,7 @@ fn nft_sender_zero_id() { None, ), ], - None, + Some(SLOT_INDEX), ); let nft_id = NftId::from(inputs[1].output_id()); let outputs = build_outputs([Basic( @@ -1072,6 +1088,7 @@ fn nft_sender_zero_id() { inputs.clone(), outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select() @@ -1102,7 +1119,7 @@ fn missing_nft_sender() { None, None, )], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 1_000_000, @@ -1119,6 +1136,7 @@ fn missing_nft_sender() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select(); @@ -1144,7 +1162,7 @@ fn simple_remainder() { None, None, )], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 500_000, @@ -1161,6 +1179,7 @@ fn simple_remainder() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select() @@ -1210,7 +1229,7 @@ fn simple_remainder() { // inputs, // outputs, // [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], -// protocol_parameters, +// SLOT_INDEX+1,protocol_parameters, // ) // .select(); @@ -1248,7 +1267,7 @@ fn simple_remainder() { // inputs, // outputs, // [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], -// protocol_parameters, +// SLOT_INDEX+1,protocol_parameters, // ) // .select(); @@ -1276,7 +1295,7 @@ fn one_provided_one_needed() { None, None, )], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 1_000_000, @@ -1293,6 +1312,7 @@ fn one_provided_one_needed() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select() @@ -1317,7 +1337,7 @@ fn insufficient_amount() { None, None, )], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 1_250_000, @@ -1334,6 +1354,7 @@ fn insufficient_amount() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select(); @@ -1374,7 +1395,7 @@ fn two_inputs_remainder_2() { None, ), ], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 500_000, @@ -1391,6 +1412,7 @@ fn two_inputs_remainder_2() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select() @@ -1439,7 +1461,7 @@ fn two_inputs_remainder_3() { None, ), ], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 1_750_000, @@ -1456,6 +1478,7 @@ fn two_inputs_remainder_3() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select() @@ -1501,7 +1524,7 @@ fn two_inputs_remainder_3() { // inputs.clone(), // outputs.clone(), // [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], -// protocol_parameters, +// SLOT_INDEX+1,protocol_parameters, // ) // .select() // .unwrap(); @@ -1531,7 +1554,7 @@ fn sender_already_selected() { None, None, )], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 1_000_000, @@ -1551,6 +1574,7 @@ fn sender_already_selected() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), ], + SLOT_INDEX, protocol_parameters, ) .with_required_inputs([*inputs[0].output_id()]) @@ -1576,7 +1600,7 @@ fn single_mandatory_input() { None, None, )], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 1_000_000, @@ -1596,6 +1620,7 @@ fn single_mandatory_input() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), ], + SLOT_INDEX, protocol_parameters, ) .with_required_inputs([*inputs[0].output_id()]) @@ -1642,6 +1667,7 @@ fn too_many_inputs() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select(); @@ -1685,7 +1711,7 @@ fn more_than_max_inputs_only_one_needed() { None, None, )], - None, + Some(SLOT_INDEX), ); inputs.push(needed_input[0].clone()); @@ -1704,6 +1730,7 @@ fn more_than_max_inputs_only_one_needed() { inputs, outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select() @@ -1728,7 +1755,7 @@ fn too_many_outputs() { None, None, )], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs( std::iter::repeat_with(|| { @@ -1750,6 +1777,7 @@ fn too_many_outputs() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select(); @@ -1775,7 +1803,7 @@ fn too_many_outputs_with_remainder() { None, None, )], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs( @@ -1798,6 +1826,7 @@ fn too_many_outputs_with_remainder() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select(); @@ -1859,7 +1888,7 @@ fn restricted_ed25519() { None, ), ], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 1_000_000, @@ -1876,6 +1905,7 @@ fn restricted_ed25519() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select() @@ -1907,7 +1937,7 @@ fn restricted_nft() { None, ), ], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 3_000_000, @@ -1924,6 +1954,7 @@ fn restricted_nft() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select() @@ -1953,7 +1984,7 @@ fn restricted_account() { None, ), ], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 3_000_000, @@ -1970,6 +2001,7 @@ fn restricted_account() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select() @@ -2039,7 +2071,7 @@ fn restricted_ed25519_sender() { None, ), ], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 2_000_000, @@ -2059,6 +2091,7 @@ fn restricted_ed25519_sender() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), ], + SLOT_INDEX, protocol_parameters, ) .select() @@ -2127,7 +2160,7 @@ fn multi_address_sender_already_fulfilled() { None, ), ], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 3_000_000, @@ -2148,6 +2181,7 @@ fn multi_address_sender_already_fulfilled() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), Address::try_from_bech32(BECH32_ADDRESS_ED25519_2).unwrap(), ], + SLOT_INDEX, protocol_parameters, ) .with_required_inputs([*inputs[0].output_id(), *inputs[1].output_id(), *inputs[2].output_id()]) @@ -2182,7 +2216,7 @@ fn ed25519_backed_available_address() { ), Basic(1_000_000, ed25519.clone(), None, None, None, None, None, None), ], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([ Basic( @@ -2212,6 +2246,7 @@ fn ed25519_backed_available_address() { outputs.clone(), // Restricted address is provided, but it can also unlock the ed25519 one [restricted_address], + SLOT_INDEX, protocol_parameters, ) .select() diff --git a/sdk/tests/client/input_selection/expiration.rs b/sdk/tests/client/input_selection/expiration.rs index 8dc60c5696..82c56051c5 100644 --- a/sdk/tests/client/input_selection/expiration.rs +++ b/sdk/tests/client/input_selection/expiration.rs @@ -9,6 +9,7 @@ use iota_sdk::{ address::Address, output::{AccountId, NftId}, protocol::protocol_parameters, + slot::SlotIndex, }, }; use pretty_assertions::assert_eq; @@ -35,7 +36,7 @@ fn one_output_expiration_not_expired() { Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 200)), None, )], - None, + Some(SlotIndex::from(100)), ); let outputs = build_outputs([Basic( 2_000_000, @@ -52,9 +53,9 @@ fn one_output_expiration_not_expired() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + 100, protocol_parameters, ) - .with_slot_index(100) .select(); assert!(matches!(selected, Err(Error::NoAvailableInputsProvided))); @@ -75,7 +76,7 @@ fn expiration_equal_timestamp() { Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 200)), None, )], - None, + Some(SlotIndex::from(200)), ); let outputs = build_outputs([Basic( 2_000_000, @@ -92,9 +93,9 @@ fn expiration_equal_timestamp() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + 200, protocol_parameters, ) - .with_slot_index(200) .select() .unwrap(); @@ -117,7 +118,7 @@ fn one_output_expiration_expired() { Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 50)), None, )], - None, + Some(SlotIndex::from(100)), ); let outputs = build_outputs([Basic( 2_000_000, @@ -134,9 +135,9 @@ fn one_output_expiration_expired() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + 100, protocol_parameters, ) - .with_slot_index(100) .select() .unwrap(); @@ -171,7 +172,7 @@ fn two_outputs_one_expiration_expired() { None, ), ], - None, + Some(SlotIndex::from(100)), ); let outputs = build_outputs([Basic( 2_000_000, @@ -188,9 +189,9 @@ fn two_outputs_one_expiration_expired() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + 100, protocol_parameters, ) - .with_slot_index(100) .select() .unwrap(); @@ -226,7 +227,7 @@ fn two_outputs_one_unexpired_one_missing() { None, ), ], - None, + Some(SlotIndex::from(100)), ); let outputs = build_outputs([Basic( 2_000_000, @@ -243,9 +244,9 @@ fn two_outputs_one_unexpired_one_missing() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + 100, protocol_parameters, ) - .with_slot_index(100) .select() .unwrap(); @@ -291,7 +292,7 @@ fn two_outputs_two_expired() { None, ), ], - None, + Some(SlotIndex::from(200)), ); let outputs = build_outputs([Basic( 2_000_000, @@ -308,9 +309,9 @@ fn two_outputs_two_expired() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_2).unwrap()], + 200, protocol_parameters, ) - .with_slot_index(200) .select() .unwrap(); @@ -346,7 +347,7 @@ fn two_outputs_two_expired_2() { None, ), ], - None, + Some(SlotIndex::from(200)), ); let outputs = build_outputs([Basic( 4_000_000, @@ -366,9 +367,9 @@ fn two_outputs_two_expired_2() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), Address::try_from_bech32(BECH32_ADDRESS_ED25519_2).unwrap(), ], + 200, protocol_parameters, ) - .with_slot_index(200) .select() .unwrap(); @@ -391,7 +392,7 @@ fn expiration_expired_with_sdr() { Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 50)), None, )], - None, + Some(SlotIndex::from(100)), ); let outputs = build_outputs([Basic( 2_000_000, @@ -408,9 +409,9 @@ fn expiration_expired_with_sdr() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + 100, protocol_parameters, ) - .with_slot_index(100) .select() .unwrap(); @@ -433,7 +434,7 @@ fn expiration_expired_with_sdr_2() { Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 50)), None, )], - None, + Some(SlotIndex::from(100)), ); let outputs = build_outputs([Basic( 2_000_000, @@ -450,9 +451,9 @@ fn expiration_expired_with_sdr_2() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + 100, protocol_parameters, ) - .with_slot_index(100) .select() .unwrap(); @@ -475,7 +476,7 @@ fn expiration_expired_with_sdr_and_timelock() { Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 50)), None, )], - None, + Some(SlotIndex::from(100)), ); let outputs = build_outputs([Basic( 2_000_000, @@ -492,9 +493,9 @@ fn expiration_expired_with_sdr_and_timelock() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + 100, protocol_parameters, ) - .with_slot_index(100) .select() .unwrap(); @@ -517,7 +518,7 @@ fn expiration_expired_with_sdr_and_timelock_2() { Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 50)), None, )], - None, + Some(SlotIndex::from(100)), ); let outputs = build_outputs([Basic( 2_000_000, @@ -534,9 +535,9 @@ fn expiration_expired_with_sdr_and_timelock_2() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + 100, protocol_parameters, ) - .with_slot_index(100) .select() .unwrap(); @@ -601,7 +602,7 @@ fn sender_in_expiration() { None, ), ], - None, + Some(SlotIndex::from(100)), ); let outputs = build_outputs([Basic( 1_000_000, @@ -621,9 +622,9 @@ fn sender_in_expiration() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), ], + 100, protocol_parameters, ) - .with_slot_index(100) .select() .unwrap(); @@ -647,7 +648,7 @@ fn sender_in_expiration_already_selected() { Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 50)), None, )], - None, + Some(SlotIndex::from(100)), ); let outputs = build_outputs([Basic( 1_000_000, @@ -667,9 +668,9 @@ fn sender_in_expiration_already_selected() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), ], + 100, protocol_parameters, ) - .with_slot_index(100) .with_required_inputs([*inputs[0].output_id()]) .select() .unwrap(); @@ -693,7 +694,7 @@ fn remainder_in_expiration() { Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 50)), None, )], - None, + Some(SlotIndex::from(100)), ); let outputs = build_outputs([Basic( 1_000_000, @@ -713,9 +714,9 @@ fn remainder_in_expiration() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), ], + 100, protocol_parameters, ) - .with_slot_index(100) .select() .unwrap(); @@ -749,7 +750,7 @@ fn expiration_expired_non_ed25519_in_address_unlock_condition() { Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 50)), None, )], - None, + Some(SlotIndex::from(100)), ); let outputs = build_outputs([Basic( 2_000_000, @@ -766,9 +767,9 @@ fn expiration_expired_non_ed25519_in_address_unlock_condition() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + 100, protocol_parameters, ) - .with_slot_index(100) .select() .unwrap(); @@ -802,7 +803,7 @@ fn expiration_expired_only_account_addresses() { None, ), ], - None, + Some(SlotIndex::from(100)), ); let outputs = build_outputs([Basic( @@ -820,9 +821,9 @@ fn expiration_expired_only_account_addresses() { inputs.clone(), outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + 100, protocol_parameters, ) - .with_slot_index(100) .select() .unwrap(); @@ -846,7 +847,7 @@ fn one_nft_output_expiration_unexpired() { Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 150)), None, )], - None, + Some(SlotIndex::from(100)), ); let outputs = build_outputs([Nft( 2_000_000, @@ -863,9 +864,9 @@ fn one_nft_output_expiration_unexpired() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()], + 100, protocol_parameters, ) - .with_slot_index(100) .select() .unwrap(); @@ -889,7 +890,7 @@ fn one_nft_output_expiration_expired() { Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 50)), None, )], - None, + Some(SlotIndex::from(100)), ); let outputs = build_outputs([Nft( 2_000_000, @@ -906,9 +907,9 @@ fn one_nft_output_expiration_expired() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + 100, protocol_parameters, ) - .with_slot_index(100) .select() .unwrap(); diff --git a/sdk/tests/client/input_selection/foundry_outputs.rs b/sdk/tests/client/input_selection/foundry_outputs.rs index bf8fe83707..7ec2d88494 100644 --- a/sdk/tests/client/input_selection/foundry_outputs.rs +++ b/sdk/tests/client/input_selection/foundry_outputs.rs @@ -15,7 +15,7 @@ use iota_sdk::{ SimpleTokenScheme, TokenId, }, protocol::protocol_parameters, - rand::output::rand_output_metadata, + rand::output::{rand_output_id_with_slot_index, rand_output_metadata_with_id}, }, }; use pretty_assertions::assert_eq; @@ -23,7 +23,7 @@ use pretty_assertions::assert_eq; use crate::client::{ build_inputs, build_outputs, is_remainder_or_return, unsorted_eq, Build::{Account, Basic, Foundry}, - ACCOUNT_ID_1, ACCOUNT_ID_2, BECH32_ADDRESS_ED25519_0, + ACCOUNT_ID_1, ACCOUNT_ID_2, BECH32_ADDRESS_ED25519_0, SLOT_INDEX, }; #[test] @@ -42,7 +42,7 @@ fn missing_input_account_for_foundry() { None, None, )], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Foundry( 1_000_000, @@ -56,6 +56,7 @@ fn missing_input_account_for_foundry() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select(); @@ -130,7 +131,7 @@ fn minted_native_tokens_in_new_remainder() { None, ), ], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Foundry( 1_000_000, @@ -144,6 +145,7 @@ fn minted_native_tokens_in_new_remainder() { inputs.clone(), outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select() @@ -189,7 +191,7 @@ fn minted_native_tokens_in_provided_output() { None, ), ], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([ Foundry( @@ -215,6 +217,7 @@ fn minted_native_tokens_in_provided_output() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select() @@ -255,7 +258,7 @@ fn melt_native_tokens() { )), ), ], - None, + Some(SLOT_INDEX), ); let account_output = AccountOutputBuilder::new_with_amount(1_000_000, account_id_1) .add_unlock_condition(AddressUnlockCondition::new( @@ -266,7 +269,7 @@ fn melt_native_tokens() { .unwrap(); inputs.push(InputSigningData { output: account_output, - output_metadata: rand_output_metadata(), + output_metadata: rand_output_metadata_with_id(rand_output_id_with_slot_index(SLOT_INDEX)), chain: None, }); let outputs = build_outputs([Foundry( @@ -282,6 +285,7 @@ fn melt_native_tokens() { inputs.clone(), outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select() @@ -322,7 +326,7 @@ fn destroy_foundry_with_account_state_transition() { None, ), ], - None, + Some(SLOT_INDEX), ); let account_output = AccountOutputBuilder::from(inputs[0].output.as_account()) .with_amount(103_100) @@ -335,6 +339,7 @@ fn destroy_foundry_with_account_state_transition() { inputs.clone(), outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .with_burn(Burn::new().add_foundry(inputs[1].output.as_foundry().id())) @@ -369,7 +374,7 @@ fn destroy_foundry_with_account_burn() { None, ), ], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 1_000_000, @@ -386,6 +391,7 @@ fn destroy_foundry_with_account_burn() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .with_burn( @@ -444,7 +450,7 @@ fn prefer_basic_to_foundry() { None, ), ], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 1_000_000, @@ -461,6 +467,7 @@ fn prefer_basic_to_foundry() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select() @@ -496,7 +503,7 @@ fn simple_foundry_transition_basic_not_needed() { None, ), ], - None, + Some(SLOT_INDEX), ); let account_output = AccountOutputBuilder::new_with_amount(2_000_000, account_id_1) .add_unlock_condition(AddressUnlockCondition::new( @@ -507,7 +514,7 @@ fn simple_foundry_transition_basic_not_needed() { .unwrap(); inputs.push(InputSigningData { output: account_output, - output_metadata: rand_output_metadata(), + output_metadata: rand_output_metadata_with_id(rand_output_id_with_slot_index(SLOT_INDEX)), chain: None, }); @@ -523,6 +530,7 @@ fn simple_foundry_transition_basic_not_needed() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select() @@ -574,7 +582,7 @@ fn simple_foundry_transition_basic_not_needed_with_remainder() { None, ), ], - None, + Some(SLOT_INDEX), ); let account_output = AccountOutputBuilder::new_with_amount(2_000_000, account_id_1) .add_unlock_condition(AddressUnlockCondition::new( @@ -585,7 +593,7 @@ fn simple_foundry_transition_basic_not_needed_with_remainder() { .unwrap(); inputs.push(InputSigningData { output: account_output, - output_metadata: rand_output_metadata(), + output_metadata: rand_output_metadata_with_id(rand_output_id_with_slot_index(SLOT_INDEX)), chain: None, }); let outputs = build_outputs([Foundry( @@ -600,6 +608,7 @@ fn simple_foundry_transition_basic_not_needed_with_remainder() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select() @@ -718,7 +727,7 @@ fn mint_and_burn_at_the_same_time() { SimpleTokenScheme::new(100, 0, 200).unwrap(), Some((&token_id.to_string(), 100)), )], - None, + Some(SLOT_INDEX), ); let account_output = AccountOutputBuilder::new_with_amount(2_000_000, account_id_1) .add_unlock_condition(AddressUnlockCondition::new( @@ -729,7 +738,7 @@ fn mint_and_burn_at_the_same_time() { .unwrap(); inputs.push(InputSigningData { output: account_output, - output_metadata: rand_output_metadata(), + output_metadata: rand_output_metadata_with_id(rand_output_id_with_slot_index(SLOT_INDEX)), chain: None, }); @@ -745,6 +754,7 @@ fn mint_and_burn_at_the_same_time() { inputs.clone(), outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .with_burn(Burn::new().add_native_token(token_id, 10)) @@ -783,7 +793,7 @@ fn take_amount_from_account_and_foundry_to_fund_basic() { Some((&token_id.to_string(), 100)), ), ], - None, + Some(SLOT_INDEX), ); let account_output = AccountOutputBuilder::new_with_amount(2_000_000, account_id_1) .add_unlock_condition(AddressUnlockCondition::new( @@ -794,7 +804,7 @@ fn take_amount_from_account_and_foundry_to_fund_basic() { .unwrap(); inputs.push(InputSigningData { output: account_output, - output_metadata: rand_output_metadata(), + output_metadata: rand_output_metadata_with_id(rand_output_id_with_slot_index(SLOT_INDEX)), chain: None, }); let outputs = build_outputs([Basic( @@ -812,6 +822,7 @@ fn take_amount_from_account_and_foundry_to_fund_basic() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select() @@ -853,7 +864,7 @@ fn create_native_token_but_burn_account() { None, ), ], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Foundry( 1_000_000, @@ -867,6 +878,7 @@ fn create_native_token_but_burn_account() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .with_burn(Burn::new().add_account(account_id_1)) @@ -914,7 +926,7 @@ fn melted_tokens_not_provided() { None, ), ], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Foundry( 1_000_000, @@ -928,6 +940,7 @@ fn melted_tokens_not_provided() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select(); @@ -966,7 +979,7 @@ fn burned_tokens_not_provided() { None, ), ], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Foundry( 1_000_000, @@ -980,6 +993,7 @@ fn burned_tokens_not_provided() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .with_burn(Burn::new().add_native_token(token_id_1, 100)) @@ -1007,7 +1021,7 @@ fn foundry_in_outputs_and_required() { SimpleTokenScheme::new(0, 0, 10).unwrap(), None, )], - None, + Some(SLOT_INDEX), ); let account_output = AccountOutputBuilder::new_with_amount(1_251_500, account_id_2) .add_unlock_condition(AddressUnlockCondition::new( @@ -1018,7 +1032,7 @@ fn foundry_in_outputs_and_required() { .unwrap(); inputs.push(InputSigningData { output: account_output, - output_metadata: rand_output_metadata(), + output_metadata: rand_output_metadata_with_id(rand_output_id_with_slot_index(SLOT_INDEX)), chain: None, }); let outputs = build_outputs([Foundry( @@ -1033,6 +1047,7 @@ fn foundry_in_outputs_and_required() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .with_required_inputs([*inputs[1].output_id()]) @@ -1076,7 +1091,7 @@ fn melt_and_burn_native_tokens() { Some((&token_id.to_string(), 1000)), ), ], - None, + Some(SLOT_INDEX), ); let account_output = AccountOutputBuilder::new_with_amount(1_000_000, account_id) .add_unlock_condition(AddressUnlockCondition::new( @@ -1087,7 +1102,7 @@ fn melt_and_burn_native_tokens() { .unwrap(); inputs.push(InputSigningData { output: account_output, - output_metadata: rand_output_metadata(), + output_metadata: rand_output_metadata_with_id(rand_output_id_with_slot_index(SLOT_INDEX)), chain: None, }); let outputs = build_outputs([Foundry( @@ -1103,6 +1118,7 @@ fn melt_and_burn_native_tokens() { inputs.clone(), outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) // Burn 456 native tokens diff --git a/sdk/tests/client/input_selection/nft_outputs.rs b/sdk/tests/client/input_selection/nft_outputs.rs index ad3d40db1e..96ae5c18b9 100644 --- a/sdk/tests/client/input_selection/nft_outputs.rs +++ b/sdk/tests/client/input_selection/nft_outputs.rs @@ -12,7 +12,7 @@ use iota_sdk::{ address::Address, output::{feature::MetadataFeature, unlock_condition::AddressUnlockCondition, NftId, NftOutputBuilder, Output}, protocol::protocol_parameters, - rand::output::rand_output_metadata, + rand::output::{rand_output_id_with_slot_index, rand_output_metadata_with_id}, }, }; use pretty_assertions::{assert_eq, assert_ne}; @@ -21,7 +21,7 @@ use crate::client::{ build_inputs, build_outputs, is_remainder_or_return, unsorted_eq, Build::{Basic, Nft}, BECH32_ADDRESS_ACCOUNT_1, BECH32_ADDRESS_ED25519_0, BECH32_ADDRESS_ED25519_1, BECH32_ADDRESS_NFT_1, NFT_ID_0, - NFT_ID_1, NFT_ID_2, + NFT_ID_1, NFT_ID_2, SLOT_INDEX, }; #[test] @@ -40,7 +40,7 @@ fn input_nft_eq_output_nft() { None, None, )], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Nft( 1_000_000, @@ -57,6 +57,7 @@ fn input_nft_eq_output_nft() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select() @@ -82,7 +83,7 @@ fn transition_nft_id_zero() { None, None, )], - None, + Some(SLOT_INDEX), ); let nft_id = NftId::from(inputs[0].output_id()); let outputs = build_outputs([Nft( @@ -100,6 +101,7 @@ fn transition_nft_id_zero() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select() @@ -213,7 +215,7 @@ fn mint_nft() { None, None, )], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Nft( 1_000_000, @@ -230,6 +232,7 @@ fn mint_nft() { inputs.clone(), outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select() @@ -264,7 +267,7 @@ fn burn_nft() { None, None, )], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 2_000_000, @@ -281,6 +284,7 @@ fn burn_nft() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .with_burn(Burn::new().add_nft(nft_id_2)) @@ -352,7 +356,7 @@ fn missing_input_for_nft_output() { None, None, )], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Nft( 1_000_000, @@ -369,6 +373,7 @@ fn missing_input_for_nft_output() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select(); @@ -395,7 +400,7 @@ fn missing_input_for_nft_output_but_created() { None, None, )], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Nft( 1_000_000, @@ -412,6 +417,7 @@ fn missing_input_for_nft_output_but_created() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select(); @@ -447,7 +453,7 @@ fn nft_in_output_and_sender() { None, ), ], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([ Nft( @@ -476,6 +482,7 @@ fn nft_in_output_and_sender() { inputs.clone(), outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select() @@ -509,7 +516,7 @@ fn missing_ed25519_sender() { None, None, )], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Nft( 1_000_000, @@ -526,6 +533,7 @@ fn missing_ed25519_sender() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select(); @@ -552,7 +560,7 @@ fn missing_ed25519_issuer_created() { None, None, )], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Nft( 1_000_000, @@ -569,6 +577,7 @@ fn missing_ed25519_issuer_created() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select(); @@ -595,7 +604,7 @@ fn missing_ed25519_issuer_transition() { None, None, )], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Nft( 1_000_000, @@ -612,6 +621,7 @@ fn missing_ed25519_issuer_transition() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select(); @@ -635,7 +645,7 @@ fn missing_account_sender() { None, None, )], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Nft( 1_000_000, @@ -652,6 +662,7 @@ fn missing_account_sender() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select(); @@ -678,7 +689,7 @@ fn missing_account_issuer_created() { None, None, )], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Nft( 1_000_000, @@ -695,6 +706,7 @@ fn missing_account_issuer_created() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select(); @@ -721,7 +733,7 @@ fn missing_account_issuer_transition() { None, None, )], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Nft( 1_000_000, @@ -738,6 +750,7 @@ fn missing_account_issuer_transition() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select(); @@ -761,7 +774,7 @@ fn missing_nft_sender() { None, None, )], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Nft( 1_000_000, @@ -778,6 +791,7 @@ fn missing_nft_sender() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select(); @@ -804,7 +818,7 @@ fn missing_nft_issuer_created() { None, None, )], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Nft( 1_000_000, @@ -821,6 +835,7 @@ fn missing_nft_issuer_created() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select(); @@ -847,7 +862,7 @@ fn missing_nft_issuer_transition() { None, None, )], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Nft( 1_000_000, @@ -864,6 +879,7 @@ fn missing_nft_issuer_transition() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select(); @@ -899,7 +915,7 @@ fn increase_nft_amount() { None, ), ], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Nft( 3_000_000, @@ -916,6 +932,7 @@ fn increase_nft_amount() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select() @@ -953,7 +970,7 @@ fn decrease_nft_amount() { None, ), ], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Nft( 1_000_000, @@ -970,6 +987,7 @@ fn decrease_nft_amount() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select() @@ -1019,7 +1037,7 @@ fn prefer_basic_to_nft() { None, ), ], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 1_000_000, @@ -1036,6 +1054,7 @@ fn prefer_basic_to_nft() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select() @@ -1074,7 +1093,7 @@ fn take_amount_from_nft_to_fund_basic() { None, ), ], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 1_200_000, @@ -1091,6 +1110,7 @@ fn take_amount_from_nft_to_fund_basic() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select() @@ -1141,7 +1161,7 @@ fn nft_burn_should_validate_nft_sender() { None, ), ], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 3_000_000, @@ -1158,6 +1178,7 @@ fn nft_burn_should_validate_nft_sender() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .with_burn(Burn::new().add_nft(nft_id_1)) @@ -1196,7 +1217,7 @@ fn nft_burn_should_validate_nft_address() { None, ), ], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 3_000_000, @@ -1213,6 +1234,7 @@ fn nft_burn_should_validate_nft_address() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .with_burn(Burn::new().add_nft(nft_id_1)) @@ -1239,7 +1261,7 @@ fn transitioned_zero_nft_id_no_longer_is_zero() { None, None, )], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 1_000_000, @@ -1256,6 +1278,7 @@ fn transitioned_zero_nft_id_no_longer_is_zero() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select() @@ -1305,7 +1328,7 @@ fn changed_immutable_metadata() { let inputs = [InputSigningData { output: nft_output.clone(), - output_metadata: rand_output_metadata(), + output_metadata: rand_output_metadata_with_id(rand_output_id_with_slot_index(SLOT_INDEX)), chain: None, }]; @@ -1332,6 +1355,7 @@ fn changed_immutable_metadata() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select(); diff --git a/sdk/tests/client/input_selection/outputs.rs b/sdk/tests/client/input_selection/outputs.rs index 98551690e9..bdce5ea3cd 100644 --- a/sdk/tests/client/input_selection/outputs.rs +++ b/sdk/tests/client/input_selection/outputs.rs @@ -12,7 +12,7 @@ use pretty_assertions::assert_eq; use crate::client::{ build_inputs, build_outputs, is_remainder_or_return, unsorted_eq, Build::{Account, Basic}, - ACCOUNT_ID_2, BECH32_ADDRESS_ED25519_0, BECH32_ADDRESS_ED25519_1, + ACCOUNT_ID_2, BECH32_ADDRESS_ED25519_0, BECH32_ADDRESS_ED25519_1, SLOT_INDEX, }; #[test] @@ -35,6 +35,7 @@ fn no_inputs() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select(); @@ -65,6 +66,7 @@ fn no_outputs() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select(); @@ -86,7 +88,7 @@ fn no_outputs_but_burn() { None, None, )], - None, + Some(SLOT_INDEX), ); let outputs = Vec::new(); @@ -94,6 +96,7 @@ fn no_outputs_but_burn() { inputs.clone(), outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .with_burn(Burn::new().add_account(account_id_2)) @@ -125,7 +128,7 @@ fn no_address_provided() { None, None, )], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 1_000_000, @@ -138,7 +141,7 @@ fn no_address_provided() { None, )]); - let selected = InputSelection::new(inputs, outputs, [], protocol_parameters).select(); + let selected = InputSelection::new(inputs, outputs, [], SLOT_INDEX, protocol_parameters).select(); assert!(matches!(selected, Err(Error::NoAvailableInputsProvided))); } @@ -175,6 +178,7 @@ fn no_matching_address_provided() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select(); @@ -209,7 +213,7 @@ fn two_addresses_one_missing() { None, ), ], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 2_000_000, @@ -226,6 +230,7 @@ fn two_addresses_one_missing() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select(); @@ -266,7 +271,7 @@ fn two_addresses() { None, ), ], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 2_000_000, @@ -286,6 +291,7 @@ fn two_addresses() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), ], + SLOT_INDEX, protocol_parameters, ) .select() diff --git a/sdk/tests/client/input_selection/storage_deposit_return.rs b/sdk/tests/client/input_selection/storage_deposit_return.rs index 1ccec61b40..3b451de41a 100644 --- a/sdk/tests/client/input_selection/storage_deposit_return.rs +++ b/sdk/tests/client/input_selection/storage_deposit_return.rs @@ -13,7 +13,7 @@ use crate::client::{ build_inputs, build_outputs, is_remainder_or_return, unsorted_eq, Build::{Account, Basic}, ACCOUNT_ID_1, BECH32_ADDRESS_ACCOUNT_1, BECH32_ADDRESS_ED25519_0, BECH32_ADDRESS_ED25519_1, - BECH32_ADDRESS_ED25519_2, + BECH32_ADDRESS_ED25519_2, SLOT_INDEX, }; #[test] @@ -31,7 +31,7 @@ fn sdruc_output_not_provided_no_remainder() { None, None, )], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 1_000_000, @@ -48,6 +48,7 @@ fn sdruc_output_not_provided_no_remainder() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select() @@ -83,7 +84,7 @@ fn sdruc_output_provided_no_remainder() { None, None, )], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([ Basic( @@ -112,6 +113,7 @@ fn sdruc_output_provided_no_remainder() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select() @@ -136,7 +138,7 @@ fn sdruc_output_provided_remainder() { None, None, )], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 1_000_000, @@ -153,6 +155,7 @@ fn sdruc_output_provided_remainder() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select() @@ -200,7 +203,7 @@ fn two_sdrucs_to_the_same_address_both_needed() { None, ), ], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 2_000_000, @@ -217,6 +220,7 @@ fn two_sdrucs_to_the_same_address_both_needed() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select() @@ -264,7 +268,7 @@ fn two_sdrucs_to_the_same_address_one_needed() { None, ), ], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 1_000_000, @@ -281,6 +285,7 @@ fn two_sdrucs_to_the_same_address_one_needed() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select() @@ -329,7 +334,7 @@ fn two_sdrucs_to_different_addresses_both_needed() { None, ), ], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 2_000_000, @@ -346,6 +351,7 @@ fn two_sdrucs_to_different_addresses_both_needed() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select() @@ -399,7 +405,7 @@ fn two_sdrucs_to_different_addresses_one_needed() { None, ), ], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 1_000_000, @@ -416,6 +422,7 @@ fn two_sdrucs_to_different_addresses_one_needed() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select() @@ -452,7 +459,7 @@ fn insufficient_amount_because_of_sdruc() { None, None, )], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 2_000_000, @@ -469,6 +476,7 @@ fn insufficient_amount_because_of_sdruc() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select(); @@ -509,7 +517,7 @@ fn useless_sdruc_required_for_sender_feature() { None, ), ], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 1_000_000, @@ -529,6 +537,7 @@ fn useless_sdruc_required_for_sender_feature() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), ], + SLOT_INDEX, protocol_parameters, ) .select() @@ -575,7 +584,7 @@ fn sdruc_required_non_ed25519_in_address_unlock() { None, ), ], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 1_000_000, @@ -592,6 +601,7 @@ fn sdruc_required_non_ed25519_in_address_unlock() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select() @@ -648,7 +658,7 @@ fn useless_sdruc_non_ed25519_in_address_unlock() { None, ), ], - None, + Some(SLOT_INDEX), ); let outputs = build_outputs([Basic( 1_000_000, @@ -665,6 +675,7 @@ fn useless_sdruc_non_ed25519_in_address_unlock() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + SLOT_INDEX, protocol_parameters, ) .select() diff --git a/sdk/tests/client/input_selection/timelock.rs b/sdk/tests/client/input_selection/timelock.rs index d5a100cf6d..a57655846c 100644 --- a/sdk/tests/client/input_selection/timelock.rs +++ b/sdk/tests/client/input_selection/timelock.rs @@ -3,7 +3,7 @@ use iota_sdk::{ client::api::input_selection::{Error, InputSelection}, - types::block::{address::Address, protocol::protocol_parameters}, + types::block::{address::Address, protocol::protocol_parameters, slot::SlotIndex}, }; use pretty_assertions::assert_eq; @@ -43,9 +43,9 @@ fn one_output_timelock_not_expired() { inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + 100, protocol_parameters, ) - .with_slot_index(100) .select(); assert!(matches!(selected, Err(Error::NoAvailableInputsProvided))); @@ -66,7 +66,7 @@ fn timelock_equal_timestamp() { None, None, )], - None, + Some(SlotIndex::from(200)), ); let outputs = build_outputs([Basic( 2_000_000, @@ -83,9 +83,9 @@ fn timelock_equal_timestamp() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + 200, protocol_parameters, ) - .with_slot_index(200) .select() .unwrap(); @@ -120,7 +120,7 @@ fn two_outputs_one_timelock_expired() { None, ), ], - None, + Some(SlotIndex::from(100)), ); let outputs = build_outputs([Basic( 2_000_000, @@ -137,9 +137,9 @@ fn two_outputs_one_timelock_expired() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + 100, protocol_parameters, ) - .with_slot_index(100) .select() .unwrap(); @@ -175,7 +175,7 @@ fn two_outputs_one_timelocked_one_missing() { None, ), ], - None, + Some(SlotIndex::from(100)), ); let outputs = build_outputs([Basic( 2_000_000, @@ -192,9 +192,9 @@ fn two_outputs_one_timelocked_one_missing() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + 100, protocol_parameters, ) - .with_slot_index(100) .select() .unwrap(); @@ -218,7 +218,7 @@ fn one_output_timelock_expired() { None, None, )], - None, + Some(SlotIndex::from(100)), ); let outputs = build_outputs([Basic( 2_000_000, @@ -235,9 +235,9 @@ fn one_output_timelock_expired() { inputs.clone(), outputs.clone(), [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], + 100, protocol_parameters, ) - .with_slot_index(100) .select() .unwrap(); diff --git a/sdk/tests/client/mod.rs b/sdk/tests/client/mod.rs index e65ca490d2..db6209fcbb 100644 --- a/sdk/tests/client/mod.rs +++ b/sdk/tests/client/mod.rs @@ -57,6 +57,7 @@ const BECH32_ADDRESS_ACCOUNT_1: &str = "rms1pqg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3 const BECH32_ADDRESS_ACCOUNT_2: &str = "rms1pq3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zymxrh9z"; // Corresponds to ACCOUNT_ID_2 const BECH32_ADDRESS_NFT_1: &str = "rms1zqg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zxddmy7"; // Corresponds to NFT_ID_1 const _BECH32_ADDRESS_NFT_2: &str = "rms1zq3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zynm6ctf"; // Corresponds to NFT_ID_2 +const SLOT_INDEX: SlotIndex = SlotIndex(10); #[derive(Debug, Clone)] enum Build<'a> { diff --git a/sdk/tests/client/signing/mod.rs b/sdk/tests/client/signing/mod.rs index dc38b1fd3d..761f7ff555 100644 --- a/sdk/tests/client/signing/mod.rs +++ b/sdk/tests/client/signing/mod.rs @@ -210,9 +210,9 @@ async fn all_combined() -> Result<()> { inputs.clone(), outputs.clone(), [ed25519_0, ed25519_1, ed25519_2], + slot_index, protocol_parameters.clone(), ) - .with_slot_index(slot_index) .select() .unwrap();