diff --git a/sdk/tests/client/input_selection/account_outputs.rs b/sdk/tests/client/input_selection/account_outputs.rs index 46be201a92..a350d1a584 100644 --- a/sdk/tests/client/input_selection/account_outputs.rs +++ b/sdk/tests/client/input_selection/account_outputs.rs @@ -14,7 +14,7 @@ use iota_sdk::{ use pretty_assertions::{assert_eq, assert_ne}; use crate::client::{ - addresses, build_inputs, build_outputs, is_remainder_or_return, unsorted_eq, + build_inputs, build_outputs, is_remainder_or_return, unsorted_eq, Build::{Account, Basic}, ACCOUNT_ID_0, ACCOUNT_ID_1, ACCOUNT_ID_2, BECH32_ADDRESS_ACCOUNT_1, BECH32_ADDRESS_ED25519_0, BECH32_ADDRESS_ED25519_1, BECH32_ADDRESS_NFT_1, @@ -28,7 +28,7 @@ fn input_account_eq_output_account() { let inputs = build_inputs([Account( 1_000_000, account_id_2, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -36,7 +36,7 @@ fn input_account_eq_output_account() { let outputs = build_outputs([Account( 1_000_000, account_id_2, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -45,7 +45,7 @@ fn input_account_eq_output_account() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select() @@ -63,7 +63,7 @@ fn transition_account_id_zero() { let inputs = build_inputs([Account( 1_000_000, account_id_0, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -72,7 +72,7 @@ fn transition_account_id_zero() { let outputs = build_outputs([Account( 1_000_000, account_id, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -81,7 +81,7 @@ fn transition_account_id_zero() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select() @@ -100,8 +100,8 @@ fn transition_account_id_zero() { // 1_000_000, // account_id_2, // 0, -// BECH32_ADDRESS_ED25519_0, -// BECH32_ADDRESS_ED25519_0, +// Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), +// Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), // None, // None, // None, @@ -109,7 +109,7 @@ fn transition_account_id_zero() { // )]); // let outputs = build_outputs([Basic( // 2_000_000, -// BECH32_ADDRESS_ED25519_0, +// Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), // None, // None, // None, @@ -121,7 +121,7 @@ fn transition_account_id_zero() { // let selected = InputSelection::new( // inputs, // outputs, -// addresses([BECH32_ADDRESS_ED25519_0]), +// [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], // protocol_parameters, // ) // .select(); @@ -146,18 +146,18 @@ fn transition_account_id_zero() { // 2_000_000, // account_id_2, // 0, -// BECH32_ADDRESS_ED25519_0, -// BECH32_ADDRESS_ED25519_0, +// Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), +// Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), // None, // None, // None, // None, // ), -// Basic(1_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), -// ]); +// Basic(1_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, None, None, +// None), ]); // let outputs = build_outputs([Basic( // 3_000_001, -// BECH32_ADDRESS_ED25519_0, +// Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), // None, // None, // None, @@ -169,7 +169,7 @@ fn transition_account_id_zero() { // let selected = InputSelection::new( // inputs, // outputs, -// addresses([BECH32_ADDRESS_ED25519_0]), +// [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], // protocol_parameters, // ) // .select(); @@ -193,8 +193,8 @@ fn transition_account_id_zero() { // 2_259_500, // account_id_2, // 0, -// BECH32_ADDRESS_ED25519_0, -// BECH32_ADDRESS_ED25519_0, +// Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), +// Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), // None, // None, // None, @@ -202,7 +202,7 @@ fn transition_account_id_zero() { // )]); // let outputs = build_outputs([Basic( // 2_000_000, -// BECH32_ADDRESS_ED25519_0, +// Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), // None, // None, // None, @@ -214,7 +214,7 @@ fn transition_account_id_zero() { // let selected = InputSelection::new( // inputs.clone(), // outputs, -// addresses([BECH32_ADDRESS_ED25519_0]), +// [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], // protocol_parameters, // ) // .select() @@ -232,7 +232,7 @@ fn create_account() { let inputs = build_inputs([Basic( 2_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -243,7 +243,7 @@ fn create_account() { let outputs = build_outputs([Account( 1_000_000, account_id_0, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -252,7 +252,7 @@ fn create_account() { let selected = InputSelection::new( inputs.clone(), outputs, - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select() @@ -279,14 +279,14 @@ fn burn_account() { let inputs = build_inputs([Account( 2_000_000, account_id_2, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, )]); let outputs = build_outputs([Basic( 2_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -298,7 +298,7 @@ fn burn_account() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .with_burn(Burn::new().add_account(account_id_2)) @@ -318,8 +318,8 @@ fn burn_account() { // 1_000_001, // account_id_2, // 0, -// BECH32_ADDRESS_ED25519_0, -// BECH32_ADDRESS_ED25519_0, +// Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), +// Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), // None, // None, // None, @@ -329,8 +329,8 @@ fn burn_account() { // 1_000_000, // account_id_2, // 0, -// BECH32_ADDRESS_ED25519_0, -// BECH32_ADDRESS_ED25519_0, +// Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), +// Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), // None, // None, // None, @@ -340,7 +340,7 @@ fn burn_account() { // let selected = InputSelection::new( // inputs, // outputs, -// addresses([BECH32_ADDRESS_ED25519_0]), +// [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], // protocol_parameters, // ) // .select(); @@ -361,7 +361,7 @@ fn missing_input_for_account_output() { let inputs = build_inputs([Basic( 1_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -372,7 +372,7 @@ fn missing_input_for_account_output() { let outputs = build_outputs([Account( 1_000_000, account_id_2, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -381,7 +381,7 @@ fn missing_input_for_account_output() { let selected = InputSelection::new( inputs, outputs, - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select(); @@ -399,13 +399,29 @@ fn missing_input_for_account_output_2() { let account_id_2 = AccountId::from_str(ACCOUNT_ID_2).unwrap(); let inputs = build_inputs([ - Account(2_000_000, account_id_1, BECH32_ADDRESS_ED25519_0, None, None, None), - Basic(1_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), + Account( + 2_000_000, + account_id_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + ), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), ]); let outputs = build_outputs([Account( 1_000_000, account_id_2, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -414,7 +430,7 @@ fn missing_input_for_account_output_2() { let selected = InputSelection::new( inputs, outputs, - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select(); @@ -432,7 +448,7 @@ fn missing_input_for_account_output_but_created() { let inputs = build_inputs([Basic( 1_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -443,7 +459,7 @@ fn missing_input_for_account_output_but_created() { let outputs = build_outputs([Account( 1_000_000, account_id_0, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -452,7 +468,7 @@ fn missing_input_for_account_output_but_created() { let selected = InputSelection::new( inputs, outputs, - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select(); @@ -466,17 +482,33 @@ fn account_in_output_and_sender() { let account_id_1 = AccountId::from_str(ACCOUNT_ID_1).unwrap(); let inputs = build_inputs([ - Account(1_000_000, account_id_1, BECH32_ADDRESS_ED25519_0, None, None, None), - Basic(1_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), + Account( + 1_000_000, + account_id_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + ), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), ]); let account_output = AccountOutputBuilder::from(inputs[0].output.as_account()) .finish_output() .unwrap(); let mut outputs = build_outputs([Basic( 1_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, - Some(BECH32_ADDRESS_ACCOUNT_1), + Some(Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap()), None, None, None, @@ -487,7 +519,7 @@ fn account_in_output_and_sender() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select() @@ -505,7 +537,7 @@ fn missing_ed25519_sender() { let inputs = build_inputs([Account( 1_000_000, account_id_2, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -513,8 +545,8 @@ fn missing_ed25519_sender() { let outputs = build_outputs([Account( 1_000_000, account_id_2, - BECH32_ADDRESS_ED25519_0, - Some(BECH32_ADDRESS_ED25519_1), + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + Some(Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()), None, None, )]); @@ -522,7 +554,7 @@ fn missing_ed25519_sender() { let selected = InputSelection::new( inputs, outputs, - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select(); @@ -540,7 +572,7 @@ fn missing_ed25519_issuer_created() { let inputs = build_inputs([Basic( 1_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -551,16 +583,16 @@ fn missing_ed25519_issuer_created() { let outputs = build_outputs([Account( 1_000_000, account_id_0, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, - Some(BECH32_ADDRESS_ED25519_1), + Some(Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()), None, )]); let selected = InputSelection::new( inputs, outputs, - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select(); @@ -579,24 +611,24 @@ fn missing_ed25519_issuer_transition() { let inputs = build_inputs([Account( 1_000_000, account_id_1, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, - Some(BECH32_ADDRESS_ED25519_1), + Some(Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()), None, )]); let outputs = build_outputs([Account( 1_000_000, account_id_1, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, - Some(BECH32_ADDRESS_ED25519_1), + Some(Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()), None, )]); let selected = InputSelection::new( inputs, outputs, - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select(); @@ -612,7 +644,7 @@ fn missing_account_sender() { let inputs = build_inputs([Account( 1_000_000, account_id_2, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -620,8 +652,8 @@ fn missing_account_sender() { let outputs = build_outputs([Account( 1_000_000, account_id_2, - BECH32_ADDRESS_ED25519_0, - Some(BECH32_ADDRESS_ACCOUNT_1), + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + Some(Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap()), None, None, )]); @@ -629,7 +661,7 @@ fn missing_account_sender() { let selected = InputSelection::new( inputs, outputs, - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select(); @@ -647,7 +679,7 @@ fn missing_account_issuer_created() { let inputs = build_inputs([Basic( 1_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -658,16 +690,16 @@ fn missing_account_issuer_created() { let outputs = build_outputs([Account( 1_000_000, account_id_0, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, - Some(BECH32_ADDRESS_ACCOUNT_1), + Some(Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap()), None, )]); let selected = InputSelection::new( inputs, outputs, - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select(); @@ -686,24 +718,24 @@ fn missing_account_issuer_transition() { let inputs = build_inputs([Account( 1_000_000, account_id_2, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, - Some(BECH32_ADDRESS_ACCOUNT_1), + Some(Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap()), None, )]); let outputs = build_outputs([Account( 1_000_000, account_id_2, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, - Some(BECH32_ADDRESS_ACCOUNT_1), + Some(Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap()), None, )]); let selected = InputSelection::new( inputs, outputs, - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select(); @@ -719,7 +751,7 @@ fn missing_nft_sender() { let inputs = build_inputs([Account( 1_000_000, account_id_2, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -727,8 +759,8 @@ fn missing_nft_sender() { let outputs = build_outputs([Account( 1_000_000, account_id_2, - BECH32_ADDRESS_ED25519_0, - Some(BECH32_ADDRESS_NFT_1), + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + Some(Address::try_from_bech32(BECH32_ADDRESS_NFT_1).unwrap()), None, None, )]); @@ -736,7 +768,7 @@ fn missing_nft_sender() { let selected = InputSelection::new( inputs, outputs, - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select(); @@ -754,7 +786,7 @@ fn missing_nft_issuer_created() { let inputs = build_inputs([Basic( 1_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -765,16 +797,16 @@ fn missing_nft_issuer_created() { let outputs = build_outputs([Account( 1_000_000, account_id_0, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, - Some(BECH32_ADDRESS_NFT_1), + Some(Address::try_from_bech32(BECH32_ADDRESS_NFT_1).unwrap()), None, )]); let selected = InputSelection::new( inputs, outputs, - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select(); @@ -793,24 +825,24 @@ fn missing_nft_issuer_transition() { let inputs = build_inputs([Account( 1_000_000, account_id_1, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, - Some(BECH32_ADDRESS_NFT_1), + Some(Address::try_from_bech32(BECH32_ADDRESS_NFT_1).unwrap()), None, )]); let outputs = build_outputs([Account( 1_000_000, account_id_1, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, - Some(BECH32_ADDRESS_NFT_1), + Some(Address::try_from_bech32(BECH32_ADDRESS_NFT_1).unwrap()), None, )]); let selected = InputSelection::new( inputs, outputs, - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select(); @@ -824,13 +856,29 @@ fn increase_account_amount() { let account_id_1 = AccountId::from_str(ACCOUNT_ID_1).unwrap(); let inputs = build_inputs([ - Account(2_000_000, account_id_1, BECH32_ADDRESS_ED25519_0, None, None, None), - Basic(1_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), + Account( + 2_000_000, + account_id_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + ), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), ]); let outputs = build_outputs([Account( 3_000_000, account_id_1, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -839,7 +887,7 @@ fn increase_account_amount() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select() @@ -855,13 +903,29 @@ fn decrease_account_amount() { let account_id_1 = AccountId::from_str(ACCOUNT_ID_1).unwrap(); let inputs = build_inputs([ - Account(2_000_000, account_id_1, BECH32_ADDRESS_ED25519_0, None, None, None), - Basic(1_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), + Account( + 2_000_000, + account_id_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + ), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), ]); let outputs = build_outputs([Account( 1_000_000, account_id_1, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -870,7 +934,7 @@ fn decrease_account_amount() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select() @@ -885,7 +949,7 @@ fn decrease_account_amount() { assert!(is_remainder_or_return( output, 1_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None )); } @@ -898,12 +962,28 @@ fn prefer_basic_to_account() { let account_id_1 = AccountId::from_str(ACCOUNT_ID_1).unwrap(); let inputs = build_inputs([ - Account(1_000_000, account_id_1, BECH32_ADDRESS_ED25519_0, None, None, None), - Basic(1_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), + Account( + 1_000_000, + account_id_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + ), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), ]); let outputs = build_outputs([Basic( 1_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -915,7 +995,7 @@ fn prefer_basic_to_account() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select() @@ -932,12 +1012,28 @@ fn take_amount_from_account_to_fund_basic() { let account_id_1 = AccountId::from_str(ACCOUNT_ID_1).unwrap(); let inputs = build_inputs([ - Account(2_000_000, account_id_1, BECH32_ADDRESS_ED25519_0, None, None, None), - Basic(1_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), + Account( + 2_000_000, + account_id_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + ), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), ]); let outputs = build_outputs([Basic( 1_200_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -949,7 +1045,7 @@ fn take_amount_from_account_to_fund_basic() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select() @@ -980,14 +1076,30 @@ fn account_burn_should_validate_account_sender() { let account_id_1 = AccountId::from_str(ACCOUNT_ID_1).unwrap(); let inputs = build_inputs([ - Basic(2_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), - Account(1_000_000, account_id_1, BECH32_ADDRESS_ED25519_0, None, None, None), + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Account( + 1_000_000, + account_id_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + ), ]); let outputs = build_outputs([Basic( 2_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, - Some(BECH32_ADDRESS_ACCOUNT_1), + Some(Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap()), None, None, None, @@ -997,7 +1109,7 @@ fn account_burn_should_validate_account_sender() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .with_burn(Burn::new().add_account(account_id_1)) @@ -1013,7 +1125,7 @@ fn account_burn_should_validate_account_sender() { assert!(is_remainder_or_return( output, 1_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, )); } @@ -1026,12 +1138,28 @@ fn account_burn_should_validate_account_address() { let account_id_1 = AccountId::from_str(ACCOUNT_ID_1).unwrap(); let inputs = build_inputs([ - Basic(2_000_000, BECH32_ADDRESS_ACCOUNT_1, None, None, None, None, None, None), - Account(1_000_000, account_id_1, BECH32_ADDRESS_ED25519_0, None, None, None), + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Account( + 1_000_000, + account_id_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + ), ]); let outputs = build_outputs([Basic( 2_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -1043,7 +1171,7 @@ fn account_burn_should_validate_account_address() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .with_burn(Burn::new().add_account(account_id_1)) @@ -1059,7 +1187,7 @@ fn account_burn_should_validate_account_address() { assert!(is_remainder_or_return( output, 1_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, )); } @@ -1074,14 +1202,14 @@ fn transitioned_zero_account_id_no_longer_is_zero() { let inputs = build_inputs([Account( 2_000_000, account_id_0, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, )]); let outputs = build_outputs([Basic( 1_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -1093,7 +1221,7 @@ fn transitioned_zero_account_id_no_longer_is_zero() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select() @@ -1125,12 +1253,26 @@ fn two_accounts_required() { let account_id_2 = AccountId::from_str(ACCOUNT_ID_2).unwrap(); let inputs = build_inputs([ - Account(2_000_000, account_id_1, BECH32_ADDRESS_ED25519_0, None, None, None), - Account(2_000_000, account_id_2, BECH32_ADDRESS_ED25519_0, None, None, None), + Account( + 2_000_000, + account_id_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + ), + Account( + 2_000_000, + account_id_2, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + ), ]); let outputs = build_outputs([Basic( 3_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -1142,7 +1284,7 @@ fn two_accounts_required() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select() @@ -1181,16 +1323,16 @@ fn state_controller_sender_required() { let inputs = build_inputs([Account( 2_000_000, account_id_1, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, )]); let outputs = build_outputs([Basic( 1_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, - Some(BECH32_ADDRESS_ED25519_0), + Some(Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()), None, None, None, @@ -1200,7 +1342,7 @@ fn state_controller_sender_required() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select() @@ -1219,18 +1361,25 @@ fn state_controller_sender_required_already_selected() { let inputs = build_inputs([Account( 2_000_000, account_id_1, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, )]); let outputs = build_outputs([ - Account(1_000_000, account_id_1, BECH32_ADDRESS_ED25519_0, None, None, None), + Account( + 1_000_000, + account_id_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + ), Basic( 1_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, - Some(BECH32_ADDRESS_ED25519_0), + Some(Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()), None, None, None, @@ -1241,7 +1390,7 @@ fn state_controller_sender_required_already_selected() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .with_required_inputs([*inputs[0].output_id()]) @@ -1260,7 +1409,7 @@ fn state_transition_and_required() { let inputs = build_inputs([Account( 2_000_000, account_id_1, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -1268,7 +1417,7 @@ fn state_transition_and_required() { let outputs = build_outputs([Account( 2_000_000, account_id_1, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -1277,7 +1426,7 @@ fn state_transition_and_required() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .with_required_inputs([*inputs[0].output_id()]) @@ -1296,7 +1445,7 @@ fn remainder_address_in_state_controller() { let inputs = build_inputs([Account( 2_000_000, account_id_1, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -1304,7 +1453,7 @@ fn remainder_address_in_state_controller() { let outputs = build_outputs([Account( 1_000_000, account_id_1, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -1313,7 +1462,7 @@ fn remainder_address_in_state_controller() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select() @@ -1327,7 +1476,7 @@ fn remainder_address_in_state_controller() { assert!(is_remainder_or_return( output, 1_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None )); } diff --git a/sdk/tests/client/input_selection/basic_outputs.rs b/sdk/tests/client/input_selection/basic_outputs.rs index 760799e75b..90533d1a64 100644 --- a/sdk/tests/client/input_selection/basic_outputs.rs +++ b/sdk/tests/client/input_selection/basic_outputs.rs @@ -6,7 +6,7 @@ use std::str::FromStr; use iota_sdk::{ client::api::input_selection::{Error, InputSelection, Requirement}, types::block::{ - address::{AccountAddress, Address, Bech32Address, NftAddress, RestrictedAddress, ToBech32Ext}, + address::{AccountAddress, Address, NftAddress, RestrictedAddress}, output::{AccountId, NftId}, protocol::protocol_parameters, }, @@ -14,7 +14,7 @@ use iota_sdk::{ use pretty_assertions::assert_eq; use crate::client::{ - addresses, build_inputs, build_outputs, is_remainder_or_return, unsorted_eq, + build_inputs, build_outputs, is_remainder_or_return, unsorted_eq, Build::{Account, Basic, Nft}, ACCOUNT_ID_0, ACCOUNT_ID_1, BECH32_ADDRESS_ACCOUNT_1, BECH32_ADDRESS_ED25519_0, BECH32_ADDRESS_ED25519_1, BECH32_ADDRESS_NFT_1, BECH32_ADDRESS_REMAINDER, NFT_ID_0, NFT_ID_1, @@ -26,7 +26,7 @@ fn input_amount_equal_output_amount() { let inputs = build_inputs([Basic( 1_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -36,7 +36,7 @@ fn input_amount_equal_output_amount() { )]); let outputs = build_outputs([Basic( 1_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -48,7 +48,7 @@ fn input_amount_equal_output_amount() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select() @@ -64,7 +64,7 @@ fn input_amount_lower_than_output_amount() { let inputs = build_inputs([Basic( 1_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -74,7 +74,7 @@ fn input_amount_lower_than_output_amount() { )]); let outputs = build_outputs([Basic( 2_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -86,7 +86,7 @@ fn input_amount_lower_than_output_amount() { let selected = InputSelection::new( inputs, outputs, - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select(); @@ -105,12 +105,30 @@ fn input_amount_lower_than_output_amount_2() { let protocol_parameters = protocol_parameters(); let inputs = build_inputs([ - Basic(1_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), - Basic(2_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), ]); let outputs = build_outputs([Basic( 3_500_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -122,7 +140,7 @@ fn input_amount_lower_than_output_amount_2() { let selected = InputSelection::new( inputs, outputs, - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select(); @@ -142,7 +160,7 @@ fn input_amount_greater_than_output_amount() { let inputs = build_inputs([Basic( 2_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -152,7 +170,7 @@ fn input_amount_greater_than_output_amount() { )]); let outputs = build_outputs([Basic( 500_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -164,7 +182,7 @@ fn input_amount_greater_than_output_amount() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select() @@ -179,7 +197,7 @@ fn input_amount_greater_than_output_amount() { assert!(is_remainder_or_return( output, 1_500_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, )); } @@ -193,7 +211,7 @@ fn input_amount_greater_than_output_amount_with_remainder_address() { let inputs = build_inputs([Basic( 2_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -203,7 +221,7 @@ fn input_amount_greater_than_output_amount_with_remainder_address() { )]); let outputs = build_outputs([Basic( 500_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -215,7 +233,7 @@ fn input_amount_greater_than_output_amount_with_remainder_address() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .with_remainder_address(remainder_address) @@ -231,7 +249,7 @@ fn input_amount_greater_than_output_amount_with_remainder_address() { assert!(is_remainder_or_return( output, 1_500_000, - BECH32_ADDRESS_REMAINDER, + Address::try_from_bech32(BECH32_ADDRESS_REMAINDER).unwrap(), None, )); } @@ -243,12 +261,30 @@ fn two_same_inputs_one_needed() { let protocol_parameters = protocol_parameters(); let inputs = build_inputs([ - Basic(2_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), - Basic(2_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), ]); let outputs = build_outputs([Basic( 500_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -260,7 +296,7 @@ fn two_same_inputs_one_needed() { let selected = InputSelection::new( inputs, outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select() @@ -276,7 +312,7 @@ fn two_same_inputs_one_needed() { assert!(is_remainder_or_return( output, 1_500_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, )); } @@ -288,12 +324,30 @@ fn two_inputs_one_needed() { let protocol_parameters = protocol_parameters(); let inputs = build_inputs([ - Basic(1_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), - Basic(2_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), ]); let outputs = build_outputs([Basic( 1_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -305,7 +359,7 @@ fn two_inputs_one_needed() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select() @@ -320,12 +374,30 @@ fn two_inputs_one_needed_reversed() { let protocol_parameters = protocol_parameters(); let inputs = build_inputs([ - Basic(2_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), - Basic(1_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), ]); let outputs = build_outputs([Basic( 1_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -337,7 +409,7 @@ fn two_inputs_one_needed_reversed() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select() @@ -352,12 +424,30 @@ fn two_inputs_both_needed() { let protocol_parameters = protocol_parameters(); let inputs = build_inputs([ - Basic(1_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), - Basic(2_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), ]); let outputs = build_outputs([Basic( 3_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -369,7 +459,7 @@ fn two_inputs_both_needed() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select() @@ -384,12 +474,30 @@ fn two_inputs_remainder() { let protocol_parameters = protocol_parameters(); let inputs = build_inputs([ - Basic(1_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), - Basic(2_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), ]); let outputs = build_outputs([Basic( 2_500_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -401,7 +509,7 @@ fn two_inputs_remainder() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select() @@ -413,7 +521,12 @@ fn two_inputs_remainder() { assert!(selected.outputs.contains(&outputs[0])); selected.outputs.iter().for_each(|output| { if !outputs.contains(output) { - assert!(is_remainder_or_return(output, 500_000, BECH32_ADDRESS_ED25519_0, None)); + assert!(is_remainder_or_return( + output, + 500_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None + )); } }); } @@ -424,7 +537,7 @@ fn two_inputs_remainder() { // let inputs = build_inputs([Basic( // 1_000_001, -// BECH32_ADDRESS_ED25519_0, +// Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), // None, // None, // None, @@ -434,7 +547,7 @@ fn two_inputs_remainder() { // )]); // let outputs = build_outputs([Basic( // 1_000_000, -// BECH32_ADDRESS_ED25519_0, +// Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), // None, // None, // None, @@ -446,7 +559,7 @@ fn two_inputs_remainder() { // let selected = InputSelection::new( // inputs, // outputs, -// addresses([BECH32_ADDRESS_ED25519_0]), +// [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], // protocol_parameters, // ) // .select(); @@ -466,17 +579,62 @@ fn ed25519_sender() { let sender = Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(); let inputs = build_inputs([ - Basic(2_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), - Basic(2_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), - Basic(1_000_000, BECH32_ADDRESS_ED25519_1, None, None, None, None, None, None), - Basic(2_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), - Basic(2_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), ]); let outputs = build_outputs([Basic( 2_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, - Some(BECH32_ADDRESS_ED25519_1), + Some(Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()), None, None, None, @@ -486,7 +644,10 @@ fn ed25519_sender() { let selected = InputSelection::new( inputs, outputs, - addresses([BECH32_ADDRESS_ED25519_0, BECH32_ADDRESS_ED25519_1]), + [ + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + ], protocol_parameters, ) .select() @@ -510,7 +671,7 @@ fn missing_ed25519_sender() { let inputs = build_inputs([Basic( 5_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -520,9 +681,9 @@ fn missing_ed25519_sender() { )]); let outputs = build_outputs([Basic( 1_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, - Some(BECH32_ADDRESS_ED25519_1), + Some(Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()), None, None, None, @@ -532,7 +693,7 @@ fn missing_ed25519_sender() { let selected = InputSelection::new( inputs, outputs, - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select(); @@ -549,18 +710,61 @@ fn account_sender() { let account_id_1 = AccountId::from_str(ACCOUNT_ID_1).unwrap(); let inputs = build_inputs([ - Basic(2_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), - Basic(2_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), - Account(1_000_000, account_id_1, BECH32_ADDRESS_ED25519_0, None, None, None), - Basic(2_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), - Basic(2_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Account( + 1_000_000, + account_id_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + ), + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), ]); let outputs = build_outputs([Basic( 2_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, - Some(BECH32_ADDRESS_ACCOUNT_1), + Some(Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap()), None, None, None, @@ -570,7 +774,7 @@ fn account_sender() { let selected = InputSelection::new( inputs, outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select() @@ -595,19 +799,31 @@ fn account_sender_zero_id() { let account_id_0 = AccountId::from_str(ACCOUNT_ID_0).unwrap(); let inputs = build_inputs([ - Basic(2_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), - Account(1_000_000, account_id_0, BECH32_ADDRESS_ED25519_0, None, None, None), + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Account( + 1_000_000, + account_id_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + ), ]); let account_id = AccountId::from(inputs[1].output_id()); let outputs = build_outputs([Basic( 2_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, - Some( - &Bech32Address::try_new("rms", AccountAddress::from(account_id)) - .unwrap() - .to_string(), - ), + Some(Address::from(AccountAddress::from(account_id))), None, None, None, @@ -617,7 +833,7 @@ fn account_sender_zero_id() { let selected = InputSelection::new( inputs.clone(), outputs, - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select() @@ -639,7 +855,7 @@ fn missing_account_sender() { let inputs = build_inputs([Basic( 5_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -649,9 +865,9 @@ fn missing_account_sender() { )]); let outputs = build_outputs([Basic( 1_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, - Some(BECH32_ADDRESS_ACCOUNT_1), + Some(Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap()), None, None, None, @@ -661,7 +877,7 @@ fn missing_account_sender() { let selected = InputSelection::new( inputs, outputs, - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select(); @@ -678,26 +894,62 @@ fn nft_sender() { let nft_id_1 = NftId::from_str(NFT_ID_1).unwrap(); let inputs = build_inputs([ - Basic(2_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), - Basic(2_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), Nft( 1_000_000, nft_id_1, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + ), + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, None, None, None, None, None, ), - Basic(2_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), - Basic(2_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), ]); let outputs = build_outputs([Basic( 2_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, - Some(BECH32_ADDRESS_NFT_1), + Some(Address::try_from_bech32(BECH32_ADDRESS_NFT_1).unwrap()), None, None, None, @@ -707,7 +959,7 @@ fn nft_sender() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select() @@ -733,11 +985,20 @@ fn nft_sender_zero_id() { let nft_id_0 = NftId::from_str(NFT_ID_0).unwrap(); let inputs = build_inputs([ - Basic(2_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), Nft( 1_000_000, nft_id_0, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -748,13 +1009,9 @@ fn nft_sender_zero_id() { let nft_id = NftId::from(inputs[1].output_id()); let outputs = build_outputs([Basic( 2_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, - Some( - &Bech32Address::try_new("rms", NftAddress::from(nft_id)) - .unwrap() - .to_string(), - ), + Some(Address::from(NftAddress::from(nft_id))), None, None, None, @@ -764,7 +1021,7 @@ fn nft_sender_zero_id() { let selected = InputSelection::new( inputs.clone(), outputs, - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select() @@ -786,7 +1043,7 @@ fn missing_nft_sender() { let inputs = build_inputs([Basic( 5_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -796,9 +1053,9 @@ fn missing_nft_sender() { )]); let outputs = build_outputs([Basic( 1_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, - Some(BECH32_ADDRESS_NFT_1), + Some(Address::try_from_bech32(BECH32_ADDRESS_NFT_1).unwrap()), None, None, None, @@ -808,7 +1065,7 @@ fn missing_nft_sender() { let selected = InputSelection::new( inputs, outputs, - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select(); @@ -825,7 +1082,7 @@ fn simple_remainder() { let inputs = build_inputs([Basic( 1_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -835,7 +1092,7 @@ fn simple_remainder() { )]); let outputs = build_outputs([Basic( 500_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -847,7 +1104,7 @@ fn simple_remainder() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select() @@ -858,7 +1115,12 @@ fn simple_remainder() { assert!(selected.outputs.contains(&outputs[0])); selected.outputs.iter().for_each(|output| { if !outputs.contains(output) { - assert!(is_remainder_or_return(output, 500_000, BECH32_ADDRESS_ED25519_0, None)); + assert!(is_remainder_or_return( + output, + 500_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None + )); } }); } @@ -869,7 +1131,7 @@ fn simple_remainder() { // let inputs = build_inputs([Basic( // 1_000_000, -// BECH32_ADDRESS_ED25519_0, +// Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), // None, // None, // None, @@ -879,7 +1141,7 @@ fn simple_remainder() { // )]); // let outputs = build_outputs([Basic( // 800_000, -// BECH32_ADDRESS_ED25519_0, +// Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), // None, // None, // None, @@ -891,7 +1153,7 @@ fn simple_remainder() { // let selected = InputSelection::new( // inputs, // outputs, -// addresses([BECH32_ADDRESS_ED25519_0]), +// [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], // protocol_parameters, // ) // .select(); @@ -912,12 +1174,12 @@ fn simple_remainder() { // let protocol_parameters = protocol_parameters(); // let inputs = build_inputs([ -// Basic(1_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), -// Basic(2_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), -// ]); +// Basic(1_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, None, None, +// None), Basic(2_000_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, None, +// None, None), ]); // let outputs = build_outputs([Basic( // 2_800_000, -// BECH32_ADDRESS_ED25519_0, +// Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), // None, // None, // None, @@ -929,7 +1191,7 @@ fn simple_remainder() { // let selected = InputSelection::new( // inputs, // outputs, -// addresses([BECH32_ADDRESS_ED25519_0]), +// [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], // protocol_parameters, // ) // .select(); @@ -949,7 +1211,7 @@ fn one_provided_one_needed() { let inputs = build_inputs([Basic( 1_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -959,7 +1221,7 @@ fn one_provided_one_needed() { )]); let outputs = build_outputs([Basic( 1_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -971,7 +1233,7 @@ fn one_provided_one_needed() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select() @@ -987,7 +1249,7 @@ fn insufficient_amount() { let inputs = build_inputs([Basic( 1_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -997,7 +1259,7 @@ fn insufficient_amount() { )]); let outputs = build_outputs([Basic( 1_250_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -1009,7 +1271,7 @@ fn insufficient_amount() { let selected = InputSelection::new( inputs, outputs, - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select(); @@ -1028,12 +1290,30 @@ fn two_inputs_remainder_2() { let protocol_parameters = protocol_parameters(); let inputs = build_inputs([ - Basic(1_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), - Basic(2_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), ]); let outputs = build_outputs([Basic( 500_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -1045,7 +1325,7 @@ fn two_inputs_remainder_2() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select() @@ -1057,7 +1337,12 @@ fn two_inputs_remainder_2() { assert!(selected.outputs.contains(&outputs[0])); selected.outputs.iter().for_each(|output| { if !outputs.contains(output) { - assert!(is_remainder_or_return(output, 500_000, BECH32_ADDRESS_ED25519_0, None)); + assert!(is_remainder_or_return( + output, + 500_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None + )); } }); } @@ -1067,12 +1352,30 @@ fn two_inputs_remainder_3() { let protocol_parameters = protocol_parameters(); let inputs = build_inputs([ - Basic(1_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), - Basic(2_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), ]); let outputs = build_outputs([Basic( 1_750_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -1084,7 +1387,7 @@ fn two_inputs_remainder_3() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select() @@ -1098,7 +1401,7 @@ fn two_inputs_remainder_3() { assert!(is_remainder_or_return( output, 1_250_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None )); } @@ -1111,13 +1414,13 @@ fn two_inputs_remainder_3() { // let protocol_parameters = protocol_parameters(); // let inputs = build_inputs([ -// Basic(500_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), -// Basic(600_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), -// Basic(700_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), -// ]); +// Basic(500_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, None, None, +// None), Basic(600_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, None, +// None, None), Basic(700_000, Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, +// None, None, None), ]); // let outputs = build_outputs([Basic( // 1_000_000, -// BECH32_ADDRESS_ED25519_0, +// Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), // None, // None, // None, @@ -1129,7 +1432,7 @@ fn two_inputs_remainder_3() { // let selected = InputSelection::new( // inputs.clone(), // outputs.clone(), -// addresses([BECH32_ADDRESS_ED25519_0]), +// [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], // protocol_parameters, // ) // .select() @@ -1140,8 +1443,8 @@ fn two_inputs_remainder_3() { // assert!(selected.outputs.contains(&outputs[0])); // selected.outputs.iter().for_each(|output| { // if !outputs.contains(output) { -// assert!(is_remainder_or_return(output, 800_000, BECH32_ADDRESS_ED25519_0, None)); -// } +// assert!(is_remainder_or_return(output, 800_000, +// Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None)); } // }); // } @@ -1151,7 +1454,7 @@ fn sender_already_selected() { let inputs = build_inputs([Basic( 1_000_000, - BECH32_ADDRESS_ED25519_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), None, None, None, @@ -1161,9 +1464,9 @@ fn sender_already_selected() { )]); let outputs = build_outputs([Basic( 1_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, - Some(BECH32_ADDRESS_ED25519_1), + Some(Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()), None, None, None, @@ -1173,7 +1476,10 @@ fn sender_already_selected() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0, BECH32_ADDRESS_ED25519_1]), + [ + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + ], protocol_parameters, ) .with_required_inputs([*inputs[0].output_id()]) @@ -1190,7 +1496,7 @@ fn single_mandatory_input() { let inputs = build_inputs([Basic( 1_000_000, - BECH32_ADDRESS_ED25519_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), None, None, None, @@ -1200,7 +1506,7 @@ fn single_mandatory_input() { )]); let outputs = build_outputs([Basic( 1_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -1212,7 +1518,10 @@ fn single_mandatory_input() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0, BECH32_ADDRESS_ED25519_1]), + [ + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + ], protocol_parameters, ) .with_required_inputs([*inputs[0].output_id()]) @@ -1229,13 +1538,24 @@ fn too_many_inputs() { // 129 inputs that would be required for the amount, but that's above max inputs let inputs = build_inputs( - std::iter::repeat_with(|| Basic(1_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None)) - .take(129), + std::iter::repeat_with(|| { + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ) + }) + .take(129), ); let outputs = build_outputs([Basic( 129_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -1247,7 +1567,7 @@ fn too_many_inputs() { let selected = InputSelection::new( inputs, outputs, - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select(); @@ -1264,13 +1584,24 @@ fn more_than_max_inputs_only_one_needed() { // 1000 inputs where 129 would be needed for the required amount which is above the max inputs let mut inputs = build_inputs( - std::iter::repeat_with(|| Basic(1_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None)) - .take(1000), + std::iter::repeat_with(|| { + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ) + }) + .take(1000), ); // Add the needed input let needed_input = build_inputs([Basic( 129_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -1282,7 +1613,7 @@ fn more_than_max_inputs_only_one_needed() { let outputs = build_outputs([Basic( 129_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -1294,7 +1625,7 @@ fn more_than_max_inputs_only_one_needed() { let selected = InputSelection::new( inputs, outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select() @@ -1310,7 +1641,7 @@ fn too_many_outputs() { let inputs = build_inputs([Basic( 2_000_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -1320,14 +1651,25 @@ fn too_many_outputs() { )]); let outputs = build_outputs( - std::iter::repeat_with(|| Basic(1_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None)) - .take(129), + std::iter::repeat_with(|| { + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ) + }) + .take(129), ); let selected = InputSelection::new( inputs, outputs, - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select(); @@ -1344,7 +1686,7 @@ fn too_many_outputs_with_remainder() { let inputs = build_inputs([Basic( 2_000_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -1354,14 +1696,25 @@ fn too_many_outputs_with_remainder() { )]); let outputs = build_outputs( - std::iter::repeat_with(|| Basic(1_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None)) - .take(128), + std::iter::repeat_with(|| { + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ) + }) + .take(128), ); let selected = InputSelection::new( inputs, outputs, - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select(); @@ -1377,19 +1730,54 @@ fn too_many_outputs_with_remainder() { fn restricted_ed25519() { let protocol_parameters = protocol_parameters(); let address = Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(); - let restricted = RestrictedAddress::new(address.clone()).unwrap(); - let restricted_bech32 = restricted.to_bech32_unchecked("rms").to_string(); + let restricted = Address::from(RestrictedAddress::new(address.clone()).unwrap()); let inputs = build_inputs([ - Basic(1_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), - Basic(1_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), - Basic(1_000_000, &restricted_bech32, None, None, None, None, None, None), - Basic(1_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), - Basic(1_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Basic(1_000_000, restricted, None, None, None, None, None, None), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), ]); let outputs = build_outputs([Basic( 1_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -1401,7 +1789,7 @@ fn restricted_ed25519() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_1]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()], protocol_parameters, ) .select() @@ -1417,15 +1805,14 @@ fn restricted_nft() { let protocol_parameters = protocol_parameters(); let nft_id_1 = NftId::from_str(NFT_ID_1).unwrap(); let nft_address = Address::from(nft_id_1); - let restricted = RestrictedAddress::new(nft_address.clone()).unwrap(); - let restricted_bech32 = restricted.to_bech32_unchecked("rms").to_string(); + let restricted = Address::from(RestrictedAddress::new(nft_address.clone()).unwrap()); let inputs = build_inputs([ - Basic(2_000_000, &restricted_bech32, None, None, None, None, None, None), + Basic(2_000_000, restricted, None, None, None, None, None, None), Nft( 2_000_000, nft_id_1, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -1435,7 +1822,7 @@ fn restricted_nft() { ]); let outputs = build_outputs([Basic( 3_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -1447,7 +1834,7 @@ fn restricted_nft() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select() @@ -1463,17 +1850,23 @@ fn restricted_account() { let protocol_parameters = protocol_parameters(); let account_id_1 = AccountId::from_str(ACCOUNT_ID_1).unwrap(); let account_address = Address::from(account_id_1); - let restricted = RestrictedAddress::new(account_address.clone()).unwrap(); - let restricted_bech32 = restricted.to_bech32_unchecked("rms").to_string(); + let restricted = Address::from(RestrictedAddress::new(account_address.clone()).unwrap()); let inputs = build_inputs([ - Basic(2_000_000, &restricted_bech32, None, None, None, None, None, None), - Account(2_000_000, account_id_1, BECH32_ADDRESS_ED25519_0, None, None, None), + Basic(2_000_000, restricted, None, None, None, None, None, None), + Account( + 2_000_000, + account_id_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + ), ]); let outputs = build_outputs([Basic( 3_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -1485,7 +1878,7 @@ fn restricted_account() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select() @@ -1500,21 +1893,65 @@ fn restricted_account() { fn restricted_ed25519_sender() { let protocol_parameters = protocol_parameters(); let sender = Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(); - let restricted_sender = RestrictedAddress::new(sender.clone()).unwrap(); - let restricted_sender_bech32 = restricted_sender.to_bech32_unchecked("rms").to_string(); + let restricted_sender = Address::from(RestrictedAddress::new(sender.clone()).unwrap()); let inputs = build_inputs([ - Basic(2_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), - Basic(2_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), - Basic(1_000_000, BECH32_ADDRESS_ED25519_1, None, None, None, None, None, None), - Basic(2_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), - Basic(2_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), ]); let outputs = build_outputs([Basic( 2_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, - Some(&restricted_sender_bech32), + Some(restricted_sender), None, None, None, @@ -1524,7 +1961,10 @@ fn restricted_ed25519_sender() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0, BECH32_ADDRESS_ED25519_1]), + [ + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + ], protocol_parameters, ) .select() diff --git a/sdk/tests/client/input_selection/expiration.rs b/sdk/tests/client/input_selection/expiration.rs index 320316d9e4..08852b876f 100644 --- a/sdk/tests/client/input_selection/expiration.rs +++ b/sdk/tests/client/input_selection/expiration.rs @@ -6,6 +6,7 @@ use std::str::FromStr; use iota_sdk::{ client::api::input_selection::{Error, InputSelection}, types::block::{ + address::Address, output::{AccountId, NftId}, protocol::protocol_parameters, }, @@ -13,7 +14,7 @@ use iota_sdk::{ use pretty_assertions::assert_eq; use crate::client::{ - addresses, build_inputs, build_outputs, is_remainder_or_return, unsorted_eq, + build_inputs, build_outputs, is_remainder_or_return, unsorted_eq, Build::{Account, Basic, Nft}, ACCOUNT_ID_1, BECH32_ADDRESS_ACCOUNT_1, BECH32_ADDRESS_ED25519_0, BECH32_ADDRESS_ED25519_1, BECH32_ADDRESS_ED25519_2, NFT_ID_1, @@ -25,17 +26,17 @@ fn one_output_expiration_not_expired() { let inputs = build_inputs([Basic( 2_000_000, - BECH32_ADDRESS_ED25519_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), None, None, None, None, - Some((BECH32_ADDRESS_ED25519_0, 200)), + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 200)), None, )]); let outputs = build_outputs([Basic( 2_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -47,7 +48,7 @@ fn one_output_expiration_not_expired() { let selected = InputSelection::new( inputs, outputs, - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .with_slot_index(100) @@ -62,17 +63,17 @@ fn expiration_equal_timestamp() { let inputs = build_inputs([Basic( 2_000_000, - BECH32_ADDRESS_ED25519_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), None, None, None, None, - Some((BECH32_ADDRESS_ED25519_0, 200)), + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 200)), None, )]); let outputs = build_outputs([Basic( 2_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -84,7 +85,7 @@ fn expiration_equal_timestamp() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .with_slot_index(200) @@ -101,17 +102,17 @@ fn one_output_expiration_expired() { let inputs = build_inputs([Basic( 2_000_000, - BECH32_ADDRESS_ED25519_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), None, None, None, None, - Some((BECH32_ADDRESS_ED25519_0, 50)), + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 50)), None, )]); let outputs = build_outputs([Basic( 2_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -123,7 +124,7 @@ fn one_output_expiration_expired() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .with_slot_index(100) @@ -141,28 +142,28 @@ fn two_outputs_one_expiration_expired() { let inputs = build_inputs([ Basic( 2_000_000, - BECH32_ADDRESS_ED25519_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), None, None, None, None, - Some((BECH32_ADDRESS_ED25519_0, 200)), + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 200)), None, ), Basic( 2_000_000, - BECH32_ADDRESS_ED25519_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), None, None, None, None, - Some((BECH32_ADDRESS_ED25519_0, 50)), + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 50)), None, ), ]); let outputs = build_outputs([Basic( 2_000_000, - BECH32_ADDRESS_ED25519_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), None, None, None, @@ -174,7 +175,7 @@ fn two_outputs_one_expiration_expired() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .with_slot_index(100) @@ -193,19 +194,28 @@ fn two_outputs_one_unexpired_one_missing() { let inputs = build_inputs([ Basic( 2_000_000, - BECH32_ADDRESS_ED25519_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + None, + None, + None, + None, + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 200)), + None, + ), + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, None, None, None, None, - Some((BECH32_ADDRESS_ED25519_0, 200)), None, ), - Basic(2_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), ]); let outputs = build_outputs([Basic( 2_000_000, - BECH32_ADDRESS_ED25519_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), None, None, None, @@ -217,7 +227,7 @@ fn two_outputs_one_unexpired_one_missing() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .with_slot_index(100) @@ -236,29 +246,38 @@ fn two_outputs_two_expired() { let inputs = build_inputs([ Basic( 2_000_000, - BECH32_ADDRESS_ED25519_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + None, + None, + None, + None, + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 100)), + None, + ), + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), None, None, None, None, - Some((BECH32_ADDRESS_ED25519_0, 100)), + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_2).unwrap(), 100)), None, ), Basic( 2_000_000, - BECH32_ADDRESS_ED25519_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, None, None, None, None, - Some((BECH32_ADDRESS_ED25519_2, 100)), None, ), - Basic(2_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), ]); let outputs = build_outputs([Basic( 2_000_000, - BECH32_ADDRESS_ED25519_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), None, None, None, @@ -270,7 +289,7 @@ fn two_outputs_two_expired() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_2]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_2).unwrap()], protocol_parameters, ) .with_slot_index(200) @@ -289,28 +308,28 @@ fn two_outputs_two_expired_2() { let inputs = build_inputs([ Basic( 2_000_000, - BECH32_ADDRESS_ED25519_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), None, None, None, None, - Some((BECH32_ADDRESS_ED25519_1, 100)), + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 100)), None, ), Basic( 2_000_000, - BECH32_ADDRESS_ED25519_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), None, None, None, None, - Some((BECH32_ADDRESS_ED25519_2, 100)), + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_2).unwrap(), 100)), None, ), ]); let outputs = build_outputs([Basic( 4_000_000, - BECH32_ADDRESS_ED25519_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), None, None, None, @@ -322,7 +341,10 @@ fn two_outputs_two_expired_2() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_1, BECH32_ADDRESS_ED25519_2]), + [ + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + Address::try_from_bech32(BECH32_ADDRESS_ED25519_2).unwrap(), + ], protocol_parameters, ) .with_slot_index(200) @@ -339,17 +361,17 @@ fn expiration_expired_with_sdr() { let inputs = build_inputs([Basic( 2_000_000, - BECH32_ADDRESS_ED25519_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), None, None, - Some((BECH32_ADDRESS_ED25519_1, 1_000_000)), + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), None, - Some((BECH32_ADDRESS_ED25519_0, 50)), + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 50)), None, )]); let outputs = build_outputs([Basic( 2_000_000, - BECH32_ADDRESS_ED25519_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), None, None, None, @@ -361,7 +383,7 @@ fn expiration_expired_with_sdr() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .with_slot_index(100) @@ -378,17 +400,17 @@ fn expiration_expired_with_sdr_2() { let inputs = build_inputs([Basic( 2_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, - Some((BECH32_ADDRESS_ED25519_1, 1_000_000)), + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), None, - Some((BECH32_ADDRESS_ED25519_0, 50)), + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 50)), None, )]); let outputs = build_outputs([Basic( 2_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -400,7 +422,7 @@ fn expiration_expired_with_sdr_2() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .with_slot_index(100) @@ -417,17 +439,17 @@ fn expiration_expired_with_sdr_and_timelock() { let inputs = build_inputs([Basic( 2_000_000, - BECH32_ADDRESS_ED25519_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), None, None, - Some((BECH32_ADDRESS_ED25519_0, 1_000_000)), + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 1_000_000)), Some(50), - Some((BECH32_ADDRESS_ED25519_0, 50)), + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 50)), None, )]); let outputs = build_outputs([Basic( 2_000_000, - BECH32_ADDRESS_ED25519_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), None, None, None, @@ -439,7 +461,7 @@ fn expiration_expired_with_sdr_and_timelock() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .with_slot_index(100) @@ -456,17 +478,17 @@ fn expiration_expired_with_sdr_and_timelock_2() { let inputs = build_inputs([Basic( 2_000_000, - BECH32_ADDRESS_ED25519_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), None, None, - Some((BECH32_ADDRESS_ED25519_1, 1_000_000)), + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), Some(50), - Some((BECH32_ADDRESS_ED25519_0, 50)), + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 50)), None, )]); let outputs = build_outputs([Basic( 2_000_000, - BECH32_ADDRESS_ED25519_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), None, None, None, @@ -478,7 +500,7 @@ fn expiration_expired_with_sdr_and_timelock_2() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .with_slot_index(100) @@ -494,26 +516,62 @@ fn sender_in_expiration() { let protocol_parameters = protocol_parameters(); let inputs = build_inputs([ - Basic(1_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), - Basic(1_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), Basic( 1_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 50)), + None, + ), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, None, None, None, None, - Some((BECH32_ADDRESS_ED25519_1, 50)), None, ), - Basic(1_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), - Basic(1_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), ]); let outputs = build_outputs([Basic( 1_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, - Some(BECH32_ADDRESS_ED25519_1), + Some(Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()), None, None, None, @@ -523,7 +581,10 @@ fn sender_in_expiration() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0, BECH32_ADDRESS_ED25519_1]), + [ + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + ], protocol_parameters, ) .with_slot_index(100) @@ -541,19 +602,19 @@ fn sender_in_expiration_already_selected() { let inputs = build_inputs([Basic( 1_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, None, - Some((BECH32_ADDRESS_ED25519_1, 50)), + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 50)), None, )]); let outputs = build_outputs([Basic( 1_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, - Some(BECH32_ADDRESS_ED25519_1), + Some(Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()), None, None, None, @@ -563,7 +624,10 @@ fn sender_in_expiration_already_selected() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0, BECH32_ADDRESS_ED25519_1]), + [ + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + ], protocol_parameters, ) .with_slot_index(100) @@ -581,19 +645,19 @@ fn remainder_in_expiration() { let inputs = build_inputs([Basic( 2_000_000, - BECH32_ADDRESS_ACCOUNT_1, + Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap(), None, None, None, None, - Some((BECH32_ADDRESS_ED25519_1, 50)), + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 50)), None, )]); let outputs = build_outputs([Basic( 1_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, - Some(BECH32_ADDRESS_ED25519_1), + Some(Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()), None, None, None, @@ -603,7 +667,10 @@ fn remainder_in_expiration() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0, BECH32_ADDRESS_ED25519_1]), + [ + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + ], protocol_parameters, ) .with_slot_index(100) @@ -618,7 +685,7 @@ fn remainder_in_expiration() { assert!(is_remainder_or_return( output, 1_000_000, - BECH32_ADDRESS_ED25519_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), None )); } @@ -631,17 +698,17 @@ fn expiration_expired_non_ed25519_in_address_unlock_condition() { let inputs = build_inputs([Basic( 2_000_000, - BECH32_ADDRESS_ACCOUNT_1, + Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap(), None, None, None, None, - Some((BECH32_ADDRESS_ED25519_0, 50)), + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 50)), None, )]); let outputs = build_outputs([Basic( 2_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -653,7 +720,7 @@ fn expiration_expired_non_ed25519_in_address_unlock_condition() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .with_slot_index(100) @@ -672,20 +739,27 @@ fn expiration_expired_only_account_addresses() { let inputs = build_inputs([ Basic( 2_000_000, - BECH32_ADDRESS_ACCOUNT_1, + Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap(), + None, + None, None, None, + Some((Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap(), 50)), + None, + ), + Account( + 1_000_000, + account_id_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, - Some((BECH32_ADDRESS_ACCOUNT_1, 50)), None, ), - Account(1_000_000, account_id_1, BECH32_ADDRESS_ED25519_0, None, None, None), ]); let outputs = build_outputs([Basic( 2_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -697,7 +771,7 @@ fn expiration_expired_only_account_addresses() { let selected = InputSelection::new( inputs.clone(), outputs, - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .with_slot_index(100) @@ -716,17 +790,17 @@ fn one_nft_output_expiration_unexpired() { let inputs = build_inputs([Nft( 2_000_000, nft_id_1, - BECH32_ADDRESS_ED25519_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), None, None, None, - Some((BECH32_ADDRESS_ED25519_0, 150)), + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 150)), None, )]); let outputs = build_outputs([Nft( 2_000_000, nft_id_1, - BECH32_ADDRESS_ED25519_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), None, None, None, @@ -737,7 +811,7 @@ fn one_nft_output_expiration_unexpired() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_1]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()], protocol_parameters, ) .with_slot_index(100) @@ -756,17 +830,17 @@ fn one_nft_output_expiration_expired() { let inputs = build_inputs([Nft( 2_000_000, nft_id_1, - BECH32_ADDRESS_ED25519_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), None, None, None, - Some((BECH32_ADDRESS_ED25519_0, 50)), + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 50)), None, )]); let outputs = build_outputs([Nft( 2_000_000, nft_id_1, - BECH32_ADDRESS_ED25519_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), None, None, None, @@ -777,7 +851,7 @@ fn one_nft_output_expiration_expired() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .with_slot_index(100) diff --git a/sdk/tests/client/input_selection/foundry_outputs.rs b/sdk/tests/client/input_selection/foundry_outputs.rs index 8e40b50d78..52c510b70c 100644 --- a/sdk/tests/client/input_selection/foundry_outputs.rs +++ b/sdk/tests/client/input_selection/foundry_outputs.rs @@ -21,7 +21,7 @@ use iota_sdk::{ use pretty_assertions::assert_eq; use crate::client::{ - addresses, build_inputs, build_outputs, is_remainder_or_return, unsorted_eq, + build_inputs, build_outputs, is_remainder_or_return, unsorted_eq, Build::{Account, Basic, Foundry}, ACCOUNT_ID_1, ACCOUNT_ID_2, BECH32_ADDRESS_ED25519_0, }; @@ -33,7 +33,7 @@ fn missing_input_account_for_foundry() { let inputs = build_inputs([Basic( 1_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -52,7 +52,7 @@ fn missing_input_account_for_foundry() { let selected = InputSelection::new( inputs, outputs, - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select(); @@ -72,8 +72,8 @@ fn missing_input_account_for_foundry() { // 1_255_500, // account_id_2, // 0, -// BECH32_ADDRESS_ED25519_0, -// BECH32_ADDRESS_ED25519_0, +// Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), +// Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), // None, // None, // None, @@ -90,7 +90,7 @@ fn missing_input_account_for_foundry() { // let selected = InputSelection::new( // inputs.clone(), // outputs, -// addresses([BECH32_ADDRESS_ED25519_0]), +// [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], // protocol_parameters, // ) // .select() @@ -107,8 +107,24 @@ fn minted_native_tokens_in_new_remainder() { let account_id_2 = AccountId::from_str(ACCOUNT_ID_2).unwrap(); let inputs = build_inputs([ - Basic(1_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), - Account(1_000_000, account_id_2, BECH32_ADDRESS_ED25519_0, None, None, None), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Account( + 1_000_000, + account_id_2, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + ), ]); let outputs = build_outputs([Foundry( 1_000_000, @@ -121,7 +137,7 @@ fn minted_native_tokens_in_new_remainder() { let selected = InputSelection::new( inputs.clone(), outputs, - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select() @@ -147,8 +163,24 @@ fn minted_native_tokens_in_provided_output() { let token_id = TokenId::from(foundry_id); let inputs = build_inputs([ - Basic(2_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), - Account(1_000_000, account_id_2, BECH32_ADDRESS_ED25519_0, None, None, None), + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Account( + 1_000_000, + account_id_2, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + ), ]); let outputs = build_outputs([ Foundry( @@ -160,7 +192,7 @@ fn minted_native_tokens_in_provided_output() { ), Basic( 1_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), Some((&token_id.to_string(), 100)), None, None, @@ -173,7 +205,7 @@ fn minted_native_tokens_in_provided_output() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select() @@ -192,7 +224,16 @@ fn melt_native_tokens() { let account_id_1 = AccountId::from_str(ACCOUNT_ID_1).unwrap(); let mut inputs = build_inputs([ - Basic(1_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), Foundry( 1_000_000, account_id_1, @@ -228,7 +269,7 @@ fn melt_native_tokens() { let selected = InputSelection::new( inputs.clone(), outputs, - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select() @@ -252,7 +293,14 @@ fn destroy_foundry_with_account_state_transition() { let account_id_2 = AccountId::from_str(ACCOUNT_ID_2).unwrap(); let inputs = build_inputs([ - Account(50_300, account_id_2, BECH32_ADDRESS_ED25519_0, None, None, None), + Account( + 50_300, + account_id_2, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + ), Foundry( 52_800, account_id_2, @@ -271,7 +319,7 @@ fn destroy_foundry_with_account_state_transition() { let selected = InputSelection::new( inputs.clone(), outputs, - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .with_burn(Burn::new().add_foundry(inputs[1].output.as_foundry().id())) @@ -289,7 +337,14 @@ fn destroy_foundry_with_account_burn() { let account_id_2 = AccountId::from_str(ACCOUNT_ID_2).unwrap(); let inputs = build_inputs([ - Account(1_000_000, account_id_2, BECH32_ADDRESS_ED25519_0, None, None, None), + Account( + 1_000_000, + account_id_2, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + ), Foundry( 1_000_000, account_id_2, @@ -300,7 +355,7 @@ fn destroy_foundry_with_account_burn() { ]); let outputs = build_outputs([Basic( 1_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -312,7 +367,7 @@ fn destroy_foundry_with_account_burn() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .with_burn( @@ -331,7 +386,7 @@ fn destroy_foundry_with_account_burn() { assert!(is_remainder_or_return( output, 1_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, )); } @@ -344,7 +399,14 @@ fn prefer_basic_to_foundry() { let account_id_1 = AccountId::from_str(ACCOUNT_ID_1).unwrap(); let inputs = build_inputs([ - Account(1_000_000, account_id_1, BECH32_ADDRESS_ED25519_0, None, None, None), + Account( + 1_000_000, + account_id_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + ), Foundry( 1_000_000, account_id_1, @@ -352,11 +414,20 @@ fn prefer_basic_to_foundry() { SimpleTokenScheme::new(10, 10, 10).unwrap(), None, ), - Basic(1_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), ]); let outputs = build_outputs([Basic( 1_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -368,7 +439,7 @@ fn prefer_basic_to_foundry() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select() @@ -385,7 +456,16 @@ fn simple_foundry_transition_basic_not_needed() { let account_id_1 = AccountId::from_str(ACCOUNT_ID_1).unwrap(); let mut inputs = build_inputs([ - Basic(1_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), Foundry( 1_000_000, account_id_1, @@ -418,7 +498,7 @@ fn simple_foundry_transition_basic_not_needed() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select() @@ -451,7 +531,16 @@ fn simple_foundry_transition_basic_not_needed_with_remainder() { let account_id_1 = AccountId::from_str(ACCOUNT_ID_1).unwrap(); let mut inputs = build_inputs([ - Basic(1_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), Foundry( 2_000_000, account_id_1, @@ -483,7 +572,7 @@ fn simple_foundry_transition_basic_not_needed_with_remainder() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select() @@ -510,7 +599,7 @@ fn simple_foundry_transition_basic_not_needed_with_remainder() { assert!(is_remainder_or_return( output, 1_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, )); } else { @@ -625,7 +714,7 @@ fn mint_and_burn_at_the_same_time() { let selected = InputSelection::new( inputs.clone(), outputs, - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .with_burn(Burn::new().add_native_token(token_id, 10)) @@ -645,7 +734,16 @@ fn take_amount_from_account_and_foundry_to_fund_basic() { let token_id = TokenId::from(foundry_id); let mut inputs = build_inputs([ - Basic(1_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), Foundry( 1_000_000, account_id_1, @@ -668,7 +766,7 @@ fn take_amount_from_account_and_foundry_to_fund_basic() { }); let outputs = build_outputs([Basic( 3_200_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -680,7 +778,7 @@ fn take_amount_from_account_and_foundry_to_fund_basic() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select() @@ -705,7 +803,14 @@ fn create_native_token_but_burn_account() { let token_id = TokenId::from(foundry_id); let inputs = build_inputs([ - Account(2_000_000, account_id_1, BECH32_ADDRESS_ED25519_0, None, None, None), + Account( + 2_000_000, + account_id_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + ), Foundry( 1_000_000, account_id_1, @@ -725,7 +830,7 @@ fn create_native_token_but_burn_account() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .with_burn(Burn::new().add_account(account_id_1)) @@ -741,7 +846,7 @@ fn create_native_token_but_burn_account() { assert!(is_remainder_or_return( output, 2_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, )); } @@ -756,7 +861,14 @@ fn melted_tokens_not_provided() { let token_id_1 = TokenId::from(foundry_id); let inputs = build_inputs([ - Account(2_000_000, account_id_1, BECH32_ADDRESS_ED25519_0, None, None, None), + Account( + 2_000_000, + account_id_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + ), Foundry( 1_000_000, account_id_1, @@ -776,7 +888,7 @@ fn melted_tokens_not_provided() { let selected = InputSelection::new( inputs, outputs, - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select(); @@ -798,7 +910,14 @@ fn burned_tokens_not_provided() { let token_id_1 = TokenId::from(foundry_id); let inputs = build_inputs([ - Account(2_000_000, account_id_1, BECH32_ADDRESS_ED25519_0, None, None, None), + Account( + 2_000_000, + account_id_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + ), Foundry( 1_000_000, account_id_1, @@ -818,7 +937,7 @@ fn burned_tokens_not_provided() { let selected = InputSelection::new( inputs, outputs, - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .with_burn(Burn::new().add_native_token(token_id_1, 100)) @@ -868,7 +987,7 @@ fn foundry_in_outputs_and_required() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .with_required_inputs([*inputs[1].output_id()]) @@ -893,7 +1012,16 @@ fn melt_and_burn_native_tokens() { let token_id = TokenId::from(foundry_id); let mut inputs = build_inputs([ - Basic(1_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), Foundry( 1_000_000, account_id, @@ -926,7 +1054,7 @@ fn melt_and_burn_native_tokens() { let selected = InputSelection::new( inputs.clone(), outputs, - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) // Burn 456 native tokens diff --git a/sdk/tests/client/input_selection/nft_outputs.rs b/sdk/tests/client/input_selection/nft_outputs.rs index a73866c7dc..33ddf7c960 100644 --- a/sdk/tests/client/input_selection/nft_outputs.rs +++ b/sdk/tests/client/input_selection/nft_outputs.rs @@ -18,7 +18,7 @@ use iota_sdk::{ use pretty_assertions::{assert_eq, assert_ne}; use crate::client::{ - addresses, build_inputs, build_outputs, is_remainder_or_return, unsorted_eq, + build_inputs, build_outputs, is_remainder_or_return, unsorted_eq, Build::{Basic, Nft}, BECH32_ADDRESS_ACCOUNT_1, BECH32_ADDRESS_ED25519_0, BECH32_ADDRESS_ED25519_1, BECH32_ADDRESS_NFT_1, NFT_ID_0, NFT_ID_1, NFT_ID_2, @@ -32,7 +32,7 @@ fn input_nft_eq_output_nft() { let inputs = build_inputs([Nft( 1_000_000, nft_id_2, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -42,7 +42,7 @@ fn input_nft_eq_output_nft() { let outputs = build_outputs([Nft( 1_000_000, nft_id_2, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -53,7 +53,7 @@ fn input_nft_eq_output_nft() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select() @@ -71,7 +71,7 @@ fn transition_nft_id_zero() { let inputs = build_inputs([Nft( 1_000_000, nft_id_0, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -82,7 +82,7 @@ fn transition_nft_id_zero() { let outputs = build_outputs([Nft( 1_000_000, nft_id, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -93,7 +93,7 @@ fn transition_nft_id_zero() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select() @@ -111,7 +111,7 @@ fn transition_nft_id_zero() { // let inputs = build_inputs([Nft( // 1_000_000, // nft_id_2, -// BECH32_ADDRESS_ED25519_0, +// Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), // None, // None, // None, @@ -121,7 +121,7 @@ fn transition_nft_id_zero() { // )]); // let outputs = build_outputs([Basic( // 2_000_000, -// BECH32_ADDRESS_ED25519_0, +// Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), // None, // None, // None, @@ -133,7 +133,7 @@ fn transition_nft_id_zero() { // let selected = InputSelection::new( // inputs, // outputs, -// addresses([BECH32_ADDRESS_ED25519_0]), +// [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], // protocol_parameters, // ) // .select(); @@ -158,7 +158,7 @@ fn transition_nft_id_zero() { // let inputs = build_inputs([Nft( // 2_237_500, // nft_id_2, -// BECH32_ADDRESS_ED25519_0, +// Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), // None, // None, // None, @@ -168,7 +168,7 @@ fn transition_nft_id_zero() { // )]); // let outputs = build_outputs([Basic( // 2_000_000, -// BECH32_ADDRESS_ED25519_0, +// Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), // None, // None, // None, @@ -180,7 +180,7 @@ fn transition_nft_id_zero() { // let selected = InputSelection::new( // inputs.clone(), // outputs, -// addresses([BECH32_ADDRESS_ED25519_0]), +// [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], // protocol_parameters, // ) // .select() @@ -198,7 +198,7 @@ fn mint_nft() { let inputs = build_inputs([Basic( 2_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -209,7 +209,7 @@ fn mint_nft() { let outputs = build_outputs([Nft( 1_000_000, nft_id_0, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -220,7 +220,7 @@ fn mint_nft() { let selected = InputSelection::new( inputs.clone(), outputs, - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select() @@ -247,7 +247,7 @@ fn burn_nft() { let inputs = build_inputs([Nft( 2_000_000, nft_id_2, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -256,7 +256,7 @@ fn burn_nft() { )]); let outputs = build_outputs([Basic( 2_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -268,7 +268,7 @@ fn burn_nft() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .with_burn(Burn::new().add_nft(nft_id_2)) @@ -287,7 +287,7 @@ fn burn_nft() { // let inputs = build_inputs([Nft( // 1_000_001, // nft_id_2, -// BECH32_ADDRESS_ED25519_0, +// Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), // None, // None, // None, @@ -298,7 +298,7 @@ fn burn_nft() { // let outputs = build_outputs([Nft( // 1_000_000, // nft_id_2, -// BECH32_ADDRESS_ED25519_0, +// Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), // None, // None, // None, @@ -310,7 +310,7 @@ fn burn_nft() { // let selected = InputSelection::new( // inputs, // outputs, -// addresses([BECH32_ADDRESS_ED25519_0]), +// [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], // protocol_parameters, // ) // .select(); @@ -331,7 +331,7 @@ fn missing_input_for_nft_output() { let inputs = build_inputs([Basic( 1_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -342,7 +342,7 @@ fn missing_input_for_nft_output() { let outputs = build_outputs([Nft( 1_000_000, nft_id_2, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -353,7 +353,7 @@ fn missing_input_for_nft_output() { let selected = InputSelection::new( inputs, outputs, - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select(); @@ -371,7 +371,7 @@ fn missing_input_for_nft_output_but_created() { let inputs = build_inputs([Basic( 1_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -382,7 +382,7 @@ fn missing_input_for_nft_output_but_created() { let outputs = build_outputs([Nft( 1_000_000, nft_id_0, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -393,7 +393,7 @@ fn missing_input_for_nft_output_but_created() { let selected = InputSelection::new( inputs, outputs, - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select(); @@ -410,20 +410,29 @@ fn nft_in_output_and_sender() { Nft( 1_000_000, nft_id_1, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + ), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, None, None, None, None, None, ), - Basic(1_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), ]); let outputs = build_outputs([ Nft( 1_000_000, nft_id_1, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -432,9 +441,9 @@ fn nft_in_output_and_sender() { ), Basic( 1_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, - Some(BECH32_ADDRESS_NFT_1), + Some(Address::try_from_bech32(BECH32_ADDRESS_NFT_1).unwrap()), None, None, None, @@ -445,7 +454,7 @@ fn nft_in_output_and_sender() { let selected = InputSelection::new( inputs.clone(), outputs, - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select() @@ -471,7 +480,7 @@ fn missing_ed25519_sender() { let inputs = build_inputs([Nft( 1_000_000, nft_id_2, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -481,8 +490,8 @@ fn missing_ed25519_sender() { let outputs = build_outputs([Nft( 1_000_000, nft_id_2, - BECH32_ADDRESS_ED25519_0, - Some(BECH32_ADDRESS_ED25519_1), + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + Some(Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()), None, None, None, @@ -492,7 +501,7 @@ fn missing_ed25519_sender() { let selected = InputSelection::new( inputs, outputs, - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select(); @@ -510,7 +519,7 @@ fn missing_ed25519_issuer_created() { let inputs = build_inputs([Basic( 1_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -521,9 +530,9 @@ fn missing_ed25519_issuer_created() { let outputs = build_outputs([Nft( 1_000_000, nft_id_0, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, - Some(BECH32_ADDRESS_ED25519_1), + Some(Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()), None, None, None, @@ -532,7 +541,7 @@ fn missing_ed25519_issuer_created() { let selected = InputSelection::new( inputs, outputs, - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select(); @@ -551,9 +560,9 @@ fn missing_ed25519_issuer_transition() { let inputs = build_inputs([Nft( 1_000_000, nft_id_1, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, - Some(BECH32_ADDRESS_ED25519_1), + Some(Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()), None, None, None, @@ -561,9 +570,9 @@ fn missing_ed25519_issuer_transition() { let outputs = build_outputs([Nft( 1_000_000, nft_id_1, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, - Some(BECH32_ADDRESS_ED25519_1), + Some(Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()), None, None, None, @@ -572,7 +581,7 @@ fn missing_ed25519_issuer_transition() { let selected = InputSelection::new( inputs, outputs, - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select(); @@ -588,7 +597,7 @@ fn missing_account_sender() { let inputs = build_inputs([Nft( 1_000_000, nft_id_2, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -598,8 +607,8 @@ fn missing_account_sender() { let outputs = build_outputs([Nft( 1_000_000, nft_id_2, - BECH32_ADDRESS_ED25519_0, - Some(BECH32_ADDRESS_ACCOUNT_1), + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + Some(Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap()), None, None, None, @@ -609,7 +618,7 @@ fn missing_account_sender() { let selected = InputSelection::new( inputs, outputs, - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select(); @@ -627,7 +636,7 @@ fn missing_account_issuer_created() { let inputs = build_inputs([Basic( 1_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -638,9 +647,9 @@ fn missing_account_issuer_created() { let outputs = build_outputs([Nft( 1_000_000, nft_id_0, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, - Some(BECH32_ADDRESS_ACCOUNT_1), + Some(Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap()), None, None, None, @@ -649,7 +658,7 @@ fn missing_account_issuer_created() { let selected = InputSelection::new( inputs, outputs, - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select(); @@ -668,9 +677,9 @@ fn missing_account_issuer_transition() { let inputs = build_inputs([Nft( 1_000_000, nft_id_2, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, - Some(BECH32_ADDRESS_ACCOUNT_1), + Some(Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap()), None, None, None, @@ -678,9 +687,9 @@ fn missing_account_issuer_transition() { let outputs = build_outputs([Nft( 1_000_000, nft_id_2, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, - Some(BECH32_ADDRESS_ACCOUNT_1), + Some(Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap()), None, None, None, @@ -689,7 +698,7 @@ fn missing_account_issuer_transition() { let selected = InputSelection::new( inputs, outputs, - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select(); @@ -705,7 +714,7 @@ fn missing_nft_sender() { let inputs = build_inputs([Nft( 1_000_000, nft_id_2, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -715,8 +724,8 @@ fn missing_nft_sender() { let outputs = build_outputs([Nft( 1_000_000, nft_id_2, - BECH32_ADDRESS_ED25519_0, - Some(BECH32_ADDRESS_NFT_1), + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + Some(Address::try_from_bech32(BECH32_ADDRESS_NFT_1).unwrap()), None, None, None, @@ -726,7 +735,7 @@ fn missing_nft_sender() { let selected = InputSelection::new( inputs, outputs, - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select(); @@ -744,7 +753,7 @@ fn missing_nft_issuer_created() { let inputs = build_inputs([Basic( 1_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -755,9 +764,9 @@ fn missing_nft_issuer_created() { let outputs = build_outputs([Nft( 1_000_000, nft_id_0, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, - Some(BECH32_ADDRESS_NFT_1), + Some(Address::try_from_bech32(BECH32_ADDRESS_NFT_1).unwrap()), None, None, None, @@ -766,7 +775,7 @@ fn missing_nft_issuer_created() { let selected = InputSelection::new( inputs, outputs, - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select(); @@ -785,9 +794,9 @@ fn missing_nft_issuer_transition() { let inputs = build_inputs([Nft( 1_000_000, nft_id_2, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, - Some(BECH32_ADDRESS_NFT_1), + Some(Address::try_from_bech32(BECH32_ADDRESS_NFT_1).unwrap()), None, None, None, @@ -795,9 +804,9 @@ fn missing_nft_issuer_transition() { let outputs = build_outputs([Nft( 1_000_000, nft_id_2, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, - Some(BECH32_ADDRESS_NFT_1), + Some(Address::try_from_bech32(BECH32_ADDRESS_NFT_1).unwrap()), None, None, None, @@ -806,7 +815,7 @@ fn missing_nft_issuer_transition() { let selected = InputSelection::new( inputs, outputs, - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select(); @@ -823,19 +832,28 @@ fn increase_nft_amount() { Nft( 2_000_000, nft_id_1, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + ), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, None, None, None, None, None, ), - Basic(1_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), ]); let outputs = build_outputs([Nft( 3_000_000, nft_id_1, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -846,7 +864,7 @@ fn increase_nft_amount() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select() @@ -865,19 +883,28 @@ fn decrease_nft_amount() { Nft( 2_000_000, nft_id_1, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + ), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, None, None, None, None, None, ), - Basic(1_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), ]); let outputs = build_outputs([Nft( 1_000_000, nft_id_1, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -888,7 +915,7 @@ fn decrease_nft_amount() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select() @@ -903,7 +930,7 @@ fn decrease_nft_amount() { assert!(is_remainder_or_return( output, 1_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None )); } @@ -919,18 +946,27 @@ fn prefer_basic_to_nft() { Nft( 2_000_000, nft_id_1, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + ), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, None, None, None, None, None, ), - Basic(1_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), ]); let outputs = build_outputs([Basic( 1_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -942,7 +978,7 @@ fn prefer_basic_to_nft() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select() @@ -962,18 +998,27 @@ fn take_amount_from_nft_to_fund_basic() { Nft( 2_000_000, nft_id_1, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + ), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, None, None, None, None, None, ), - Basic(1_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), ]); let outputs = build_outputs([Basic( 1_200_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -985,7 +1030,7 @@ fn take_amount_from_nft_to_fund_basic() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select() @@ -1014,11 +1059,20 @@ fn nft_burn_should_validate_nft_sender() { let nft_id_1 = NftId::from_str(NFT_ID_1).unwrap(); let inputs = build_inputs([ - Basic(2_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), Nft( 1_000_000, nft_id_1, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -1028,9 +1082,9 @@ fn nft_burn_should_validate_nft_sender() { ]); let outputs = build_outputs([Basic( 3_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, - Some(BECH32_ADDRESS_NFT_1), + Some(Address::try_from_bech32(BECH32_ADDRESS_NFT_1).unwrap()), None, None, None, @@ -1040,7 +1094,7 @@ fn nft_burn_should_validate_nft_sender() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .with_burn(Burn::new().add_nft(nft_id_1)) @@ -1057,11 +1111,20 @@ fn nft_burn_should_validate_nft_address() { let nft_id_1 = NftId::from_str(NFT_ID_1).unwrap(); let inputs = build_inputs([ - Basic(2_000_000, BECH32_ADDRESS_NFT_1, None, None, None, None, None, None), + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_NFT_1).unwrap(), + None, + None, + None, + None, + None, + None, + ), Nft( 1_000_000, nft_id_1, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -1071,7 +1134,7 @@ fn nft_burn_should_validate_nft_address() { ]); let outputs = build_outputs([Basic( 3_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -1083,7 +1146,7 @@ fn nft_burn_should_validate_nft_address() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .with_burn(Burn::new().add_nft(nft_id_1)) @@ -1102,7 +1165,7 @@ fn transitioned_zero_nft_id_no_longer_is_zero() { let inputs = build_inputs([Nft( 2_000_000, nft_id_0, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -1111,7 +1174,7 @@ fn transitioned_zero_nft_id_no_longer_is_zero() { )]); let outputs = build_outputs([Basic( 1_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -1123,7 +1186,7 @@ fn transitioned_zero_nft_id_no_longer_is_zero() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select() @@ -1199,7 +1262,7 @@ fn changed_immutable_metadata() { let selected = InputSelection::new( inputs, outputs, - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select(); diff --git a/sdk/tests/client/input_selection/outputs.rs b/sdk/tests/client/input_selection/outputs.rs index 4977a0eb72..7fae73e9c5 100644 --- a/sdk/tests/client/input_selection/outputs.rs +++ b/sdk/tests/client/input_selection/outputs.rs @@ -5,12 +5,12 @@ use std::str::FromStr; use iota_sdk::{ client::api::input_selection::{Burn, Error, InputSelection}, - types::block::{output::AccountId, protocol::protocol_parameters}, + types::block::{address::Address, output::AccountId, protocol::protocol_parameters}, }; use pretty_assertions::assert_eq; use crate::client::{ - addresses, build_inputs, build_outputs, is_remainder_or_return, unsorted_eq, + build_inputs, build_outputs, is_remainder_or_return, unsorted_eq, Build::{Account, Basic}, ACCOUNT_ID_2, BECH32_ADDRESS_ED25519_0, BECH32_ADDRESS_ED25519_1, }; @@ -22,7 +22,7 @@ fn no_inputs() { let inputs = Vec::new(); let outputs = build_outputs([Basic( 1_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -34,7 +34,7 @@ fn no_inputs() { let selected = InputSelection::new( inputs, outputs, - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select(); @@ -48,7 +48,7 @@ fn no_outputs() { let inputs = build_inputs([Basic( 1_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -61,7 +61,7 @@ fn no_outputs() { let selected = InputSelection::new( inputs, outputs, - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select(); @@ -77,7 +77,7 @@ fn no_outputs_but_burn() { let inputs = build_inputs([Account( 2_000_000, account_id_2, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -87,7 +87,7 @@ fn no_outputs_but_burn() { let selected = InputSelection::new( inputs.clone(), outputs, - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .with_burn(Burn::new().add_account(account_id_2)) @@ -99,7 +99,7 @@ fn no_outputs_but_burn() { assert!(is_remainder_or_return( &selected.outputs[0], 2_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None )); } @@ -110,7 +110,7 @@ fn no_address_provided() { let inputs = build_inputs([Basic( 1_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -120,7 +120,7 @@ fn no_address_provided() { )]); let outputs = build_outputs([Basic( 1_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -140,7 +140,7 @@ fn no_matching_address_provided() { let inputs = build_inputs([Basic( 1_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -150,7 +150,7 @@ fn no_matching_address_provided() { )]); let outputs = build_outputs([Basic( 1_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -162,7 +162,7 @@ fn no_matching_address_provided() { let selected = InputSelection::new( inputs, outputs, - addresses([BECH32_ADDRESS_ED25519_1]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()], protocol_parameters, ) .select(); @@ -175,12 +175,30 @@ fn two_addresses_one_missing() { let protocol_parameters = protocol_parameters(); let inputs = build_inputs([ - Basic(1_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), - Basic(1_000_000, BECH32_ADDRESS_ED25519_1, None, None, None, None, None, None), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + None, + None, + None, + None, + None, + None, + ), ]); let outputs = build_outputs([Basic( 2_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -192,7 +210,7 @@ fn two_addresses_one_missing() { let selected = InputSelection::new( inputs, outputs, - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select(); @@ -211,12 +229,30 @@ fn two_addresses() { let protocol_parameters = protocol_parameters(); let inputs = build_inputs([ - Basic(1_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), - Basic(1_000_000, BECH32_ADDRESS_ED25519_1, None, None, None, None, None, None), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + None, + None, + None, + None, + None, + None, + ), ]); let outputs = build_outputs([Basic( 2_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -228,7 +264,10 @@ fn two_addresses() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0, BECH32_ADDRESS_ED25519_1]), + [ + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + ], protocol_parameters, ) .select() diff --git a/sdk/tests/client/input_selection/storage_deposit_return.rs b/sdk/tests/client/input_selection/storage_deposit_return.rs index 55e8fb23dc..5c7ba2b633 100644 --- a/sdk/tests/client/input_selection/storage_deposit_return.rs +++ b/sdk/tests/client/input_selection/storage_deposit_return.rs @@ -5,12 +5,12 @@ use std::str::FromStr; use iota_sdk::{ client::api::input_selection::{Error, InputSelection}, - types::block::{output::AccountId, protocol::protocol_parameters}, + types::block::{address::Address, output::AccountId, protocol::protocol_parameters}, }; use pretty_assertions::assert_eq; use crate::client::{ - addresses, build_inputs, build_outputs, is_remainder_or_return, unsorted_eq, + build_inputs, build_outputs, is_remainder_or_return, unsorted_eq, Build::{Account, Basic}, ACCOUNT_ID_1, BECH32_ADDRESS_ACCOUNT_1, BECH32_ADDRESS_ED25519_0, BECH32_ADDRESS_ED25519_1, BECH32_ADDRESS_ED25519_2, @@ -22,17 +22,17 @@ fn sdruc_output_not_provided_no_remainder() { let inputs = build_inputs([Basic( 2_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, - Some((BECH32_ADDRESS_ED25519_1, 1_000_000)), + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), None, None, None, )]); let outputs = build_outputs([Basic( 1_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -44,7 +44,7 @@ fn sdruc_output_not_provided_no_remainder() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select() @@ -58,7 +58,7 @@ fn sdruc_output_not_provided_no_remainder() { assert!(is_remainder_or_return( output, 1_000_000, - BECH32_ADDRESS_ED25519_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), None )); } @@ -71,23 +71,41 @@ fn sdruc_output_provided_no_remainder() { let inputs = build_inputs([Basic( 2_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, - Some((BECH32_ADDRESS_ED25519_1, 1_000_000)), + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), None, None, None, )]); let outputs = build_outputs([ - Basic(1_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), - Basic(1_000_000, BECH32_ADDRESS_ED25519_1, None, None, None, None, None, None), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + None, + None, + None, + None, + None, + None, + ), ]); let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select() @@ -103,17 +121,17 @@ fn sdruc_output_provided_remainder() { let inputs = build_inputs([Basic( 2_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, - Some((BECH32_ADDRESS_ED25519_1, 1_000_000)), + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), None, None, None, )]); let outputs = build_outputs([Basic( 1_000_000, - BECH32_ADDRESS_ED25519_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), None, None, None, @@ -125,7 +143,7 @@ fn sdruc_output_provided_remainder() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select() @@ -139,7 +157,7 @@ fn sdruc_output_provided_remainder() { assert!(is_remainder_or_return( output, 1_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None )); } @@ -153,20 +171,20 @@ fn two_sdrucs_to_the_same_address_both_needed() { let inputs = build_inputs([ Basic( 2_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, - Some((BECH32_ADDRESS_ED25519_1, 1_000_000)), + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), None, None, None, ), Basic( 2_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, - Some((BECH32_ADDRESS_ED25519_1, 1_000_000)), + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), None, None, None, @@ -174,7 +192,7 @@ fn two_sdrucs_to_the_same_address_both_needed() { ]); let outputs = build_outputs([Basic( 2_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -186,7 +204,7 @@ fn two_sdrucs_to_the_same_address_both_needed() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select() @@ -200,7 +218,7 @@ fn two_sdrucs_to_the_same_address_both_needed() { assert!(is_remainder_or_return( output, 2_000_000, - BECH32_ADDRESS_ED25519_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), None )); } @@ -214,20 +232,20 @@ fn two_sdrucs_to_the_same_address_one_needed() { let inputs = build_inputs([ Basic( 2_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, - Some((BECH32_ADDRESS_ED25519_1, 1_000_000)), + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), None, None, None, ), Basic( 1_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, - Some((BECH32_ADDRESS_ED25519_1, 1_000_000)), + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), None, None, None, @@ -235,7 +253,7 @@ fn two_sdrucs_to_the_same_address_one_needed() { ]); let outputs = build_outputs([Basic( 1_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -247,7 +265,7 @@ fn two_sdrucs_to_the_same_address_one_needed() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select() @@ -262,7 +280,7 @@ fn two_sdrucs_to_the_same_address_one_needed() { assert!(is_remainder_or_return( output, 1_000_000, - BECH32_ADDRESS_ED25519_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), None )); } @@ -276,20 +294,20 @@ fn two_sdrucs_to_different_addresses_both_needed() { let inputs = build_inputs([ Basic( 2_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, - Some((BECH32_ADDRESS_ED25519_1, 1_000_000)), + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), None, None, None, ), Basic( 2_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, - Some((BECH32_ADDRESS_ED25519_2, 1_000_000)), + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_2).unwrap(), 1_000_000)), None, None, None, @@ -297,7 +315,7 @@ fn two_sdrucs_to_different_addresses_both_needed() { ]); let outputs = build_outputs([Basic( 2_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -309,7 +327,7 @@ fn two_sdrucs_to_different_addresses_both_needed() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select() @@ -318,18 +336,22 @@ fn two_sdrucs_to_different_addresses_both_needed() { assert!(unsorted_eq(&selected.inputs, &inputs)); assert_eq!(selected.outputs.len(), 3); assert!(selected.outputs.contains(&outputs[0])); - assert!( - selected - .outputs - .iter() - .any(|output| { is_remainder_or_return(output, 1_000_000, BECH32_ADDRESS_ED25519_1, None) }) - ); - assert!( - selected - .outputs - .iter() - .any(|output| { is_remainder_or_return(output, 1_000_000, BECH32_ADDRESS_ED25519_2, None) }) - ); + assert!(selected.outputs.iter().any(|output| { + is_remainder_or_return( + output, + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + None, + ) + })); + assert!(selected.outputs.iter().any(|output| { + is_remainder_or_return( + output, + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_2).unwrap(), + None, + ) + })); } #[test] @@ -339,20 +361,20 @@ fn two_sdrucs_to_different_addresses_one_needed() { let inputs = build_inputs([ Basic( 2_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, - Some((BECH32_ADDRESS_ED25519_1, 1_000_000)), + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), None, None, None, ), Basic( 1_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, - Some((BECH32_ADDRESS_ED25519_2, 1_000_000)), + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_2).unwrap(), 1_000_000)), None, None, None, @@ -360,7 +382,7 @@ fn two_sdrucs_to_different_addresses_one_needed() { ]); let outputs = build_outputs([Basic( 1_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -372,7 +394,7 @@ fn two_sdrucs_to_different_addresses_one_needed() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select() @@ -387,7 +409,7 @@ fn two_sdrucs_to_different_addresses_one_needed() { assert!(is_remainder_or_return( output, 1_000_000, - BECH32_ADDRESS_ED25519_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), None )); } @@ -400,17 +422,17 @@ fn insufficient_amount_because_of_sdruc() { let inputs = build_inputs([Basic( 2_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, - Some((BECH32_ADDRESS_ED25519_1, 1_000_000)), + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), None, None, None, )]); let outputs = build_outputs([Basic( 2_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -422,7 +444,7 @@ fn insufficient_amount_because_of_sdruc() { let selected = InputSelection::new( inputs, outputs, - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select(); @@ -443,21 +465,30 @@ fn useless_sdruc_required_for_sender_feature() { let inputs = build_inputs([ Basic( 1_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_2).unwrap(), 1_000_000)), + None, + None, + None, + ), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + None, None, None, - Some((BECH32_ADDRESS_ED25519_2, 1_000_000)), None, None, None, ), - Basic(1_000_000, BECH32_ADDRESS_ED25519_1, None, None, None, None, None, None), ]); let outputs = build_outputs([Basic( 1_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, - Some(BECH32_ADDRESS_ED25519_0), + Some(Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()), None, None, None, @@ -467,7 +498,10 @@ fn useless_sdruc_required_for_sender_feature() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0, BECH32_ADDRESS_ED25519_1]), + [ + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + ], protocol_parameters, ) .select() @@ -481,7 +515,7 @@ fn useless_sdruc_required_for_sender_feature() { assert!(is_remainder_or_return( output, 1_000_000, - BECH32_ADDRESS_ED25519_2, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_2).unwrap(), None )); } @@ -496,21 +530,28 @@ fn sdruc_required_non_ed25519_in_address_unlock() { let inputs = build_inputs([ Basic( 2_000_000, - BECH32_ADDRESS_ACCOUNT_1, + Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap(), None, None, - Some((BECH32_ADDRESS_ED25519_2, 1_000_000)), + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_2).unwrap(), 1_000_000)), + None, + None, + None, + ), + Account( + 1_000_000, + account_id_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, ), - Account(1_000_000, account_id_1, BECH32_ADDRESS_ED25519_0, None, None, None), ]); let outputs = build_outputs([Basic( 1_000_000, - BECH32_ADDRESS_ED25519_2, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_2).unwrap(), None, - Some(BECH32_ADDRESS_ACCOUNT_1), + Some(Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap()), None, None, None, @@ -520,7 +561,7 @@ fn sdruc_required_non_ed25519_in_address_unlock() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select() @@ -534,7 +575,7 @@ fn sdruc_required_non_ed25519_in_address_unlock() { assert!(is_remainder_or_return( output, 1_000_000, - BECH32_ADDRESS_ED25519_2, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_2).unwrap(), None )); } @@ -549,20 +590,36 @@ fn useless_sdruc_non_ed25519_in_address_unlock() { let inputs = build_inputs([ Basic( 1_000_000, - BECH32_ADDRESS_ACCOUNT_1, + Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap(), + None, + None, + Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_2).unwrap(), 1_000_000)), None, None, - Some((BECH32_ADDRESS_ED25519_2, 1_000_000)), + None, + ), + Basic( + 1_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap(), + None, + None, + None, + None, + None, + None, + ), + Account( + 1_000_000, + account_id_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, ), - Basic(1_000_000, BECH32_ADDRESS_ACCOUNT_1, None, None, None, None, None, None), - Account(1_000_000, account_id_1, BECH32_ADDRESS_ED25519_0, None, None, None), ]); let outputs = build_outputs([Basic( 1_000_000, - BECH32_ADDRESS_ED25519_2, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_2).unwrap(), None, None, None, @@ -574,7 +631,7 @@ fn useless_sdruc_non_ed25519_in_address_unlock() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .select() diff --git a/sdk/tests/client/input_selection/timelock.rs b/sdk/tests/client/input_selection/timelock.rs index f8c3519d58..7c27a9bad9 100644 --- a/sdk/tests/client/input_selection/timelock.rs +++ b/sdk/tests/client/input_selection/timelock.rs @@ -3,13 +3,12 @@ use iota_sdk::{ client::api::input_selection::{Error, InputSelection}, - types::block::protocol::protocol_parameters, + types::block::{address::Address, protocol::protocol_parameters}, }; use pretty_assertions::assert_eq; use crate::client::{ - addresses, build_inputs, build_outputs, unsorted_eq, Build::Basic, BECH32_ADDRESS_ED25519_0, - BECH32_ADDRESS_ED25519_1, + build_inputs, build_outputs, unsorted_eq, Build::Basic, BECH32_ADDRESS_ED25519_0, BECH32_ADDRESS_ED25519_1, }; #[test] @@ -18,7 +17,7 @@ fn one_output_timelock_not_expired() { let inputs = build_inputs([Basic( 2_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -28,7 +27,7 @@ fn one_output_timelock_not_expired() { )]); let outputs = build_outputs([Basic( 1_000_000, - BECH32_ADDRESS_ED25519_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), None, None, None, @@ -40,7 +39,7 @@ fn one_output_timelock_not_expired() { let selected = InputSelection::new( inputs, outputs, - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .with_slot_index(100) @@ -55,7 +54,7 @@ fn timelock_equal_timestamp() { let inputs = build_inputs([Basic( 2_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -65,7 +64,7 @@ fn timelock_equal_timestamp() { )]); let outputs = build_outputs([Basic( 2_000_000, - BECH32_ADDRESS_ED25519_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), None, None, None, @@ -77,7 +76,7 @@ fn timelock_equal_timestamp() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .with_slot_index(200) @@ -95,7 +94,7 @@ fn two_outputs_one_timelock_expired() { let inputs = build_inputs([ Basic( 2_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -105,7 +104,7 @@ fn two_outputs_one_timelock_expired() { ), Basic( 2_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -116,7 +115,7 @@ fn two_outputs_one_timelock_expired() { ]); let outputs = build_outputs([Basic( 2_000_000, - BECH32_ADDRESS_ED25519_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), None, None, None, @@ -128,7 +127,7 @@ fn two_outputs_one_timelock_expired() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .with_slot_index(100) @@ -147,7 +146,7 @@ fn two_outputs_one_timelocked_one_missing() { let inputs = build_inputs([ Basic( 2_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -155,11 +154,20 @@ fn two_outputs_one_timelocked_one_missing() { None, None, ), - Basic(2_000_000, BECH32_ADDRESS_ED25519_0, None, None, None, None, None, None), + Basic( + 2_000_000, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + None, + None, + None, + None, + None, + None, + ), ]); let outputs = build_outputs([Basic( 2_000_000, - BECH32_ADDRESS_ED25519_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), None, None, None, @@ -171,7 +179,7 @@ fn two_outputs_one_timelocked_one_missing() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .with_slot_index(100) @@ -189,7 +197,7 @@ fn one_output_timelock_expired() { let inputs = build_inputs([Basic( 2_000_000, - BECH32_ADDRESS_ED25519_0, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), None, None, None, @@ -199,7 +207,7 @@ fn one_output_timelock_expired() { )]); let outputs = build_outputs([Basic( 2_000_000, - BECH32_ADDRESS_ED25519_1, + Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), None, None, None, @@ -211,7 +219,7 @@ fn one_output_timelock_expired() { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - addresses([BECH32_ADDRESS_ED25519_0]), + [Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()], protocol_parameters, ) .with_slot_index(100) diff --git a/sdk/tests/client/mod.rs b/sdk/tests/client/mod.rs index 6e5be5e3ca..987ef89ea8 100644 --- a/sdk/tests/client/mod.rs +++ b/sdk/tests/client/mod.rs @@ -21,7 +21,7 @@ use crypto::keys::bip44::Bip44; use iota_sdk::{ client::secret::types::InputSigningData, types::block::{ - address::{AccountAddress, Address, Bech32Address}, + address::{AccountAddress, Address}, output::{ feature::{IssuerFeature, SenderFeature}, unlock_condition::{ @@ -58,50 +58,51 @@ const _BECH32_ADDRESS_NFT_2: &str = "rms1zq3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3zyg3 enum Build<'a> { Basic( u64, - &'a str, - Option<(&'a str, u64)>, - Option<&'a str>, + Address, Option<(&'a str, u64)>, + Option
, + Option<(Address, u64)>, Option, - Option<(&'a str, u32)>, + Option<(Address, u32)>, Option, ), Nft( u64, NftId, - &'a str, - Option<&'a str>, - Option<&'a str>, - Option<(&'a str, u64)>, - Option<(&'a str, u32)>, + Address, + Option
, + Option
, + Option<(Address, u64)>, + Option<(Address, u32)>, Option, ), - Account(u64, AccountId, &'a str, Option<&'a str>, Option<&'a str>, Option), + Account(u64, AccountId, Address, Option
, Option
, Option), Foundry(u64, AccountId, u32, SimpleTokenScheme, Option<(&'a str, u64)>), } fn build_basic_output( amount: u64, - bech32_address: Bech32Address, + address: Address, native_token: Option<(&str, u64)>, - bech32_sender: Option, - sdruc: Option<(Bech32Address, u64)>, + sender: Option
, + sdruc: Option<(Address, u64)>, timelock: Option, - expiration: Option<(Bech32Address, u32)>, + expiration: Option<(Address, u32)>, ) -> Output { let mut builder = - BasicOutputBuilder::new_with_amount(amount).add_unlock_condition(AddressUnlockCondition::new(bech32_address)); + BasicOutputBuilder::new_with_amount(amount).add_unlock_condition(AddressUnlockCondition::new(address.clone())); if let Some((id, amount)) = native_token { builder = builder.with_native_token(NativeToken::new(TokenId::from_str(id).unwrap(), amount).unwrap()); } - if let Some(bech32_sender) = bech32_sender { - builder = builder.add_feature(SenderFeature::new(bech32_sender)); + if let Some(sender) = sender { + builder = builder.add_feature(SenderFeature::new(sender.clone())); } if let Some((address, amount)) = sdruc { - builder = builder.add_unlock_condition(StorageDepositReturnUnlockCondition::new(address, amount).unwrap()); + builder = + builder.add_unlock_condition(StorageDepositReturnUnlockCondition::new(address.clone(), amount).unwrap()); } if let Some(timelock) = timelock { @@ -109,61 +110,60 @@ fn build_basic_output( } if let Some((address, timestamp)) = expiration { - builder = builder.add_unlock_condition(ExpirationUnlockCondition::new(address, timestamp).unwrap()); + builder = builder.add_unlock_condition(ExpirationUnlockCondition::new(address.clone(), timestamp).unwrap()); } builder.finish_output().unwrap() } -#[allow(clippy::too_many_arguments)] fn build_nft_output( amount: u64, nft_id: NftId, - bech32_address: Bech32Address, - bech32_sender: Option, - bech32_issuer: Option, - sdruc: Option<(Bech32Address, u64)>, - expiration: Option<(Bech32Address, u32)>, + address: Address, + sender: Option
, + issuer: Option
, + sdruc: Option<(Address, u64)>, + expiration: Option<(Address, u32)>, ) -> Output { let mut builder = NftOutputBuilder::new_with_amount(amount, nft_id) - .add_unlock_condition(AddressUnlockCondition::new(bech32_address)); + .add_unlock_condition(AddressUnlockCondition::new(address.clone())); - if let Some(bech32_sender) = bech32_sender { - builder = builder.add_feature(SenderFeature::new(bech32_sender)); + if let Some(sender) = sender { + builder = builder.add_feature(SenderFeature::new(sender.clone())); } - if let Some(bech32_issuer) = bech32_issuer { - builder = builder.add_immutable_feature(IssuerFeature::new(bech32_issuer)); + if let Some(issuer) = issuer { + builder = builder.add_immutable_feature(IssuerFeature::new(issuer.clone())); } if let Some((address, amount)) = sdruc { - builder = builder.add_unlock_condition(StorageDepositReturnUnlockCondition::new(address, amount).unwrap()); + builder = + builder.add_unlock_condition(StorageDepositReturnUnlockCondition::new(address.clone(), amount).unwrap()); } if let Some((address, timestamp)) = expiration { - builder = builder.add_unlock_condition(ExpirationUnlockCondition::new(address, timestamp).unwrap()); + builder = builder.add_unlock_condition(ExpirationUnlockCondition::new(address.clone(), timestamp).unwrap()); } builder.finish_output().unwrap() } -#[allow(clippy::too_many_arguments)] fn build_account_output( amount: u64, account_id: AccountId, - address: Bech32Address, - bech32_sender: Option, - bech32_issuer: Option, + address: Address, + sender: Option
, + issuer: Option
, ) -> Output { let mut builder = AccountOutputBuilder::new_with_amount(amount, account_id) - .add_unlock_condition(AddressUnlockCondition::new(address)); + .add_unlock_condition(AddressUnlockCondition::new(address.clone())); - if let Some(bech32_sender) = bech32_sender { - builder = builder.add_feature(SenderFeature::new(bech32_sender)); + if let Some(sender) = sender { + builder = builder.add_feature(SenderFeature::new(sender.clone())); } - if let Some(bech32_issuer) = bech32_issuer { - builder = builder.add_immutable_feature(IssuerFeature::new(bech32_issuer)); + if let Some(issuer) = issuer { + builder = builder.add_immutable_feature(IssuerFeature::new(issuer.clone())); } builder.finish_output().unwrap() @@ -190,40 +190,17 @@ fn build_foundry_output( fn build_output_inner(build: Build) -> (Output, Option) { match build { - Build::Basic(amount, bech32_address, native_token, bech32_sender, sdruc, timelock, expiration, chain) => ( - build_basic_output( - amount, - Bech32Address::try_from_str(bech32_address).unwrap(), - native_token, - bech32_sender.map(|address| Bech32Address::try_from_str(address).unwrap()), - sdruc.map(|(address, exp)| (Bech32Address::try_from_str(address).unwrap(), exp)), - timelock, - expiration.map(|(address, exp)| (Bech32Address::try_from_str(address).unwrap(), exp)), - ), + 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, bech32_address, bech32_sender, bech32_issuer, sdruc, expiration, chain) => ( - build_nft_output( - amount, - nft_id, - Bech32Address::try_from_str(bech32_address).unwrap(), - bech32_sender.map(|address| Bech32Address::try_from_str(address).unwrap()), - bech32_issuer.map(|address| Bech32Address::try_from_str(address).unwrap()), - sdruc.map(|(address, exp)| (Bech32Address::try_from_str(address).unwrap(), exp)), - expiration.map(|(address, exp)| (Bech32Address::try_from_str(address).unwrap(), exp)), - ), - chain, - ), - Build::Account(amount, account_id, address, bech32_sender, bech32_issuer, chain) => ( - build_account_output( - amount, - account_id, - Bech32Address::try_from_str(address).unwrap(), - bech32_sender.map(|address| Bech32Address::try_from_str(address).unwrap()), - bech32_issuer.map(|address| Bech32Address::try_from_str(address).unwrap()), - ), + 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::Foundry(amount, account_id, serial_number, token_scheme, native_token) => ( build_foundry_output(amount, account_id, serial_number, token_scheme, native_token), None, @@ -268,7 +245,7 @@ where count(a) == count(b) } -fn is_remainder_or_return(output: &Output, amount: u64, address: &str, native_token: Option<(&str, u64)>) -> bool { +fn is_remainder_or_return(output: &Output, amount: u64, address: Address, native_token: Option<(&str, u64)>) -> bool { if let Output::Basic(output) = output { if output.amount() != amount { return false; @@ -277,7 +254,7 @@ fn is_remainder_or_return(output: &Output, amount: u64, address: &str, native_to // assert_eq!(output.as_basic().native_tokens().len(), 0); if let [UnlockCondition::Address(address_unlock_condition)] = output.unlock_conditions().as_ref() { - if address_unlock_condition.address() != Bech32Address::try_from_str(address).unwrap().inner() { + if address_unlock_condition.address() != &address { return false; } } else { @@ -303,10 +280,3 @@ fn is_remainder_or_return(output: &Output, amount: u64, address: &str, native_to false } } - -fn addresses<'a>(addresses: impl IntoIterator) -> Vec
{ - addresses - .into_iter() - .map(|address| Address::try_from_bech32(address).unwrap()) - .collect() -} diff --git a/sdk/tests/client/signing/account.rs b/sdk/tests/client/signing/account.rs index 6b6043a2a5..e88faab90d 100644 --- a/sdk/tests/client/signing/account.rs +++ b/sdk/tests/client/signing/account.rs @@ -10,12 +10,12 @@ use iota_sdk::{ transaction::validate_signed_transaction_payload_length, verify_semantic, GetAddressesOptions, PreparedTransactionData, }, - constants::{SHIMMER_COIN_TYPE, SHIMMER_TESTNET_BECH32_HRP}, + constants::SHIMMER_COIN_TYPE, secret::{SecretManage, SecretManager}, Client, Result, }, types::block::{ - address::{AccountAddress, Address, ToBech32Ext}, + address::{AccountAddress, Address}, input::{Input, UtxoInput}, output::AccountId, payload::{signed_transaction::Transaction, SignedTransactionPayload}, @@ -36,7 +36,7 @@ use crate::client::{ async fn sign_account_state_transition() -> Result<()> { let secret_manager = SecretManager::try_from_mnemonic(Client::generate_mnemonic()?)?; - let bech32_address = &secret_manager + let address = secret_manager .generate_ed25519_addresses( GetAddressesOptions::default() .with_coin_type(SHIMMER_COIN_TYPE) @@ -44,7 +44,7 @@ async fn sign_account_state_transition() -> Result<()> { ) .await?[0] .clone() - .to_bech32(SHIMMER_TESTNET_BECH32_HRP); + .into_inner(); let protocol_parameters = protocol_parameters(); let account_id = AccountId::from_str(ACCOUNT_ID_1)?; @@ -52,20 +52,13 @@ async fn sign_account_state_transition() -> Result<()> { let inputs = build_inputs([Account( 1_000_000, account_id, - &bech32_address.to_string(), + address.clone(), None, None, Some(Bip44::new(SHIMMER_COIN_TYPE)), )]); - let outputs = build_outputs([Account( - 1_000_000, - account_id, - &bech32_address.to_string(), - None, - None, - None, - )]); + let outputs = build_outputs([Account(1_000_000, account_id, address.clone(), None, None, None)]); let transaction = Transaction::builder(protocol_parameters.network_id()) .with_inputs( @@ -106,7 +99,7 @@ async fn sign_account_state_transition() -> Result<()> { async fn account_reference_unlocks() -> Result<()> { let secret_manager = SecretManager::try_from_mnemonic(Client::generate_mnemonic()?)?; - let bech32_address = &secret_manager + let address = secret_manager .generate_ed25519_addresses( GetAddressesOptions::default() .with_coin_type(SHIMMER_COIN_TYPE) @@ -114,56 +107,28 @@ async fn account_reference_unlocks() -> Result<()> { ) .await?[0] .clone() - .to_bech32(SHIMMER_TESTNET_BECH32_HRP); + .into_inner(); let protocol_parameters = protocol_parameters(); let account_id = AccountId::from_str(ACCOUNT_ID_1)?; - let account_bech32_address = - &Address::Account(AccountAddress::new(account_id)).to_bech32(SHIMMER_TESTNET_BECH32_HRP); + let account_address = Address::Account(AccountAddress::new(account_id)); let inputs = build_inputs([ Account( 1_000_000, account_id, - &bech32_address.to_string(), + address.clone(), None, None, Some(Bip44::new(SHIMMER_COIN_TYPE)), ), - Basic( - 1_000_000, - &account_bech32_address.to_string(), - None, - None, - None, - None, - None, - None, - ), - Basic( - 1_000_000, - &account_bech32_address.to_string(), - None, - None, - None, - None, - None, - None, - ), + 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), ]); let outputs = build_outputs([ - Account(1_000_000, account_id, &bech32_address.to_string(), None, None, None), - Basic( - 2_000_000, - &account_bech32_address.to_string(), - None, - None, - None, - None, - None, - None, - ), + Account(1_000_000, account_id, address, None, None, None), + Basic(2_000_000, account_address, None, None, None, None, None, None), ]); let transaction = Transaction::builder(protocol_parameters.network_id()) diff --git a/sdk/tests/client/signing/basic.rs b/sdk/tests/client/signing/basic.rs index 95af23db4d..31a60ba833 100644 --- a/sdk/tests/client/signing/basic.rs +++ b/sdk/tests/client/signing/basic.rs @@ -8,12 +8,11 @@ use iota_sdk::{ transaction::validate_signed_transaction_payload_length, verify_semantic, GetAddressesOptions, PreparedTransactionData, }, - constants::{SHIMMER_COIN_TYPE, SHIMMER_TESTNET_BECH32_HRP}, + constants::SHIMMER_COIN_TYPE, secret::{SecretManage, SecretManager}, Client, Result, }, types::block::{ - address::ToBech32Ext, input::{Input, UtxoInput}, payload::{signed_transaction::Transaction, SignedTransactionPayload}, protocol::protocol_parameters, @@ -29,7 +28,7 @@ use crate::client::{build_inputs, build_outputs, Build::Basic}; async fn single_ed25519_unlock() -> Result<()> { let secret_manager = SecretManager::try_from_mnemonic(Client::generate_mnemonic()?)?; - let bech32_address_0 = &secret_manager + let address_0 = secret_manager .generate_ed25519_addresses( GetAddressesOptions::default() .with_coin_type(SHIMMER_COIN_TYPE) @@ -37,13 +36,13 @@ async fn single_ed25519_unlock() -> Result<()> { ) .await?[0] .clone() - .to_bech32(SHIMMER_TESTNET_BECH32_HRP); + .into_inner(); let protocol_parameters = protocol_parameters(); let inputs = build_inputs([Basic( 1_000_000, - &bech32_address_0.to_string(), + address_0.clone(), None, None, None, @@ -54,7 +53,7 @@ async fn single_ed25519_unlock() -> Result<()> { let outputs = build_outputs([Basic( 1_000_000, - &bech32_address_0.to_string(), + address_0, None, None, None, @@ -102,7 +101,7 @@ async fn single_ed25519_unlock() -> Result<()> { async fn ed25519_reference_unlocks() -> Result<()> { let secret_manager = SecretManager::try_from_mnemonic(Client::generate_mnemonic()?)?; - let bech32_address_0 = &secret_manager + let address_0 = secret_manager .generate_ed25519_addresses( GetAddressesOptions::default() .with_coin_type(SHIMMER_COIN_TYPE) @@ -110,14 +109,14 @@ async fn ed25519_reference_unlocks() -> Result<()> { ) .await?[0] .clone() - .to_bech32(SHIMMER_TESTNET_BECH32_HRP); + .into_inner(); let protocol_parameters = protocol_parameters(); let inputs = build_inputs([ Basic( 1_000_000, - &bech32_address_0.to_string(), + address_0.clone(), None, None, None, @@ -127,7 +126,7 @@ async fn ed25519_reference_unlocks() -> Result<()> { ), Basic( 1_000_000, - &bech32_address_0.to_string(), + address_0.clone(), None, None, None, @@ -137,7 +136,7 @@ async fn ed25519_reference_unlocks() -> Result<()> { ), Basic( 1_000_000, - &bech32_address_0.to_string(), + address_0.clone(), None, None, None, @@ -149,7 +148,7 @@ async fn ed25519_reference_unlocks() -> Result<()> { let outputs = build_outputs([Basic( 3_000_000, - &bech32_address_0.to_string(), + address_0, None, None, None, @@ -209,7 +208,7 @@ async fn ed25519_reference_unlocks() -> Result<()> { async fn two_signature_unlocks() -> Result<()> { let secret_manager = SecretManager::try_from_mnemonic(Client::generate_mnemonic()?)?; - let bech32_address_0 = &secret_manager + let address_0 = secret_manager .generate_ed25519_addresses( GetAddressesOptions::default() .with_coin_type(SHIMMER_COIN_TYPE) @@ -217,8 +216,8 @@ async fn two_signature_unlocks() -> Result<()> { ) .await?[0] .clone() - .to_bech32(SHIMMER_TESTNET_BECH32_HRP); - let bech32_address_1 = &secret_manager + .into_inner(); + let address_1 = secret_manager .generate_ed25519_addresses( GetAddressesOptions::default() .with_coin_type(SHIMMER_COIN_TYPE) @@ -226,14 +225,14 @@ async fn two_signature_unlocks() -> Result<()> { ) .await?[0] .clone() - .to_bech32(SHIMMER_TESTNET_BECH32_HRP); + .into_inner(); let protocol_parameters = protocol_parameters(); let inputs = build_inputs([ Basic( 1_000_000, - &bech32_address_0.to_string(), + address_0.clone(), None, None, None, @@ -243,7 +242,7 @@ async fn two_signature_unlocks() -> Result<()> { ), Basic( 1_000_000, - &bech32_address_1.to_string(), + address_1, None, None, None, @@ -255,7 +254,7 @@ async fn two_signature_unlocks() -> Result<()> { let outputs = build_outputs([Basic( 2_000_000, - &bech32_address_0.to_string(), + address_0, None, None, None, diff --git a/sdk/tests/client/signing/mod.rs b/sdk/tests/client/signing/mod.rs index 9082ecda60..c5efd789c9 100644 --- a/sdk/tests/client/signing/mod.rs +++ b/sdk/tests/client/signing/mod.rs @@ -14,12 +14,12 @@ use iota_sdk::{ input_selection::InputSelection, transaction::validate_signed_transaction_payload_length, verify_semantic, GetAddressesOptions, PreparedTransactionData, }, - constants::{SHIMMER_COIN_TYPE, SHIMMER_TESTNET_BECH32_HRP}, + constants::SHIMMER_COIN_TYPE, secret::{SecretManage, SecretManager}, Result, }, types::block::{ - address::{AccountAddress, Address, NftAddress, ToBech32Ext}, + address::{AccountAddress, Address, NftAddress}, input::{Input, UtxoInput}, output::{AccountId, NftId}, payload::{signed_transaction::Transaction, SignedTransactionPayload}, @@ -53,112 +53,43 @@ async fn all_combined() -> Result<()> { .with_range(0..3), ) .await?; - let ed25519_bech32_address_0 = ed25519_bech32_addresses[0] - .clone() - .to_bech32(SHIMMER_TESTNET_BECH32_HRP); - let ed25519_bech32_address_1 = ed25519_bech32_addresses[1] - .clone() - .to_bech32(SHIMMER_TESTNET_BECH32_HRP); - let ed25519_bech32_address_2 = ed25519_bech32_addresses[2] - .clone() - .to_bech32(SHIMMER_TESTNET_BECH32_HRP); + let ed25519_0 = ed25519_bech32_addresses[0].clone().into_inner(); + let ed25519_1 = ed25519_bech32_addresses[1].clone().into_inner(); + let ed25519_2 = ed25519_bech32_addresses[2].clone().into_inner(); let account_id_1 = AccountId::from_str(ACCOUNT_ID_1)?; let account_id_2 = AccountId::from_str(ACCOUNT_ID_2)?; - let account_1_bech32_address = - &Address::Account(AccountAddress::new(account_id_1)).to_bech32(SHIMMER_TESTNET_BECH32_HRP); - let account_2_bech32_address = - &Address::Account(AccountAddress::new(account_id_2)).to_bech32(SHIMMER_TESTNET_BECH32_HRP); + let account_1 = Address::Account(AccountAddress::new(account_id_1)); + let account_2 = Address::Account(AccountAddress::new(account_id_2)); let nft_id_1 = NftId::from_str(NFT_ID_1)?; let nft_id_2 = NftId::from_str(NFT_ID_2)?; let nft_id_3 = NftId::from_str(NFT_ID_3)?; let nft_id_4 = NftId::from_str(NFT_ID_4)?; - let nft_1_bech32_address = &Address::Nft(NftAddress::new(nft_id_1)).to_bech32(SHIMMER_TESTNET_BECH32_HRP); - let nft_2_bech32_address = &Address::Nft(NftAddress::new(nft_id_2)).to_bech32(SHIMMER_TESTNET_BECH32_HRP); - let nft_3_bech32_address = &Address::Nft(NftAddress::new(nft_id_3)).to_bech32(SHIMMER_TESTNET_BECH32_HRP); - let nft_4_bech32_address = &Address::Nft(NftAddress::new(nft_id_4)).to_bech32(SHIMMER_TESTNET_BECH32_HRP); + let nft_1 = Address::Nft(NftAddress::new(nft_id_1)); + let nft_2 = Address::Nft(NftAddress::new(nft_id_2)); + let nft_3 = Address::Nft(NftAddress::new(nft_id_3)); + let nft_4 = Address::Nft(NftAddress::new(nft_id_4)); let inputs = build_inputs([ - Account( - 1_000_000, - account_id_1, - &nft_1_bech32_address.to_string(), - None, - None, - None, - ), + Account(1_000_000, account_id_1, nft_1.clone(), None, None, None), Account( 1_000_000, account_id_2, - &ed25519_bech32_address_0.to_string(), + ed25519_0.clone(), 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, - &account_1_bech32_address.to_string(), - None, - None, - None, - None, - None, - None, - ), - Basic( - 1_000_000, - &account_2_bech32_address.to_string(), - None, - None, - None, - None, - None, - None, - ), - Basic( - 1_000_000, - &account_2_bech32_address.to_string(), - None, - None, - None, - None, - None, - None, - ), - Basic( - 1_000_000, - &nft_2_bech32_address.to_string(), - None, - None, - None, - None, - None, - None, - ), - Basic( - 1_000_000, - &nft_2_bech32_address.to_string(), - None, - None, - None, - None, - None, - None, - ), - Basic( - 1_000_000, - &nft_4_bech32_address.to_string(), - None, - None, - None, - None, - None, - None, - ), - Basic( - 1_000_000, - &ed25519_bech32_address_0.to_string(), + ed25519_0.clone(), None, None, None, @@ -168,7 +99,7 @@ async fn all_combined() -> Result<()> { ), Basic( 1_000_000, - &ed25519_bech32_address_1.to_string(), + ed25519_1.clone(), None, None, None, @@ -178,7 +109,7 @@ async fn all_combined() -> Result<()> { ), Basic( 1_000_000, - &ed25519_bech32_address_2.to_string(), + ed25519_2.clone(), None, None, None, @@ -188,7 +119,7 @@ async fn all_combined() -> Result<()> { ), Basic( 1_000_000, - &ed25519_bech32_address_2.to_string(), + ed25519_2.clone(), None, None, None, @@ -199,143 +130,75 @@ async fn all_combined() -> Result<()> { Nft( 1_000_000, nft_id_1, - &ed25519_bech32_address_0.to_string(), + ed25519_0.clone(), None, None, None, None, Some(Bip44::new(SHIMMER_COIN_TYPE)), ), - Nft( - 1_000_000, - nft_id_2, - &account_1_bech32_address.to_string(), - None, - None, - None, - None, - None, - ), + Nft(1_000_000, nft_id_2, account_1.clone(), None, None, None, None, None), // Expirations Basic( 2_000_000, - &ed25519_bech32_address_0.to_string(), + ed25519_0.clone(), None, None, None, None, - Some((&account_1_bech32_address.to_string(), 50)), + Some((account_1.clone(), 50)), None, ), Basic( 2_000_000, - &ed25519_bech32_address_0.to_string(), + ed25519_0.clone(), None, None, None, None, - Some((&nft_3_bech32_address.to_string(), 50)), + Some((nft_3.clone(), 50)), None, ), Basic( 2_000_000, - &ed25519_bech32_address_0.to_string(), + ed25519_0.clone(), None, None, None, None, - Some((&nft_3_bech32_address.to_string(), 150)), + Some((nft_3.clone(), 150)), Some(Bip44::new(SHIMMER_COIN_TYPE)), ), Nft( 1_000_000, nft_id_3, - &account_1_bech32_address.to_string(), + account_1.clone(), None, None, None, - Some((&nft_4_bech32_address.to_string(), 50)), + Some((nft_4, 50)), None, ), Nft( 1_000_000, nft_id_4, - &account_1_bech32_address.to_string(), + account_1, None, None, None, - Some((&nft_3_bech32_address.to_string(), 150)), + Some((nft_3, 150)), None, ), ]); let outputs = build_outputs([ - Account( - 1_000_000, - account_id_1, - &nft_1_bech32_address.to_string(), - None, - None, - None, - ), - Account( - 1_000_000, - account_id_2, - &ed25519_bech32_address_0.to_string(), - None, - None, - None, - ), - Basic( - 10_000_000, - &ed25519_bech32_address_0.to_string(), - None, - None, - None, - None, - None, - None, - ), - Nft( - 1_000_000, - nft_id_1, - &ed25519_bech32_address_0.to_string(), - None, - None, - None, - None, - None, - ), - Nft( - 1_000_000, - nft_id_2, - &ed25519_bech32_address_0.to_string(), - None, - None, - None, - None, - None, - ), - Nft( - 1_000_000, - nft_id_3, - &ed25519_bech32_address_0.to_string(), - None, - None, - None, - None, - None, - ), - Nft( - 1_000_000, - nft_id_4, - &ed25519_bech32_address_0.to_string(), - None, - None, - None, - None, - None, - ), + Account(1_000_000, account_id_1, nft_1, None, None, None), + Account(1_000_000, account_id_2, ed25519_0.clone(), None, None, None), + Basic(10_000_000, ed25519_0.clone(), None, None, None, None, None, None), + Nft(1_000_000, nft_id_1, ed25519_0.clone(), None, None, None, None, None), + Nft(1_000_000, nft_id_2, ed25519_0.clone(), None, None, None, None, None), + Nft(1_000_000, nft_id_3, ed25519_0.clone(), None, None, None, None, None), + Nft(1_000_000, nft_id_4, ed25519_0.clone(), None, None, None, None, None), ]); let slot_index = SlotIndex::from(100); @@ -343,11 +206,7 @@ async fn all_combined() -> Result<()> { let selected = InputSelection::new( inputs.clone(), outputs.clone(), - [ - ed25519_bech32_address_0.into_inner(), - ed25519_bech32_address_1.into_inner(), - ed25519_bech32_address_2.into_inner(), - ], + [ed25519_0, ed25519_1, ed25519_2], protocol_parameters.clone(), ) .with_slot_index(slot_index) diff --git a/sdk/tests/client/signing/nft.rs b/sdk/tests/client/signing/nft.rs index 81746e3451..e36ea3c16d 100644 --- a/sdk/tests/client/signing/nft.rs +++ b/sdk/tests/client/signing/nft.rs @@ -10,12 +10,12 @@ use iota_sdk::{ transaction::validate_signed_transaction_payload_length, verify_semantic, GetAddressesOptions, PreparedTransactionData, }, - constants::{SHIMMER_COIN_TYPE, SHIMMER_TESTNET_BECH32_HRP}, + constants::SHIMMER_COIN_TYPE, secret::{SecretManage, SecretManager}, Client, Result, }, types::block::{ - address::{Address, NftAddress, ToBech32Ext}, + address::{Address, NftAddress}, input::{Input, UtxoInput}, output::NftId, payload::{signed_transaction::Transaction, SignedTransactionPayload}, @@ -36,7 +36,7 @@ use crate::client::{ async fn nft_reference_unlocks() -> Result<()> { let secret_manager = SecretManager::try_from_mnemonic(Client::generate_mnemonic()?)?; - let bech32_address_0 = &secret_manager + let address_0 = secret_manager .generate_ed25519_addresses( GetAddressesOptions::default() .with_coin_type(SHIMMER_COIN_TYPE) @@ -44,66 +44,30 @@ async fn nft_reference_unlocks() -> Result<()> { ) .await?[0] .clone() - .to_bech32(SHIMMER_TESTNET_BECH32_HRP); + .into_inner(); let protocol_parameters = protocol_parameters(); let nft_id = NftId::from_str(NFT_ID_1)?; - let nft_bech32_address = &Address::Nft(NftAddress::new(nft_id)).to_bech32(SHIMMER_TESTNET_BECH32_HRP); + let nft_address = Address::Nft(NftAddress::new(nft_id)); let inputs = build_inputs([ Nft( 1_000_000, nft_id, - &bech32_address_0.to_string(), + address_0.clone(), None, None, None, None, Some(Bip44::new(SHIMMER_COIN_TYPE)), ), - Basic( - 1_000_000, - &nft_bech32_address.to_string(), - None, - None, - None, - None, - None, - None, - ), - Basic( - 1_000_000, - &nft_bech32_address.to_string(), - None, - None, - None, - None, - None, - None, - ), + 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), ]); let outputs = build_outputs([ - Nft( - 1_000_000, - nft_id, - &bech32_address_0.to_string(), - None, - None, - None, - None, - None, - ), - Basic( - 2_000_000, - &nft_bech32_address.to_string(), - None, - None, - None, - None, - None, - None, - ), + 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), ]); let transaction = Transaction::builder(protocol_parameters.network_id())