diff --git a/bindings/core/src/method/secret_manager.rs b/bindings/core/src/method/secret_manager.rs index 57343f9bdc..7e9001ea77 100644 --- a/bindings/core/src/method/secret_manager.rs +++ b/bindings/core/src/method/secret_manager.rs @@ -57,8 +57,10 @@ pub enum SecretManagerMethod { #[serde(rename_all = "camelCase")] SignTransaction { /// Prepared transaction data - prepared_transaction_data: PreparedTransactionDataDto, + prepared_transaction_data: PreparedTransactionDataDto, protocol_parameters: ProtocolParameters, + /// Options used to sign the transaction + signing_options: serde_json::Value, }, // Sign a block. #[serde(rename_all = "camelCase")] diff --git a/bindings/core/src/method/utils.rs b/bindings/core/src/method/utils.rs index 4c07470e92..be706f9d46 100644 --- a/bindings/core/src/method/utils.rs +++ b/bindings/core/src/method/utils.rs @@ -124,7 +124,7 @@ pub enum UtilsMethod { /// Verifies the semantic of a transaction. VerifyTransactionSemantic { transaction: TransactionDto, - inputs: Vec>, + inputs: Vec, unlocks: Option>, }, } diff --git a/bindings/core/src/method/wallet.rs b/bindings/core/src/method/wallet.rs index c8381598d9..54718fd730 100644 --- a/bindings/core/src/method/wallet.rs +++ b/bindings/core/src/method/wallet.rs @@ -4,7 +4,6 @@ #[cfg(feature = "stronghold")] use std::path::PathBuf; -use crypto::keys::bip44::Bip44; use derivative::Derivative; #[cfg(feature = "events")] use iota_sdk::wallet::events::types::{WalletEvent, WalletEventType}; @@ -390,19 +389,19 @@ pub enum WalletMethod { /// Expected response: [`SentTransaction`](crate::Response::SentTransaction) #[serde(rename_all = "camelCase")] SignAndSubmitTransaction { - prepared_transaction_data: PreparedTransactionDataDto, + prepared_transaction_data: PreparedTransactionDataDto, }, /// Sign a prepared transaction. /// Expected response: [`SignedTransactionData`](crate::Response::SignedTransactionData) #[serde(rename_all = "camelCase")] SignTransaction { - prepared_transaction_data: PreparedTransactionDataDto, + prepared_transaction_data: PreparedTransactionDataDto, }, /// Validate the transaction, submit it to a node and store it in the wallet. /// Expected response: [`SentTransaction`](crate::Response::SentTransaction) #[serde(rename_all = "camelCase")] SubmitAndStoreTransaction { - signed_transaction_data: SignedTransactionDataDto, + signed_transaction_data: SignedTransactionDataDto, }, /// Sync the wallet by fetching new information from the nodes. Will also reissue pending transactions /// if necessary. A custom default can be set using SetDefaultSyncOptions. @@ -423,7 +422,7 @@ pub enum WalletMethod { /// Expected response: [`Ok`](crate::Response::Ok) #[cfg(feature = "events")] #[cfg_attr(docsrs, doc(cfg(feature = "events")))] - EmitTestEvent { event: WalletEvent }, + EmitTestEvent { event: WalletEvent }, // TODO: reconsider whether to have the following methods on the wallet /// Get the ledger nano status diff --git a/bindings/core/src/method_handler/secret_manager.rs b/bindings/core/src/method_handler/secret_manager.rs index ab4ae933e4..4d3fe5748b 100644 --- a/bindings/core/src/method_handler/secret_manager.rs +++ b/bindings/core/src/method_handler/secret_manager.rs @@ -54,11 +54,13 @@ pub(crate) async fn call_secret_manager_method_internal( SecretManagerMethod::SignTransaction { prepared_transaction_data, protocol_parameters, + signing_options, } => { let transaction = &secret_manager .sign_transaction( PreparedTransactionData::try_from_dto(prepared_transaction_data)?, &protocol_parameters, + &signing_options, ) .await .map_err(iota_sdk::client::Error::from)?; diff --git a/bindings/core/src/response.rs b/bindings/core/src/response.rs index f8b23d2e99..5fc5938060 100644 --- a/bindings/core/src/response.rs +++ b/bindings/core/src/response.rs @@ -270,11 +270,11 @@ pub enum Response { OutputIds(Vec), /// Response for: /// - [`GetOutput`](crate::method::WalletMethod::GetOutput) - OutputData(Option>>), + OutputData(Option>), /// Response for: /// - [`Outputs`](crate::method::WalletMethod::Outputs), /// - [`UnspentOutputs`](crate::method::WalletMethod::UnspentOutputs) - OutputsData(Vec>), + OutputsData(Vec), /// Response for: /// - [`PrepareBurn`](crate::method::WalletMethod::PrepareBurn), /// - [`PrepareClaimOutputs`](crate::method::WalletMethod::PrepareClaimOutputs) @@ -292,10 +292,10 @@ pub enum Response { /// - [`PrepareTransaction`](crate::method::WalletMethod::PrepareTransaction) /// - [`PrepareVote`](crate::method::WalletMethod::PrepareVote) /// - [`PrepareImplicitAccountTransition`](crate::method::WalletMethod::PrepareImplicitAccountTransition) - PreparedTransaction(PreparedTransactionDataDto), + PreparedTransaction(PreparedTransactionDataDto), /// Response for: /// - [`PrepareCreateNativeToken`](crate::method::WalletMethod::PrepareCreateNativeToken), - PreparedCreateNativeTokenTransaction(PreparedCreateNativeTokenTransactionDto), + PreparedCreateNativeTokenTransaction(PreparedCreateNativeTokenTransactionDto), /// Response for: /// - [`GetIncomingTransaction`](crate::method::WalletMethod::GetIncomingTransaction) /// - [`GetTransaction`](crate::method::WalletMethod::GetTransaction), @@ -307,7 +307,7 @@ pub enum Response { Transactions(Vec), /// Response for: /// - [`SignTransaction`](crate::method::WalletMethod::SignTransaction) - SignedTransactionData(SignedTransactionDataDto), + SignedTransactionData(SignedTransactionDataDto), /// Response for: /// - [`GetBalance`](crate::method::WalletMethod::GetBalance), /// - [`Sync`](crate::method::WalletMethod::Sync) diff --git a/bindings/wasm/src/wallet.rs b/bindings/wasm/src/wallet.rs index e5b163cb53..ed794d02eb 100644 --- a/bindings/wasm/src/wallet.rs +++ b/bindings/wasm/src/wallet.rs @@ -114,10 +114,7 @@ pub async fn listen_wallet( event_types.push(wallet_event_type); } - let (tx, mut rx): ( - UnboundedSender>, - UnboundedReceiver>, - ) = unbounded_channel(); + let (tx, mut rx): (UnboundedSender, UnboundedReceiver) = unbounded_channel(); method_handler .wallet .lock() diff --git a/cli/src/wallet_cli/mod.rs b/cli/src/wallet_cli/mod.rs index a7078b9210..5f31a51288 100644 --- a/cli/src/wallet_cli/mod.rs +++ b/cli/src/wallet_cli/mod.rs @@ -1236,7 +1236,7 @@ pub async fn prompt_internal( Ok(PromptResponse::Reprompt) } -fn print_outputs(mut outputs: Vec>, title: &str) -> Result<(), Error> { +fn print_outputs(mut outputs: Vec, title: &str) -> Result<(), Error> { if outputs.is_empty() { println_log_info!("No outputs found"); } else { diff --git a/sdk/examples/wallet/offline_signing/1_prepare_transaction.rs b/sdk/examples/wallet/offline_signing/1_prepare_transaction.rs index 48e1643513..7971cc4ee2 100644 --- a/sdk/examples/wallet/offline_signing/1_prepare_transaction.rs +++ b/sdk/examples/wallet/offline_signing/1_prepare_transaction.rs @@ -76,9 +76,7 @@ async fn read_address_from_file() -> Result { Ok(serde_json::from_str(&json)?) } -async fn write_transaction_to_file( - prepared_transaction: PreparedTransactionData, -) -> Result<()> { +async fn write_transaction_to_file(prepared_transaction: PreparedTransactionData) -> Result<()> { use tokio::io::AsyncWriteExt; let json = serde_json::to_string_pretty(&PreparedTransactionDataDto::from(&prepared_transaction))?; diff --git a/sdk/examples/wallet/offline_signing/2_sign_transaction.rs b/sdk/examples/wallet/offline_signing/2_sign_transaction.rs index 442aea0393..aa8db57d84 100644 --- a/sdk/examples/wallet/offline_signing/2_sign_transaction.rs +++ b/sdk/examples/wallet/offline_signing/2_sign_transaction.rs @@ -8,24 +8,22 @@ //! cargo run --release --all-features --example 2_sign_transaction //! ``` +use crypto::keys::bip44::Bip44; use iota_sdk::{ client::{ api::{ transaction::validate_signed_transaction_payload_length, PreparedTransactionData, SignedTransactionData, SignedTransactionDataDto, }, + constants::IOTA_COIN_TYPE, secret::{stronghold::StrongholdSecretManager, SignTransaction}, }, types::{ - block::{ - payload::SignedTransactionPayload, - protocol::{protocol_parameters, ProtocolParameters}, - }, + block::{payload::SignedTransactionPayload, protocol::protocol_parameters}, TryFromDto, }, wallet::Result, }; -use serde::{de::DeserializeOwned, Serialize}; const STRONGHOLD_SNAPSHOT_PATH: &str = "./examples/wallet/offline_signing/example.stronghold"; const PREPARED_TRANSACTION_FILE_PATH: &str = "./examples/wallet/offline_signing/example.prepared_transaction.json"; @@ -46,13 +44,15 @@ async fn main() -> Result<()> { .password(std::env::var("STRONGHOLD_PASSWORD").unwrap()) .build(STRONGHOLD_SNAPSHOT_PATH)?; + let signing_options = Bip44::new(IOTA_COIN_TYPE); + let prepared_transaction_data = read_prepared_transaction_from_file().await?; let protocol_parameters = protocol_parameters(); // Signs prepared transaction offline. let unlocks = secret_manager - .transaction_unlocks(&prepared_transaction_data, &protocol_parameters) + .transaction_unlocks(&prepared_transaction_data, &protocol_parameters, &signing_options) .await?; let signed_transaction = SignedTransactionPayload::new(prepared_transaction_data.transaction.clone(), unlocks)?; @@ -71,7 +71,7 @@ async fn main() -> Result<()> { Ok(()) } -async fn read_prepared_transaction_from_file() -> Result> { +async fn read_prepared_transaction_from_file() -> Result { use tokio::io::AsyncReadExt; let mut file = tokio::io::BufReader::new(tokio::fs::File::open(PREPARED_TRANSACTION_FILE_PATH).await?); @@ -81,9 +81,7 @@ async fn read_prepared_transaction_from_file() -> Result( - signed_transaction_data: &SignedTransactionData, -) -> Result<()> { +async fn write_signed_transaction_to_file(signed_transaction_data: &SignedTransactionData) -> Result<()> { use tokio::io::AsyncWriteExt; let dto = SignedTransactionDataDto::from(signed_transaction_data); diff --git a/sdk/examples/wallet/offline_signing/3_send_transaction.rs b/sdk/examples/wallet/offline_signing/3_send_transaction.rs index 3e3675e0bf..9763aec488 100644 --- a/sdk/examples/wallet/offline_signing/3_send_transaction.rs +++ b/sdk/examples/wallet/offline_signing/3_send_transaction.rs @@ -18,7 +18,6 @@ use iota_sdk::{ wallet::Result, Wallet, }; -use serde::de::DeserializeOwned; const ONLINE_WALLET_DB_PATH: &str = "./examples/wallet/offline_signing/example-online-walletdb"; const SIGNED_TRANSACTION_FILE_PATH: &str = "./examples/wallet/offline_signing/example.signed_transaction.json"; @@ -51,16 +50,14 @@ async fn main() -> Result<()> { Ok(()) } -async fn read_signed_transaction_from_file( - client: &Client, -) -> Result> { +async fn read_signed_transaction_from_file(client: &Client) -> Result { use tokio::io::AsyncReadExt; let mut file = tokio::io::BufReader::new(tokio::fs::File::open(SIGNED_TRANSACTION_FILE_PATH).await?); let mut json = String::new(); file.read_to_string(&mut json).await?; - let dto = serde_json::from_str::>(&json)?; + let dto = serde_json::from_str::(&json)?; Ok(SignedTransactionData::try_from_dto_with_params( dto, 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 04fb56e061..ba4ed047ab 100644 --- a/sdk/src/client/api/block_builder/input_selection/mod.rs +++ b/sdk/src/client/api/block_builder/input_selection/mod.rs @@ -31,11 +31,11 @@ use crate::{ }; /// Working state for the input selection algorithm. -pub struct InputSelection { - available_inputs: Vec>, +pub struct InputSelection { + available_inputs: Vec, required_inputs: HashSet, forbidden_inputs: HashSet, - selected_inputs: Vec>, + selected_inputs: Vec, outputs: Vec, addresses: HashSet
, burn: Option, @@ -48,17 +48,17 @@ pub struct InputSelection { /// Result of the input selection algorithm. #[derive(Clone, Debug)] -pub struct Selected { +pub struct Selected { /// Selected inputs. - pub inputs: Vec>, + pub inputs: Vec, /// Provided and created outputs. pub outputs: Vec, /// Remainder, if there was one. - pub remainder: Option>, + pub remainder: Option, } -impl InputSelection { - fn required_account_nft_addresses(&self, input: &InputSigningData) -> Result, Error> { +impl InputSelection { + fn required_account_nft_addresses(&self, input: &InputSigningData) -> Result, Error> { let required_address = input .output .required_and_unlocked_address(self.slot_index, input.output_id())? @@ -75,7 +75,7 @@ impl InputSelection { } } - fn select_input(&mut self, input: InputSigningData) -> Result<(), Error> { + fn select_input(&mut self, input: InputSigningData) -> Result<(), Error> { log::debug!("Selecting input {:?}", input.output_id()); if let Some(output) = self.transition_input(&input)? { @@ -145,7 +145,7 @@ impl InputSelection { /// Creates a new [`InputSelection`]. pub fn new( - available_inputs: impl Into>>, + available_inputs: impl Into>, outputs: impl Into>, addresses: impl IntoIterator, protocol_parameters: ProtocolParameters, @@ -249,15 +249,15 @@ impl InputSelection { // Inputs need to be sorted before signing, because the reference unlock conditions can only reference a lower index pub(crate) fn sort_input_signing_data( - mut inputs: Vec>, + mut inputs: Vec, slot_index: SlotIndex, - ) -> Result>, Error> { + ) -> Result, Error> { // initially sort by output to make it deterministic // TODO: rethink this, we only need it deterministic for tests, for the protocol it doesn't matter, also there // might be a more efficient way to do this inputs.sort_by_key(|i| i.output.pack_to_vec()); // filter for ed25519 address first - let (mut sorted_inputs, account_nft_address_inputs): (Vec>, Vec>) = + let (mut sorted_inputs, account_nft_address_inputs): (Vec, Vec) = inputs.into_iter().partition(|input_signing_data| { let (input_address, _) = input_signing_data .output @@ -338,7 +338,7 @@ impl InputSelection { /// Selects inputs that meet the requirements of the outputs to satisfy the semantic validation of the overall /// transaction. Also creates a remainder output and chain transition outputs if required. - pub fn select(mut self) -> Result, Error> { + pub fn select(mut self) -> Result { if !OUTPUT_COUNT_RANGE.contains(&(self.outputs.len() as u16)) { // If burn is provided, outputs will be added later if !(self.outputs.is_empty() && self.burn.is_some()) { 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 ead42f71d0..0e786d0797 100644 --- a/sdk/src/client/api/block_builder/input_selection/remainder.rs +++ b/sdk/src/client/api/block_builder/input_selection/remainder.rs @@ -16,9 +16,9 @@ use crate::{ }, }; -impl InputSelection { +impl InputSelection { // Gets the remainder address from configuration of finds one from the inputs. - fn get_remainder_address(&self) -> Result)>, Error> { + fn get_remainder_address(&self) -> Result, Error> { if let Some(remainder_address) = &self.remainder_address { // Search in inputs for the Bip44 chain for the remainder address, so the ledger can regenerate it for input in self.available_inputs.iter().chain(self.selected_inputs.iter()) { @@ -27,10 +27,10 @@ impl InputSelection { .required_and_unlocked_address(self.slot_index, input.output_id())?; if &required_address == remainder_address { - return Ok(Some((remainder_address.clone(), input.signing_options.clone()))); + return Ok(Some(remainder_address.clone())); } } - return Ok(Some((remainder_address.clone(), None))); + return Ok(Some(remainder_address.clone())); } for input in &self.selected_inputs { @@ -40,7 +40,7 @@ impl InputSelection { .0; if required_address.is_ed25519() { - return Ok(Some((required_address, input.signing_options.clone()))); + return Ok(Some(required_address)); } } @@ -79,7 +79,7 @@ impl InputSelection { pub(crate) fn remainder_and_storage_deposit_return_outputs( &self, - ) -> Result<(Option>, Vec), Error> { + ) -> Result<(Option, Vec), Error> { let (inputs_sum, outputs_sum, inputs_sdr, outputs_sdr) = amount_sums(&self.selected_inputs, &self.outputs, self.slot_index); let mut storage_deposit_returns = Vec::new(); @@ -120,7 +120,7 @@ impl InputSelection { return Ok((None, storage_deposit_returns)); } - let Some((remainder_address, chain)) = self.get_remainder_address()? else { + let Some(remainder_address) = self.get_remainder_address()? else { return Err(Error::MissingInputWithEd25519Address); }; @@ -145,7 +145,6 @@ impl InputSelection { Ok(( Some(RemainderData { output: remainder, - signing_options: chain, address: remainder_address, }), storage_deposit_returns, diff --git a/sdk/src/client/api/block_builder/input_selection/requirement/account.rs b/sdk/src/client/api/block_builder/input_selection/requirement/account.rs index 72a6fa9abc..87f8cd20cd 100644 --- a/sdk/src/client/api/block_builder/input_selection/requirement/account.rs +++ b/sdk/src/client/api/block_builder/input_selection/requirement/account.rs @@ -26,12 +26,12 @@ pub(crate) fn is_account_with_id_non_null(output: &Output, account_id: &AccountI } } -impl InputSelection { +impl InputSelection { /// Fulfills an account requirement by selecting the appropriate account from the available inputs. pub(crate) fn fulfill_account_requirement( &mut self, account_id: AccountId, - ) -> Result>, Error> { + ) -> Result, Error> { // Check if the requirement is already fulfilled. if let Some(input) = self .selected_inputs 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 78ebeeefe1..e0822901dc 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 @@ -35,8 +35,8 @@ pub(crate) fn sdruc_not_expired( }) } -pub(crate) fn amount_sums( - selected_inputs: &[InputSigningData], +pub(crate) fn amount_sums( + selected_inputs: &[InputSigningData], outputs: &[Output], slot_index: SlotIndex, ) -> (u64, u64, HashMap, HashMap) { @@ -76,8 +76,8 @@ pub(crate) fn amount_sums( } #[derive(Debug, Clone)] -struct AmountSelection { - newly_selected_inputs: HashMap>, +struct AmountSelection { + newly_selected_inputs: HashMap, inputs_sum: u64, outputs_sum: u64, inputs_sdr: HashMap, @@ -87,8 +87,8 @@ struct AmountSelection { slot_index: SlotIndex, } -impl AmountSelection { - fn new(input_selection: &InputSelection) -> Result { +impl AmountSelection { + fn new(input_selection: &InputSelection) -> Result { let (inputs_sum, outputs_sum, inputs_sdr, outputs_sdr) = amount_sums( &input_selection.selected_inputs, &input_selection.outputs, @@ -127,7 +127,7 @@ impl AmountSelection { } } - fn fulfil<'a>(&mut self, inputs: impl Iterator>) -> bool { + fn fulfil<'a>(&mut self, inputs: impl Iterator) -> bool { for input in inputs { if self.newly_selected_inputs.contains_key(input.output_id()) { continue; @@ -161,16 +161,16 @@ impl AmountSelection { false } - fn into_newly_selected_inputs(self) -> Vec> { + fn into_newly_selected_inputs(self) -> Vec { self.newly_selected_inputs.into_values().collect() } } -impl InputSelection { +impl InputSelection { fn fulfil<'a>( &self, - base_inputs: impl Iterator> + Clone, - amount_selection: &mut AmountSelection, + base_inputs: impl Iterator + Clone, + amount_selection: &mut AmountSelection, ) -> bool { // No native token, expired SDRUC. let inputs = base_inputs.clone().filter(|input| { @@ -216,7 +216,7 @@ impl InputSelection { false } - fn reduce_funds_of_chains(&mut self, amount_selection: &mut AmountSelection) -> Result<(), Error> { + fn reduce_funds_of_chains(&mut self, amount_selection: &mut AmountSelection) -> Result<(), Error> { // Only consider automatically transitioned outputs. let outputs = self.outputs.iter_mut().filter(|output| { output @@ -273,7 +273,7 @@ impl InputSelection { }) } - pub(crate) fn fulfill_amount_requirement(&mut self) -> Result>, Error> { + pub(crate) fn fulfill_amount_requirement(&mut self) -> Result, Error> { let mut amount_selection = AmountSelection::new(self)?; if amount_selection.missing_amount() == 0 { @@ -341,8 +341,8 @@ impl InputSelection { fn fulfill_amount_requirement_inner( &mut self, - amount_selection: &mut AmountSelection, - ) -> Option>> { + amount_selection: &mut AmountSelection, + ) -> Option> { let basic_ed25519_inputs = self.available_inputs.iter().filter(|input| { if let Output::Basic(output) = &input.output { output diff --git a/sdk/src/client/api/block_builder/input_selection/requirement/ed25519.rs b/sdk/src/client/api/block_builder/input_selection/requirement/ed25519.rs index 53a4503501..ce6fb8ee6e 100644 --- a/sdk/src/client/api/block_builder/input_selection/requirement/ed25519.rs +++ b/sdk/src/client/api/block_builder/input_selection/requirement/ed25519.rs @@ -4,9 +4,9 @@ use super::{Error, InputSelection, Requirement}; use crate::{client::secret::types::InputSigningData, types::block::address::Address}; -impl InputSelection { +impl InputSelection { // Checks if a selected input unlocks a given ED25519 address. - fn selected_unlocks_ed25519_address(&self, input: &InputSigningData, address: &Address) -> bool { + fn selected_unlocks_ed25519_address(&self, input: &InputSigningData, address: &Address) -> bool { // PANIC: safe to unwrap as outputs with no address have been filtered out already. let required_address = input .output @@ -19,7 +19,7 @@ impl InputSelection { // Checks if an available input can unlock a given ED25519 address. // In case an account input is selected, also tells if it needs to be state or governance transitioned. - fn available_has_ed25519_address(&self, input: &InputSigningData, address: &Address) -> bool { + fn available_has_ed25519_address(&self, input: &InputSigningData, address: &Address) -> bool { let (required_address, _) = input .output .required_and_unlocked_address(self.slot_index, input.output_id()) @@ -29,7 +29,7 @@ impl InputSelection { } /// Fulfills an ed25519 sender requirement by selecting an available input that unlocks its address. - pub(crate) fn fulfill_ed25519_requirement(&mut self, address: &Address) -> Result>, Error> { + pub(crate) fn fulfill_ed25519_requirement(&mut self, address: &Address) -> Result, Error> { // Checks if the requirement is already fulfilled. if let Some(input) = self .selected_inputs diff --git a/sdk/src/client/api/block_builder/input_selection/requirement/foundry.rs b/sdk/src/client/api/block_builder/input_selection/requirement/foundry.rs index cf56b37d4c..f1a2f5be1b 100644 --- a/sdk/src/client/api/block_builder/input_selection/requirement/foundry.rs +++ b/sdk/src/client/api/block_builder/input_selection/requirement/foundry.rs @@ -16,12 +16,12 @@ pub(crate) fn is_foundry_with_id(output: &Output, foundry_id: &FoundryId) -> boo } } -impl InputSelection { +impl InputSelection { /// Fulfills a foundry requirement by selecting the appropriate foundry from the available inputs. pub(crate) fn fulfill_foundry_requirement( &mut self, foundry_id: FoundryId, - ) -> Result>, Error> { + ) -> Result, Error> { // Check if the requirement is already fulfilled. if let Some(input) = self .selected_inputs diff --git a/sdk/src/client/api/block_builder/input_selection/requirement/issuer.rs b/sdk/src/client/api/block_builder/input_selection/requirement/issuer.rs index d955eadd6d..99c961c418 100644 --- a/sdk/src/client/api/block_builder/input_selection/requirement/issuer.rs +++ b/sdk/src/client/api/block_builder/input_selection/requirement/issuer.rs @@ -4,10 +4,10 @@ use super::{Error, InputSelection, Requirement}; use crate::{client::secret::types::InputSigningData, types::block::address::Address}; -impl InputSelection { +impl InputSelection { /// Fulfills an issuer requirement by fulfilling the equivalent sender requirement. /// Potentially converts the error for a more accurate one. - pub(crate) fn fulfill_issuer_requirement(&mut self, address: &Address) -> Result>, Error> { + pub(crate) fn fulfill_issuer_requirement(&mut self, address: &Address) -> Result, Error> { log::debug!("Treating {address:?} issuer requirement as a sender requirement"); match self.fulfill_sender_requirement(address) { 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 512323c2d0..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 @@ -41,10 +41,10 @@ pub enum Requirement { Amount, } -impl InputSelection { +impl InputSelection { /// Fulfills a requirement by selecting the appropriate available inputs. /// Returns the selected inputs and an optional new requirement. - pub(crate) fn fulfill_requirement(&mut self, requirement: Requirement) -> Result>, Error> { + pub(crate) fn fulfill_requirement(&mut self, requirement: Requirement) -> Result, Error> { log::debug!("Fulfilling requirement {requirement:?}"); match requirement { diff --git a/sdk/src/client/api/block_builder/input_selection/requirement/native_tokens.rs b/sdk/src/client/api/block_builder/input_selection/requirement/native_tokens.rs index 6892d7c00d..e355d74dbd 100644 --- a/sdk/src/client/api/block_builder/input_selection/requirement/native_tokens.rs +++ b/sdk/src/client/api/block_builder/input_selection/requirement/native_tokens.rs @@ -23,8 +23,8 @@ pub(crate) fn get_native_tokens<'a>(outputs: impl Iterator) - Ok(required_native_tokens) } -pub(crate) fn get_minted_and_melted_native_tokens( - inputs: &[InputSigningData], +pub(crate) fn get_minted_and_melted_native_tokens( + inputs: &[InputSigningData], outputs: &[Output], ) -> Result<(NativeTokensBuilder, NativeTokensBuilder), Error> { let mut minted_native_tokens = NativeTokensBuilder::new(); @@ -110,8 +110,8 @@ pub(crate) fn get_native_tokens_diff( } } -impl InputSelection { - pub(crate) fn fulfill_native_tokens_requirement(&mut self) -> Result>, Error> { +impl InputSelection { + pub(crate) fn fulfill_native_tokens_requirement(&mut self) -> Result, Error> { let mut input_native_tokens = get_native_tokens(self.selected_inputs.iter().map(|input| &input.output))?; let mut output_native_tokens = get_native_tokens(self.outputs.iter())?; let (minted_native_tokens, melted_native_tokens) = diff --git a/sdk/src/client/api/block_builder/input_selection/requirement/nft.rs b/sdk/src/client/api/block_builder/input_selection/requirement/nft.rs index 3e854b407b..0ae00082c3 100644 --- a/sdk/src/client/api/block_builder/input_selection/requirement/nft.rs +++ b/sdk/src/client/api/block_builder/input_selection/requirement/nft.rs @@ -29,9 +29,9 @@ pub(crate) fn is_nft_with_id_non_null(output: &Output, nft_id: &NftId) -> bool { } } -impl InputSelection { +impl InputSelection { /// Fulfills an nft requirement by selecting the appropriate nft from the available inputs. - pub(crate) fn fulfill_nft_requirement(&mut self, nft_id: NftId) -> Result>, Error> { + pub(crate) fn fulfill_nft_requirement(&mut self, nft_id: NftId) -> Result, Error> { // Check if the requirement is already fulfilled. if let Some(input) = self .selected_inputs diff --git a/sdk/src/client/api/block_builder/input_selection/requirement/sender.rs b/sdk/src/client/api/block_builder/input_selection/requirement/sender.rs index ce4273db5b..e79dfc82cf 100644 --- a/sdk/src/client/api/block_builder/input_selection/requirement/sender.rs +++ b/sdk/src/client/api/block_builder/input_selection/requirement/sender.rs @@ -4,9 +4,9 @@ use super::{Error, InputSelection, Requirement}; use crate::{client::secret::types::InputSigningData, types::block::address::Address}; -impl InputSelection { +impl InputSelection { /// Fulfills a sender requirement by selecting an available input that unlocks its address. - pub(crate) fn fulfill_sender_requirement(&mut self, address: &Address) -> Result>, Error> { + pub(crate) fn fulfill_sender_requirement(&mut self, address: &Address) -> Result, Error> { match address { Address::Ed25519(_) => { log::debug!("Treating {address:?} sender requirement as an ed25519 requirement"); 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 03ca7cbe16..18344028c6 100644 --- a/sdk/src/client/api/block_builder/input_selection/transition.rs +++ b/sdk/src/client/api/block_builder/input_selection/transition.rs @@ -13,7 +13,7 @@ use crate::{ }, }; -impl InputSelection { +impl InputSelection { /// Transitions an account input by creating a new account output if required. fn transition_account_input( &mut self, @@ -149,7 +149,7 @@ impl InputSelection { /// Transitions an input by creating a new output if required. /// If no `account_transition` is provided, assumes a state transition. - pub(crate) fn transition_input(&mut self, input: &InputSigningData) -> Result, Error> { + 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::Foundry(foundry_input) => self.transition_foundry_input(foundry_input, input.output_id()), diff --git a/sdk/src/client/api/block_builder/transaction.rs b/sdk/src/client/api/block_builder/transaction.rs index 772a275e0a..76e01d4991 100644 --- a/sdk/src/client/api/block_builder/transaction.rs +++ b/sdk/src/client/api/block_builder/transaction.rs @@ -25,8 +25,8 @@ const SINGLE_UNLOCK_LENGTH: usize = 1 + 1 + Ed25519Signature::PUBLIC_KEY_LENGTH const REFERENCE_ACCOUNT_NFT_UNLOCK_LENGTH: usize = 1 + 2; /// Verifies the semantic of a prepared transaction. -pub fn verify_semantic( - input_signing_data: &[InputSigningData], +pub fn verify_semantic( + input_signing_data: &[InputSigningData], transaction_payload: &SignedTransactionPayload, ) -> crate::client::Result> { let inputs = input_signing_data diff --git a/sdk/src/client/api/types.rs b/sdk/src/client/api/types.rs index 2cbd4f3f3e..85c30f21ba 100644 --- a/sdk/src/client/api/types.rs +++ b/sdk/src/client/api/types.rs @@ -25,29 +25,29 @@ use crate::{ /// Helper struct for offline signing #[derive(Clone, Debug, Eq, PartialEq)] -pub struct PreparedTransactionData { +pub struct PreparedTransactionData { /// Transaction pub transaction: Transaction, /// Required input information for signing. Inputs need to be ordered by address type - pub inputs_data: Vec>, + pub inputs_data: Vec, /// Optional remainder output information - pub remainder: Option>, + pub remainder: Option, } /// PreparedTransactionData Dto #[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] -pub struct PreparedTransactionDataDto { +pub struct PreparedTransactionDataDto { /// Transaction pub transaction: TransactionDto, /// Required address information for signing - pub inputs_data: Vec>, + pub inputs_data: Vec, /// Optional remainder output information - pub remainder: Option>, + pub remainder: Option, } -impl From<&PreparedTransactionData> for PreparedTransactionDataDto { - fn from(value: &PreparedTransactionData) -> Self { +impl From<&PreparedTransactionData> for PreparedTransactionDataDto { + fn from(value: &PreparedTransactionData) -> Self { Self { transaction: TransactionDto::from(&value.transaction), inputs_data: value.inputs_data.clone(), @@ -56,11 +56,11 @@ impl From<&PreparedTransactionData> for PreparedTransactionDataDto< } } -impl TryFromDto> for PreparedTransactionData { +impl TryFromDto for PreparedTransactionData { type Error = Error; fn try_from_dto_with_params_inner( - dto: PreparedTransactionDataDto, + dto: PreparedTransactionDataDto, params: Option<&ProtocolParameters>, ) -> Result { Ok(Self { @@ -74,25 +74,25 @@ impl TryFromDto> for PreparedTransactionData /// Helper struct for offline signing #[derive(Clone, Debug, Eq, PartialEq)] -pub struct SignedTransactionData { +pub struct SignedTransactionData { /// Signed transaction payload pub payload: SignedTransactionPayload, /// Required address information for signing - pub inputs_data: Vec>, + pub inputs_data: Vec, } /// SignedTransactionData Dto #[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] -pub struct SignedTransactionDataDto { +pub struct SignedTransactionDataDto { /// Signed transaction payload pub payload: SignedTransactionPayloadDto, /// Required address information for signing - pub inputs_data: Vec>, + pub inputs_data: Vec, } -impl From<&SignedTransactionData> for SignedTransactionDataDto { - fn from(value: &SignedTransactionData) -> Self { +impl From<&SignedTransactionData> for SignedTransactionDataDto { + fn from(value: &SignedTransactionData) -> Self { Self { payload: SignedTransactionPayloadDto::from(&value.payload), inputs_data: value.inputs_data.clone(), @@ -100,11 +100,11 @@ impl From<&SignedTransactionData> for SignedTransactionDataDto { } } -impl TryFromDto> for SignedTransactionData { +impl TryFromDto for SignedTransactionData { type Error = Error; fn try_from_dto_with_params_inner( - dto: SignedTransactionDataDto, + dto: SignedTransactionDataDto, params: Option<&ProtocolParameters>, ) -> Result { Ok(Self { @@ -117,11 +117,9 @@ impl TryFromDto> for SignedTransactionData { /// Data for a remainder output, used for ledger nano #[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] -pub struct RemainderData { +pub struct RemainderData { /// The remainder output pub output: Output, - /// The signing options for the remainder addresses - pub signing_options: Option, /// The remainder address pub address: Address, } diff --git a/sdk/src/client/secret/ledger_nano.rs b/sdk/src/client/secret/ledger_nano.rs index ffac04f8b6..229fb66ad5 100644 --- a/sdk/src/client/secret/ledger_nano.rs +++ b/sdk/src/client/secret/ledger_nano.rs @@ -313,8 +313,9 @@ impl Sign for LedgerSecretManager { impl SignTransaction for LedgerSecretManager { async fn transaction_unlocks( &self, - prepared_transaction: &PreparedTransactionData, + prepared_transaction: &PreparedTransactionData, _protocol_parameters: &ProtocolParameters, + chain: &Self::Options, ) -> crate::client::Result { let mut input_bip32_indices = Vec::new(); let mut coin_type = None; @@ -323,8 +324,6 @@ impl SignTransaction for LedgerSecretManager { let input_len = prepared_transaction.inputs_data.len(); for input in &prepared_transaction.inputs_data { - let chain = input.signing_options.ok_or(Error::MissingBip32Chain)?; - // coin_type and account_index should be the same in each output if (coin_type.is_some() && coin_type != Some(chain.coin_type)) || (account_index.is_some() && account_index != Some(chain.account)) @@ -371,19 +370,13 @@ impl SignTransaction for LedgerSecretManager { // figure out the remainder output and bip32 index (if there is one) #[allow(clippy::option_if_let_else)] let (remainder_output, remainder_bip32) = match &prepared_transaction.remainder { - Some(remainder) => { - if let Some(chain) = remainder.signing_options { - ( - Some(&remainder.output), - LedgerBIP32Index { - bip32_change: chain.change.harden().into(), - bip32_index: chain.address_index.harden().into(), - }, - ) - } else { - (None, LedgerBIP32Index::default()) - } - } + Some(remainder) => ( + Some(&remainder.output), + LedgerBIP32Index { + bip32_change: chain.change.harden().into(), + bip32_index: chain.address_index.harden().into(), + }, + ), None => (None, LedgerBIP32Index::default()), }; @@ -492,7 +485,7 @@ impl SecretManagerConfig for LedgerSecretManager { /// is signed but only with BasicOutputs, without extra-features and if the transaction is not too large. /// If criteria are not met, blind signing is needed. /// This method finds out if we have to switch to blind signing mode. -pub fn needs_blind_signing(prepared_transaction: &PreparedTransactionData, buffer_size: usize) -> bool { +pub fn needs_blind_signing(prepared_transaction: &PreparedTransactionData, buffer_size: usize) -> bool { if !prepared_transaction .transaction .outputs() @@ -576,7 +569,7 @@ impl LedgerSecretManager { // Merge signature unlocks with Account/Nft/Reference unlocks fn merge_unlocks( - prepared_transaction_data: &PreparedTransactionData, + prepared_transaction_data: &PreparedTransactionData, mut unlocks: impl Iterator, ) -> Result, Error> { let slot_index = prepared_transaction_data.transaction.creation_slot(); diff --git a/sdk/src/client/secret/mod.rs b/sdk/src/client/secret/mod.rs index 9c832d564b..f298b1ec63 100644 --- a/sdk/src/client/secret/mod.rs +++ b/sdk/src/client/secret/mod.rs @@ -200,8 +200,9 @@ pub trait SignTransaction: Sign { async fn transaction_unlocks( &self, - prepared_transaction_data: &PreparedTransactionData, + prepared_transaction_data: &PreparedTransactionData, _protocol_parameters: &ProtocolParameters, + options: &Self::Options, ) -> crate::client::Result { let transaction_signing_hash = prepared_transaction_data.transaction.signing_hash(); let mut blocks = Vec::new(); @@ -239,8 +240,6 @@ pub trait SignTransaction: Sign { _ => Err(InputSelectionError::MissingInputWithEd25519Address)?, } - let options = input.signing_options.as_ref().ok_or(Error::MissingSigningOptions)?; - let block = self.signature_unlock(&transaction_signing_hash, options).await?; blocks.push(block.into()); @@ -271,13 +270,14 @@ pub trait SignTransaction: Sign { async fn sign_transaction( &self, - prepared_transaction_data: PreparedTransactionData, + prepared_transaction_data: PreparedTransactionData, protocol_parameters: &ProtocolParameters, + options: &Self::Options, ) -> crate::client::Result { log::debug!("[sign_transaction] {:?}", prepared_transaction_data); let unlocks = self - .transaction_unlocks(&prepared_transaction_data, protocol_parameters) + .transaction_unlocks(&prepared_transaction_data, protocol_parameters, options) .await?; let PreparedTransactionData { diff --git a/sdk/src/client/secret/types.rs b/sdk/src/client/secret/types.rs index 931705a1fb..8aa4047bb5 100644 --- a/sdk/src/client/secret/types.rs +++ b/sdk/src/client/secret/types.rs @@ -115,15 +115,14 @@ impl LedgerNanoStatus { /// Data for transaction inputs for signing and ordering of unlock blocks #[derive(Clone, Debug, Eq, PartialEq, Hash, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] -pub struct InputSigningData { +pub struct InputSigningData { /// The output pub output: Output, /// The output metadata pub output_metadata: OutputMetadata, - pub signing_options: Option, } -impl InputSigningData { +impl InputSigningData { /// Return the [OutputId] pub fn output_id(&self) -> &OutputId { self.output_metadata.output_id() diff --git a/sdk/src/wallet/core/mod.rs b/sdk/src/wallet/core/mod.rs index 90b015acd2..ea47dba06e 100644 --- a/sdk/src/wallet/core/mod.rs +++ b/sdk/src/wallet/core/mod.rs @@ -23,10 +23,7 @@ use crate::wallet::events::{ #[cfg(feature = "storage")] use crate::wallet::storage::{StorageManager, StorageOptions}; use crate::{ - client::{ - secret::{SecretManage, SecretManager}, - verify_mnemonic, Client, - }, + client::{secret::SecretManage, verify_mnemonic, Client}, types::{ block::{ address::{Address, Bech32Address, Hrp, ImplicitAccountCreationAddress}, @@ -83,7 +80,7 @@ pub struct WalletInner { pub(crate) client: Client, pub(crate) secret_manager: Arc>, #[cfg(feature = "events")] - pub(crate) event_emitter: tokio::sync::RwLock>, + pub(crate) event_emitter: tokio::sync::RwLock, #[cfg(feature = "storage")] pub(crate) storage_options: StorageOptions, #[cfg(feature = "storage")] @@ -102,14 +99,14 @@ pub struct WalletData { pub(crate) alias: Option, /// Outputs // stored separated from the wallet for performance? - pub(crate) outputs: HashMap>, + pub(crate) outputs: HashMap, /// Unspent outputs that are currently used as input for transactions // outputs used in transactions should be locked here so they don't get used again, which would result in a // conflicting transaction pub(crate) locked_outputs: HashSet, /// Unspent outputs // have unspent outputs in a separated hashmap so we don't need to iterate over all outputs we have - pub(crate) unspent_outputs: HashMap>, + pub(crate) unspent_outputs: HashMap, /// Sent transactions // stored separated from the wallet for performance and only the transaction id here? where to add the network id? // transactions: HashSet, @@ -152,9 +149,9 @@ impl WalletData { } fn filter_outputs<'a>( - outputs: impl Iterator>, + outputs: impl Iterator, filter: FilterOptions, - ) -> impl Iterator> { + ) -> impl Iterator { outputs.filter(move |output| { match &output.output { Output::Account(account) => { @@ -242,30 +239,27 @@ impl WalletData { } /// Returns outputs map of the wallet. - pub fn outputs(&self) -> &HashMap> { + pub fn outputs(&self) -> &HashMap { &self.outputs } /// Returns unspent outputs map of the wallet. - pub fn unspent_outputs(&self) -> &HashMap> { + pub fn unspent_outputs(&self) -> &HashMap { &self.unspent_outputs } /// Returns outputs of the wallet. - pub fn filtered_outputs(&self, filter: FilterOptions) -> impl Iterator> { + pub fn filtered_outputs(&self, filter: FilterOptions) -> impl Iterator { Self::filter_outputs(self.outputs.values(), filter) } /// Returns unspent outputs of the wallet. - pub fn filtered_unspent_outputs( - &self, - filter: FilterOptions, - ) -> impl Iterator> { + pub fn filtered_unspent_outputs(&self, filter: FilterOptions) -> impl Iterator { Self::filter_outputs(self.unspent_outputs.values(), filter) } /// Gets the unspent account output matching the given ID. - pub fn unspent_account_output(&self, account_id: &AccountId) -> Option<&OutputData> { + pub fn unspent_account_output(&self, account_id: &AccountId) -> Option<&OutputData> { self.filtered_unspent_outputs(FilterOptions { account_ids: Some([*account_id].into()), ..Default::default() @@ -274,7 +268,7 @@ impl WalletData { } /// Gets the unspent anchor output matching the given ID. - pub fn unspent_anchor_output(&self, anchor_id: &AnchorId) -> Option<&OutputData> { + pub fn unspent_anchor_output(&self, anchor_id: &AnchorId) -> Option<&OutputData> { self.filtered_unspent_outputs(FilterOptions { anchor_ids: Some([*anchor_id].into()), ..Default::default() @@ -283,7 +277,7 @@ impl WalletData { } /// Gets the unspent foundry output matching the given ID. - pub fn unspent_foundry_output(&self, foundry_id: &FoundryId) -> Option<&OutputData> { + pub fn unspent_foundry_output(&self, foundry_id: &FoundryId) -> Option<&OutputData> { self.filtered_unspent_outputs(FilterOptions { foundry_ids: Some([*foundry_id].into()), ..Default::default() @@ -292,7 +286,7 @@ impl WalletData { } /// Gets the unspent nft output matching the given ID. - pub fn unspent_nft_output(&self, nft_id: &NftId) -> Option<&OutputData> { + pub fn unspent_nft_output(&self, nft_id: &NftId) -> Option<&OutputData> { self.filtered_unspent_outputs(FilterOptions { nft_ids: Some([*nft_id].into()), ..Default::default() @@ -301,7 +295,7 @@ impl WalletData { } /// Gets the unspent delegation output matching the given ID. - pub fn unspent_delegation_output(&self, delegation_id: &DelegationId) -> Option<&OutputData> { + pub fn unspent_delegation_output(&self, delegation_id: &DelegationId) -> Option<&OutputData> { self.filtered_unspent_outputs(FilterOptions { delegation_ids: Some([*delegation_id].into()), ..Default::default() @@ -310,21 +304,21 @@ impl WalletData { } /// Returns implicit accounts of the wallet. - pub fn implicit_accounts(&self) -> impl Iterator> { + pub fn implicit_accounts(&self) -> impl Iterator { self.unspent_outputs .values() .filter(|output_data| output_data.output.is_implicit_account()) } /// Returns accounts of the wallet. - pub fn accounts(&self) -> impl Iterator> { + pub fn accounts(&self) -> impl Iterator { self.unspent_outputs .values() .filter(|output_data| output_data.output.is_account()) } /// Get the [`OutputData`] of an output stored in the wallet. - pub fn get_output(&self, output_id: &OutputId) -> Option<&OutputData> { + pub fn get_output(&self, output_id: &OutputId) -> Option<&OutputData> { self.outputs.get(output_id) } @@ -485,7 +479,7 @@ impl Wallet { } #[cfg(feature = "events")] - pub(crate) async fn emit(&self, wallet_event: super::events::types::WalletEvent) { + pub(crate) async fn emit(&self, wallet_event: super::events::types::WalletEvent) { self.inner.emit(wallet_event).await } @@ -539,7 +533,7 @@ impl WalletInner { pub async fn listen + Send>(&self, events: I, handler: F) where I::IntoIter: Send, - F: Fn(&WalletEvent) + 'static + Send + Sync, + F: Fn(&WalletEvent) + 'static + Send + Sync, { let mut emitter = self.event_emitter.write().await; emitter.on(events, handler); @@ -568,14 +562,14 @@ impl WalletInner { } #[cfg(feature = "events")] - pub(crate) async fn emit(&self, event: crate::wallet::events::types::WalletEvent) { + pub(crate) async fn emit(&self, event: crate::wallet::events::types::WalletEvent) { self.event_emitter.read().await.emit(event); } /// Helper function to test events. #[cfg(feature = "events")] #[cfg_attr(docsrs, doc(cfg(feature = "events")))] - pub async fn emit_test_event(&self, event: crate::wallet::events::types::WalletEvent) { + pub async fn emit_test_event(&self, event: crate::wallet::events::types::WalletEvent) { self.emit(event).await } } @@ -594,9 +588,9 @@ pub struct WalletDataDto { pub signing_options: S, pub address: Bech32Address, pub alias: Option, - pub outputs: HashMap>, + pub outputs: HashMap, pub locked_outputs: HashSet, - pub unspent_outputs: HashMap>, + pub unspent_outputs: HashMap, pub transactions: HashMap, pub pending_transactions: HashSet, pub incoming_transactions: HashMap, diff --git a/sdk/src/wallet/events/mod.rs b/sdk/src/wallet/events/mod.rs index f5765a7153..e908a0d1f9 100644 --- a/sdk/src/wallet/events/mod.rs +++ b/sdk/src/wallet/events/mod.rs @@ -13,11 +13,11 @@ pub use self::types::{WalletEvent, WalletEventType}; type Handler = Arc; -pub struct EventEmitter { - handlers: HashMap>>>, +pub struct EventEmitter { + handlers: HashMap>>, } -impl EventEmitter { +impl EventEmitter { /// Creates a new instance of `EventEmitter`. pub fn new() -> Self { Self { @@ -29,7 +29,7 @@ impl EventEmitter { /// multiple listeners for a single event. pub fn on(&mut self, events: impl IntoIterator, handler: F) where - F: Fn(&WalletEvent) + 'static + Send + Sync, + F: Fn(&WalletEvent) + 'static + Send + Sync, { let mut events = events.into_iter().peekable(); let handler = Arc::new(handler); @@ -68,7 +68,7 @@ impl EventEmitter { /// Invokes all listeners of `event`, passing a reference to `payload` as an /// argument to each of them. - pub fn emit(&self, event: WalletEvent) { + pub fn emit(&self, event: WalletEvent) { let event_type = match &event { WalletEvent::NewOutput(_) => WalletEventType::NewOutput, WalletEvent::SpentOutput(_) => WalletEventType::SpentOutput, @@ -86,13 +86,13 @@ impl EventEmitter { } } -impl Default for EventEmitter { +impl Default for EventEmitter { fn default() -> Self { Self::new() } } -impl Debug for EventEmitter { +impl Debug for EventEmitter { fn fmt(&self, f: &mut Formatter<'_>) -> Result { write!( f, @@ -122,7 +122,7 @@ mod tests { #[test] fn events() { - let mut emitter = EventEmitter::<()>::new(); + let mut emitter = EventEmitter::new(); let event_counter = Arc::new(AtomicUsize::new(0)); // single event diff --git a/sdk/src/wallet/events/types.rs b/sdk/src/wallet/events/types.rs index 04c3b0aa1a..bb08fff0bd 100644 --- a/sdk/src/wallet/events/types.rs +++ b/sdk/src/wallet/events/types.rs @@ -13,52 +13,49 @@ use crate::{ payload::signed_transaction::{dto::SignedTransactionPayloadDto, TransactionId}, }, }, - wallet::{ - types::{InclusionState, OutputData}, - Error, - }, + wallet::{types::InclusionState, Error, OutputData}, }; #[derive(Clone, Debug, Eq, PartialEq)] #[non_exhaustive] -pub enum WalletEvent { +pub enum WalletEvent { ConsolidationRequired, #[cfg(feature = "ledger_nano")] #[cfg_attr(docsrs, doc(cfg(feature = "ledger_nano")))] LedgerAddressGeneration(AddressData), - NewOutput(Box>), - SpentOutput(Box>), + NewOutput(Box), + SpentOutput(Box), TransactionInclusion(TransactionInclusionEvent), - TransactionProgress(TransactionProgressEvent), + TransactionProgress(TransactionProgressEvent), } -impl Serialize for WalletEvent { +impl Serialize for WalletEvent { fn serialize(&self, serializer: S) -> Result where S: Serializer, { #[derive(Serialize)] - struct TransactionProgressEvent_<'a, O> { - progress: &'a TransactionProgressEvent, + struct TransactionProgressEvent_<'a> { + progress: &'a TransactionProgressEvent, } #[derive(Serialize)] #[serde(untagged)] - enum WalletEvent_<'a, O> { + enum WalletEvent_<'a> { T0, #[cfg(feature = "ledger_nano")] T1(&'a AddressData), - T2(&'a NewOutputEvent), - T3(&'a SpentOutputEvent), + T2(&'a NewOutputEvent), + T3(&'a SpentOutputEvent), T4(&'a TransactionInclusionEvent), - T5(TransactionProgressEvent_<'a, O>), + T5(TransactionProgressEvent_<'a>), } #[derive(Serialize)] - struct TypedWalletEvent_<'a, O> { + struct TypedWalletEvent_<'a> { #[serde(rename = "type")] kind: u8, #[serde(flatten)] - event: WalletEvent_<'a, O>, + event: WalletEvent_<'a>, } let event = match self { Self::ConsolidationRequired => TypedWalletEvent_ { @@ -91,11 +88,11 @@ impl Serialize for WalletEvent { } } -impl<'de, O: Deserialize<'de>> Deserialize<'de> for WalletEvent { +impl<'de> Deserialize<'de> for WalletEvent { fn deserialize>(d: D) -> Result { #[derive(Deserialize)] - struct TransactionProgressEvent_ { - progress: TransactionProgressEvent, + struct TransactionProgressEvent_ { + progress: TransactionProgressEvent, } let value = serde_json::Value::deserialize(d)?; @@ -176,9 +173,9 @@ impl TryFrom for WalletEventType { #[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] -pub struct NewOutputEvent { +pub struct NewOutputEvent { /// The new output. - pub output: OutputData, + pub output: OutputData, /// The transaction that created the output. Might be pruned and not available. #[serde(skip_serializing_if = "Option::is_none")] pub transaction: Option, @@ -188,9 +185,9 @@ pub struct NewOutputEvent { } #[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] -pub struct SpentOutputEvent { +pub struct SpentOutputEvent { /// The spent output. - pub output: OutputData, + pub output: OutputData, } #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] @@ -202,13 +199,13 @@ pub struct TransactionInclusionEvent { #[derive(Clone, Debug, Eq, PartialEq)] #[non_exhaustive] -pub enum TransactionProgressEvent { +pub enum TransactionProgressEvent { /// Performing input selection. SelectingInputs, /// Generating remainder value deposit address. GeneratingRemainderDepositAddress(AddressData), /// Prepared transaction. - PreparedTransaction(Box>), + PreparedTransaction(Box), /// Prepared transaction signing hash hex encoded, required for blindsigning with a ledger nano PreparedTransactionSigningHash(String), /// Signing the transaction. @@ -217,7 +214,7 @@ pub enum TransactionProgressEvent { Broadcasting, } -impl Serialize for TransactionProgressEvent { +impl Serialize for TransactionProgressEvent { fn serialize(&self, serializer: S) -> Result where S: Serializer, @@ -230,20 +227,20 @@ impl Serialize for TransactionProgressEvent { #[derive(Serialize)] #[serde(untagged)] - enum TransactionProgressEvent_<'a, O> { + enum TransactionProgressEvent_<'a> { T0, T1(&'a AddressData), - T2(&'a PreparedTransactionDataDto), + T2(&'a PreparedTransactionDataDto), T3(PreparedTransactionSigningHash_<'a>), T4, T5, } #[derive(Serialize)] - struct TypedTransactionProgressEvent_<'a, O> { + struct TypedTransactionProgressEvent_<'a> { #[serde(rename = "type")] kind: u8, #[serde(flatten)] - event: TransactionProgressEvent_<'a, O>, + event: TransactionProgressEvent_<'a>, } let event = match self { Self::SelectingInputs => TypedTransactionProgressEvent_ { @@ -275,7 +272,7 @@ impl Serialize for TransactionProgressEvent { } } -impl<'de, O: Deserialize<'de>> Deserialize<'de> for TransactionProgressEvent { +impl<'de> Deserialize<'de> for TransactionProgressEvent { fn deserialize>(d: D) -> Result { #[derive(Deserialize)] #[serde(rename_all = "camelCase")] diff --git a/sdk/src/wallet/operations/helpers/time.rs b/sdk/src/wallet/operations/helpers/time.rs index cabbefbb8d..ebd3675688 100644 --- a/sdk/src/wallet/operations/helpers/time.rs +++ b/sdk/src/wallet/operations/helpers/time.rs @@ -7,9 +7,9 @@ use crate::{ }; // Check if an output can be unlocked by the wallet address at the current time -pub(crate) fn can_output_be_unlocked_now( +pub(crate) fn can_output_be_unlocked_now( wallet_address: &Address, - output_data: &OutputData, + output_data: &OutputData, slot_index: SlotIndex, ) -> crate::wallet::Result { if let Some(unlock_conditions) = output_data.output.unlock_conditions() { diff --git a/sdk/src/wallet/operations/output_claiming.rs b/sdk/src/wallet/operations/output_claiming.rs index 819f4ee999..2e887bc1f4 100644 --- a/sdk/src/wallet/operations/output_claiming.rs +++ b/sdk/src/wallet/operations/output_claiming.rs @@ -142,16 +142,14 @@ impl Wallet { /// Get basic outputs that have only one unlock condition which is [AddressUnlockCondition], so they can be used as /// additional inputs - pub(crate) async fn get_basic_outputs_for_additional_inputs( - &self, - ) -> crate::wallet::Result>> { + pub(crate) async fn get_basic_outputs_for_additional_inputs(&self) -> crate::wallet::Result> { log::debug!("[OUTPUT_CLAIMING] get_basic_outputs_for_additional_inputs"); #[cfg(feature = "participation")] let voting_output = self.get_voting_output().await?; let wallet_data = self.data().await; // Get basic outputs only with AddressUnlockCondition and no other unlock condition - let mut basic_outputs: Vec> = Vec::new(); + let mut basic_outputs: Vec = Vec::new(); for (output_id, output_data) in &wallet_data.unspent_outputs { #[cfg(feature = "participation")] if let Some(ref voting_output) = voting_output { @@ -220,7 +218,7 @@ impl Wallet { pub async fn prepare_claim_outputs + Send>( &self, output_ids_to_claim: I, - ) -> crate::wallet::Result> + ) -> crate::wallet::Result where I::IntoIter: Send, { diff --git a/sdk/src/wallet/operations/output_consolidation.rs b/sdk/src/wallet/operations/output_consolidation.rs index a671ddcde9..2de51f570c 100644 --- a/sdk/src/wallet/operations/output_consolidation.rs +++ b/sdk/src/wallet/operations/output_consolidation.rs @@ -68,7 +68,7 @@ impl ConsolidationParams { impl Wallet { fn should_consolidate_output( &self, - output_data: &OutputData, + output_data: &OutputData, slot_index: SlotIndex, wallet_address: &Address, ) -> Result { @@ -115,10 +115,7 @@ impl Wallet { } /// Prepares the transaction for [Wallet::consolidate_outputs()]. - pub async fn prepare_consolidate_outputs( - &self, - params: ConsolidationParams, - ) -> Result> { + pub async fn prepare_consolidate_outputs(&self, params: ConsolidationParams) -> Result { log::debug!("[OUTPUT_CONSOLIDATION] prepare consolidating outputs if needed"); #[cfg(feature = "participation")] let voting_output = self.get_voting_output().await?; diff --git a/sdk/src/wallet/operations/participation/mod.rs b/sdk/src/wallet/operations/participation/mod.rs index 8d31b45800..28690f3380 100644 --- a/sdk/src/wallet/operations/participation/mod.rs +++ b/sdk/src/wallet/operations/participation/mod.rs @@ -219,7 +219,7 @@ impl Wallet { /// Returns the voting output ("PARTICIPATION" tag). /// /// If multiple outputs with this tag exist, the one with the largest amount will be returned. - pub async fn get_voting_output(&self) -> Result>> { + pub async fn get_voting_output(&self) -> Result> { self.data().await.get_voting_output() } @@ -277,7 +277,7 @@ impl WalletData { /// Returns the voting output ("PARTICIPATION" tag). /// /// If multiple outputs with this tag exist, the one with the largest amount will be returned. - pub(crate) fn get_voting_output(&self) -> Result>> { + pub(crate) fn get_voting_output(&self) -> Result> { log::debug!("[get_voting_output]"); Ok(self .unspent_outputs diff --git a/sdk/src/wallet/operations/participation/voting.rs b/sdk/src/wallet/operations/participation/voting.rs index a4dc030be3..cb7a62ead5 100644 --- a/sdk/src/wallet/operations/participation/voting.rs +++ b/sdk/src/wallet/operations/participation/voting.rs @@ -45,7 +45,7 @@ impl Wallet { &self, event_id: impl Into> + Send, answers: impl Into>> + Send, - ) -> Result> { + ) -> Result { let event_id = event_id.into(); let answers = answers.into(); if let Some(event_id) = event_id { @@ -131,10 +131,7 @@ impl Wallet { } /// Prepares the transaction for [Wallet::stop_participating()]. - pub async fn prepare_stop_participating( - &self, - event_id: ParticipationEventId, - ) -> Result> { + pub async fn prepare_stop_participating(&self, event_id: ParticipationEventId) -> Result { let voting_output = self .get_voting_output() .await? diff --git a/sdk/src/wallet/operations/participation/voting_power.rs b/sdk/src/wallet/operations/participation/voting_power.rs index 7a4f5fb424..cca6c50b4a 100644 --- a/sdk/src/wallet/operations/participation/voting_power.rs +++ b/sdk/src/wallet/operations/participation/voting_power.rs @@ -44,10 +44,7 @@ impl Wallet { } /// Prepares the transaction for [Wallet::increase_voting_power()]. - pub async fn prepare_increase_voting_power( - &self, - amount: u64, - ) -> Result> { + pub async fn prepare_increase_voting_power(&self, amount: u64) -> Result { let (new_output, tx_options) = match self.get_voting_output().await? { Some(current_output_data) => { let output = current_output_data.output.as_basic(); @@ -95,10 +92,7 @@ impl Wallet { } /// Prepares the transaction for [Wallet::decrease_voting_power()]. - pub async fn prepare_decrease_voting_power( - &self, - amount: u64, - ) -> Result> { + pub async fn prepare_decrease_voting_power(&self, amount: u64) -> Result { let current_output_data = self .get_voting_output() .await? diff --git a/sdk/src/wallet/operations/syncing/addresses/outputs.rs b/sdk/src/wallet/operations/syncing/addresses/outputs.rs index d6f374854e..a2db37f604 100644 --- a/sdk/src/wallet/operations/syncing/addresses/outputs.rs +++ b/sdk/src/wallet/operations/syncing/addresses/outputs.rs @@ -18,7 +18,7 @@ impl Wallet { pub(crate) async fn get_outputs_from_address_output_ids( &self, addresses_with_unspent_outputs: Vec, - ) -> crate::wallet::Result<(Vec, Vec>)> { + ) -> crate::wallet::Result<(Vec, Vec)> { log::debug!("[SYNC] start get_outputs_from_address_output_ids"); let address_outputs_start_time = Instant::now(); @@ -47,7 +47,7 @@ impl Wallet { } let results = futures::future::try_join_all(tasks).await?; for res in results { - let (address, outputs): (AddressWithUnspentOutputs, Vec>) = res?; + let (address, outputs): (AddressWithUnspentOutputs, Vec) = res?; addresses_with_outputs.push(address); outputs_data.extend(outputs); } diff --git a/sdk/src/wallet/operations/syncing/mod.rs b/sdk/src/wallet/operations/syncing/mod.rs index d1cc51c6f0..31ff45f093 100644 --- a/sdk/src/wallet/operations/syncing/mod.rs +++ b/sdk/src/wallet/operations/syncing/mod.rs @@ -111,7 +111,7 @@ impl Wallet { let (addresses_with_unspent_outputs, spent_or_not_synced_output_ids, outputs_data): ( Vec, Vec, - Vec>, + Vec, ) = self.request_outputs_recursively(address_to_sync, options).await?; // Request possible spent outputs @@ -166,11 +166,7 @@ impl Wallet { &self, addresses_to_sync: Vec, options: &SyncOptions, - ) -> crate::wallet::Result<( - Vec, - Vec, - Vec>, - )> { + ) -> crate::wallet::Result<(Vec, Vec, Vec)> { // Cache the account and nft address with the related ed2559 address, so we can update the account address with // the new output ids diff --git a/sdk/src/wallet/operations/syncing/outputs.rs b/sdk/src/wallet/operations/syncing/outputs.rs index 0213d2662e..06aec25554 100644 --- a/sdk/src/wallet/operations/syncing/outputs.rs +++ b/sdk/src/wallet/operations/syncing/outputs.rs @@ -27,7 +27,7 @@ impl Wallet { &self, outputs_with_meta: Vec, associated_address: &AddressWithUnspentOutputs, - ) -> crate::wallet::Result>> { + ) -> crate::wallet::Result> { log::debug!("[SYNC] convert output_responses"); // store outputs with network_id let network_id = self.client().get_network_id().await?; @@ -51,9 +51,6 @@ impl Wallet { address: associated_address.address.inner.clone(), network_id, remainder, - // TODO: previously we set the internal and address index here, but - // they were always default values anyway. Do we need some mechanism here tho? - signing_options: Some(wallet_data.signing_options.clone()), } }) .collect()) diff --git a/sdk/src/wallet/operations/transaction/account.rs b/sdk/src/wallet/operations/transaction/account.rs index 2301e96848..0732cc1256 100644 --- a/sdk/src/wallet/operations/transaction/account.rs +++ b/sdk/src/wallet/operations/transaction/account.rs @@ -42,7 +42,7 @@ impl Wallet { &self, output_id: &OutputId, key_source: impl Into>> + Send, - ) -> Result> { + ) -> Result { 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 { diff --git a/sdk/src/wallet/operations/transaction/build_transaction.rs b/sdk/src/wallet/operations/transaction/build_transaction.rs index 34fb960422..3651052793 100644 --- a/sdk/src/wallet/operations/transaction/build_transaction.rs +++ b/sdk/src/wallet/operations/transaction/build_transaction.rs @@ -19,16 +19,16 @@ impl Wallet { /// Builds the transaction from the selected in and outputs. pub(crate) async fn build_transaction( &self, - selected_transaction_data: Selected, + selected_transaction_data: Selected, options: impl Into> + Send, - ) -> crate::wallet::Result> { + ) -> crate::wallet::Result { log::debug!("[TRANSACTION] build_transaction"); let build_transaction_start_time = Instant::now(); let protocol_parameters = self.client().get_protocol_parameters().await?; let mut inputs: Vec = Vec::new(); - let mut inputs_for_signing: Vec> = Vec::new(); + let mut inputs_for_signing: Vec = Vec::new(); for utxo in &selected_transaction_data.inputs { let input = Input::Utxo(UtxoInput::from(*utxo.output_id())); diff --git a/sdk/src/wallet/operations/transaction/high_level/burning_melting/melt_native_token.rs b/sdk/src/wallet/operations/transaction/high_level/burning_melting/melt_native_token.rs index d42d2b6743..ee17b2f5d9 100644 --- a/sdk/src/wallet/operations/transaction/high_level/burning_melting/melt_native_token.rs +++ b/sdk/src/wallet/operations/transaction/high_level/burning_melting/melt_native_token.rs @@ -43,7 +43,7 @@ impl Wallet { token_id: TokenId, melt_amount: impl Into + Send, options: impl Into> + Send, - ) -> crate::wallet::Result> { + ) -> crate::wallet::Result { log::debug!("[TRANSACTION] prepare_melt_native_token"); let foundry_id = FoundryId::from(token_id); @@ -86,7 +86,7 @@ impl Wallet { &self, account_id: AccountId, foundry_id: FoundryId, - ) -> crate::wallet::Result<(OutputData, OutputData)> { + ) -> crate::wallet::Result<(OutputData, OutputData)> { let mut existing_account_output_data = None; let mut existing_foundry_output = None; diff --git a/sdk/src/wallet/operations/transaction/high_level/burning_melting/mod.rs b/sdk/src/wallet/operations/transaction/high_level/burning_melting/mod.rs index be341e5e86..1d22610a7b 100644 --- a/sdk/src/wallet/operations/transaction/high_level/burning_melting/mod.rs +++ b/sdk/src/wallet/operations/transaction/high_level/burning_melting/mod.rs @@ -38,7 +38,7 @@ impl Wallet { &self, burn: impl Into + Send, options: impl Into> + Send, - ) -> crate::wallet::Result> { + ) -> crate::wallet::Result { let mut options: TransactionOptions = options.into().unwrap_or_default(); options.burn = Some(burn.into()); diff --git a/sdk/src/wallet/operations/transaction/high_level/create_account.rs b/sdk/src/wallet/operations/transaction/high_level/create_account.rs index 1a26dd21d3..c9adb9cfc5 100644 --- a/sdk/src/wallet/operations/transaction/high_level/create_account.rs +++ b/sdk/src/wallet/operations/transaction/high_level/create_account.rs @@ -67,7 +67,7 @@ impl Wallet { &self, params: Option, options: impl Into> + Send, - ) -> crate::wallet::Result> { + ) -> crate::wallet::Result { log::debug!("[TRANSACTION] prepare_create_account_output"); let storage_score_params = self.client().get_storage_score_parameters().await?; @@ -104,10 +104,7 @@ impl Wallet { } /// Gets an existing account output. - pub(crate) async fn get_account_output( - &self, - account_id: Option, - ) -> Option<(AccountId, OutputData)> { + pub(crate) async fn get_account_output(&self, account_id: Option) -> Option<(AccountId, OutputData)> { log::debug!("[get_account_output]"); self.data() .await diff --git a/sdk/src/wallet/operations/transaction/high_level/minting/create_native_token.rs b/sdk/src/wallet/operations/transaction/high_level/minting/create_native_token.rs index dc957dabf3..38d5886117 100644 --- a/sdk/src/wallet/operations/transaction/high_level/minting/create_native_token.rs +++ b/sdk/src/wallet/operations/transaction/high_level/minting/create_native_token.rs @@ -64,21 +64,21 @@ impl From<&CreateNativeTokenTransaction> for CreateNativeTokenTransactionDto { /// The result of preparing a transaction to create a native token #[derive(Debug)] -pub struct PreparedCreateNativeTokenTransaction { +pub struct PreparedCreateNativeTokenTransaction { pub token_id: TokenId, - pub transaction: PreparedTransactionData, + pub transaction: PreparedTransactionData, } /// Dto for PreparedNativeTokenTransaction #[derive(Debug, Eq, PartialEq, Serialize)] #[serde(rename_all = "camelCase")] -pub struct PreparedCreateNativeTokenTransactionDto { +pub struct PreparedCreateNativeTokenTransactionDto { pub token_id: TokenId, - pub transaction: PreparedTransactionDataDto, + pub transaction: PreparedTransactionDataDto, } -impl From<&PreparedCreateNativeTokenTransaction> for PreparedCreateNativeTokenTransactionDto { - fn from(value: &PreparedCreateNativeTokenTransaction) -> Self { +impl From<&PreparedCreateNativeTokenTransaction> for PreparedCreateNativeTokenTransactionDto { + fn from(value: &PreparedCreateNativeTokenTransaction) -> Self { Self { token_id: value.token_id, transaction: PreparedTransactionDataDto::from(&value.transaction), @@ -126,7 +126,7 @@ impl Wallet { &self, params: CreateNativeTokenParams, options: impl Into> + Send, - ) -> crate::wallet::Result> { + ) -> crate::wallet::Result { log::debug!("[TRANSACTION] create_native_token"); let storage_score_params = self.client().get_storage_score_parameters().await?; diff --git a/sdk/src/wallet/operations/transaction/high_level/minting/mint_native_token.rs b/sdk/src/wallet/operations/transaction/high_level/minting/mint_native_token.rs index 3107c193c4..87a233f898 100644 --- a/sdk/src/wallet/operations/transaction/high_level/minting/mint_native_token.rs +++ b/sdk/src/wallet/operations/transaction/high_level/minting/mint_native_token.rs @@ -48,7 +48,7 @@ impl Wallet { token_id: TokenId, mint_amount: impl Into + Send, options: impl Into> + Send, - ) -> crate::wallet::Result> { + ) -> crate::wallet::Result { log::debug!("[TRANSACTION] mint_native_token"); let mint_amount = mint_amount.into(); diff --git a/sdk/src/wallet/operations/transaction/high_level/minting/mint_nfts.rs b/sdk/src/wallet/operations/transaction/high_level/minting/mint_nfts.rs index 5b59b1f627..f120e95ef8 100644 --- a/sdk/src/wallet/operations/transaction/high_level/minting/mint_nfts.rs +++ b/sdk/src/wallet/operations/transaction/high_level/minting/mint_nfts.rs @@ -152,7 +152,7 @@ impl Wallet { &self, params: I, options: impl Into> + Send, - ) -> crate::wallet::Result> + ) -> crate::wallet::Result where I::IntoIter: Send, { diff --git a/sdk/src/wallet/operations/transaction/high_level/send.rs b/sdk/src/wallet/operations/transaction/high_level/send.rs index b9ba07be43..84f1b4bf5c 100644 --- a/sdk/src/wallet/operations/transaction/high_level/send.rs +++ b/sdk/src/wallet/operations/transaction/high_level/send.rs @@ -126,7 +126,7 @@ impl Wallet { &self, params: I, options: impl Into> + Send, - ) -> crate::wallet::Result> + ) -> crate::wallet::Result where I::IntoIter: Send, { diff --git a/sdk/src/wallet/operations/transaction/high_level/send_native_tokens.rs b/sdk/src/wallet/operations/transaction/high_level/send_native_tokens.rs index 93e176706e..7702871d65 100644 --- a/sdk/src/wallet/operations/transaction/high_level/send_native_tokens.rs +++ b/sdk/src/wallet/operations/transaction/high_level/send_native_tokens.rs @@ -116,7 +116,7 @@ impl Wallet { &self, params: I, options: impl Into> + Send, - ) -> crate::wallet::Result> + ) -> crate::wallet::Result where I::IntoIter: Send, { diff --git a/sdk/src/wallet/operations/transaction/high_level/send_nft.rs b/sdk/src/wallet/operations/transaction/high_level/send_nft.rs index f4cfa12b1e..820ccbf505 100644 --- a/sdk/src/wallet/operations/transaction/high_level/send_nft.rs +++ b/sdk/src/wallet/operations/transaction/high_level/send_nft.rs @@ -84,7 +84,7 @@ impl Wallet { &self, params: I, options: impl Into> + Send, - ) -> crate::wallet::Result> + ) -> crate::wallet::Result where I::IntoIter: Send, { diff --git a/sdk/src/wallet/operations/transaction/input_selection.rs b/sdk/src/wallet/operations/transaction/input_selection.rs index d7dec257ac..82e0b5db39 100644 --- a/sdk/src/wallet/operations/transaction/input_selection.rs +++ b/sdk/src/wallet/operations/transaction/input_selection.rs @@ -30,7 +30,7 @@ impl Wallet { mandatory_inputs: Option>, remainder_address: Option
, burn: Option<&Burn>, - ) -> crate::wallet::Result> { + ) -> crate::wallet::Result { log::debug!("[TRANSACTION] select_inputs"); // Voting output needs to be requested before to prevent a deadlock #[cfg(feature = "participation")] @@ -213,11 +213,11 @@ impl Wallet { #[allow(clippy::too_many_arguments)] fn filter_inputs( wallet_data: &WalletData, - available_outputs: Values<'_, OutputId, OutputData>, + available_outputs: Values<'_, OutputId, OutputData>, slot_index: SlotIndex, custom_inputs: Option<&HashSet>, mandatory_inputs: Option<&HashSet>, -) -> crate::wallet::Result>> { +) -> crate::wallet::Result> { let mut available_outputs_signing_data = Vec::new(); for output_data in available_outputs { @@ -242,7 +242,7 @@ fn filter_inputs( } } - if let Some(available_input) = output_data.input_signing_data(wallet_data, slot_index)? { + if let Some(available_input) = output_data.input_signing_data(slot_index)? { available_outputs_signing_data.push(available_input); } } diff --git a/sdk/src/wallet/operations/transaction/mod.rs b/sdk/src/wallet/operations/transaction/mod.rs index 55b599b5b2..574f4d8c6b 100644 --- a/sdk/src/wallet/operations/transaction/mod.rs +++ b/sdk/src/wallet/operations/transaction/mod.rs @@ -98,7 +98,7 @@ impl Wallet { /// Signs a transaction, submit it to a node and store it in the wallet pub async fn sign_and_submit_transaction( &self, - prepared_transaction_data: PreparedTransactionData, + prepared_transaction_data: PreparedTransactionData, issuer_id: impl Into> + Send, options: impl Into> + Send, ) -> crate::wallet::Result { @@ -120,7 +120,7 @@ impl Wallet { /// Validates the transaction, submit it to a node and store it in the wallet pub async fn submit_and_store_transaction( &self, - signed_transaction_data: SignedTransactionData, + signed_transaction_data: SignedTransactionData, issuer_id: impl Into> + Send, options: impl Into> + Send, ) -> crate::wallet::Result { @@ -196,7 +196,7 @@ impl Wallet { } // unlock outputs - async fn unlock_inputs(&self, inputs: &[InputSigningData]) -> crate::wallet::Result<()> { + async fn unlock_inputs(&self, inputs: &[InputSigningData]) -> crate::wallet::Result<()> { let mut wallet_data = self.data_mut().await; for input_signing_data in inputs { let output_id = input_signing_data.output_id(); diff --git a/sdk/src/wallet/operations/transaction/prepare_output.rs b/sdk/src/wallet/operations/transaction/prepare_output.rs index 85b088c7c7..758b87c6fe 100644 --- a/sdk/src/wallet/operations/transaction/prepare_output.rs +++ b/sdk/src/wallet/operations/transaction/prepare_output.rs @@ -231,7 +231,7 @@ impl Wallet { recipient_address: Bech32Address, nft_id: Option, params: StorageScoreParameters, - ) -> crate::wallet::Result<(OutputBuilder, Option>)> { + ) -> crate::wallet::Result<(OutputBuilder, Option)> { let (mut first_output_builder, existing_nft_output_data) = if let Some(nft_id) = &nft_id { if nft_id.is_null() { // Mint a new NFT output diff --git a/sdk/src/wallet/operations/transaction/prepare_transaction.rs b/sdk/src/wallet/operations/transaction/prepare_transaction.rs index 59f553cabf..dfde411a99 100644 --- a/sdk/src/wallet/operations/transaction/prepare_transaction.rs +++ b/sdk/src/wallet/operations/transaction/prepare_transaction.rs @@ -24,7 +24,7 @@ impl Wallet { &self, outputs: impl Into> + Send, options: impl Into> + Send, - ) -> crate::wallet::Result> { + ) -> crate::wallet::Result { log::debug!("[TRANSACTION] prepare_transaction"); let options = options.into(); let outputs = outputs.into(); diff --git a/sdk/src/wallet/operations/transaction/sign_transaction.rs b/sdk/src/wallet/operations/transaction/sign_transaction.rs index dd32b00301..f8a5b2008d 100644 --- a/sdk/src/wallet/operations/transaction/sign_transaction.rs +++ b/sdk/src/wallet/operations/transaction/sign_transaction.rs @@ -23,8 +23,8 @@ impl Wallet { /// Signs a transaction. pub async fn sign_transaction( &self, - prepared_transaction_data: &PreparedTransactionData, - ) -> crate::wallet::Result> { + prepared_transaction_data: &PreparedTransactionData, + ) -> crate::wallet::Result { log::debug!("[TRANSACTION] sign_transaction"); log::debug!("[TRANSACTION] prepared_transaction_data {prepared_transaction_data:?}"); #[cfg(feature = "events")] @@ -73,7 +73,11 @@ impl Wallet { .secret_manager .read() .await - .transaction_unlocks(prepared_transaction_data, &protocol_parameters) + .transaction_unlocks( + prepared_transaction_data, + &protocol_parameters, + self.data().await.signing_options(), + ) .await { Ok(res) => res, diff --git a/sdk/src/wallet/types/mod.rs b/sdk/src/wallet/types/mod.rs index 98c7dc9102..188620cef0 100644 --- a/sdk/src/wallet/types/mod.rs +++ b/sdk/src/wallet/types/mod.rs @@ -16,7 +16,7 @@ pub use self::{ balance::{Balance, BaseCoinBalance, NativeTokensBalance, RequiredStorageDeposit}, }; use crate::{ - client::secret::{types::InputSigningData, SecretManage}, + client::secret::types::InputSigningData, types::{ api::core::OutputWithMetadataResponse, block::{ @@ -29,13 +29,12 @@ use crate::{ }, TryFromDto, }, - wallet::core::WalletData, }; /// An output with metadata #[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] -pub struct OutputData { +pub struct OutputData { /// The output id pub output_id: OutputId, pub metadata: OutputMetadata, @@ -48,36 +47,13 @@ pub struct OutputData { /// Network ID pub network_id: u64, pub remainder: bool, - // bip44 path - pub signing_options: Option, } -impl OutputData { - pub fn input_signing_data>( - &self, - wallet_data: &WalletData, - slot_index: SlotIndex, - ) -> crate::wallet::Result>> { - let (unlock_address, _unlocked_account_or_nft_address) = - self.output.required_and_unlocked_address(slot_index, &self.output_id)?; - - let chain = if unlock_address == self.address { - self.signing_options.clone() - } else if let Address::Ed25519(_) = unlock_address { - if wallet_data.address.inner() == &unlock_address { - Some(wallet_data.signing_options.clone()) - } else { - return Ok(None); - } - } else { - // Account and NFT addresses have no chain - None - }; - +impl OutputData { + pub fn input_signing_data(&self, slot_index: SlotIndex) -> crate::wallet::Result> { Ok(Some(InputSigningData { output: self.output.clone(), output_metadata: self.metadata, - signing_options: self.signing_options.clone(), })) } } diff --git a/sdk/src/wallet/update.rs b/sdk/src/wallet/update.rs index 24787a8f72..4e8ed4fbba 100644 --- a/sdk/src/wallet/update.rs +++ b/sdk/src/wallet/update.rs @@ -34,7 +34,7 @@ impl Wallet { /// Update wallet with newly synced data and emit events for outputs. pub(crate) async fn update_after_sync( &self, - unspent_outputs: Vec>, + unspent_outputs: Vec, spent_or_unsynced_output_metadata_map: HashMap>, ) -> crate::wallet::Result<()> { log::debug!("[SYNC] Update wallet with new synced transactions"); diff --git a/sdk/tests/client/input_selection/account_outputs.rs b/sdk/tests/client/input_selection/account_outputs.rs index a350d1a584..76df1dbd57 100644 --- a/sdk/tests/client/input_selection/account_outputs.rs +++ b/sdk/tests/client/input_selection/account_outputs.rs @@ -31,7 +31,6 @@ fn input_account_eq_output_account() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, - None, )]); let outputs = build_outputs([Account( 1_000_000, @@ -39,7 +38,6 @@ fn input_account_eq_output_account() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, - None, )]); let selected = InputSelection::new( @@ -66,7 +64,6 @@ fn transition_account_id_zero() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, - None, )]); let account_id = AccountId::from(inputs[0].output_id()); let outputs = build_outputs([Account( @@ -75,7 +72,6 @@ fn transition_account_id_zero() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, - None, )]); let selected = InputSelection::new( @@ -238,7 +234,6 @@ fn create_account() { None, None, None, - None, )]); let outputs = build_outputs([Account( 1_000_000, @@ -246,7 +241,6 @@ fn create_account() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, - None, )]); let selected = InputSelection::new( @@ -282,7 +276,6 @@ fn burn_account() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, - None, )]); let outputs = build_outputs([Basic( 2_000_000, @@ -292,7 +285,6 @@ fn burn_account() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -367,7 +359,6 @@ fn missing_input_for_account_output() { None, None, None, - None, )]); let outputs = build_outputs([Account( 1_000_000, @@ -375,7 +366,6 @@ fn missing_input_for_account_output() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, - None, )]); let selected = InputSelection::new( @@ -405,7 +395,6 @@ fn missing_input_for_account_output_2() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, - None, ), Basic( 1_000_000, @@ -415,7 +404,6 @@ fn missing_input_for_account_output_2() { None, None, None, - None, ), ]); let outputs = build_outputs([Account( @@ -424,7 +412,6 @@ fn missing_input_for_account_output_2() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, - None, )]); let selected = InputSelection::new( @@ -454,7 +441,6 @@ fn missing_input_for_account_output_but_created() { None, None, None, - None, )]); let outputs = build_outputs([Account( 1_000_000, @@ -462,7 +448,6 @@ fn missing_input_for_account_output_but_created() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, - None, )]); let selected = InputSelection::new( @@ -488,7 +473,6 @@ fn account_in_output_and_sender() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, - None, ), Basic( 1_000_000, @@ -498,7 +482,6 @@ fn account_in_output_and_sender() { None, None, None, - None, ), ]); let account_output = AccountOutputBuilder::from(inputs[0].output.as_account()) @@ -512,7 +495,6 @@ fn account_in_output_and_sender() { None, None, None, - None, )]); outputs.push(account_output); @@ -540,7 +522,6 @@ fn missing_ed25519_sender() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, - None, )]); let outputs = build_outputs([Account( 1_000_000, @@ -548,7 +529,6 @@ fn missing_ed25519_sender() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), Some(Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()), None, - None, )]); let selected = InputSelection::new( @@ -578,7 +558,6 @@ fn missing_ed25519_issuer_created() { None, None, None, - None, )]); let outputs = build_outputs([Account( 1_000_000, @@ -586,7 +565,6 @@ fn missing_ed25519_issuer_created() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, Some(Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()), - None, )]); let selected = InputSelection::new( @@ -614,7 +592,6 @@ fn missing_ed25519_issuer_transition() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, Some(Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()), - None, )]); let outputs = build_outputs([Account( 1_000_000, @@ -622,7 +599,6 @@ fn missing_ed25519_issuer_transition() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, Some(Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()), - None, )]); let selected = InputSelection::new( @@ -647,7 +623,6 @@ fn missing_account_sender() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, - None, )]); let outputs = build_outputs([Account( 1_000_000, @@ -655,7 +630,6 @@ fn missing_account_sender() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), Some(Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap()), None, - None, )]); let selected = InputSelection::new( @@ -685,7 +659,6 @@ fn missing_account_issuer_created() { None, None, None, - None, )]); let outputs = build_outputs([Account( 1_000_000, @@ -693,7 +666,6 @@ fn missing_account_issuer_created() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, Some(Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap()), - None, )]); let selected = InputSelection::new( @@ -721,7 +693,6 @@ fn missing_account_issuer_transition() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, Some(Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap()), - None, )]); let outputs = build_outputs([Account( 1_000_000, @@ -729,7 +700,6 @@ fn missing_account_issuer_transition() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, Some(Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap()), - None, )]); let selected = InputSelection::new( @@ -754,7 +724,6 @@ fn missing_nft_sender() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, - None, )]); let outputs = build_outputs([Account( 1_000_000, @@ -762,7 +731,6 @@ fn missing_nft_sender() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), Some(Address::try_from_bech32(BECH32_ADDRESS_NFT_1).unwrap()), None, - None, )]); let selected = InputSelection::new( @@ -792,7 +760,6 @@ fn missing_nft_issuer_created() { None, None, None, - None, )]); let outputs = build_outputs([Account( 1_000_000, @@ -800,7 +767,6 @@ fn missing_nft_issuer_created() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, Some(Address::try_from_bech32(BECH32_ADDRESS_NFT_1).unwrap()), - None, )]); let selected = InputSelection::new( @@ -828,7 +794,6 @@ fn missing_nft_issuer_transition() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, Some(Address::try_from_bech32(BECH32_ADDRESS_NFT_1).unwrap()), - None, )]); let outputs = build_outputs([Account( 1_000_000, @@ -836,7 +801,6 @@ fn missing_nft_issuer_transition() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, Some(Address::try_from_bech32(BECH32_ADDRESS_NFT_1).unwrap()), - None, )]); let selected = InputSelection::new( @@ -862,7 +826,6 @@ fn increase_account_amount() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, - None, ), Basic( 1_000_000, @@ -872,7 +835,6 @@ fn increase_account_amount() { None, None, None, - None, ), ]); let outputs = build_outputs([Account( @@ -881,7 +843,6 @@ fn increase_account_amount() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, - None, )]); let selected = InputSelection::new( @@ -909,7 +870,6 @@ fn decrease_account_amount() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, - None, ), Basic( 1_000_000, @@ -919,7 +879,6 @@ fn decrease_account_amount() { None, None, None, - None, ), ]); let outputs = build_outputs([Account( @@ -928,7 +887,6 @@ fn decrease_account_amount() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, - None, )]); let selected = InputSelection::new( @@ -968,7 +926,6 @@ fn prefer_basic_to_account() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, - None, ), Basic( 1_000_000, @@ -978,7 +935,6 @@ fn prefer_basic_to_account() { None, None, None, - None, ), ]); let outputs = build_outputs([Basic( @@ -989,7 +945,6 @@ fn prefer_basic_to_account() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -1018,7 +973,6 @@ fn take_amount_from_account_to_fund_basic() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, - None, ), Basic( 1_000_000, @@ -1028,7 +982,6 @@ fn take_amount_from_account_to_fund_basic() { None, None, None, - None, ), ]); let outputs = build_outputs([Basic( @@ -1039,7 +992,6 @@ fn take_amount_from_account_to_fund_basic() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -1084,7 +1036,6 @@ fn account_burn_should_validate_account_sender() { None, None, None, - None, ), Account( 1_000_000, @@ -1092,7 +1043,6 @@ fn account_burn_should_validate_account_sender() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, - None, ), ]); let outputs = build_outputs([Basic( @@ -1103,7 +1053,6 @@ fn account_burn_should_validate_account_sender() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -1146,7 +1095,6 @@ fn account_burn_should_validate_account_address() { None, None, None, - None, ), Account( 1_000_000, @@ -1154,7 +1102,6 @@ fn account_burn_should_validate_account_address() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, - None, ), ]); let outputs = build_outputs([Basic( @@ -1165,7 +1112,6 @@ fn account_burn_should_validate_account_address() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -1205,7 +1151,6 @@ fn transitioned_zero_account_id_no_longer_is_zero() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, - None, )]); let outputs = build_outputs([Basic( 1_000_000, @@ -1215,7 +1160,6 @@ fn transitioned_zero_account_id_no_longer_is_zero() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -1259,7 +1203,6 @@ fn two_accounts_required() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, - None, ), Account( 2_000_000, @@ -1267,7 +1210,6 @@ fn two_accounts_required() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, - None, ), ]); let outputs = build_outputs([Basic( @@ -1278,7 +1220,6 @@ fn two_accounts_required() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -1326,7 +1267,6 @@ fn state_controller_sender_required() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, - None, )]); let outputs = build_outputs([Basic( 1_000_000, @@ -1336,7 +1276,6 @@ fn state_controller_sender_required() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -1364,7 +1303,6 @@ fn state_controller_sender_required_already_selected() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, - None, )]); let outputs = build_outputs([ Account( @@ -1373,7 +1311,6 @@ fn state_controller_sender_required_already_selected() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, - None, ), Basic( 1_000_000, @@ -1383,7 +1320,6 @@ fn state_controller_sender_required_already_selected() { None, None, None, - None, ), ]); @@ -1412,7 +1348,6 @@ fn state_transition_and_required() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, - None, )]); let outputs = build_outputs([Account( 2_000_000, @@ -1420,7 +1355,6 @@ fn state_transition_and_required() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, - None, )]); let selected = InputSelection::new( @@ -1448,7 +1382,6 @@ fn remainder_address_in_state_controller() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, - None, )]); let outputs = build_outputs([Account( 1_000_000, @@ -1456,7 +1389,6 @@ fn remainder_address_in_state_controller() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, - None, )]); let selected = InputSelection::new( diff --git a/sdk/tests/client/input_selection/basic_outputs.rs b/sdk/tests/client/input_selection/basic_outputs.rs index 10af45e799..180b7b1414 100644 --- a/sdk/tests/client/input_selection/basic_outputs.rs +++ b/sdk/tests/client/input_selection/basic_outputs.rs @@ -32,7 +32,6 @@ fn input_amount_equal_output_amount() { None, None, None, - None, )]); let outputs = build_outputs([Basic( 1_000_000, @@ -42,7 +41,6 @@ fn input_amount_equal_output_amount() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -70,7 +68,6 @@ fn input_amount_lower_than_output_amount() { None, None, None, - None, )]); let outputs = build_outputs([Basic( 2_000_000, @@ -80,7 +77,6 @@ fn input_amount_lower_than_output_amount() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -113,7 +109,6 @@ fn input_amount_lower_than_output_amount_2() { None, None, None, - None, ), Basic( 2_000_000, @@ -123,7 +118,6 @@ fn input_amount_lower_than_output_amount_2() { None, None, None, - None, ), ]); let outputs = build_outputs([Basic( @@ -134,7 +128,6 @@ fn input_amount_lower_than_output_amount_2() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -166,7 +159,6 @@ fn input_amount_greater_than_output_amount() { None, None, None, - None, )]); let outputs = build_outputs([Basic( 500_000, @@ -176,7 +168,6 @@ fn input_amount_greater_than_output_amount() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -217,7 +208,6 @@ fn input_amount_greater_than_output_amount_with_remainder_address() { None, None, None, - None, )]); let outputs = build_outputs([Basic( 500_000, @@ -227,7 +217,6 @@ fn input_amount_greater_than_output_amount_with_remainder_address() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -269,7 +258,6 @@ fn two_same_inputs_one_needed() { None, None, None, - None, ), Basic( 2_000_000, @@ -279,7 +267,6 @@ fn two_same_inputs_one_needed() { None, None, None, - None, ), ]); let outputs = build_outputs([Basic( @@ -290,7 +277,6 @@ fn two_same_inputs_one_needed() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -332,7 +318,6 @@ fn two_inputs_one_needed() { None, None, None, - None, ), Basic( 2_000_000, @@ -342,7 +327,6 @@ fn two_inputs_one_needed() { None, None, None, - None, ), ]); let outputs = build_outputs([Basic( @@ -353,7 +337,6 @@ fn two_inputs_one_needed() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -382,7 +365,6 @@ fn two_inputs_one_needed_reversed() { None, None, None, - None, ), Basic( 1_000_000, @@ -392,7 +374,6 @@ fn two_inputs_one_needed_reversed() { None, None, None, - None, ), ]); let outputs = build_outputs([Basic( @@ -403,7 +384,6 @@ fn two_inputs_one_needed_reversed() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -432,7 +412,6 @@ fn two_inputs_both_needed() { None, None, None, - None, ), Basic( 2_000_000, @@ -442,7 +421,6 @@ fn two_inputs_both_needed() { None, None, None, - None, ), ]); let outputs = build_outputs([Basic( @@ -453,7 +431,6 @@ fn two_inputs_both_needed() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -482,7 +459,6 @@ fn two_inputs_remainder() { None, None, None, - None, ), Basic( 2_000_000, @@ -492,7 +468,6 @@ fn two_inputs_remainder() { None, None, None, - None, ), ]); let outputs = build_outputs([Basic( @@ -503,7 +478,6 @@ fn two_inputs_remainder() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -587,7 +561,6 @@ fn ed25519_sender() { None, None, None, - None, ), Basic( 2_000_000, @@ -597,7 +570,6 @@ fn ed25519_sender() { None, None, None, - None, ), Basic( 1_000_000, @@ -607,7 +579,6 @@ fn ed25519_sender() { None, None, None, - None, ), Basic( 2_000_000, @@ -617,7 +588,6 @@ fn ed25519_sender() { None, None, None, - None, ), Basic( 2_000_000, @@ -627,7 +597,6 @@ fn ed25519_sender() { None, None, None, - None, ), ]); let outputs = build_outputs([Basic( @@ -638,7 +607,6 @@ fn ed25519_sender() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -677,7 +645,6 @@ fn missing_ed25519_sender() { None, None, None, - None, )]); let outputs = build_outputs([Basic( 1_000_000, @@ -687,7 +654,6 @@ fn missing_ed25519_sender() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -718,7 +684,6 @@ fn account_sender() { None, None, None, - None, ), Basic( 2_000_000, @@ -728,7 +693,6 @@ fn account_sender() { None, None, None, - None, ), Account( 1_000_000, @@ -736,7 +700,6 @@ fn account_sender() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, - None, ), Basic( 2_000_000, @@ -746,7 +709,6 @@ fn account_sender() { None, None, None, - None, ), Basic( 2_000_000, @@ -756,7 +718,6 @@ fn account_sender() { None, None, None, - None, ), ]); @@ -768,7 +729,6 @@ fn account_sender() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -807,7 +767,6 @@ fn account_sender_zero_id() { None, None, None, - None, ), Account( 1_000_000, @@ -815,7 +774,6 @@ fn account_sender_zero_id() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, - None, ), ]); let account_id = AccountId::from(inputs[1].output_id()); @@ -827,7 +785,6 @@ fn account_sender_zero_id() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -861,7 +818,6 @@ fn missing_account_sender() { None, None, None, - None, )]); let outputs = build_outputs([Basic( 1_000_000, @@ -871,7 +827,6 @@ fn missing_account_sender() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -902,7 +857,6 @@ fn nft_sender() { None, None, None, - None, ), Basic( 2_000_000, @@ -912,7 +866,6 @@ fn nft_sender() { None, None, None, - None, ), Nft( 1_000_000, @@ -922,7 +875,6 @@ fn nft_sender() { None, None, None, - None, ), Basic( 2_000_000, @@ -932,7 +884,6 @@ fn nft_sender() { None, None, None, - None, ), Basic( 2_000_000, @@ -942,7 +893,6 @@ fn nft_sender() { None, None, None, - None, ), ]); let outputs = build_outputs([Basic( @@ -953,7 +903,6 @@ fn nft_sender() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -993,7 +942,6 @@ fn nft_sender_zero_id() { None, None, None, - None, ), Nft( 1_000_000, @@ -1003,7 +951,6 @@ fn nft_sender_zero_id() { None, None, None, - None, ), ]); let nft_id = NftId::from(inputs[1].output_id()); @@ -1015,7 +962,6 @@ fn nft_sender_zero_id() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -1049,7 +995,6 @@ fn missing_nft_sender() { None, None, None, - None, )]); let outputs = build_outputs([Basic( 1_000_000, @@ -1059,7 +1004,6 @@ fn missing_nft_sender() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -1088,7 +1032,6 @@ fn simple_remainder() { None, None, None, - None, )]); let outputs = build_outputs([Basic( 500_000, @@ -1098,7 +1041,6 @@ fn simple_remainder() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -1217,7 +1159,6 @@ fn one_provided_one_needed() { None, None, None, - None, )]); let outputs = build_outputs([Basic( 1_000_000, @@ -1227,7 +1168,6 @@ fn one_provided_one_needed() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -1255,7 +1195,6 @@ fn insufficient_amount() { None, None, None, - None, )]); let outputs = build_outputs([Basic( 1_250_000, @@ -1265,7 +1204,6 @@ fn insufficient_amount() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -1298,7 +1236,6 @@ fn two_inputs_remainder_2() { None, None, None, - None, ), Basic( 2_000_000, @@ -1308,7 +1245,6 @@ fn two_inputs_remainder_2() { None, None, None, - None, ), ]); let outputs = build_outputs([Basic( @@ -1319,7 +1255,6 @@ fn two_inputs_remainder_2() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -1360,7 +1295,6 @@ fn two_inputs_remainder_3() { None, None, None, - None, ), Basic( 2_000_000, @@ -1370,7 +1304,6 @@ fn two_inputs_remainder_3() { None, None, None, - None, ), ]); let outputs = build_outputs([Basic( @@ -1381,7 +1314,6 @@ fn two_inputs_remainder_3() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -1460,7 +1392,6 @@ fn sender_already_selected() { None, None, None, - None, )]); let outputs = build_outputs([Basic( 1_000_000, @@ -1470,7 +1401,6 @@ fn sender_already_selected() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -1502,7 +1432,6 @@ fn single_mandatory_input() { None, None, None, - None, )]); let outputs = build_outputs([Basic( 1_000_000, @@ -1512,7 +1441,6 @@ fn single_mandatory_input() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -1547,7 +1475,6 @@ fn too_many_inputs() { None, None, None, - None, ) }) .take(129), @@ -1561,7 +1488,6 @@ fn too_many_inputs() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -1593,7 +1519,6 @@ fn more_than_max_inputs_only_one_needed() { None, None, None, - None, ) }) .take(1000), @@ -1607,7 +1532,6 @@ fn more_than_max_inputs_only_one_needed() { None, None, None, - None, )]); inputs.push(needed_input[0].clone()); @@ -1619,7 +1543,6 @@ fn more_than_max_inputs_only_one_needed() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -1647,7 +1570,6 @@ fn too_many_outputs() { None, None, None, - None, )]); let outputs = build_outputs( @@ -1660,7 +1582,6 @@ fn too_many_outputs() { None, None, None, - None, ) }) .take(129), @@ -1692,7 +1613,6 @@ fn too_many_outputs_with_remainder() { None, None, None, - None, )]); let outputs = build_outputs( @@ -1705,7 +1625,6 @@ fn too_many_outputs_with_remainder() { None, None, None, - None, ) }) .take(128), @@ -1741,7 +1660,6 @@ fn restricted_ed25519() { None, None, None, - None, ), Basic( 1_000_000, @@ -1751,9 +1669,8 @@ fn restricted_ed25519() { None, None, None, - None, ), - Basic(1_000_000, restricted, None, None, None, None, None, None), + Basic(1_000_000, restricted, None, None, None, None, None), Basic( 1_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), @@ -1762,7 +1679,6 @@ fn restricted_ed25519() { None, None, None, - None, ), Basic( 1_000_000, @@ -1772,7 +1688,6 @@ fn restricted_ed25519() { None, None, None, - None, ), ]); let outputs = build_outputs([Basic( @@ -1783,7 +1698,6 @@ fn restricted_ed25519() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -1808,7 +1722,7 @@ fn restricted_nft() { let restricted = Address::from(RestrictedAddress::new(nft_address.clone()).unwrap()); let inputs = build_inputs([ - Basic(2_000_000, restricted, None, None, None, None, None, None), + Basic(2_000_000, restricted, None, None, None, None, None), Nft( 2_000_000, nft_id_1, @@ -1817,7 +1731,6 @@ fn restricted_nft() { None, None, None, - None, ), ]); let outputs = build_outputs([Basic( @@ -1828,7 +1741,6 @@ fn restricted_nft() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -1853,14 +1765,13 @@ 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(2_000_000, restricted, None, None, None, None, None), Account( 2_000_000, account_id_1, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, - None, ), ]); @@ -1872,7 +1783,6 @@ fn restricted_account() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -1904,7 +1814,6 @@ fn restricted_ed25519_sender() { None, None, None, - None, ), Basic( 2_000_000, @@ -1914,7 +1823,6 @@ fn restricted_ed25519_sender() { None, None, None, - None, ), Basic( 1_000_000, @@ -1924,7 +1832,6 @@ fn restricted_ed25519_sender() { None, None, None, - None, ), Basic( 2_000_000, @@ -1934,7 +1841,6 @@ fn restricted_ed25519_sender() { None, None, None, - None, ), Basic( 2_000_000, @@ -1944,7 +1850,6 @@ fn restricted_ed25519_sender() { None, None, None, - None, ), ]); let outputs = build_outputs([Basic( @@ -1955,7 +1860,6 @@ fn restricted_ed25519_sender() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -2009,7 +1913,6 @@ fn multi_address_sender_already_fulfilled() { None, None, None, - None, ), Basic( 1_000_000, @@ -2019,7 +1922,6 @@ fn multi_address_sender_already_fulfilled() { None, None, None, - None, ), Basic( 1_000_000, @@ -2029,7 +1931,6 @@ fn multi_address_sender_already_fulfilled() { None, None, None, - None, ), ]); let outputs = build_outputs([Basic( @@ -2040,7 +1941,6 @@ fn multi_address_sender_already_fulfilled() { None, None, None, - None, )]); let selected = InputSelection::new( diff --git a/sdk/tests/client/input_selection/expiration.rs b/sdk/tests/client/input_selection/expiration.rs index 08852b876f..f731019f05 100644 --- a/sdk/tests/client/input_selection/expiration.rs +++ b/sdk/tests/client/input_selection/expiration.rs @@ -32,7 +32,6 @@ fn one_output_expiration_not_expired() { None, None, Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 200)), - None, )]); let outputs = build_outputs([Basic( 2_000_000, @@ -42,7 +41,6 @@ fn one_output_expiration_not_expired() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -69,7 +67,6 @@ fn expiration_equal_timestamp() { None, None, Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 200)), - None, )]); let outputs = build_outputs([Basic( 2_000_000, @@ -79,7 +76,6 @@ fn expiration_equal_timestamp() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -108,7 +104,6 @@ fn one_output_expiration_expired() { None, None, Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 50)), - None, )]); let outputs = build_outputs([Basic( 2_000_000, @@ -118,7 +113,6 @@ fn one_output_expiration_expired() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -148,7 +142,6 @@ fn two_outputs_one_expiration_expired() { None, None, Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 200)), - None, ), Basic( 2_000_000, @@ -158,7 +151,6 @@ fn two_outputs_one_expiration_expired() { None, None, Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 50)), - None, ), ]); let outputs = build_outputs([Basic( @@ -169,7 +161,6 @@ fn two_outputs_one_expiration_expired() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -200,7 +191,6 @@ fn two_outputs_one_unexpired_one_missing() { None, None, Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 200)), - None, ), Basic( 2_000_000, @@ -210,7 +200,6 @@ fn two_outputs_one_unexpired_one_missing() { None, None, None, - None, ), ]); let outputs = build_outputs([Basic( @@ -221,7 +210,6 @@ fn two_outputs_one_unexpired_one_missing() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -252,7 +240,6 @@ fn two_outputs_two_expired() { None, None, Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 100)), - None, ), Basic( 2_000_000, @@ -262,7 +249,6 @@ fn two_outputs_two_expired() { None, None, Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_2).unwrap(), 100)), - None, ), Basic( 2_000_000, @@ -272,7 +258,6 @@ fn two_outputs_two_expired() { None, None, None, - None, ), ]); let outputs = build_outputs([Basic( @@ -283,7 +268,6 @@ fn two_outputs_two_expired() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -314,7 +298,6 @@ fn two_outputs_two_expired_2() { None, None, Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 100)), - None, ), Basic( 2_000_000, @@ -324,7 +307,6 @@ fn two_outputs_two_expired_2() { None, None, Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_2).unwrap(), 100)), - None, ), ]); let outputs = build_outputs([Basic( @@ -335,7 +317,6 @@ fn two_outputs_two_expired_2() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -367,7 +348,6 @@ fn expiration_expired_with_sdr() { Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), None, Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 50)), - None, )]); let outputs = build_outputs([Basic( 2_000_000, @@ -377,7 +357,6 @@ fn expiration_expired_with_sdr() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -406,7 +385,6 @@ fn expiration_expired_with_sdr_2() { Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), None, Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 50)), - None, )]); let outputs = build_outputs([Basic( 2_000_000, @@ -416,7 +394,6 @@ fn expiration_expired_with_sdr_2() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -445,7 +422,6 @@ fn expiration_expired_with_sdr_and_timelock() { Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 1_000_000)), Some(50), Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 50)), - None, )]); let outputs = build_outputs([Basic( 2_000_000, @@ -455,7 +431,6 @@ fn expiration_expired_with_sdr_and_timelock() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -484,7 +459,6 @@ fn expiration_expired_with_sdr_and_timelock_2() { Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), Some(50), Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 50)), - None, )]); let outputs = build_outputs([Basic( 2_000_000, @@ -494,7 +468,6 @@ fn expiration_expired_with_sdr_and_timelock_2() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -524,7 +497,6 @@ fn sender_in_expiration() { None, None, None, - None, ), Basic( 1_000_000, @@ -534,7 +506,6 @@ fn sender_in_expiration() { None, None, None, - None, ), Basic( 1_000_000, @@ -544,7 +515,6 @@ fn sender_in_expiration() { None, None, Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 50)), - None, ), Basic( 1_000_000, @@ -554,7 +524,6 @@ fn sender_in_expiration() { None, None, None, - None, ), Basic( 1_000_000, @@ -564,7 +533,6 @@ fn sender_in_expiration() { None, None, None, - None, ), ]); let outputs = build_outputs([Basic( @@ -575,7 +543,6 @@ fn sender_in_expiration() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -608,7 +575,6 @@ fn sender_in_expiration_already_selected() { None, None, Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 50)), - None, )]); let outputs = build_outputs([Basic( 1_000_000, @@ -618,7 +584,6 @@ fn sender_in_expiration_already_selected() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -651,7 +616,6 @@ fn remainder_in_expiration() { None, None, Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 50)), - None, )]); let outputs = build_outputs([Basic( 1_000_000, @@ -661,7 +625,6 @@ fn remainder_in_expiration() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -704,7 +667,6 @@ fn expiration_expired_non_ed25519_in_address_unlock_condition() { None, None, Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 50)), - None, )]); let outputs = build_outputs([Basic( 2_000_000, @@ -714,7 +676,6 @@ fn expiration_expired_non_ed25519_in_address_unlock_condition() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -745,7 +706,6 @@ fn expiration_expired_only_account_addresses() { None, None, Some((Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap(), 50)), - None, ), Account( 1_000_000, @@ -753,7 +713,6 @@ fn expiration_expired_only_account_addresses() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, - None, ), ]); @@ -765,7 +724,6 @@ fn expiration_expired_only_account_addresses() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -795,7 +753,6 @@ fn one_nft_output_expiration_unexpired() { None, None, Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 150)), - None, )]); let outputs = build_outputs([Nft( 2_000_000, @@ -805,7 +762,6 @@ fn one_nft_output_expiration_unexpired() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -835,7 +791,6 @@ fn one_nft_output_expiration_expired() { None, None, Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 50)), - None, )]); let outputs = build_outputs([Nft( 2_000_000, @@ -845,7 +800,6 @@ fn one_nft_output_expiration_expired() { None, None, None, - None, )]); let selected = InputSelection::new( diff --git a/sdk/tests/client/input_selection/foundry_outputs.rs b/sdk/tests/client/input_selection/foundry_outputs.rs index b4ca32e705..58dc54f754 100644 --- a/sdk/tests/client/input_selection/foundry_outputs.rs +++ b/sdk/tests/client/input_selection/foundry_outputs.rs @@ -39,7 +39,6 @@ fn missing_input_account_for_foundry() { None, None, None, - None, )]); let outputs = build_outputs([Foundry( 1_000_000, @@ -115,7 +114,6 @@ fn minted_native_tokens_in_new_remainder() { None, None, None, - None, ), Account( 1_000_000, @@ -123,7 +121,6 @@ fn minted_native_tokens_in_new_remainder() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, - None, ), ]); let outputs = build_outputs([Foundry( @@ -171,7 +168,6 @@ fn minted_native_tokens_in_provided_output() { None, None, None, - None, ), Account( 1_000_000, @@ -179,7 +175,6 @@ fn minted_native_tokens_in_provided_output() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, - None, ), ]); let outputs = build_outputs([ @@ -198,7 +193,6 @@ fn minted_native_tokens_in_provided_output() { None, None, None, - None, ), ]); @@ -232,7 +226,6 @@ fn melt_native_tokens() { None, None, None, - None, ), Foundry( 1_000_000, @@ -255,7 +248,6 @@ fn melt_native_tokens() { inputs.push(InputSigningData { output: account_output, output_metadata: rand_output_metadata(), - signing_options: None, }); let outputs = build_outputs([Foundry( 1_000_000, @@ -299,7 +291,6 @@ fn destroy_foundry_with_account_state_transition() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, - None, ), Foundry( 52_800, @@ -343,7 +334,6 @@ fn destroy_foundry_with_account_burn() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, - None, ), Foundry( 1_000_000, @@ -361,7 +351,6 @@ fn destroy_foundry_with_account_burn() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -405,7 +394,6 @@ fn prefer_basic_to_foundry() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, - None, ), Foundry( 1_000_000, @@ -422,7 +410,6 @@ fn prefer_basic_to_foundry() { None, None, None, - None, ), ]); let outputs = build_outputs([Basic( @@ -433,7 +420,6 @@ fn prefer_basic_to_foundry() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -464,7 +450,6 @@ fn simple_foundry_transition_basic_not_needed() { None, None, None, - None, ), Foundry( 1_000_000, @@ -484,7 +469,6 @@ fn simple_foundry_transition_basic_not_needed() { inputs.push(InputSigningData { output: account_output, output_metadata: rand_output_metadata(), - signing_options: None, }); let outputs = build_outputs([Foundry( @@ -539,7 +523,6 @@ fn simple_foundry_transition_basic_not_needed_with_remainder() { None, None, None, - None, ), Foundry( 2_000_000, @@ -559,7 +542,6 @@ fn simple_foundry_transition_basic_not_needed_with_remainder() { inputs.push(InputSigningData { output: account_output, output_metadata: rand_output_metadata(), - signing_options: None, }); let outputs = build_outputs([Foundry( 1_000_000, @@ -700,7 +682,6 @@ fn mint_and_burn_at_the_same_time() { inputs.push(InputSigningData { output: account_output, output_metadata: rand_output_metadata(), - signing_options: None, }); let outputs = build_outputs([Foundry( @@ -742,7 +723,6 @@ fn take_amount_from_account_and_foundry_to_fund_basic() { None, None, None, - None, ), Foundry( 1_000_000, @@ -762,7 +742,6 @@ fn take_amount_from_account_and_foundry_to_fund_basic() { inputs.push(InputSigningData { output: account_output, output_metadata: rand_output_metadata(), - signing_options: None, }); let outputs = build_outputs([Basic( 3_200_000, @@ -772,7 +751,6 @@ fn take_amount_from_account_and_foundry_to_fund_basic() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -809,7 +787,6 @@ fn create_native_token_but_burn_account() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, - None, ), Foundry( 1_000_000, @@ -867,7 +844,6 @@ fn melted_tokens_not_provided() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, - None, ), Foundry( 1_000_000, @@ -916,7 +892,6 @@ fn burned_tokens_not_provided() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, - None, ), Foundry( 1_000_000, @@ -974,7 +949,6 @@ fn foundry_in_outputs_and_required() { inputs.push(InputSigningData { output: account_output, output_metadata: rand_output_metadata(), - signing_options: None, }); let outputs = build_outputs([Foundry( 1_000_000, @@ -1020,7 +994,6 @@ fn melt_and_burn_native_tokens() { None, None, None, - None, ), Foundry( 1_000_000, @@ -1040,7 +1013,6 @@ fn melt_and_burn_native_tokens() { inputs.push(InputSigningData { output: account_output, output_metadata: rand_output_metadata(), - signing_options: None, }); let outputs = build_outputs([Foundry( 1_000_000, diff --git a/sdk/tests/client/input_selection/nft_outputs.rs b/sdk/tests/client/input_selection/nft_outputs.rs index a4702de635..ae8e7ce116 100644 --- a/sdk/tests/client/input_selection/nft_outputs.rs +++ b/sdk/tests/client/input_selection/nft_outputs.rs @@ -38,7 +38,6 @@ fn input_nft_eq_output_nft() { None, None, None, - None, )]); let outputs = build_outputs([Nft( 1_000_000, @@ -48,7 +47,6 @@ fn input_nft_eq_output_nft() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -77,7 +75,6 @@ fn transition_nft_id_zero() { None, None, None, - None, )]); let nft_id = NftId::from(inputs[0].output_id()); let outputs = build_outputs([Nft( @@ -88,7 +85,6 @@ fn transition_nft_id_zero() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -205,7 +201,6 @@ fn mint_nft() { None, None, None, - None, )]); let outputs = build_outputs([Nft( 1_000_000, @@ -215,7 +210,6 @@ fn mint_nft() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -253,7 +247,6 @@ fn burn_nft() { None, None, None, - None, )]); let outputs = build_outputs([Basic( 2_000_000, @@ -263,7 +256,6 @@ fn burn_nft() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -338,7 +330,6 @@ fn missing_input_for_nft_output() { None, None, None, - None, )]); let outputs = build_outputs([Nft( 1_000_000, @@ -348,7 +339,6 @@ fn missing_input_for_nft_output() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -378,7 +368,6 @@ fn missing_input_for_nft_output_but_created() { None, None, None, - None, )]); let outputs = build_outputs([Nft( 1_000_000, @@ -388,7 +377,6 @@ fn missing_input_for_nft_output_but_created() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -416,7 +404,6 @@ fn nft_in_output_and_sender() { None, None, None, - None, ), Basic( 1_000_000, @@ -426,7 +413,6 @@ fn nft_in_output_and_sender() { None, None, None, - None, ), ]); let outputs = build_outputs([ @@ -438,7 +424,6 @@ fn nft_in_output_and_sender() { None, None, None, - None, ), Basic( 1_000_000, @@ -448,7 +433,6 @@ fn nft_in_output_and_sender() { None, None, None, - None, ), ]); @@ -486,7 +470,6 @@ fn missing_ed25519_sender() { None, None, None, - None, )]); let outputs = build_outputs([Nft( 1_000_000, @@ -496,7 +479,6 @@ fn missing_ed25519_sender() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -526,7 +508,6 @@ fn missing_ed25519_issuer_created() { None, None, None, - None, )]); let outputs = build_outputs([Nft( 1_000_000, @@ -536,7 +517,6 @@ fn missing_ed25519_issuer_created() { Some(Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()), None, None, - None, )]); let selected = InputSelection::new( @@ -566,7 +546,6 @@ fn missing_ed25519_issuer_transition() { Some(Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()), None, None, - None, )]); let outputs = build_outputs([Nft( 1_000_000, @@ -576,7 +555,6 @@ fn missing_ed25519_issuer_transition() { Some(Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()), None, None, - None, )]); let selected = InputSelection::new( @@ -603,7 +581,6 @@ fn missing_account_sender() { None, None, None, - None, )]); let outputs = build_outputs([Nft( 1_000_000, @@ -613,7 +590,6 @@ fn missing_account_sender() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -643,7 +619,6 @@ fn missing_account_issuer_created() { None, None, None, - None, )]); let outputs = build_outputs([Nft( 1_000_000, @@ -653,7 +628,6 @@ fn missing_account_issuer_created() { Some(Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap()), None, None, - None, )]); let selected = InputSelection::new( @@ -683,7 +657,6 @@ fn missing_account_issuer_transition() { Some(Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap()), None, None, - None, )]); let outputs = build_outputs([Nft( 1_000_000, @@ -693,7 +666,6 @@ fn missing_account_issuer_transition() { Some(Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap()), None, None, - None, )]); let selected = InputSelection::new( @@ -720,7 +692,6 @@ fn missing_nft_sender() { None, None, None, - None, )]); let outputs = build_outputs([Nft( 1_000_000, @@ -730,7 +701,6 @@ fn missing_nft_sender() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -760,7 +730,6 @@ fn missing_nft_issuer_created() { None, None, None, - None, )]); let outputs = build_outputs([Nft( 1_000_000, @@ -770,7 +739,6 @@ fn missing_nft_issuer_created() { Some(Address::try_from_bech32(BECH32_ADDRESS_NFT_1).unwrap()), None, None, - None, )]); let selected = InputSelection::new( @@ -800,7 +768,6 @@ fn missing_nft_issuer_transition() { Some(Address::try_from_bech32(BECH32_ADDRESS_NFT_1).unwrap()), None, None, - None, )]); let outputs = build_outputs([Nft( 1_000_000, @@ -810,7 +777,6 @@ fn missing_nft_issuer_transition() { Some(Address::try_from_bech32(BECH32_ADDRESS_NFT_1).unwrap()), None, None, - None, )]); let selected = InputSelection::new( @@ -838,7 +804,6 @@ fn increase_nft_amount() { None, None, None, - None, ), Basic( 1_000_000, @@ -848,7 +813,6 @@ fn increase_nft_amount() { None, None, None, - None, ), ]); let outputs = build_outputs([Nft( @@ -859,7 +823,6 @@ fn increase_nft_amount() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -889,7 +852,6 @@ fn decrease_nft_amount() { None, None, None, - None, ), Basic( 1_000_000, @@ -899,7 +861,6 @@ fn decrease_nft_amount() { None, None, None, - None, ), ]); let outputs = build_outputs([Nft( @@ -910,7 +871,6 @@ fn decrease_nft_amount() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -952,7 +912,6 @@ fn prefer_basic_to_nft() { None, None, None, - None, ), Basic( 1_000_000, @@ -962,7 +921,6 @@ fn prefer_basic_to_nft() { None, None, None, - None, ), ]); let outputs = build_outputs([Basic( @@ -973,7 +931,6 @@ fn prefer_basic_to_nft() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -1004,7 +961,6 @@ fn take_amount_from_nft_to_fund_basic() { None, None, None, - None, ), Basic( 1_000_000, @@ -1014,7 +970,6 @@ fn take_amount_from_nft_to_fund_basic() { None, None, None, - None, ), ]); let outputs = build_outputs([Basic( @@ -1025,7 +980,6 @@ fn take_amount_from_nft_to_fund_basic() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -1068,7 +1022,6 @@ fn nft_burn_should_validate_nft_sender() { None, None, None, - None, ), Nft( 1_000_000, @@ -1078,7 +1031,6 @@ fn nft_burn_should_validate_nft_sender() { None, None, None, - None, ), ]); let outputs = build_outputs([Basic( @@ -1089,7 +1041,6 @@ fn nft_burn_should_validate_nft_sender() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -1120,7 +1071,6 @@ fn nft_burn_should_validate_nft_address() { None, None, None, - None, ), Nft( 1_000_000, @@ -1130,7 +1080,6 @@ fn nft_burn_should_validate_nft_address() { None, None, None, - None, ), ]); let outputs = build_outputs([Basic( @@ -1141,7 +1090,6 @@ fn nft_burn_should_validate_nft_address() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -1171,7 +1119,6 @@ fn transitioned_zero_nft_id_no_longer_is_zero() { None, None, None, - None, )]); let outputs = build_outputs([Basic( 1_000_000, @@ -1181,7 +1128,6 @@ fn transitioned_zero_nft_id_no_longer_is_zero() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -1235,10 +1181,9 @@ fn changed_immutable_metadata() { .finish_output() .unwrap(); - let inputs = [InputSigningData:: { + let inputs = [InputSigningData { output: nft_output.clone(), output_metadata: rand_output_metadata(), - signing_options: None, }]; #[cfg(feature = "irc_27")] diff --git a/sdk/tests/client/input_selection/outputs.rs b/sdk/tests/client/input_selection/outputs.rs index ab134ccab9..249b51c3e6 100644 --- a/sdk/tests/client/input_selection/outputs.rs +++ b/sdk/tests/client/input_selection/outputs.rs @@ -29,10 +29,9 @@ fn no_inputs() { None, None, None, - None, )]); - let selected = InputSelection::::new( + let selected = InputSelection::new( inputs, outputs, [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], @@ -55,7 +54,6 @@ fn no_outputs() { None, None, None, - None, )]); let outputs = Vec::new(); @@ -81,7 +79,6 @@ fn no_outputs_but_burn() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, - None, )]); let outputs = Vec::new(); @@ -117,7 +114,6 @@ fn no_address_provided() { None, None, None, - None, )]); let outputs = build_outputs([Basic( 1_000_000, @@ -127,7 +123,6 @@ fn no_address_provided() { None, None, None, - None, )]); let selected = InputSelection::new(inputs, outputs, [], protocol_parameters).select(); @@ -147,7 +142,6 @@ fn no_matching_address_provided() { None, None, None, - None, )]); let outputs = build_outputs([Basic( 1_000_000, @@ -157,7 +151,6 @@ fn no_matching_address_provided() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -184,7 +177,6 @@ fn two_addresses_one_missing() { None, None, None, - None, ), Basic( 1_000_000, @@ -194,7 +186,6 @@ fn two_addresses_one_missing() { None, None, None, - None, ), ]); let outputs = build_outputs([Basic( @@ -205,7 +196,6 @@ fn two_addresses_one_missing() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -238,7 +228,6 @@ fn two_addresses() { None, None, None, - None, ), Basic( 1_000_000, @@ -248,7 +237,6 @@ fn two_addresses() { None, None, None, - None, ), ]); let outputs = build_outputs([Basic( @@ -259,7 +247,6 @@ fn two_addresses() { None, None, None, - None, )]); let selected = InputSelection::new( diff --git a/sdk/tests/client/input_selection/storage_deposit_return.rs b/sdk/tests/client/input_selection/storage_deposit_return.rs index 5c7ba2b633..8dfb63c8cc 100644 --- a/sdk/tests/client/input_selection/storage_deposit_return.rs +++ b/sdk/tests/client/input_selection/storage_deposit_return.rs @@ -28,7 +28,6 @@ fn sdruc_output_not_provided_no_remainder() { Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), None, None, - None, )]); let outputs = build_outputs([Basic( 1_000_000, @@ -38,7 +37,6 @@ fn sdruc_output_not_provided_no_remainder() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -77,7 +75,6 @@ fn sdruc_output_provided_no_remainder() { Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), None, None, - None, )]); let outputs = build_outputs([ Basic( @@ -88,7 +85,6 @@ fn sdruc_output_provided_no_remainder() { None, None, None, - None, ), Basic( 1_000_000, @@ -98,7 +94,6 @@ fn sdruc_output_provided_no_remainder() { None, None, None, - None, ), ]); @@ -127,7 +122,6 @@ fn sdruc_output_provided_remainder() { Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), None, None, - None, )]); let outputs = build_outputs([Basic( 1_000_000, @@ -137,7 +131,6 @@ fn sdruc_output_provided_remainder() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -177,7 +170,6 @@ fn two_sdrucs_to_the_same_address_both_needed() { Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), None, None, - None, ), Basic( 2_000_000, @@ -187,7 +179,6 @@ fn two_sdrucs_to_the_same_address_both_needed() { Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), None, None, - None, ), ]); let outputs = build_outputs([Basic( @@ -198,7 +189,6 @@ fn two_sdrucs_to_the_same_address_both_needed() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -238,7 +228,6 @@ fn two_sdrucs_to_the_same_address_one_needed() { Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), None, None, - None, ), Basic( 1_000_000, @@ -248,7 +237,6 @@ fn two_sdrucs_to_the_same_address_one_needed() { Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), None, None, - None, ), ]); let outputs = build_outputs([Basic( @@ -259,7 +247,6 @@ fn two_sdrucs_to_the_same_address_one_needed() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -300,7 +287,6 @@ fn two_sdrucs_to_different_addresses_both_needed() { Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), None, None, - None, ), Basic( 2_000_000, @@ -310,7 +296,6 @@ fn two_sdrucs_to_different_addresses_both_needed() { Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_2).unwrap(), 1_000_000)), None, None, - None, ), ]); let outputs = build_outputs([Basic( @@ -321,7 +306,6 @@ fn two_sdrucs_to_different_addresses_both_needed() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -367,7 +351,6 @@ fn two_sdrucs_to_different_addresses_one_needed() { Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), None, None, - None, ), Basic( 1_000_000, @@ -377,7 +360,6 @@ fn two_sdrucs_to_different_addresses_one_needed() { Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_2).unwrap(), 1_000_000)), None, None, - None, ), ]); let outputs = build_outputs([Basic( @@ -388,7 +370,6 @@ fn two_sdrucs_to_different_addresses_one_needed() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -428,7 +409,6 @@ fn insufficient_amount_because_of_sdruc() { Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), None, None, - None, )]); let outputs = build_outputs([Basic( 2_000_000, @@ -438,7 +418,6 @@ fn insufficient_amount_because_of_sdruc() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -471,7 +450,6 @@ fn useless_sdruc_required_for_sender_feature() { Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_2).unwrap(), 1_000_000)), None, None, - None, ), Basic( 1_000_000, @@ -481,7 +459,6 @@ fn useless_sdruc_required_for_sender_feature() { None, None, None, - None, ), ]); let outputs = build_outputs([Basic( @@ -492,7 +469,6 @@ fn useless_sdruc_required_for_sender_feature() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -536,7 +512,6 @@ fn sdruc_required_non_ed25519_in_address_unlock() { Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_2).unwrap(), 1_000_000)), None, None, - None, ), Account( 1_000_000, @@ -544,7 +519,6 @@ fn sdruc_required_non_ed25519_in_address_unlock() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, - None, ), ]); let outputs = build_outputs([Basic( @@ -555,7 +529,6 @@ fn sdruc_required_non_ed25519_in_address_unlock() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -596,7 +569,6 @@ fn useless_sdruc_non_ed25519_in_address_unlock() { Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_2).unwrap(), 1_000_000)), None, None, - None, ), Basic( 1_000_000, @@ -606,7 +578,6 @@ fn useless_sdruc_non_ed25519_in_address_unlock() { None, None, None, - None, ), Account( 1_000_000, @@ -614,7 +585,6 @@ fn useless_sdruc_non_ed25519_in_address_unlock() { Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, - None, ), ]); let outputs = build_outputs([Basic( @@ -625,7 +595,6 @@ fn useless_sdruc_non_ed25519_in_address_unlock() { None, None, None, - None, )]); let selected = InputSelection::new( diff --git a/sdk/tests/client/input_selection/timelock.rs b/sdk/tests/client/input_selection/timelock.rs index 7c27a9bad9..da6f3ffaa7 100644 --- a/sdk/tests/client/input_selection/timelock.rs +++ b/sdk/tests/client/input_selection/timelock.rs @@ -23,7 +23,6 @@ fn one_output_timelock_not_expired() { None, Some(200), None, - None, )]); let outputs = build_outputs([Basic( 1_000_000, @@ -33,7 +32,6 @@ fn one_output_timelock_not_expired() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -60,7 +58,6 @@ fn timelock_equal_timestamp() { None, Some(200), None, - None, )]); let outputs = build_outputs([Basic( 2_000_000, @@ -70,7 +67,6 @@ fn timelock_equal_timestamp() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -100,7 +96,6 @@ fn two_outputs_one_timelock_expired() { None, Some(200), None, - None, ), Basic( 2_000_000, @@ -110,7 +105,6 @@ fn two_outputs_one_timelock_expired() { None, Some(50), None, - None, ), ]); let outputs = build_outputs([Basic( @@ -121,7 +115,6 @@ fn two_outputs_one_timelock_expired() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -152,7 +145,6 @@ fn two_outputs_one_timelocked_one_missing() { None, Some(200), None, - None, ), Basic( 2_000_000, @@ -162,7 +154,6 @@ fn two_outputs_one_timelocked_one_missing() { None, None, None, - None, ), ]); let outputs = build_outputs([Basic( @@ -173,7 +164,6 @@ fn two_outputs_one_timelocked_one_missing() { None, None, None, - None, )]); let selected = InputSelection::new( @@ -203,7 +193,6 @@ fn one_output_timelock_expired() { None, Some(50), None, - None, )]); let outputs = build_outputs([Basic( 2_000_000, @@ -213,7 +202,6 @@ fn one_output_timelock_expired() { None, None, None, - None, )]); let selected = InputSelection::new( diff --git a/sdk/tests/client/input_signing_data.rs b/sdk/tests/client/input_signing_data.rs index 11fb0796a4..b44ffdd5c9 100644 --- a/sdk/tests/client/input_signing_data.rs +++ b/sdk/tests/client/input_signing_data.rs @@ -1,7 +1,6 @@ // Copyright 2023 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -use crypto::keys::bip44::Bip44; use iota_sdk::{ client::{constants::SHIMMER_COIN_TYPE, secret::types::InputSigningData}, types::block::{ @@ -14,8 +13,6 @@ use pretty_assertions::assert_eq; #[test] fn input_signing_data_conversion() { - let bip44_chain = Bip44::new(SHIMMER_COIN_TYPE); - let output = BasicOutput::build_with_amount(1_000_000) .add_unlock_condition(AddressUnlockCondition::new( Address::try_from_bech32("rms1qpllaj0pyveqfkwxmnngz2c488hfdtmfrj3wfkgxtk4gtyrax0jaxzt70zy").unwrap(), @@ -26,15 +23,10 @@ fn input_signing_data_conversion() { let input_signing_data = InputSigningData { output, output_metadata: rand_output_metadata(), - signing_options: Some(bip44_chain), }; - assert_eq!(input_signing_data.signing_options.as_ref(), Some(&bip44_chain)); - let input_signing_data_json = serde_json::to_value(&input_signing_data).unwrap(); - let restored_input_signing_data = - serde_json::from_value::>(input_signing_data_json).unwrap(); + let restored_input_signing_data = serde_json::from_value::(input_signing_data_json).unwrap(); assert!(restored_input_signing_data.output.is_basic()); - assert_eq!(restored_input_signing_data.signing_options.as_ref(), Some(&bip44_chain)); } diff --git a/sdk/tests/client/mod.rs b/sdk/tests/client/mod.rs index f178b58a60..888b443041 100644 --- a/sdk/tests/client/mod.rs +++ b/sdk/tests/client/mod.rs @@ -17,7 +17,6 @@ mod signing; use std::{collections::HashMap, hash::Hash, str::FromStr}; -use crypto::keys::bip44::Bip44; use iota_sdk::{ client::secret::types::InputSigningData, types::block::{ @@ -64,7 +63,6 @@ enum Build<'a> { Option<(Address, u64)>, Option, Option<(Address, u32)>, - Option, ), Nft( u64, @@ -74,9 +72,8 @@ enum Build<'a> { Option
, Option<(Address, u64)>, Option<(Address, u32)>, - Option, ), - Account(u64, AccountId, Address, Option
, Option
, Option), + Account(u64, AccountId, Address, Option
, Option
), Foundry(u64, AccountId, u32, SimpleTokenScheme, Option<(&'a str, u64)>), } @@ -188,43 +185,39 @@ fn build_foundry_output( builder.finish_output().unwrap() } -fn build_output_inner(build: Build) -> (Output, Option) { +fn build_output_inner(build: Build) -> Output { match build { - Build::Basic(amount, address, native_token, sender, sdruc, timelock, expiration, chain) => ( - build_basic_output(amount, address, native_token, sender, sdruc, timelock, expiration), - chain, - ), - Build::Nft(amount, nft_id, address, sender, issuer, sdruc, expiration, chain) => ( - build_nft_output(amount, nft_id, address, sender, issuer, sdruc, expiration), - chain, - ), - Build::Account(amount, account_id, address, sender, issuer, chain) => { - (build_account_output(amount, account_id, address, sender, issuer), chain) + Build::Basic(amount, address, native_token, sender, sdruc, timelock, expiration) => { + build_basic_output(amount, address, native_token, sender, sdruc, timelock, expiration) + } + Build::Nft(amount, nft_id, address, sender, issuer, sdruc, expiration) => { + build_nft_output(amount, nft_id, address, sender, issuer, sdruc, expiration) + } + Build::Account(amount, account_id, address, sender, issuer) => { + build_account_output(amount, account_id, address, sender, issuer) + } + Build::Foundry(amount, account_id, serial_number, token_scheme, native_token) => { + build_foundry_output(amount, account_id, serial_number, token_scheme, native_token) } - Build::Foundry(amount, account_id, serial_number, token_scheme, native_token) => ( - build_foundry_output(amount, account_id, serial_number, token_scheme, native_token), - None, - ), } } -fn build_inputs<'a>(outputs: impl IntoIterator>) -> Vec> { +fn build_inputs<'a>(outputs: impl IntoIterator>) -> Vec { outputs .into_iter() .map(|build| { - let (output, chain) = build_output_inner(build); + let output = build_output_inner(build); InputSigningData { output, output_metadata: rand_output_metadata_with_id(OutputId::new(rand_transaction_id(), 0)), - signing_options: chain, } }) .collect() } fn build_outputs<'a>(outputs: impl IntoIterator>) -> Vec { - outputs.into_iter().map(|build| build_output_inner(build).0).collect() + outputs.into_iter().map(|build| build_output_inner(build)).collect() } fn unsorted_eq(a: &[T], b: &[T]) -> bool diff --git a/sdk/tests/client/signing/account.rs b/sdk/tests/client/signing/account.rs index 08f3107fda..fb1dc9b946 100644 --- a/sdk/tests/client/signing/account.rs +++ b/sdk/tests/client/signing/account.rs @@ -42,16 +42,11 @@ async fn sign_account_state_transition() -> Result<()> { let protocol_parameters = protocol_parameters(); let account_id = AccountId::from_str(ACCOUNT_ID_1)?; - let inputs = build_inputs([Account( - 1_000_000, - account_id, - address.clone(), - None, - None, - Some(Bip44::new(SHIMMER_COIN_TYPE)), - )]); + let signing_options = Bip44::new(SHIMMER_COIN_TYPE); - let outputs = build_outputs([Account(1_000_000, account_id, address.clone(), None, None, None)]); + let inputs = build_inputs([Account(1_000_000, account_id, address.clone(), None, None)]); + + let outputs = build_outputs([Account(1_000_000, account_id, address.clone(), None, None)]); let transaction = Transaction::builder(protocol_parameters.network_id()) .with_inputs( @@ -71,7 +66,7 @@ async fn sign_account_state_transition() -> Result<()> { }; let unlocks = secret_manager - .transaction_unlocks(&prepared_transaction_data, &protocol_parameters) + .transaction_unlocks(&prepared_transaction_data, &protocol_parameters, &signing_options) .await?; assert_eq!(unlocks.len(), 1); @@ -104,22 +99,17 @@ async fn account_reference_unlocks() -> Result<()> { let account_id = AccountId::from_str(ACCOUNT_ID_1)?; let account_address = Address::Account(AccountAddress::new(account_id)); + let signing_options = Bip44::new(SHIMMER_COIN_TYPE); + let inputs = build_inputs([ - Account( - 1_000_000, - account_id, - address.clone(), - None, - None, - Some(Bip44::new(SHIMMER_COIN_TYPE)), - ), - Basic(1_000_000, account_address.clone(), None, None, None, None, None, None), - Basic(1_000_000, account_address.clone(), None, None, None, None, None, None), + Account(1_000_000, account_id, address.clone(), None, None), + Basic(1_000_000, account_address.clone(), None, None, None, None, None), + Basic(1_000_000, account_address.clone(), None, None, None, None, None), ]); let outputs = build_outputs([ - Account(1_000_000, account_id, address, None, None, None), - Basic(2_000_000, account_address, None, None, None, None, None, None), + Account(1_000_000, account_id, address, None, None), + Basic(2_000_000, account_address, None, None, None, None, None), ]); let transaction = Transaction::builder(protocol_parameters.network_id()) @@ -140,7 +130,7 @@ async fn account_reference_unlocks() -> Result<()> { }; let unlocks = secret_manager - .transaction_unlocks(&prepared_transaction_data, &protocol_parameters) + .transaction_unlocks(&prepared_transaction_data, &protocol_parameters, &signing_options) .await?; assert_eq!(unlocks.len(), 3); diff --git a/sdk/tests/client/signing/basic.rs b/sdk/tests/client/signing/basic.rs index ea135ea3d8..09d726662b 100644 --- a/sdk/tests/client/signing/basic.rs +++ b/sdk/tests/client/signing/basic.rs @@ -34,27 +34,9 @@ async fn single_ed25519_unlock() -> Result<()> { let protocol_parameters = protocol_parameters(); - let inputs = build_inputs([Basic( - 1_000_000, - address_0.clone(), - None, - None, - None, - None, - None, - Some(Bip44::new(SHIMMER_COIN_TYPE)), - )]); - - let outputs = build_outputs([Basic( - 1_000_000, - address_0, - None, - None, - None, - None, - None, - Some(Bip44::new(SHIMMER_COIN_TYPE)), - )]); + let inputs = build_inputs([Basic(1_000_000, address_0.clone(), None, None, None, None, None)]); + + let outputs = build_outputs([Basic(1_000_000, address_0, None, None, None, None, None)]); let transaction = Transaction::builder(protocol_parameters.network_id()) .with_inputs( @@ -73,8 +55,10 @@ async fn single_ed25519_unlock() -> Result<()> { remainder: None, }; + let signing_options = Bip44::new(SHIMMER_COIN_TYPE); + let unlocks = secret_manager - .transaction_unlocks(&prepared_transaction_data, &protocol_parameters) + .transaction_unlocks(&prepared_transaction_data, &protocol_parameters, &signing_options) .await?; assert_eq!(unlocks.len(), 1); @@ -106,48 +90,12 @@ async fn ed25519_reference_unlocks() -> Result<()> { let protocol_parameters = protocol_parameters(); let inputs = build_inputs([ - Basic( - 1_000_000, - address_0.clone(), - None, - None, - None, - None, - None, - Some(Bip44::new(SHIMMER_COIN_TYPE)), - ), - Basic( - 1_000_000, - address_0.clone(), - None, - None, - None, - None, - None, - Some(Bip44::new(SHIMMER_COIN_TYPE)), - ), - Basic( - 1_000_000, - address_0.clone(), - None, - None, - None, - None, - None, - Some(Bip44::new(SHIMMER_COIN_TYPE)), - ), + Basic(1_000_000, address_0.clone(), None, None, None, None, None), + Basic(1_000_000, address_0.clone(), None, None, None, None, None), + Basic(1_000_000, address_0.clone(), None, None, None, None, None), ]); - let outputs = build_outputs([Basic( - 3_000_000, - address_0, - None, - None, - None, - None, - None, - Some(Bip44::new(SHIMMER_COIN_TYPE)), - )]); + let outputs = build_outputs([Basic(3_000_000, address_0, None, None, None, None, None)]); let transaction = Transaction::builder(protocol_parameters.network_id()) .with_inputs( @@ -166,8 +114,10 @@ async fn ed25519_reference_unlocks() -> Result<()> { remainder: None, }; + let signing_options = Bip44::new(SHIMMER_COIN_TYPE); + let unlocks = secret_manager - .transaction_unlocks(&prepared_transaction_data, &protocol_parameters) + .transaction_unlocks(&prepared_transaction_data, &protocol_parameters, &signing_options) .await?; assert_eq!(unlocks.len(), 3); @@ -216,38 +166,11 @@ async fn two_signature_unlocks() -> Result<()> { let protocol_parameters = protocol_parameters(); let inputs = build_inputs([ - Basic( - 1_000_000, - address_0.clone(), - None, - None, - None, - None, - None, - Some(Bip44::new(SHIMMER_COIN_TYPE)), - ), - Basic( - 1_000_000, - address_1, - None, - None, - None, - None, - None, - Some(Bip44::new(SHIMMER_COIN_TYPE).with_address_index(1)), - ), + Basic(1_000_000, address_0.clone(), None, None, None, None, None), + Basic(1_000_000, address_1, None, None, None, None, None), ]); - let outputs = build_outputs([Basic( - 2_000_000, - address_0, - None, - None, - None, - None, - None, - Some(Bip44::new(SHIMMER_COIN_TYPE)), - )]); + let outputs = build_outputs([Basic(2_000_000, address_0, None, None, None, None, None)]); let transaction = Transaction::builder(protocol_parameters.network_id()) .with_inputs( @@ -266,8 +189,10 @@ async fn two_signature_unlocks() -> Result<()> { remainder: None, }; + let signing_options = Bip44::new(SHIMMER_COIN_TYPE); + let unlocks = secret_manager - .transaction_unlocks(&prepared_transaction_data, &protocol_parameters) + .transaction_unlocks(&prepared_transaction_data, &protocol_parameters, &signing_options) .await?; assert_eq!(unlocks.len(), 2); diff --git a/sdk/tests/client/signing/mod.rs b/sdk/tests/client/signing/mod.rs index eee9ab1d52..bf58102ca0 100644 --- a/sdk/tests/client/signing/mod.rs +++ b/sdk/tests/client/signing/mod.rs @@ -68,72 +68,20 @@ async fn all_combined() -> Result<()> { let nft_4 = Address::Nft(NftAddress::new(nft_id_4)); let inputs = build_inputs([ - Account(1_000_000, account_id_1, nft_1.clone(), None, None, None), - Account( - 1_000_000, - account_id_2, - ed25519_0.into(), - None, - None, - Some(Bip44::new(SHIMMER_COIN_TYPE)), - ), - Basic(1_000_000, account_1.clone(), None, None, None, None, None, None), - Basic(1_000_000, account_2.clone(), None, None, None, None, None, None), - Basic(1_000_000, account_2, None, None, None, None, None, None), - Basic(1_000_000, nft_2.clone(), None, None, None, None, None, None), - Basic(1_000_000, nft_2, None, None, None, None, None, None), - Basic(1_000_000, nft_4.clone(), None, None, None, None, None, None), - Basic( - 1_000_000, - ed25519_0.into(), - None, - None, - None, - None, - None, - Some(Bip44::new(SHIMMER_COIN_TYPE)), - ), - Basic( - 1_000_000, - ed25519_1.into(), - None, - None, - None, - None, - None, - Some(Bip44::new(SHIMMER_COIN_TYPE).with_address_index(1)), - ), - Basic( - 1_000_000, - ed25519_2.into(), - None, - None, - None, - None, - None, - Some(Bip44::new(SHIMMER_COIN_TYPE).with_address_index(2)), - ), - Basic( - 1_000_000, - ed25519_2.into(), - None, - None, - None, - None, - None, - Some(Bip44::new(SHIMMER_COIN_TYPE).with_address_index(2)), - ), - Nft( - 1_000_000, - nft_id_1, - ed25519_0.into(), - None, - None, - None, - None, - Some(Bip44::new(SHIMMER_COIN_TYPE)), - ), - Nft(1_000_000, nft_id_2, account_1.clone(), None, None, None, None, None), + Account(1_000_000, account_id_1, nft_1.clone(), None, None), + Account(1_000_000, account_id_2, ed25519_0.into(), None, None), + Basic(1_000_000, account_1.clone(), None, None, None, None, None), + Basic(1_000_000, account_2.clone(), None, None, None, None, None), + Basic(1_000_000, account_2, None, None, None, None, None), + Basic(1_000_000, nft_2.clone(), None, None, None, None, None), + Basic(1_000_000, nft_2, None, None, None, None, None), + Basic(1_000_000, nft_4.clone(), None, None, None, None, None), + Basic(1_000_000, ed25519_0.into(), None, None, None, None, None), + Basic(1_000_000, ed25519_1.into(), None, None, None, None, None), + Basic(1_000_000, ed25519_2.into(), None, None, None, None, None), + Basic(1_000_000, ed25519_2.into(), None, None, None, None, None), + Nft(1_000_000, nft_id_1, ed25519_0.into(), None, None, None, None), + Nft(1_000_000, nft_id_2, account_1.clone(), None, None, None, None), // Expirations Basic( 2_000_000, @@ -143,7 +91,6 @@ async fn all_combined() -> Result<()> { None, None, Some((account_1.clone(), 50)), - None, ), Basic( 2_000_000, @@ -153,7 +100,6 @@ async fn all_combined() -> Result<()> { None, None, Some((nft_3.clone(), 50)), - None, ), Basic( 2_000_000, @@ -163,7 +109,6 @@ async fn all_combined() -> Result<()> { None, None, Some((nft_3.clone(), 150)), - Some(Bip44::new(SHIMMER_COIN_TYPE)), ), Nft( 1_000_000, @@ -173,28 +118,18 @@ async fn all_combined() -> Result<()> { None, None, Some((nft_4, 50)), - None, - ), - Nft( - 1_000_000, - nft_id_4, - account_1, - None, - None, - None, - Some((nft_3, 150)), - None, ), + Nft(1_000_000, nft_id_4, account_1, None, None, None, Some((nft_3, 150))), ]); let outputs = build_outputs([ - Account(1_000_000, account_id_1, nft_1, None, None, None), - Account(1_000_000, account_id_2, ed25519_0.into(), None, None, None), - Basic(10_000_000, ed25519_0.into(), None, None, None, None, None, None), - Nft(1_000_000, nft_id_1, ed25519_0.into(), None, None, None, None, None), - Nft(1_000_000, nft_id_2, ed25519_0.into(), None, None, None, None, None), - Nft(1_000_000, nft_id_3, ed25519_0.into(), None, None, None, None, None), - Nft(1_000_000, nft_id_4, ed25519_0.into(), None, None, None, None, None), + Account(1_000_000, account_id_1, nft_1, None, None), + Account(1_000_000, account_id_2, ed25519_0.into(), None, None), + Basic(10_000_000, ed25519_0.into(), None, None, None, None, None), + Nft(1_000_000, nft_id_1, ed25519_0.into(), None, None, None, None), + Nft(1_000_000, nft_id_2, ed25519_0.into(), None, None, None, None), + Nft(1_000_000, nft_id_3, ed25519_0.into(), None, None, None, None), + Nft(1_000_000, nft_id_4, ed25519_0.into(), None, None, None, None), ]); let slot_index = SlotIndex::from(100); @@ -228,8 +163,10 @@ async fn all_combined() -> Result<()> { remainder: None, }; + let signing_options = Bip44::new(SHIMMER_COIN_TYPE); + let unlocks = secret_manager - .transaction_unlocks(&prepared_transaction_data, &protocol_parameters) + .transaction_unlocks(&prepared_transaction_data, &protocol_parameters, &signing_options) .await?; assert_eq!(unlocks.len(), 15); diff --git a/sdk/tests/client/signing/nft.rs b/sdk/tests/client/signing/nft.rs index 53b184474b..ed1370f613 100644 --- a/sdk/tests/client/signing/nft.rs +++ b/sdk/tests/client/signing/nft.rs @@ -44,23 +44,14 @@ async fn nft_reference_unlocks() -> Result<()> { let nft_address = Address::Nft(NftAddress::new(nft_id)); let inputs = build_inputs([ - Nft( - 1_000_000, - nft_id, - address_0.clone(), - None, - None, - None, - None, - Some(Bip44::new(SHIMMER_COIN_TYPE)), - ), - Basic(1_000_000, nft_address.clone(), None, None, None, None, None, None), - Basic(1_000_000, nft_address.clone(), None, None, None, None, None, None), + Nft(1_000_000, nft_id, address_0.clone(), None, None, None, None), + Basic(1_000_000, nft_address.clone(), None, None, None, None, None), + Basic(1_000_000, nft_address.clone(), None, None, None, None, None), ]); let outputs = build_outputs([ - Nft(1_000_000, nft_id, address_0, None, None, None, None, None), - Basic(2_000_000, nft_address, None, None, None, None, None, None), + Nft(1_000_000, nft_id, address_0, None, None, None, None), + Basic(2_000_000, nft_address, None, None, None, None, None), ]); let transaction = Transaction::builder(protocol_parameters.network_id()) @@ -80,8 +71,10 @@ async fn nft_reference_unlocks() -> Result<()> { remainder: None, }; + let signing_options = Bip44::new(SHIMMER_COIN_TYPE); + let unlocks = secret_manager - .transaction_unlocks(&prepared_transaction_data, &protocol_parameters) + .transaction_unlocks(&prepared_transaction_data, &protocol_parameters, &signing_options) .await?; assert_eq!(unlocks.len(), 3); diff --git a/sdk/tests/wallet/events.rs b/sdk/tests/wallet/events.rs index 02a027e78f..0495b82189 100644 --- a/sdk/tests/wallet/events.rs +++ b/sdk/tests/wallet/events.rs @@ -27,7 +27,7 @@ use pretty_assertions::assert_eq; const ED25519_ADDRESS: &str = "0x52fdfc072182654f163f5f0f9a621d729566c74d10037c4d7bbb0407d1e2c649"; const TRANSACTION_ID: &str = "0x52fdfc072182654f163f5f0f9a621d729566c74d10037c4d7bbb0407d1e2c64900000000"; -fn assert_serde_eq(event_0: WalletEvent<()>) { +fn assert_serde_eq(event_0: WalletEvent) { let json = serde_json::to_string(&event_0).unwrap(); let event_1 = serde_json::from_str(&json).unwrap(); @@ -52,7 +52,6 @@ fn wallet_events_serde() { address: Address::Ed25519(Ed25519Address::new([0; Ed25519Address::LENGTH])), network_id: 42, remainder: true, - signing_options: None, }; assert_serde_eq(WalletEvent::NewOutput(Box::new(NewOutputEvent {