diff --git a/bindings/core/src/method/wallet.rs b/bindings/core/src/method/wallet.rs index c1b6b86367..efd3dd13d3 100644 --- a/bindings/core/src/method/wallet.rs +++ b/bindings/core/src/method/wallet.rs @@ -397,11 +397,11 @@ pub enum WalletMethod { // RegisterParticipationEvents { // options: ParticipationEventRegistrationOptions, // }, - /// Reissues a transaction sent from the wallet for a provided transaction id until it's - /// included (referenced by a milestone). Returns the included block id. + /// Checks the transaction state for a provided transaction id until it's accepted. Interval in milliseconds. + /// Returns the block id that contains this transaction. /// Expected response: [`BlockId`](crate::Response::BlockId) #[serde(rename_all = "camelCase")] - ReissueTransactionUntilIncluded { + WaitForTransactionAcceptance { /// Transaction id transaction_id: TransactionId, /// Interval diff --git a/bindings/core/src/method_handler/wallet.rs b/bindings/core/src/method_handler/wallet.rs index 2cb6657cc4..2e69c06e15 100644 --- a/bindings/core/src/method_handler/wallet.rs +++ b/bindings/core/src/method_handler/wallet.rs @@ -373,13 +373,13 @@ pub(crate) async fn call_wallet_method_internal(wallet: &Wallet, method: WalletM // let events = wallet.register_participation_events(&options).await?; // Response::ParticipationEvents(events) // } - WalletMethod::ReissueTransactionUntilIncluded { + WalletMethod::WaitForTransactionAcceptance { transaction_id, interval, max_attempts, } => { let block_id = wallet - .reissue_transaction_until_included(&transaction_id, interval, max_attempts) + .wait_for_transaction_acceptance(&transaction_id, interval, max_attempts) .await?; Response::BlockId(block_id) } diff --git a/bindings/core/src/response.rs b/bindings/core/src/response.rs index ddb183e8dc..7e2d85b9f1 100644 --- a/bindings/core/src/response.rs +++ b/bindings/core/src/response.rs @@ -266,7 +266,7 @@ pub enum Response { /// - [`BlockId`](crate::method::UtilsMethod::BlockId) /// - [`PostBlock`](crate::method::ClientMethod::PostBlock) /// - [`PostBlockRaw`](crate::method::ClientMethod::PostBlockRaw) - /// - [`ReissueTransactionUntilIncluded`](crate::method::WalletMethod::ReissueTransactionUntilIncluded) + /// - [`WaitForTransactionAcceptance`](crate::method::WalletMethod::WaitForTransactionAcceptance) BlockId(BlockId), /// Response for: /// - [`GetHealth`](crate::method::ClientMethod::GetHealth) diff --git a/bindings/nodejs/examples/how_tos/account_output/create.ts b/bindings/nodejs/examples/how_tos/account_output/create.ts index 6f3ffd8e85..c81e1b9b6f 100644 --- a/bindings/nodejs/examples/how_tos/account_output/create.ts +++ b/bindings/nodejs/examples/how_tos/account_output/create.ts @@ -49,12 +49,12 @@ async function run() { console.log(`Transaction sent: ${transaction.transactionId}`); - // Wait for transaction to get included - const blockId = await wallet.reissueTransactionUntilIncluded( + // Wait for transaction to get accepted + const blockId = await wallet.waitForTransactionAcceptance( transaction.transactionId, ); console.log( - `Block included: ${process.env.EXPLORER_URL}/block/${blockId}`, + `Tx accepted in block: ${process.env.EXPLORER_URL}/block/${blockId}`, ); balance = await wallet.sync(); diff --git a/bindings/nodejs/examples/how_tos/account_output/destroy.ts b/bindings/nodejs/examples/how_tos/account_output/destroy.ts index f6ee3aa130..deb923a74b 100644 --- a/bindings/nodejs/examples/how_tos/account_output/destroy.ts +++ b/bindings/nodejs/examples/how_tos/account_output/destroy.ts @@ -57,12 +57,12 @@ async function run() { console.log(`Transaction sent: ${transaction.transactionId}`); - // Wait for transaction to get included - const blockId = await wallet.reissueTransactionUntilIncluded( + // Wait for transaction to get accepted + const blockId = await wallet.waitForTransactionAcceptance( transaction.transactionId, ); console.log( - `Block included: ${process.env.EXPLORER_URL}/block/${blockId}`, + `Tx accepted in block: ${process.env.EXPLORER_URL}/block/${blockId}`, ); console.log(`Destroyed account output ${accountId}`); diff --git a/bindings/nodejs/examples/how_tos/account_output/send-amount.ts b/bindings/nodejs/examples/how_tos/account_output/send-amount.ts index 9d06180e81..18a094b266 100644 --- a/bindings/nodejs/examples/how_tos/account_output/send-amount.ts +++ b/bindings/nodejs/examples/how_tos/account_output/send-amount.ts @@ -75,7 +75,7 @@ async function run() { allowMicroAmount: false, }; const transaction = await wallet.sendWithParams(params, options); - await wallet.reissueTransactionUntilIncluded(transaction.transactionId); + await wallet.waitForTransactionAcceptance(transaction.transactionId); console.log( `Transaction with custom input: https://explorer.iota.org/testnet/transaction/${transaction.transactionId}`, ); diff --git a/bindings/nodejs/examples/how_tos/advanced_transactions/advanced_transaction.ts b/bindings/nodejs/examples/how_tos/advanced_transactions/advanced_transaction.ts index 5a96d760f1..ad52edfaf7 100644 --- a/bindings/nodejs/examples/how_tos/advanced_transactions/advanced_transaction.ts +++ b/bindings/nodejs/examples/how_tos/advanced_transactions/advanced_transaction.ts @@ -62,8 +62,8 @@ async function run() { const transaction = await wallet.sendOutputs([basicOutput]); console.log(`Transaction sent: ${transaction.transactionId}`); - console.log('Waiting until included in block...'); - const blockId = await wallet.reissueTransactionUntilIncluded( + console.log('Waiting until transaction is accepted...'); + const blockId = await wallet.waitForTransactionAcceptance( transaction.transactionId, ); console.log(`Block sent: ${process.env.EXPLORER_URL}/block/${blockId}`); diff --git a/bindings/nodejs/examples/how_tos/advanced_transactions/claim_transaction.ts b/bindings/nodejs/examples/how_tos/advanced_transactions/claim_transaction.ts index 68d78345e5..9d308e5adf 100644 --- a/bindings/nodejs/examples/how_tos/advanced_transactions/claim_transaction.ts +++ b/bindings/nodejs/examples/how_tos/advanced_transactions/claim_transaction.ts @@ -44,7 +44,7 @@ async function run() { const transaction = await wallet.claimOutputs(output_ids); console.log(`Transaction sent: ${transaction.transactionId}`); - const blockId = await wallet.reissueTransactionUntilIncluded( + const blockId = await wallet.waitForTransactionAcceptance( transaction.transactionId, ); console.log(`Block sent: ${process.env.EXPLORER_URL}/block/${blockId}`); diff --git a/bindings/nodejs/examples/how_tos/advanced_transactions/send_micro_transaction.ts b/bindings/nodejs/examples/how_tos/advanced_transactions/send_micro_transaction.ts index 77b7e71680..7b0f99df78 100644 --- a/bindings/nodejs/examples/how_tos/advanced_transactions/send_micro_transaction.ts +++ b/bindings/nodejs/examples/how_tos/advanced_transactions/send_micro_transaction.ts @@ -45,7 +45,7 @@ async function run() { console.log(`Transaction sent: ${transaction.transactionId}`); - const blockId = await wallet.reissueTransactionUntilIncluded( + const blockId = await wallet.waitForTransactionAcceptance( transaction.transactionId, ); diff --git a/bindings/nodejs/examples/how_tos/native_tokens/burn.ts b/bindings/nodejs/examples/how_tos/native_tokens/burn.ts index 204bf76bac..390d02e89a 100644 --- a/bindings/nodejs/examples/how_tos/native_tokens/burn.ts +++ b/bindings/nodejs/examples/how_tos/native_tokens/burn.ts @@ -53,13 +53,13 @@ async function run() { console.log(`Transaction sent: ${transaction.transactionId}`); - // Wait for transaction to get included - const blockId = await wallet.reissueTransactionUntilIncluded( + // Wait for transaction to get accepted + const blockId = await wallet.waitForTransactionAcceptance( transaction.transactionId, ); console.log( - `Block included: ${process.env.EXPLORER_URL}/block/${blockId}`, + `Tx accepted in block: ${process.env.EXPLORER_URL}/block/${blockId}`, ); balance = await wallet.sync(); diff --git a/bindings/nodejs/examples/how_tos/native_tokens/create.ts b/bindings/nodejs/examples/how_tos/native_tokens/create.ts index 3c4d09eba8..abe0c70940 100644 --- a/bindings/nodejs/examples/how_tos/native_tokens/create.ts +++ b/bindings/nodejs/examples/how_tos/native_tokens/create.ts @@ -38,13 +38,13 @@ async function run() { .then((prepared) => prepared.send()); console.log(`Transaction sent: ${transaction.transactionId}`); - // Wait for transaction to get included - const blockId = await wallet.reissueTransactionUntilIncluded( + // Wait for transaction to get accepted + const blockId = await wallet.waitForTransactionAcceptance( transaction.transactionId, ); console.log( - `Block included: ${process.env.EXPLORER_URL}/block/${blockId}`, + `Tx accepted in block: ${process.env.EXPLORER_URL}/block/${blockId}`, ); await wallet.sync(); @@ -71,13 +71,13 @@ async function run() { console.log(`Transaction sent: ${transaction.transactionId}`); - // Wait for transaction to get included - const blockId = await wallet.reissueTransactionUntilIncluded( + // Wait for transaction to get accepted + const blockId = await wallet.waitForTransactionAcceptance( transaction.transactionId, ); console.log( - `Block included: ${process.env.EXPLORER_URL}/block/${blockId}`, + `Tx accepted in block: ${process.env.EXPLORER_URL}/block/${blockId}`, ); console.log(`Created token: ${prepared.tokenId()}`); diff --git a/bindings/nodejs/examples/how_tos/native_tokens/destroy-foundry.ts b/bindings/nodejs/examples/how_tos/native_tokens/destroy-foundry.ts index eeef85e271..0398b73dd5 100644 --- a/bindings/nodejs/examples/how_tos/native_tokens/destroy-foundry.ts +++ b/bindings/nodejs/examples/how_tos/native_tokens/destroy-foundry.ts @@ -40,12 +40,12 @@ async function run() { console.log(`Transaction sent: ${transaction.transactionId}`); - // Wait for transaction to get included - const blockId = await wallet.reissueTransactionUntilIncluded( + // Wait for transaction to get accepted + const blockId = await wallet.waitForTransactionAcceptance( transaction.transactionId, ); console.log( - `Block included: ${process.env.EXPLORER_URL}/block/${blockId}`, + `Tx accepted in block: ${process.env.EXPLORER_URL}/block/${blockId}`, ); balance = await wallet.sync(); diff --git a/bindings/nodejs/examples/how_tos/native_tokens/melt.ts b/bindings/nodejs/examples/how_tos/native_tokens/melt.ts index 903f273186..581963a3b7 100644 --- a/bindings/nodejs/examples/how_tos/native_tokens/melt.ts +++ b/bindings/nodejs/examples/how_tos/native_tokens/melt.ts @@ -47,13 +47,13 @@ async function run() { console.log(`Transaction sent: ${transaction.transactionId}`); - // Wait for transaction to get included - const blockId = await wallet.reissueTransactionUntilIncluded( + // Wait for transaction to get accepted + const blockId = await wallet.waitForTransactionAcceptance( transaction.transactionId, ); console.log( - `Block included: ${process.env.EXPLORER_URL}/block/${blockId}`, + `Tx accepted in block: ${process.env.EXPLORER_URL}/block/${blockId}`, ); balance = await wallet.sync(); diff --git a/bindings/nodejs/examples/how_tos/native_tokens/mint.ts b/bindings/nodejs/examples/how_tos/native_tokens/mint.ts index 3c615800f7..a5e7219613 100644 --- a/bindings/nodejs/examples/how_tos/native_tokens/mint.ts +++ b/bindings/nodejs/examples/how_tos/native_tokens/mint.ts @@ -48,13 +48,13 @@ async function run() { console.log(`Transaction sent: ${transaction.transactionId}`); - // Wait for transaction to get included - const blockId = await wallet.reissueTransactionUntilIncluded( + // Wait for transaction to get accepted + const blockId = await wallet.waitForTransactionAcceptance( transaction.transactionId, ); console.log( - `Block included: ${process.env.EXPLORER_URL}/block/${blockId}`, + `Tx accepted in block: ${process.env.EXPLORER_URL}/block/${blockId}`, ); balance = await wallet.sync(); diff --git a/bindings/nodejs/examples/how_tos/native_tokens/send.ts b/bindings/nodejs/examples/how_tos/native_tokens/send.ts index 566f43c591..b4a4963907 100644 --- a/bindings/nodejs/examples/how_tos/native_tokens/send.ts +++ b/bindings/nodejs/examples/how_tos/native_tokens/send.ts @@ -58,13 +58,13 @@ async function run() { console.log(`Transaction sent: ${transaction.transactionId}`); - // Wait for transaction to get included - const blockId = await wallet.reissueTransactionUntilIncluded( + // Wait for transaction to get accepted + const blockId = await wallet.waitForTransactionAcceptance( transaction.transactionId, ); console.log( - `Block included: ${process.env.EXPLORER_URL}/block/${blockId}`, + `Tx accepted in block: ${process.env.EXPLORER_URL}/block/${blockId}`, ); balance = await wallet.sync(); diff --git a/bindings/nodejs/examples/how_tos/nft_collection/00_mint_issuer_nft.ts b/bindings/nodejs/examples/how_tos/nft_collection/00_mint_issuer_nft.ts index 2784455c36..16b834845f 100644 --- a/bindings/nodejs/examples/how_tos/nft_collection/00_mint_issuer_nft.ts +++ b/bindings/nodejs/examples/how_tos/nft_collection/00_mint_issuer_nft.ts @@ -54,12 +54,12 @@ async function run() { }; const transaction = await wallet.mintNfts([params]); - // Wait for transaction to get included - const blockId = await wallet.reissueTransactionUntilIncluded( + // Wait for transaction to get accepted + const blockId = await wallet.waitForTransactionAcceptance( transaction.transactionId, ); console.log( - `Block included: ${process.env.EXPLORER_URL}/block/${blockId}`, + `Tx accepted in block: ${process.env.EXPLORER_URL}/block/${blockId}`, ); transaction.payload.transaction.outputs.forEach( diff --git a/bindings/nodejs/examples/how_tos/nft_collection/01_mint_collection_nft.ts b/bindings/nodejs/examples/how_tos/nft_collection/01_mint_collection_nft.ts index 2f35c32bb4..a7a3538992 100644 --- a/bindings/nodejs/examples/how_tos/nft_collection/01_mint_collection_nft.ts +++ b/bindings/nodejs/examples/how_tos/nft_collection/01_mint_collection_nft.ts @@ -79,12 +79,12 @@ async function run() { ); const transaction = await wallet.mintNfts(chunk); - // Wait for transaction to get included - const blockId = await wallet.reissueTransactionUntilIncluded( + // Wait for transaction to get accepted + const blockId = await wallet.waitForTransactionAcceptance( transaction.transactionId, ); console.log( - `Block included: ${process.env.EXPLORER_URL}/block/${blockId}`, + `Tx accepted in block: ${process.env.EXPLORER_URL}/block/${blockId}`, ); // Sync so the new outputs are available again for new transactions diff --git a/bindings/nodejs/examples/how_tos/nfts/burn_nft.ts b/bindings/nodejs/examples/how_tos/nfts/burn_nft.ts index 15c5e7775c..efd4288ecd 100644 --- a/bindings/nodejs/examples/how_tos/nfts/burn_nft.ts +++ b/bindings/nodejs/examples/how_tos/nfts/burn_nft.ts @@ -53,12 +53,12 @@ async function run() { console.log(`Transaction sent: ${transaction.transactionId}`); - // Wait for transaction to get included - const blockId = await wallet.reissueTransactionUntilIncluded( + // Wait for transaction to get accepted + const blockId = await wallet.waitForTransactionAcceptance( transaction.transactionId, ); console.log( - `Block included: ${process.env.EXPLORER_URL}/block/${blockId}`, + `Tx accepted in block: ${process.env.EXPLORER_URL}/block/${blockId}`, ); console.log(`Burned NFT ${nftId}`); diff --git a/bindings/nodejs/examples/how_tos/nfts/mint_nft.ts b/bindings/nodejs/examples/how_tos/nfts/mint_nft.ts index 3df3bb112c..4627c9b848 100644 --- a/bindings/nodejs/examples/how_tos/nfts/mint_nft.ts +++ b/bindings/nodejs/examples/how_tos/nfts/mint_nft.ts @@ -73,13 +73,13 @@ async function run() { let transaction = await wallet.mintNfts([params]); console.log(`Transaction sent: ${transaction.transactionId}`); - // Wait for transaction to get included - let blockId = await wallet.reissueTransactionUntilIncluded( + // Wait for transaction to get accepted + let blockId = await wallet.waitForTransactionAcceptance( transaction.transactionId, ); console.log( - `Block included: ${process.env.EXPLORER_URL}/block/${blockId}`, + `Tx accepted in block: ${process.env.EXPLORER_URL}/block/${blockId}`, ); console.log('Minted NFT 1'); @@ -104,13 +104,13 @@ async function run() { transaction = await wallet.sendOutputs([output]); console.log(`Transaction sent: ${transaction.transactionId}`); - // Wait for transaction to get included - blockId = await wallet.reissueTransactionUntilIncluded( + // Wait for transaction to get accepted + blockId = await wallet.waitForTransactionAcceptance( transaction.transactionId, ); console.log( - `Block included: ${process.env.EXPLORER_URL}/block/${blockId}`, + `Tx accepted in block: ${process.env.EXPLORER_URL}/block/${blockId}`, ); console.log('Minted NFT 2'); diff --git a/bindings/nodejs/examples/how_tos/nfts/send_nft.ts b/bindings/nodejs/examples/how_tos/nfts/send_nft.ts index b0f14cc7b6..6ad95d06e1 100644 --- a/bindings/nodejs/examples/how_tos/nfts/send_nft.ts +++ b/bindings/nodejs/examples/how_tos/nfts/send_nft.ts @@ -59,13 +59,13 @@ async function run() { console.log(`Transaction sent: ${transaction.transactionId}`); - // Wait for transaction to get included - const blockId = await wallet.reissueTransactionUntilIncluded( + // Wait for transaction to get accepted + const blockId = await wallet.waitForTransactionAcceptance( transaction.transactionId, ); console.log( - `Block included: ${process.env.EXPLORER_URL}/block/${blockId}`, + `Tx accepted in block: ${process.env.EXPLORER_URL}/block/${blockId}`, ); // To send an NFT with expiration unlock condition prepareOutput() can be used like this: diff --git a/bindings/nodejs/examples/how_tos/wallet/consolidate-outputs.ts b/bindings/nodejs/examples/how_tos/wallet/consolidate-outputs.ts index 01f6ebbf52..ab4ce6f88e 100644 --- a/bindings/nodejs/examples/how_tos/wallet/consolidate-outputs.ts +++ b/bindings/nodejs/examples/how_tos/wallet/consolidate-outputs.ts @@ -67,13 +67,13 @@ async function run() { }); console.log('Transaction sent: %s', transaction.transactionId); - // Wait for the consolidation transaction to get confirmed - const blockId = wallet.reissueTransactionUntilIncluded( + // Wait for the consolidation transaction to get accepted + const blockId = wallet.waitForTransactionAcceptance( transaction.transactionId, ); console.log( - 'Transaction included: %s/block/$s', + 'Transaction accepted: %s/block/$s', process.env.EXPLORER_URL, blockId, ); diff --git a/bindings/nodejs/examples/wallet/06-send-micro-transaction.ts b/bindings/nodejs/examples/wallet/06-send-micro-transaction.ts index f558f1a11a..13cfaf558e 100644 --- a/bindings/nodejs/examples/wallet/06-send-micro-transaction.ts +++ b/bindings/nodejs/examples/wallet/06-send-micro-transaction.ts @@ -45,13 +45,13 @@ async function run() { }); console.log(`Transaction sent: ${transaction.transactionId}`); - // Wait for transaction to get included - const blockId = await wallet.reissueTransactionUntilIncluded( + // Wait for transaction to get accepted + const blockId = await wallet.waitForTransactionAcceptance( transaction.transactionId, ); console.log( - `Block included: ${process.env.EXPLORER_URL}/block/${blockId}`, + `Tx accepted in block: ${process.env.EXPLORER_URL}/block/${blockId}`, ); } catch (error) { console.log('Error: ', error); diff --git a/bindings/nodejs/lib/types/error.ts b/bindings/nodejs/lib/types/error.ts index 6224cb4d04..78309d574e 100644 --- a/bindings/nodejs/lib/types/error.ts +++ b/bindings/nodejs/lib/types/error.ts @@ -44,7 +44,7 @@ export type ClientErrorName = | 'secretManagerMismatch' | 'healthyNodePoolEmpty' | 'taggedData' - | 'tangleInclusion' + | 'transactionAcceptance' | 'taskJoin' | 'timeNotSynced' | 'transactionSemantic' diff --git a/bindings/nodejs/lib/types/wallet/bridge/index.ts b/bindings/nodejs/lib/types/wallet/bridge/index.ts index f36c893d33..cf21474064 100644 --- a/bindings/nodejs/lib/types/wallet/bridge/index.ts +++ b/bindings/nodejs/lib/types/wallet/bridge/index.ts @@ -33,7 +33,7 @@ import type { __PrepareEndStakingMethod__, __PrepareTransactionMethod__, __RegisterParticipationEventsMethod__, - __ReissueTransactionUntilIncludedMethod__, + __WaitForTransactionAcceptanceMethod__, __SendMethod__, __SendWithParamsMethod__, __PrepareSendNativeTokensMethod__, @@ -114,7 +114,7 @@ export type __WalletMethod__ = | __PrepareEndStakingMethod__ | __PrepareTransactionMethod__ | __RegisterParticipationEventsMethod__ - | __ReissueTransactionUntilIncludedMethod__ + | __WaitForTransactionAcceptanceMethod__ | __SendMethod__ | __SendWithParamsMethod__ | __PrepareSendNativeTokensMethod__ diff --git a/bindings/nodejs/lib/types/wallet/bridge/wallet.ts b/bindings/nodejs/lib/types/wallet/bridge/wallet.ts index 7590db1b45..607b4f92f5 100644 --- a/bindings/nodejs/lib/types/wallet/bridge/wallet.ts +++ b/bindings/nodejs/lib/types/wallet/bridge/wallet.ts @@ -372,8 +372,8 @@ export type __RegisterParticipationEventsMethod__ = { }; }; -export type __ReissueTransactionUntilIncludedMethod__ = { - name: 'reissueTransactionUntilIncluded'; +export type __WaitForTransactionAcceptanceMethod__ = { + name: 'waitForTransactionAcceptance'; data: { transactionId: TransactionId; interval?: number; diff --git a/bindings/nodejs/lib/types/wallet/transaction.ts b/bindings/nodejs/lib/types/wallet/transaction.ts index 290bf7d344..83378de13c 100644 --- a/bindings/nodejs/lib/types/wallet/transaction.ts +++ b/bindings/nodejs/lib/types/wallet/transaction.ts @@ -10,8 +10,12 @@ import { OutputResponse } from '../models/api'; export enum InclusionState { /** The transaction is pending. */ Pending = 'Pending', + /** The transaction is accepted. */ + Accepted = 'Accepted', /** The transaction is confirmed. */ Confirmed = 'Confirmed', + /** The transaction is finalized. */ + Finalized = 'Finalized', /** The transaction is conflicting. */ Conflicting = 'Conflicting', /** The transaction and its in- and outputs are pruned, so it's unknown if it got confirmed or was conflicting. */ diff --git a/bindings/nodejs/lib/wallet/wallet.ts b/bindings/nodejs/lib/wallet/wallet.ts index 0bf0f27452..35e66fe489 100644 --- a/bindings/nodejs/lib/wallet/wallet.ts +++ b/bindings/nodejs/lib/wallet/wallet.ts @@ -1518,16 +1518,16 @@ export class Wallet { } /** - * Reissues a transaction sent from the wallet for a provided transaction id until it's - * included (referenced by a milestone). Returns the included block id. + * Checks the transaction state for a provided transaction id until it's accepted. Interval in milliseconds. Returns the block id that + * contains this transaction. */ - async reissueTransactionUntilIncluded( + async waitForTransactionAcceptance( transactionId: TransactionId, interval?: number, maxAttempts?: number, ): Promise { const response = await this.methodHandler.callMethod({ - name: 'reissueTransactionUntilIncluded', + name: 'waitForTransactionAcceptance', data: { transactionId, interval, diff --git a/bindings/python/examples/how_tos/account_output/send_amount.py b/bindings/python/examples/how_tos/account_output/send_amount.py index 0a4605c819..d844cadbd3 100644 --- a/bindings/python/examples/how_tos/account_output/send_amount.py +++ b/bindings/python/examples/how_tos/account_output/send_amount.py @@ -20,7 +20,8 @@ balance = wallet.sync(sync_options) total_base_token_balance = balance.base_coin.total -print(f'Balance before sending funds from the account output: {total_base_token_balance}') +print( + f'Balance before sending funds from the account output: {total_base_token_balance}') account_id = balance.accounts[0] print(f'Account Id: {account_id}') @@ -42,10 +43,11 @@ 'mandatoryInputs': inputs, } transaction = wallet.send_with_params(params, options) -wallet.reissue_transaction_until_included( +wallet.wait_for_transaction_acceptance( transaction.transaction_id) print( f'Transaction with custom input: https://explorer.shimmer.network/testnet/transaction/{transaction.transaction_id}') total_base_token_balance = wallet.sync(sync_options).base_coin.total -print(f'Balance after sending funds from the account output: {total_base_token_balance}') +print( + f'Balance after sending funds from the account output: {total_base_token_balance}') diff --git a/bindings/python/examples/how_tos/advanced_transactions/advanced_transaction.py b/bindings/python/examples/how_tos/advanced_transactions/advanced_transaction.py index acc64ca250..4f98725259 100644 --- a/bindings/python/examples/how_tos/advanced_transactions/advanced_transaction.py +++ b/bindings/python/examples/how_tos/advanced_transactions/advanced_transaction.py @@ -50,7 +50,7 @@ transaction = wallet.send_outputs([basic_output]) print(f'Transaction sent: {transaction.transaction_id}') -block_id = wallet.reissue_transaction_until_included( +block_id = wallet.wait_for_transaction_acceptance( transaction.transaction_id) print( diff --git a/bindings/python/examples/how_tos/advanced_transactions/claim_transaction.py b/bindings/python/examples/how_tos/advanced_transactions/claim_transaction.py index c833932317..ca228965d2 100644 --- a/bindings/python/examples/how_tos/advanced_transactions/claim_transaction.py +++ b/bindings/python/examples/how_tos/advanced_transactions/claim_transaction.py @@ -32,6 +32,6 @@ transaction = wallet.claim_outputs(output_ids) print(f'Transaction sent: {transaction.transaction_id}') -block_id = wallet.reissue_transaction_until_included( +block_id = wallet.wait_for_transaction_acceptance( transaction.transaction_id) print(f'Block sent: {os.environ["EXPLORER_URL"]}/block/{block_id}') diff --git a/bindings/python/examples/how_tos/advanced_transactions/send_micro_transaction.py b/bindings/python/examples/how_tos/advanced_transactions/send_micro_transaction.py index 47c47e30f8..04184dcf56 100644 --- a/bindings/python/examples/how_tos/advanced_transactions/send_micro_transaction.py +++ b/bindings/python/examples/how_tos/advanced_transactions/send_micro_transaction.py @@ -30,7 +30,7 @@ transaction = wallet.send_with_params(params, {"allowMicroAmount": True}) print(f'Transaction sent: {transaction.transaction_id}') -block_id = wallet.reissue_transaction_until_included( +block_id = wallet.wait_for_transaction_acceptance( transaction.transaction_id) print( diff --git a/bindings/python/examples/how_tos/native_tokens/burn.py b/bindings/python/examples/how_tos/native_tokens/burn.py index 077cd3cb0c..96c0b83c46 100644 --- a/bindings/python/examples/how_tos/native_tokens/burn.py +++ b/bindings/python/examples/how_tos/native_tokens/burn.py @@ -28,10 +28,10 @@ token_id, burn_amount).send() print(f'Transaction sent: {transaction.transaction_id}') -# Wait for transaction to get included -block_id = wallet.reissue_transaction_until_included( +# Wait for transaction to get accepted +block_id = wallet.wait_for_transaction_acceptance( transaction.transaction_id) -print(f'Block included: {os.environ["EXPLORER_URL"]}/block/{block_id}') +print(f'Tx accepted in block: {os.environ["EXPLORER_URL"]}/block/{block_id}') balance = wallet.sync() available_balance = balance.native_tokens[token_id].available diff --git a/bindings/python/examples/how_tos/native_tokens/create.py b/bindings/python/examples/how_tos/native_tokens/create.py index e7fefae542..f3b0d045fd 100644 --- a/bindings/python/examples/how_tos/native_tokens/create.py +++ b/bindings/python/examples/how_tos/native_tokens/create.py @@ -26,10 +26,11 @@ transaction = wallet.create_account_output(None, None) print(f'Transaction sent: {transaction.transaction_id}') - # Wait for transaction to get included - block_id = wallet.reissue_transaction_until_included( + # Wait for transaction to get accepted + block_id = wallet.wait_for_transaction_acceptance( transaction.transaction_id) - print(f'Block included: {os.environ["EXPLORER_URL"]}/block/{block_id}') + print( + f'Tx accepted in block: {os.environ["EXPLORER_URL"]}/block/{block_id}') wallet.sync() print("Wallet synced") @@ -50,10 +51,10 @@ transaction = prepared_transaction.send() print(f'Transaction sent: {transaction.transaction_id}') -# Wait for transaction to get included -block_id = wallet.reissue_transaction_until_included( +# Wait for transaction to get accepted +block_id = wallet.wait_for_transaction_acceptance( transaction.transaction_id) -print(f'Block included: {os.environ["EXPLORER_URL"]}/block/{block_id}') +print(f'Tx accepted in block: {os.environ["EXPLORER_URL"]}/block/{block_id}') print(f'Created token: {transaction.token_id}') diff --git a/bindings/python/examples/how_tos/native_tokens/destroy_foundry.py b/bindings/python/examples/how_tos/native_tokens/destroy_foundry.py index 45a04537dc..65d0d69d75 100644 --- a/bindings/python/examples/how_tos/native_tokens/destroy_foundry.py +++ b/bindings/python/examples/how_tos/native_tokens/destroy_foundry.py @@ -24,10 +24,10 @@ transaction = wallet.prepare_destroy_foundry(foundry_id).send() print(f'Transaction sent: {transaction.transaction_id}') -# Wait for transaction to get included -block_id = wallet.reissue_transaction_until_included( +# Wait for transaction to get accepted +block_id = wallet.wait_for_transaction_acceptance( transaction.transaction_id) -print(f'Block included: {os.environ["EXPLORER_URL"]}/block/{block_id}') +print(f'Tx accepted in block: {os.environ["EXPLORER_URL"]}/block/{block_id}') balance = wallet.sync() print(f'Foundries after destroying: {len(balance.foundries)}') diff --git a/bindings/python/examples/how_tos/native_tokens/melt.py b/bindings/python/examples/how_tos/native_tokens/melt.py index 185910f2c6..df24c44080 100644 --- a/bindings/python/examples/how_tos/native_tokens/melt.py +++ b/bindings/python/examples/how_tos/native_tokens/melt.py @@ -30,10 +30,10 @@ transaction = wallet.melt_native_token(token_id, melt_amount) print(f'Transaction sent: {transaction.transaction_id}') -# Wait for transaction to get included -block_id = wallet.reissue_transaction_until_included( +# Wait for transaction to get accepted +block_id = wallet.wait_for_transaction_acceptance( transaction.transaction_id) -print(f'Block included: {os.environ["EXPLORER_URL"]}/block/{block_id}') +print(f'Tx accepted in block: {os.environ["EXPLORER_URL"]}/block/{block_id}') balance = wallet.sync() available_balance = balance.native_tokens[token_id].available diff --git a/bindings/python/examples/how_tos/native_tokens/mint.py b/bindings/python/examples/how_tos/native_tokens/mint.py index b3c69738bd..f5989f88ce 100644 --- a/bindings/python/examples/how_tos/native_tokens/mint.py +++ b/bindings/python/examples/how_tos/native_tokens/mint.py @@ -30,10 +30,10 @@ transaction = wallet.mint_native_token(token_id, mint_amount) print(f'Transaction sent: {transaction.transaction_id}') -# Wait for transaction to get included -block_id = wallet.reissue_transaction_until_included( +# Wait for transaction to get accepted +block_id = wallet.wait_for_transaction_acceptance( transaction.transaction_id) -print(f'Block included: {os.environ["EXPLORER_URL"]}/block/{block_id}') +print(f'Tx accepted in block: {os.environ["EXPLORER_URL"]}/block/{block_id}') balance = wallet.sync() available_balance = balance.native_tokens[token_id].available diff --git a/bindings/python/examples/how_tos/native_tokens/send.py b/bindings/python/examples/how_tos/native_tokens/send.py index dc334d1ce7..8ddfc84e03 100644 --- a/bindings/python/examples/how_tos/native_tokens/send.py +++ b/bindings/python/examples/how_tos/native_tokens/send.py @@ -33,10 +33,10 @@ transaction = wallet.send_native_tokens(outputs, None) print(f'Transaction sent: {transaction.transaction_id}') -# Wait for transaction to get included -block_id = wallet.reissue_transaction_until_included( +# Wait for transaction to get accepted +block_id = wallet.wait_for_transaction_acceptance( transaction.transaction_id) -print(f'Block included: {os.environ["EXPLORER_URL"]}/block/{block_id}') +print(f'Tx accepted in block: {os.environ["EXPLORER_URL"]}/block/{block_id}') balance = wallet.sync() available_balance = balance.native_tokens[token_id].available diff --git a/bindings/python/examples/how_tos/nft_collection/00_mint_issuer_nft.py b/bindings/python/examples/how_tos/nft_collection/00_mint_issuer_nft.py index 0aadd23767..1b06ac99e7 100644 --- a/bindings/python/examples/how_tos/nft_collection/00_mint_issuer_nft.py +++ b/bindings/python/examples/how_tos/nft_collection/00_mint_issuer_nft.py @@ -28,8 +28,8 @@ tx = wallet.mint_nfts([params]) -# Wait for transaction to get included -block_id = wallet.reissue_transaction_until_included( +# Wait for transaction to get accepted +block_id = wallet.wait_for_transaction_acceptance( tx.transaction_id) print( diff --git a/bindings/python/examples/how_tos/nft_collection/01_mint_collection_nft.py b/bindings/python/examples/how_tos/nft_collection/01_mint_collection_nft.py index 25003d6b41..704744595e 100644 --- a/bindings/python/examples/how_tos/nft_collection/01_mint_collection_nft.py +++ b/bindings/python/examples/how_tos/nft_collection/01_mint_collection_nft.py @@ -65,8 +65,8 @@ def get_immutable_metadata(index: int) -> str: ) transaction = wallet.mint_nfts(chunk) - # Wait for transaction to get included - block_id = wallet.reissue_transaction_until_included( + # Wait for transaction to get accepted + block_id = wallet.wait_for_transaction_acceptance( transaction.transaction_id) print(f'Block sent: {os.environ["EXPLORER_URL"]}/block/{block_id}') diff --git a/bindings/python/examples/how_tos/wallet/consolidate_outputs.py b/bindings/python/examples/how_tos/wallet/consolidate_outputs.py index 434b3b692c..feedaee4b7 100644 --- a/bindings/python/examples/how_tos/wallet/consolidate_outputs.py +++ b/bindings/python/examples/how_tos/wallet/consolidate_outputs.py @@ -49,12 +49,12 @@ transaction = wallet.consolidate_outputs(ConsolidationParams(force=True)) print('Transaction sent: ', transaction.transaction_id) -# Wait for the consolidation transaction to get confirmed -block_id = wallet.reissue_transaction_until_included( +# Wait for the consolidation transaction to get accepted +block_id = wallet.wait_for_transaction_acceptance( transaction.transaction_id) print( - f'Transaction included: {os.environ["EXPLORER_URL"]}/block/{block_id}' + f'Transaction accepted: {os.environ["EXPLORER_URL"]}/block/{block_id}' ) # Sync wallet diff --git a/bindings/python/examples/wallet/offline_signing/3_send_transaction.py b/bindings/python/examples/wallet/offline_signing/3_send_transaction.py index 4cba62f441..dd8b1498ba 100644 --- a/bindings/python/examples/wallet/offline_signing/3_send_transaction.py +++ b/bindings/python/examples/wallet/offline_signing/3_send_transaction.py @@ -30,6 +30,6 @@ transaction = wallet.submit_and_store_transaction(signed_transaction_data) print( f'Transaction sent: {os.environ["EXPLORER_URL"]}/transaction/{transaction.transaction_id}') -block_id = wallet.reissue_transaction_until_included( +block_id = wallet.wait_for_transaction_acceptance( transaction.transaction_id) -print(f'Block included: {os.environ["EXPLORER_URL"]}/block/{block_id}') +print(f'Tx accepted in block: {os.environ["EXPLORER_URL"]}/block/{block_id}') diff --git a/bindings/python/iota_sdk/types/transaction_with_metadata.py b/bindings/python/iota_sdk/types/transaction_with_metadata.py index a10fc62751..625ed55c80 100644 --- a/bindings/python/iota_sdk/types/transaction_with_metadata.py +++ b/bindings/python/iota_sdk/types/transaction_with_metadata.py @@ -17,12 +17,16 @@ class InclusionState(str, Enum): Attributes: Pending: The transaction is pending. + Accepted: The transaction is accepted. Confirmed: The transaction is confirmed. + Finalized: The transaction is finalized. Conflicting: The transaction is conflicting. UnknownPruned: The transaction is unknown or already pruned. """ Pending = 'pending' + Accepted = 'accepted' Confirmed = 'confirmed' + Finalized = 'finalized' Conflicting = 'conflicting' UnknownPruned = 'unknownPruned' diff --git a/bindings/python/iota_sdk/wallet/wallet.py b/bindings/python/iota_sdk/wallet/wallet.py index 510dc70a24..9e380ccd7a 100644 --- a/bindings/python/iota_sdk/wallet/wallet.py +++ b/bindings/python/iota_sdk/wallet/wallet.py @@ -717,13 +717,13 @@ def prepare_transaction( )) return PreparedTransaction(self, prepared) - def reissue_transaction_until_included( + def wait_for_transaction_acceptance( self, transaction_id: TransactionId, interval=None, max_attempts=None) -> BlockId: - """Reissues a transaction sent from the wallet for a provided transaction id until it's - included (referenced by a milestone). Returns the included block id. + """Checks the transaction state for a provided transaction id until it's accepted. Interval in milliseconds. Returns the block id that + contains this transaction. """ return BlockId(self._call_method( - 'reissueTransactionUntilIncluded', { + 'waitForTransactionAcceptance', { 'transactionId': transaction_id, 'interval': interval, 'maxAttempts': max_attempts diff --git a/cli/src/wallet_cli/mod.rs b/cli/src/wallet_cli/mod.rs index 3b9819ea0f..49fdc8853c 100644 --- a/cli/src/wallet_cli/mod.rs +++ b/cli/src/wallet_cli/mod.rs @@ -704,7 +704,7 @@ pub async fn create_native_token_command( transaction.block_id ); wallet - .reissue_transaction_until_included(&transaction.transaction_id, None, None) + .wait_for_transaction_acceptance(&transaction.transaction_id, None, None) .await?; // Sync wallet after the transaction got confirmed, so the account output is available wallet.sync(None).await?; diff --git a/sdk/examples/how_tos/account_output/create.rs b/sdk/examples/how_tos/account_output/create.rs index 8eb107aa5b..7add1e3ddc 100644 --- a/sdk/examples/how_tos/account_output/create.rs +++ b/sdk/examples/how_tos/account_output/create.rs @@ -44,10 +44,10 @@ async fn main() -> Result<()> { println!("Transaction sent: {}", transaction.transaction_id); let block_id = wallet - .reissue_transaction_until_included(&transaction.transaction_id, None, None) + .wait_for_transaction_acceptance(&transaction.transaction_id, None, None) .await?; println!( - "Block included: {}/block/{}", + "Tx accepted in block: {}/block/{}", std::env::var("EXPLORER_URL").unwrap(), block_id ); diff --git a/sdk/examples/how_tos/account_output/destroy.rs b/sdk/examples/how_tos/account_output/destroy.rs index a77e62d370..98ce52123e 100644 --- a/sdk/examples/how_tos/account_output/destroy.rs +++ b/sdk/examples/how_tos/account_output/destroy.rs @@ -42,11 +42,11 @@ async fn main() -> Result<()> { println!("Transaction sent: {}", transaction.transaction_id); let block_id = wallet - .reissue_transaction_until_included(&transaction.transaction_id, None, None) + .wait_for_transaction_acceptance(&transaction.transaction_id, None, None) .await?; println!( - "Block included: {}/block/{}", + "Tx accepted in block: {}/block/{}", std::env::var("EXPLORER_URL").unwrap(), block_id ); diff --git a/sdk/examples/how_tos/account_output/send_amount.rs b/sdk/examples/how_tos/account_output/send_amount.rs index 1deafa7434..801d8b07ca 100644 --- a/sdk/examples/how_tos/account_output/send_amount.rs +++ b/sdk/examples/how_tos/account_output/send_amount.rs @@ -72,7 +72,7 @@ async fn main() -> Result<()> { ) .await?; wallet - .reissue_transaction_until_included(&transaction.transaction_id, None, None) + .wait_for_transaction_acceptance(&transaction.transaction_id, None, None) .await?; println!( diff --git a/sdk/examples/how_tos/advanced_transactions/advanced_transaction.rs b/sdk/examples/how_tos/advanced_transactions/advanced_transaction.rs index 55cc67f593..6ddb5458a4 100644 --- a/sdk/examples/how_tos/advanced_transactions/advanced_transaction.rs +++ b/sdk/examples/how_tos/advanced_transactions/advanced_transaction.rs @@ -57,9 +57,9 @@ async fn main() -> Result<()> { let transaction = wallet.send_outputs(vec![basic_output], None).await?; println!("Transaction sent: {}", transaction.transaction_id); - // Wait for transaction to get included + // Wait for transaction to get accepted let block_id = wallet - .reissue_transaction_until_included(&transaction.transaction_id, None, None) + .wait_for_transaction_acceptance(&transaction.transaction_id, None, None) .await?; println!( "Block sent: {}/block/{}", diff --git a/sdk/examples/how_tos/advanced_transactions/claim_transaction.rs b/sdk/examples/how_tos/advanced_transactions/claim_transaction.rs index 628cd91504..f4c7aa4d17 100644 --- a/sdk/examples/how_tos/advanced_transactions/claim_transaction.rs +++ b/sdk/examples/how_tos/advanced_transactions/claim_transaction.rs @@ -43,9 +43,9 @@ async fn main() -> Result<()> { let transaction = wallet.claim_outputs(output_ids).await?; println!("Transaction sent: {}", transaction.transaction_id); - // Wait for transaction to get included + // Wait for transaction to get accepted let block_id = wallet - .reissue_transaction_until_included(&transaction.transaction_id, None, None) + .wait_for_transaction_acceptance(&transaction.transaction_id, None, None) .await?; println!( "Block sent: {}/block/{}", diff --git a/sdk/examples/how_tos/advanced_transactions/send_micro_transaction.rs b/sdk/examples/how_tos/advanced_transactions/send_micro_transaction.rs index 52b9263977..3214dc9226 100644 --- a/sdk/examples/how_tos/advanced_transactions/send_micro_transaction.rs +++ b/sdk/examples/how_tos/advanced_transactions/send_micro_transaction.rs @@ -59,13 +59,13 @@ async fn main() -> Result<()> { .await?; println!("Transaction sent: {}", transaction.transaction_id); - // Wait for transaction to get included + // Wait for transaction to get accepted let block_id = wallet - .reissue_transaction_until_included(&transaction.transaction_id, None, None) + .wait_for_transaction_acceptance(&transaction.transaction_id, None, None) .await?; println!( - "Block included: {}/block/{}", + "Tx accepted in block: {}/block/{}", std::env::var("EXPLORER_URL").unwrap(), block_id ); diff --git a/sdk/examples/how_tos/native_tokens/burn.rs b/sdk/examples/how_tos/native_tokens/burn.rs index ac0dc734ec..48f72d69a1 100644 --- a/sdk/examples/how_tos/native_tokens/burn.rs +++ b/sdk/examples/how_tos/native_tokens/burn.rs @@ -67,10 +67,10 @@ async fn main() -> Result<()> { println!("Transaction sent: {}", transaction.transaction_id); let block_id = wallet - .reissue_transaction_until_included(&transaction.transaction_id, None, None) + .wait_for_transaction_acceptance(&transaction.transaction_id, None, None) .await?; println!( - "Block included: {}/block/{}", + "Tx accepted in block: {}/block/{}", std::env::var("EXPLORER_URL").unwrap(), block_id ); diff --git a/sdk/examples/how_tos/native_tokens/create.rs b/sdk/examples/how_tos/native_tokens/create.rs index e67fcde805..be45eaedff 100644 --- a/sdk/examples/how_tos/native_tokens/create.rs +++ b/sdk/examples/how_tos/native_tokens/create.rs @@ -50,12 +50,12 @@ async fn main() -> Result<()> { let transaction = wallet.create_account_output(None, None).await?; println!("Transaction sent: {}", transaction.transaction_id); - // Wait for transaction to get included + // Wait for transaction to get accepted let block_id = wallet - .reissue_transaction_until_included(&transaction.transaction_id, None, None) + .wait_for_transaction_acceptance(&transaction.transaction_id, None, None) .await?; println!( - "Block included: {}/block/{}", + "Tx accepted in block: {}/block/{}", std::env::var("EXPLORER_URL").unwrap(), block_id ); @@ -79,12 +79,12 @@ async fn main() -> Result<()> { let transaction = wallet.create_native_token(params, None).await?; println!("Transaction sent: {}", transaction.transaction.transaction_id); - // Wait for transaction to get included + // Wait for transaction to get accepted let block_id = wallet - .reissue_transaction_until_included(&transaction.transaction.transaction_id, None, None) + .wait_for_transaction_acceptance(&transaction.transaction.transaction_id, None, None) .await?; println!( - "Block included: {}/block/{}", + "Tx accepted in block: {}/block/{}", std::env::var("EXPLORER_URL").unwrap(), block_id ); diff --git a/sdk/examples/how_tos/native_tokens/destroy_foundry.rs b/sdk/examples/how_tos/native_tokens/destroy_foundry.rs index e79d5b905e..7fcfa7a5e3 100644 --- a/sdk/examples/how_tos/native_tokens/destroy_foundry.rs +++ b/sdk/examples/how_tos/native_tokens/destroy_foundry.rs @@ -62,10 +62,10 @@ async fn main() -> Result<()> { println!("Transaction sent: {}", transaction.transaction_id); let block_id = wallet - .reissue_transaction_until_included(&transaction.transaction_id, None, None) + .wait_for_transaction_acceptance(&transaction.transaction_id, None, None) .await?; println!( - "Block included: {}/block/{}", + "Tx accepted in block: {}/block/{}", std::env::var("EXPLORER_URL").unwrap(), block_id ); @@ -80,10 +80,10 @@ async fn main() -> Result<()> { println!("Transaction sent: {}", transaction.transaction_id); let block_id = wallet - .reissue_transaction_until_included(&transaction.transaction_id, None, None) + .wait_for_transaction_acceptance(&transaction.transaction_id, None, None) .await?; println!( - "Block included: {}/block/{}", + "Tx accepted in block: {}/block/{}", std::env::var("EXPLORER_URL").unwrap(), block_id ); diff --git a/sdk/examples/how_tos/native_tokens/melt.rs b/sdk/examples/how_tos/native_tokens/melt.rs index c4d8b86c9f..24495ced70 100644 --- a/sdk/examples/how_tos/native_tokens/melt.rs +++ b/sdk/examples/how_tos/native_tokens/melt.rs @@ -63,11 +63,11 @@ async fn main() -> Result<()> { println!("Transaction sent: {}", transaction.transaction_id); let block_id = wallet - .reissue_transaction_until_included(&transaction.transaction_id, None, None) + .wait_for_transaction_acceptance(&transaction.transaction_id, None, None) .await?; println!( - "Block included: {}/block/{}", + "Tx accepted in block: {}/block/{}", std::env::var("EXPLORER_URL").unwrap(), block_id ); diff --git a/sdk/examples/how_tos/native_tokens/mint.rs b/sdk/examples/how_tos/native_tokens/mint.rs index a19cefd48f..a424e8e043 100644 --- a/sdk/examples/how_tos/native_tokens/mint.rs +++ b/sdk/examples/how_tos/native_tokens/mint.rs @@ -62,11 +62,11 @@ async fn main() -> Result<()> { println!("Transaction sent: {}", transaction.transaction_id); let block_id = wallet - .reissue_transaction_until_included(&transaction.transaction_id, None, None) + .wait_for_transaction_acceptance(&transaction.transaction_id, None, None) .await?; println!( - "Block included: {}/block/{}", + "Tx accepted in block: {}/block/{}", std::env::var("EXPLORER_URL").unwrap(), block_id ); diff --git a/sdk/examples/how_tos/native_tokens/send.rs b/sdk/examples/how_tos/native_tokens/send.rs index c004a106d2..083cfbfa0b 100644 --- a/sdk/examples/how_tos/native_tokens/send.rs +++ b/sdk/examples/how_tos/native_tokens/send.rs @@ -64,12 +64,12 @@ async fn main() -> Result<()> { let transaction = wallet.send_native_tokens(outputs, None).await?; println!("Transaction sent: {}", transaction.transaction_id); - // Wait for transaction to get included + // Wait for transaction to get accepted let block_id = wallet - .reissue_transaction_until_included(&transaction.transaction_id, None, None) + .wait_for_transaction_acceptance(&transaction.transaction_id, None, None) .await?; println!( - "Block included: {}/block/{}", + "Tx accepted in block: {}/block/{}", std::env::var("EXPLORER_URL").unwrap(), block_id ); diff --git a/sdk/examples/how_tos/nft_collection/00_mint_issuer_nft.rs b/sdk/examples/how_tos/nft_collection/00_mint_issuer_nft.rs index f1475e8a62..add3ea962c 100644 --- a/sdk/examples/how_tos/nft_collection/00_mint_issuer_nft.rs +++ b/sdk/examples/how_tos/nft_collection/00_mint_issuer_nft.rs @@ -78,12 +78,12 @@ async fn wait_for_inclusion(transaction_id: &TransactionId, wallet: &Wallet) -> std::env::var("EXPLORER_URL").unwrap(), transaction_id ); - // Wait for transaction to get included + // Wait for transaction to get accepted let block_id = wallet - .reissue_transaction_until_included(transaction_id, None, None) + .wait_for_transaction_acceptance(transaction_id, None, None) .await?; println!( - "Block included: {}/block/{}", + "Tx accepted in block: {}/block/{}", std::env::var("EXPLORER_URL").unwrap(), block_id ); diff --git a/sdk/examples/how_tos/nft_collection/01_mint_collection_nft.rs b/sdk/examples/how_tos/nft_collection/01_mint_collection_nft.rs index efa828fb6c..a8e02528d3 100644 --- a/sdk/examples/how_tos/nft_collection/01_mint_collection_nft.rs +++ b/sdk/examples/how_tos/nft_collection/01_mint_collection_nft.rs @@ -117,12 +117,12 @@ async fn wait_for_inclusion(transaction_id: &TransactionId, wallet: &Wallet) -> std::env::var("EXPLORER_URL").unwrap(), transaction_id ); - // Wait for transaction to get included + // Wait for transaction to get accepted let block_id = wallet - .reissue_transaction_until_included(transaction_id, None, None) + .wait_for_transaction_acceptance(transaction_id, None, None) .await?; println!( - "Block included: {}/block/{}", + "Tx accepted in block: {}/block/{}", std::env::var("EXPLORER_URL").unwrap(), block_id ); diff --git a/sdk/examples/how_tos/nfts/burn_nft.rs b/sdk/examples/how_tos/nfts/burn_nft.rs index 5385778a3c..5ed95bc8f3 100644 --- a/sdk/examples/how_tos/nfts/burn_nft.rs +++ b/sdk/examples/how_tos/nfts/burn_nft.rs @@ -45,11 +45,11 @@ async fn main() -> Result<()> { println!("Transaction sent: {}", transaction.transaction_id); let block_id = wallet - .reissue_transaction_until_included(&transaction.transaction_id, None, None) + .wait_for_transaction_acceptance(&transaction.transaction_id, None, None) .await?; println!( - "Block included: {}/block/{}", + "Tx accepted in block: {}/block/{}", std::env::var("EXPLORER_URL").unwrap(), block_id ); diff --git a/sdk/examples/how_tos/nfts/mint_nft.rs b/sdk/examples/how_tos/nfts/mint_nft.rs index 1112cab852..616b55f138 100644 --- a/sdk/examples/how_tos/nfts/mint_nft.rs +++ b/sdk/examples/how_tos/nfts/mint_nft.rs @@ -81,12 +81,12 @@ async fn main() -> Result<()> { let transaction = wallet.mint_nfts(nft_params, None).await?; println!("Transaction sent: {}", transaction.transaction_id); - // Wait for transaction to get included + // Wait for transaction to get accepted let block_id = wallet - .reissue_transaction_until_included(&transaction.transaction_id, None, None) + .wait_for_transaction_acceptance(&transaction.transaction_id, None, None) .await?; println!( - "Block included: {}/block/{}", + "Tx accepted in block: {}/block/{}", std::env::var("EXPLORER_URL").unwrap(), block_id ); @@ -105,12 +105,12 @@ async fn main() -> Result<()> { let transaction = wallet.send_outputs(outputs, None).await?; println!("Transaction sent: {}", transaction.transaction_id); - // Wait for transaction to get included + // Wait for transaction to get accepted let block_id = wallet - .reissue_transaction_until_included(&transaction.transaction_id, None, None) + .wait_for_transaction_acceptance(&transaction.transaction_id, None, None) .await?; println!( - "Block included: {}/block/{}", + "Tx accepted in block: {}/block/{}", std::env::var("EXPLORER_URL").unwrap(), block_id ); diff --git a/sdk/examples/how_tos/nfts/send_nft.rs b/sdk/examples/how_tos/nfts/send_nft.rs index 603b0e7b7b..5e045e9e7f 100644 --- a/sdk/examples/how_tos/nfts/send_nft.rs +++ b/sdk/examples/how_tos/nfts/send_nft.rs @@ -51,13 +51,13 @@ async fn main() -> Result<()> { let transaction = wallet.send_nft(outputs, None).await?; println!("Transaction sent: {}", transaction.transaction_id); - // Wait for transaction to get included + // Wait for transaction to get accepted let block_id = wallet - .reissue_transaction_until_included(&transaction.transaction_id, None, None) + .wait_for_transaction_acceptance(&transaction.transaction_id, None, None) .await?; println!( - "Block included: {}/block/{}", + "Tx accepted in block: {}/block/{}", std::env::var("EXPLORER_URL").unwrap(), block_id ); diff --git a/sdk/examples/how_tos/simple_transaction/simple_transaction.rs b/sdk/examples/how_tos/simple_transaction/simple_transaction.rs index 6d98120daa..933afb56ed 100644 --- a/sdk/examples/how_tos/simple_transaction/simple_transaction.rs +++ b/sdk/examples/how_tos/simple_transaction/simple_transaction.rs @@ -43,13 +43,13 @@ async fn main() -> Result<()> { println!("Trying to send '{}' coins to '{}'...", SEND_AMOUNT, RECV_ADDRESS); let transaction = wallet.send(SEND_AMOUNT, RECV_ADDRESS, None).await?; - // Wait for transaction to get included + // Wait for transaction to get accepted let block_id = wallet - .reissue_transaction_until_included(&transaction.transaction_id, None, None) + .wait_for_transaction_acceptance(&transaction.transaction_id, None, None) .await?; println!( - "Block included: {}/block/{}", + "Tx accepted in block: {}/block/{}", std::env::var("EXPLORER_URL").unwrap(), block_id ); diff --git a/sdk/examples/how_tos/wallet/consolidate_outputs.rs b/sdk/examples/how_tos/wallet/consolidate_outputs.rs index 69e4526dfd..8b9df45733 100644 --- a/sdk/examples/how_tos/wallet/consolidate_outputs.rs +++ b/sdk/examples/how_tos/wallet/consolidate_outputs.rs @@ -72,12 +72,12 @@ async fn main() -> Result<()> { .await?; println!("Transaction sent: {}", transaction.transaction_id); - // Wait for the consolidation transaction to get confirmed + // Wait for the consolidation transaction to get accepted let block_id = wallet - .reissue_transaction_until_included(&transaction.transaction_id, None, None) + .wait_for_transaction_acceptance(&transaction.transaction_id, None, None) .await?; println!( - "Block included: {}/block/{}", + "Tx accepted in block: {}/block/{}", std::env::var("EXPLORER_URL").unwrap(), block_id ); diff --git a/sdk/examples/wallet/events.rs b/sdk/examples/wallet/events.rs index 1d9b02a9bb..24d972c47d 100644 --- a/sdk/examples/wallet/events.rs +++ b/sdk/examples/wallet/events.rs @@ -66,11 +66,11 @@ async fn main() -> Result<()> { println!("Transaction sent: {}", transaction.transaction_id); let block_id = wallet - .reissue_transaction_until_included(&transaction.transaction_id, None, None) + .wait_for_transaction_acceptance(&transaction.transaction_id, None, None) .await?; println!( - "Block included: {}/block/{}", + "Tx accepted in block: {}/block/{}", std::env::var("EXPLORER_URL").unwrap(), block_id ); diff --git a/sdk/examples/wallet/ledger_nano.rs b/sdk/examples/wallet/ledger_nano.rs index d693503442..8334ef9f2e 100644 --- a/sdk/examples/wallet/ledger_nano.rs +++ b/sdk/examples/wallet/ledger_nano.rs @@ -67,10 +67,10 @@ async fn main() -> Result<()> { println!("Transaction sent: {}", transaction.transaction_id); let block_id = wallet - .reissue_transaction_until_included(&transaction.transaction_id, None, None) + .wait_for_transaction_acceptance(&transaction.transaction_id, None, None) .await?; println!( - "Block included: {}/block/{}", + "Tx accepted in block: {}/block/{}", std::env::var("EXPLORER_URL").unwrap(), block_id ); diff --git a/sdk/examples/wallet/offline_signing/3_send_transaction.rs b/sdk/examples/wallet/offline_signing/3_send_transaction.rs index eaeb2df53f..8a49165ef3 100644 --- a/sdk/examples/wallet/offline_signing/3_send_transaction.rs +++ b/sdk/examples/wallet/offline_signing/3_send_transaction.rs @@ -70,12 +70,12 @@ async fn wait_for_inclusion(transaction_id: &TransactionId, wallet: &Wallet) -> std::env::var("EXPLORER_URL").unwrap(), transaction_id ); - // Wait for transaction to get included + // Wait for transaction to get accepted let block_id = wallet - .reissue_transaction_until_included(transaction_id, None, None) + .wait_for_transaction_acceptance(transaction_id, None, None) .await?; println!( - "Block included: {}/block/{}", + "Tx accepted in block: {}/block/{}", std::env::var("EXPLORER_URL").unwrap(), block_id ); diff --git a/sdk/examples/wallet/participation.rs b/sdk/examples/wallet/participation.rs index d3108c30b6..3720d33dcc 100644 --- a/sdk/examples/wallet/participation.rs +++ b/sdk/examples/wallet/participation.rs @@ -135,12 +135,12 @@ async fn main() -> Result<()> { let transaction = wallet.increase_voting_power(INCREASE_VOTING_POWER_AMOUNT).await?; println!("Transaction sent: {}", transaction.transaction_id); - println!("Waiting for `increase voting power` transaction to be included..."); + println!("Waiting for `increase voting power` transaction to be accepted..."); let block_id = wallet - .reissue_transaction_until_included(&transaction.transaction_id, None, None) + .wait_for_transaction_acceptance(&transaction.transaction_id, None, None) .await?; println!( - "Block included: {}/block/{}", + "Tx accepted in block: {}/block/{}", std::env::var("EXPLORER_URL").unwrap(), block_id ); @@ -160,12 +160,12 @@ async fn main() -> Result<()> { let transaction = wallet.decrease_voting_power(DECREASE_VOTING_POWER_AMOUNT).await?; println!("Transaction sent: {}", transaction.transaction_id); - println!("Waiting for `decrease voting power` transaction to be included..."); + println!("Waiting for `decrease voting power` transaction to be accepted..."); let block_id = wallet - .reissue_transaction_until_included(&transaction.transaction_id, None, None) + .wait_for_transaction_acceptance(&transaction.transaction_id, None, None) .await?; println!( - "Block included: {}/block/{}", + "Tx accepted in block: {}/block/{}", std::env::var("EXPLORER_URL").unwrap(), block_id ); @@ -185,12 +185,12 @@ async fn main() -> Result<()> { // changed the constants above with a valid (i.e. ongoing) event id for println!("Transaction sent: {}", transaction.transaction_id); - println!("Waiting for `vote` transaction to be included..."); + println!("Waiting for `vote` transaction to be accepted..."); let block_id = wallet - .reissue_transaction_until_included(&transaction.transaction_id, None, None) + .wait_for_transaction_acceptance(&transaction.transaction_id, None, None) .await?; println!( - "Block included: {}/block/{}", + "Tx accepted in block: {}/block/{}", std::env::var("EXPLORER_URL").unwrap(), block_id ); @@ -212,12 +212,12 @@ async fn main() -> Result<()> { let transaction = wallet.stop_participating(event_id).await?; println!("Transaction sent: {}", transaction.transaction_id); - println!("Waiting for `stop participating` transaction to be included..."); + println!("Waiting for `stop participating` transaction to be accepted..."); let block_id = wallet - .reissue_transaction_until_included(&transaction.transaction_id, None, None) + .wait_for_transaction_acceptance(&transaction.transaction_id, None, None) .await?; println!( - "Block included: {}/block/{}", + "Tx accepted in block: {}/block/{}", std::env::var("EXPLORER_URL").unwrap(), block_id ); @@ -236,12 +236,12 @@ async fn main() -> Result<()> { let transaction = wallet.decrease_voting_power(voting_output.output.amount()).await?; println!("Transaction sent: {}", transaction.transaction_id); - println!("Waiting for `decrease voting power` transaction to be included..."); + println!("Waiting for `decrease voting power` transaction to be accepted..."); let block_id = wallet - .reissue_transaction_until_included(&transaction.transaction_id, None, None) + .wait_for_transaction_acceptance(&transaction.transaction_id, None, None) .await?; println!( - "Block included: {}/block/{}", + "Tx accepted in block: {}/block/{}", std::env::var("EXPLORER_URL").unwrap(), block_id ); diff --git a/sdk/examples/wallet/spammer.rs b/sdk/examples/wallet/spammer.rs index df138b94a7..25f0ece4d4 100644 --- a/sdk/examples/wallet/spammer.rs +++ b/sdk/examples/wallet/spammer.rs @@ -207,12 +207,12 @@ async fn wait_for_inclusion(transaction_id: &TransactionId, wallet: &Wallet) -> std::env::var("EXPLORER_URL").unwrap(), transaction_id ); - // Wait for transaction to get included + // Wait for transaction to get accepted let block_id = wallet - .reissue_transaction_until_included(transaction_id, None, None) + .wait_for_transaction_acceptance(transaction_id, None, None) .await?; println!( - "Block included: {}/block/{}", + "Tx accepted in block: {}/block/{}", std::env::var("EXPLORER_URL").unwrap(), block_id ); diff --git a/sdk/examples/wallet/wallet.rs b/sdk/examples/wallet/wallet.rs index 86db26f320..a9d8bae81e 100644 --- a/sdk/examples/wallet/wallet.rs +++ b/sdk/examples/wallet/wallet.rs @@ -88,12 +88,12 @@ async fn wait_for_inclusion(transaction_id: &TransactionId, wallet: &Wallet) -> std::env::var("EXPLORER_URL").unwrap(), transaction_id ); - // Wait for transaction to get included + // Wait for transaction to get accepted let block_id = wallet - .reissue_transaction_until_included(transaction_id, None, None) + .wait_for_transaction_acceptance(transaction_id, None, None) .await?; println!( - "Block included: {}/block/{}", + "Tx accepted in block: {}/block/{}", std::env::var("EXPLORER_URL").unwrap(), block_id ); diff --git a/sdk/src/client/api/block_builder/input_selection/requirement/amount.rs b/sdk/src/client/api/block_builder/input_selection/requirement/amount.rs index db43ee7646..30fd2357e9 100644 --- a/sdk/src/client/api/block_builder/input_selection/requirement/amount.rs +++ b/sdk/src/client/api/block_builder/input_selection/requirement/amount.rs @@ -11,7 +11,7 @@ use crate::{ input::INPUT_COUNT_MAX, output::{ unlock_condition::StorageDepositReturnUnlockCondition, AccountOutputBuilder, FoundryOutputBuilder, - MinimumOutputAmount, NativeTokens, NftOutputBuilder, Output, OutputId, StorageScoreParameters, TokenId, + MinimumOutputAmount, NftOutputBuilder, Output, OutputId, StorageScoreParameters, TokenId, }, slot::SlotIndex, }, @@ -159,16 +159,7 @@ impl AmountSelection { } if let Some(nt) = input.output.native_token() { - let mut selected_native_tokens = self.selected_native_tokens.clone(); - - selected_native_tokens.insert(*nt.token_id()); - // Don't select input if the tx would end up with more than allowed native tokens. - if selected_native_tokens.len() > NativeTokens::COUNT_MAX.into() { - continue; - } else { - // Update selected with NTs from this output. - self.selected_native_tokens = selected_native_tokens; - } + self.selected_native_tokens.insert(*nt.token_id()); } self.inputs_sum += input.output.amount(); @@ -341,19 +332,7 @@ impl InputSelection { return Ok(r); } - // If the available inputs have more NTs than are allowed in a single tx, we might not be able to find inputs - // without exceeding the threshold, so in this case we also try again with the outputs ordered the other way - // around. - let potentially_too_many_native_tokens = self - .available_inputs - .iter() - .filter_map(|i| i.output.native_token()) - .count() - > NativeTokens::COUNT_MAX.into(); - - if self.selected_inputs.len() + amount_selection.newly_selected_inputs.len() > INPUT_COUNT_MAX.into() - || potentially_too_many_native_tokens - { + if self.selected_inputs.len() + amount_selection.newly_selected_inputs.len() > INPUT_COUNT_MAX.into() { // Clear before trying with reversed ordering. log::debug!("Clearing amount selection"); amount_selection = AmountSelection::new(self)?; diff --git a/sdk/src/client/error.rs b/sdk/src/client/error.rs index 07826b4c78..9db4610d5c 100644 --- a/sdk/src/client/error.rs +++ b/sdk/src/client/error.rs @@ -113,9 +113,9 @@ pub enum Error { /// Error when building tagged_data blocks #[error("error when building tagged_data block: {0}")] TaggedData(String), - /// The block cannot be included into the Tangle - #[error("block ID `{0}` couldn't get included into the Tangle")] - TangleInclusion(String), + /// The transaction could not be accepted + #[error("transaction ID `{0}` couldn't be accepted")] + TransactionAcceptance(String), #[cfg(not(target_family = "wasm"))] /// Tokio task join error #[error("{0}")] diff --git a/sdk/src/types/block/output/native_token.rs b/sdk/src/types/block/output/native_token.rs index 6e48df309b..20084d4c46 100644 --- a/sdk/src/types/block/output/native_token.rs +++ b/sdk/src/types/block/output/native_token.rs @@ -173,7 +173,7 @@ impl From for NativeTokensBuilder { } } -pub(crate) type NativeTokenCount = BoundedU8<0, { NativeTokens::COUNT_MAX }>; +pub(crate) type NativeTokenCount = BoundedU8<0, 255>; /// #[derive(Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Deref, Packable)] @@ -211,9 +211,6 @@ impl IntoIterator for NativeTokens { } impl NativeTokens { - /// Maximum number of different native tokens that can be referenced in one transaction. - pub const COUNT_MAX: u8 = 64; - /// Creates a new [`NativeTokens`] from a vec. pub fn from_vec(native_tokens: Vec) -> Result { let mut native_tokens = diff --git a/sdk/src/types/block/rand/output/mod.rs b/sdk/src/types/block/rand/output/mod.rs index 604eec7e5f..50ded22b85 100644 --- a/sdk/src/types/block/rand/output/mod.rs +++ b/sdk/src/types/block/rand/output/mod.rs @@ -19,7 +19,7 @@ pub use self::{ use crate::types::block::{ output::{ unlock_condition::ImmutableAccountAddressUnlockCondition, AccountId, AccountOutput, AnchorId, AnchorOutput, - BasicOutput, FoundryOutput, NftId, NftOutput, Output, OutputId, SimpleTokenScheme, TokenScheme, + BasicOutput, DelegationId, FoundryOutput, NftId, NftOutput, Output, OutputId, SimpleTokenScheme, TokenScheme, OUTPUT_INDEX_RANGE, }, rand::{ @@ -72,6 +72,11 @@ pub fn rand_anchor_id() -> AnchorId { AnchorId::from(rand_bytes_array()) } +/// Generates a random [`DelegationId`]. +pub fn rand_delegation_id() -> DelegationId { + DelegationId::from(rand_bytes_array()) +} + /// Generates a random [`AccountOutput`]. pub fn rand_account_output(token_supply: u64) -> AccountOutput { // We need to make sure that `AccountId` and `Address` don't match. diff --git a/sdk/src/types/block/semantic/mod.rs b/sdk/src/types/block/semantic/mod.rs index ac30255a8e..0c76927a0b 100644 --- a/sdk/src/types/block/semantic/mod.rs +++ b/sdk/src/types/block/semantic/mod.rs @@ -14,7 +14,7 @@ pub use self::{error::TransactionFailureReason, state_transition::StateTransitio use crate::types::block::{ address::Address, context_input::{BlockIssuanceCreditContextInput, CommitmentContextInput, RewardContextInput}, - output::{AccountId, AnchorOutput, ChainId, FoundryId, NativeTokens, Output, OutputId, TokenId}, + output::{AccountId, AnchorOutput, ChainId, FoundryId, Output, OutputId, TokenId}, payload::signed_transaction::{Transaction, TransactionCapabilityFlag, TransactionSigningHash}, protocol::ProtocolParameters, unlock::Unlock, @@ -308,9 +308,6 @@ impl<'a> SemanticValidationContext<'a> { } } - // Validation of input native tokens. - let mut native_token_ids = self.input_native_tokens.keys().collect::>(); - // Validation of output native tokens. for (token_id, output_amount) in self.output_native_tokens.iter() { let input_amount = self.input_native_tokens.get(token_id).copied().unwrap_or_default(); @@ -322,13 +319,6 @@ impl<'a> SemanticValidationContext<'a> { { return Ok(Some(TransactionFailureReason::NativeTokenSumUnbalanced)); } - - native_token_ids.insert(token_id); - } - - if native_token_ids.len() > NativeTokens::COUNT_MAX as usize { - // TODO https://github.com/iotaledger/iota-sdk/issues/1954 - return Ok(Some(TransactionFailureReason::SemanticValidationFailed)); } // Validation of state transitions and destructions. diff --git a/sdk/src/wallet/operations/mod.rs b/sdk/src/wallet/operations/mod.rs index 6206203176..6e7713077a 100644 --- a/sdk/src/wallet/operations/mod.rs +++ b/sdk/src/wallet/operations/mod.rs @@ -18,9 +18,9 @@ pub(crate) mod output_consolidation; /// The module for participation #[cfg(feature = "participation")] pub(crate) mod participation; -/// The module for reissuing blocks or transactions -pub(crate) mod reissue; /// The module for synchronization of the wallet pub(crate) mod syncing; /// The module for transactions pub(crate) mod transaction; +/// The module for waiting for transaction acceptance +pub(crate) mod wait_for_tx_acceptance; diff --git a/sdk/src/wallet/operations/reissue.rs b/sdk/src/wallet/operations/reissue.rs deleted file mode 100644 index 7bad812224..0000000000 --- a/sdk/src/wallet/operations/reissue.rs +++ /dev/null @@ -1,141 +0,0 @@ -// Copyright 2022 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -use crate::{ - client::{ - secret::{SecretManage, SignBlock}, - Error as ClientError, - }, - types::{ - api::core::{BlockState, TransactionState}, - block::{ - payload::{signed_transaction::TransactionId, Payload}, - BlockId, - }, - }, - wallet::{types::InclusionState, Error, Wallet}, -}; - -const DEFAULT_REISSUE_UNTIL_INCLUDED_INTERVAL: u64 = 1; -const DEFAULT_REISSUE_UNTIL_INCLUDED_MAX_AMOUNT: u64 = 40; - -impl Wallet -where - Error: From, - crate::client::Error: From, -{ - /// Reissues a transaction sent from the account for a provided transaction id until it's - /// included (referenced by a milestone). Returns the included block id. - pub async fn reissue_transaction_until_included( - &self, - transaction_id: &TransactionId, - interval: Option, - max_attempts: Option, - ) -> crate::wallet::Result { - log::debug!("[reissue_transaction_until_included]"); - - let protocol_parameters = self.client().get_protocol_parameters().await?; - let transaction = self.data().await.transactions.get(transaction_id).cloned(); - - if let Some(transaction) = transaction { - if transaction.inclusion_state == InclusionState::Confirmed { - return transaction.block_id.ok_or(Error::MissingParameter("block id")); - } - - if transaction.inclusion_state == InclusionState::Conflicting - || transaction.inclusion_state == InclusionState::UnknownPruned - { - return Err(ClientError::TangleInclusion(format!( - "transaction id: {} inclusion state: {:?}", - transaction_id, transaction.inclusion_state - )) - .into()); - } - - let first_block_id = match transaction.block_id { - Some(block_id) => block_id, - None => self - .client() - .build_basic_block( - todo!("issuer id"), - Some(Payload::SignedTransaction(Box::new(transaction.payload.clone()))), - ) - .await? - .sign_ed25519( - &*self.get_secret_manager().read().await, - self.bip_path().await.ok_or(Error::MissingBipPath)?, - ) - .await? - .id(&protocol_parameters), - }; - - // Attachments of the Block to check inclusion state - // TODO: remove when todos in `finish_basic_block_builder()` are removed - #[allow(unused_mut)] - let mut block_ids = vec![first_block_id]; - for _ in 0..max_attempts.unwrap_or(DEFAULT_REISSUE_UNTIL_INCLUDED_MAX_AMOUNT) { - let duration = - std::time::Duration::from_secs(interval.unwrap_or(DEFAULT_REISSUE_UNTIL_INCLUDED_INTERVAL)); - - #[cfg(target_family = "wasm")] - gloo_timers::future::TimeoutFuture::new(duration.as_millis() as u32).await; - - #[cfg(not(target_family = "wasm"))] - tokio::time::sleep(duration).await; - - // Check inclusion state for each attachment - let block_ids_len = block_ids.len(); - let mut failed = false; - for (index, block_id) in block_ids.clone().iter().enumerate() { - let block_metadata = self.client().get_block_metadata(block_id).await?; - if let Some(transaction_state) = block_metadata.transaction_metadata.map(|m| m.transaction_state) { - match transaction_state { - // TODO: find out what to do with TransactionState::Confirmed - TransactionState::Finalized => return Ok(*block_id), - // only set it as failed here and don't return, because another reissued block could - // have the included transaction - // TODO: check if the comment above is still correct with IOTA 2.0 - TransactionState::Failed => failed = true, - // TODO: what to do when confirmed? - _ => {} - }; - } - // Only reissue latest attachment of the block - if index == block_ids_len - 1 && block_metadata.block_state == BlockState::Rejected { - let reissued_block = self - .client() - .build_basic_block( - todo!("issuer id"), - Some(Payload::SignedTransaction(Box::new(transaction.payload.clone()))), - ) - .await? - .sign_ed25519( - &*self.get_secret_manager().read().await, - self.bip_path().await.ok_or(Error::MissingBipPath)?, - ) - .await?; - block_ids.push(reissued_block.id(&protocol_parameters)); - } - } - // After we checked all our reissued blocks, check if the transaction got reissued in another block - // and confirmed - // TODO: can this still be the case? Is the TransactionState per transaction or per attachment in a - // block? - if failed { - let included_block = self.client().get_included_block(transaction_id).await.map_err(|e| { - if matches!(e, ClientError::Node(crate::client::node_api::error::Error::NotFound(_))) { - // If no block was found with this transaction id, then it can't get included - ClientError::TangleInclusion(first_block_id.to_string()) - } else { - e - } - })?; - return Ok(included_block.id(&protocol_parameters)); - } - } - Err(ClientError::TangleInclusion(first_block_id.to_string()).into()) - } else { - Err(Error::TransactionNotFound(*transaction_id)) - } - } -} diff --git a/sdk/src/wallet/operations/wait_for_tx_acceptance.rs b/sdk/src/wallet/operations/wait_for_tx_acceptance.rs new file mode 100644 index 0000000000..8cd17ac7f8 --- /dev/null +++ b/sdk/src/wallet/operations/wait_for_tx_acceptance.rs @@ -0,0 +1,103 @@ +// Copyright 2022 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +use std::time::Duration; + +use crate::{ + client::{secret::SecretManage, Error as ClientError}, + types::{ + api::core::TransactionState, + block::{payload::signed_transaction::TransactionId, BlockId}, + }, + wallet::{types::InclusionState, Error, Wallet}, +}; + +const DEFAULT_WAIT_FOR_TX_ACCEPTANCE_INTERVAL: Duration = Duration::from_millis(500); +const DEFAULT_WAIT_FOR_TX_ACCEPTANCE_MAX_ATTEMPTS: u64 = 80; + +impl Wallet +where + Error: From, + crate::client::Error: From, +{ + /// Checks the transaction state for a provided transaction id until it's accepted. Interval in milliseconds. + /// Returns the block id that contains this transaction. + pub async fn wait_for_transaction_acceptance( + &self, + transaction_id: &TransactionId, + interval: Option, + max_attempts: Option, + ) -> crate::wallet::Result { + log::debug!("[wait_for_transaction_acceptance]"); + + let transaction = self + .data() + .await + .transactions + .get(transaction_id) + .cloned() + .ok_or_else(|| Error::TransactionNotFound(*transaction_id))?; + + if matches!( + transaction.inclusion_state, + InclusionState::Accepted | InclusionState::Confirmed | InclusionState::Finalized + ) { + return Ok(transaction + .block_id + // Safe to unwrap, we always set the block id together with any of these inclusion states. + .expect("missing block id in TransactionWithMetadata")); + } + + if matches!( + transaction.inclusion_state, + InclusionState::Conflicting | InclusionState::UnknownPruned + ) { + return Err(ClientError::TransactionAcceptance(format!( + "transaction id: {} inclusion state: {:?}", + transaction_id, transaction.inclusion_state + )) + .into()); + } + + let block_id = transaction + .block_id + .ok_or_else(|| ClientError::TransactionAcceptance(transaction_id.to_string()))?; + + let duration = interval + .map(std::time::Duration::from_millis) + .unwrap_or(DEFAULT_WAIT_FOR_TX_ACCEPTANCE_INTERVAL); + for _ in 0..max_attempts.unwrap_or(DEFAULT_WAIT_FOR_TX_ACCEPTANCE_MAX_ATTEMPTS) { + let block_metadata = self.client().get_block_metadata(&block_id).await?; + if let Some(transaction_state) = block_metadata.transaction_metadata.map(|m| m.transaction_state) { + match transaction_state { + TransactionState::Accepted | TransactionState::Confirmed | TransactionState::Finalized => { + return Ok(block_id); + } + TransactionState::Failed => { + // Check if the transaction got reissued in another block and confirmed there + let included_block_metadata = self + .client() + .get_included_block_metadata(transaction_id) + .await + .map_err(|e| { + if matches!(e, ClientError::Node(crate::client::node_api::error::Error::NotFound(_))) { + // If no block was found with this transaction id, then it couldn't get accepted + ClientError::TransactionAcceptance(transaction_id.to_string()) + } else { + e + } + })?; + return Ok(included_block_metadata.block_id); + } + TransactionState::Pending => {} // Just need to wait longer + }; + } + + #[cfg(target_family = "wasm")] + gloo_timers::future::TimeoutFuture::new(duration.as_millis() as u32).await; + #[cfg(not(target_family = "wasm"))] + tokio::time::sleep(duration).await; + } + Err(ClientError::TransactionAcceptance(transaction_id.to_string()).into()) + } +} diff --git a/sdk/src/wallet/types/mod.rs b/sdk/src/wallet/types/mod.rs index 0741bf4fbc..e6e3b207f1 100644 --- a/sdk/src/wallet/types/mod.rs +++ b/sdk/src/wallet/types/mod.rs @@ -189,7 +189,9 @@ impl Serialize for TransactionWithMetadata { #[non_exhaustive] pub enum InclusionState { Pending, + Accepted, Confirmed, + Finalized, Conflicting, UnknownPruned, } diff --git a/sdk/tests/client/input_selection/account_outputs.rs b/sdk/tests/client/input_selection/account_outputs.rs index d798619e03..bc5559726d 100644 --- a/sdk/tests/client/input_selection/account_outputs.rs +++ b/sdk/tests/client/input_selection/account_outputs.rs @@ -26,24 +26,25 @@ fn input_account_eq_output_account() { let account_id_2 = AccountId::from_str(ACCOUNT_ID_2).unwrap(); let inputs = build_inputs( - [Account( - 1_000_000, - account_id_2, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, + [( + Account { + amount: 1_000_000, + account_id: account_id_2, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + }, None, )], Some(SLOT_INDEX), ); - let outputs = build_outputs([Account( - 1_000_000, - account_id_2, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - )]); + let outputs = build_outputs([Account { + amount: 1_000_000, + account_id: account_id_2, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -65,25 +66,26 @@ fn transition_account_id_zero() { let account_id_0 = AccountId::from_str(ACCOUNT_ID_0).unwrap(); let inputs = build_inputs( - [Account( - 1_000_000, - account_id_0, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, + [( + Account { + amount: 1_000_000, + account_id: account_id_0, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + }, None, )], Some(SLOT_INDEX), ); let account_id = AccountId::from(inputs[0].output_id()); - let outputs = build_outputs([Account( - 1_000_000, + let outputs = build_outputs([Account { + amount: 1_000_000, account_id, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - )]); + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -239,26 +241,27 @@ fn create_account() { let account_id_0 = AccountId::from_str(ACCOUNT_ID_0).unwrap(); let inputs = build_inputs( - [Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + [( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, )], Some(SLOT_INDEX), ); - let outputs = build_outputs([Account( - 1_000_000, - account_id_0, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - )]); + let outputs = build_outputs([Account { + amount: 1_000_000, + account_id: account_id_0, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -289,26 +292,27 @@ fn burn_account() { let account_id_2 = AccountId::from_str(ACCOUNT_ID_2).unwrap(); let inputs = build_inputs( - [Account( - 2_000_000, - account_id_2, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, + [( + Account { + amount: 2_000_000, + account_id: account_id_2, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + }, None, )], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -376,26 +380,27 @@ fn missing_input_for_account_output() { let account_id_2 = AccountId::from_str(ACCOUNT_ID_2).unwrap(); let inputs = build_inputs( - [Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + [( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, )], None, ); - let outputs = build_outputs([Account( - 1_000_000, - account_id_2, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - )]); + let outputs = build_outputs([Account { + amount: 1_000_000, + account_id: account_id_2, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + }]); let selected = InputSelection::new( inputs, @@ -420,35 +425,38 @@ fn missing_input_for_account_output_2() { let inputs = build_inputs( [ - Account( - 2_000_000, - account_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, + ( + Account { + amount: 2_000_000, + account_id: account_id_1, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + }, None, ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], None, ); - let outputs = build_outputs([Account( - 1_000_000, - account_id_2, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - )]); + let outputs = build_outputs([Account { + amount: 1_000_000, + account_id: account_id_2, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + }]); let selected = InputSelection::new( inputs, @@ -471,26 +479,27 @@ fn missing_input_for_account_output_but_created() { let account_id_0 = AccountId::from_str(ACCOUNT_ID_0).unwrap(); let inputs = build_inputs( - [Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + [( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, )], Some(SLOT_INDEX), ); - let outputs = build_outputs([Account( - 1_000_000, - account_id_0, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - )]); + let outputs = build_outputs([Account { + amount: 1_000_000, + account_id: account_id_0, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + }]); let selected = InputSelection::new( inputs, @@ -511,22 +520,26 @@ fn account_in_output_and_sender() { let inputs = build_inputs( [ - Account( - 1_000_000, - account_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, + ( + Account { + amount: 1_000_000, + account_id: account_id_1, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + }, None, ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], @@ -535,16 +548,15 @@ fn account_in_output_and_sender() { let account_output = AccountOutputBuilder::from(inputs[0].output.as_account()) .finish_output() .unwrap(); - let mut outputs = build_outputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - Some(Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap()), - None, - None, - None, - None, - )]); + let mut outputs = build_outputs([Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: Some(Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap()), + sdruc: None, + timelock: None, + expiration: None, + }]); outputs.push(account_output); let selected = InputSelection::new( @@ -567,24 +579,25 @@ fn missing_ed25519_sender() { let account_id_2 = AccountId::from_str(ACCOUNT_ID_2).unwrap(); let inputs = build_inputs( - [Account( - 1_000_000, - account_id_2, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, + [( + Account { + amount: 1_000_000, + account_id: account_id_2, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + }, None, )], None, ); - let outputs = build_outputs([Account( - 1_000_000, - account_id_2, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some(Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()), - None, - None, - )]); + let outputs = build_outputs([Account { + amount: 1_000_000, + account_id: account_id_2, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: Some(Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()), + issuer: None, + }]); let selected = InputSelection::new( inputs, @@ -607,26 +620,27 @@ fn missing_ed25519_issuer_created() { let account_id_0 = AccountId::from_str(ACCOUNT_ID_0).unwrap(); let inputs = build_inputs( - [Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + [( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, )], None, ); - let outputs = build_outputs([Account( - 1_000_000, - account_id_0, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - Some(Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()), - None, - )]); + let outputs = build_outputs([Account { + amount: 1_000_000, + account_id: account_id_0, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: Some(Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()), + }]); let selected = InputSelection::new( inputs, @@ -649,24 +663,25 @@ fn missing_ed25519_issuer_transition() { let account_id_1 = AccountId::from_str(ACCOUNT_ID_1).unwrap(); let inputs = build_inputs( - [Account( - 1_000_000, - account_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - Some(Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()), + [( + Account { + amount: 1_000_000, + account_id: account_id_1, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: Some(Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()), + }, None, )], Some(SLOT_INDEX), ); - let outputs = build_outputs([Account( - 1_000_000, - account_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - Some(Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()), - None, - )]); + let outputs = build_outputs([Account { + amount: 1_000_000, + account_id: account_id_1, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: Some(Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()), + }]); let selected = InputSelection::new( inputs, @@ -686,24 +701,25 @@ fn missing_account_sender() { let account_id_2 = AccountId::from_str(ACCOUNT_ID_2).unwrap(); let inputs = build_inputs( - [Account( - 1_000_000, - account_id_2, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, + [( + Account { + amount: 1_000_000, + account_id: account_id_2, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + }, None, )], None, ); - let outputs = build_outputs([Account( - 1_000_000, - account_id_2, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some(Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap()), - None, - None, - )]); + let outputs = build_outputs([Account { + amount: 1_000_000, + account_id: account_id_2, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: Some(Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap()), + issuer: None, + }]); let selected = InputSelection::new( inputs, @@ -726,26 +742,27 @@ fn missing_account_issuer_created() { let account_id_0 = AccountId::from_str(ACCOUNT_ID_0).unwrap(); let inputs = build_inputs( - [Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + [( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, )], None, ); - let outputs = build_outputs([Account( - 1_000_000, - account_id_0, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - Some(Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap()), - None, - )]); + let outputs = build_outputs([Account { + amount: 1_000_000, + account_id: account_id_0, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: Some(Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap()), + }]); let selected = InputSelection::new( inputs, @@ -768,24 +785,25 @@ fn missing_account_issuer_transition() { let account_id_2 = AccountId::from_str(ACCOUNT_ID_2).unwrap(); let inputs = build_inputs( - [Account( - 1_000_000, - account_id_2, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - Some(Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap()), + [( + Account { + amount: 1_000_000, + account_id: account_id_2, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: Some(Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap()), + }, None, )], Some(SLOT_INDEX), ); - let outputs = build_outputs([Account( - 1_000_000, - account_id_2, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - Some(Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap()), - None, - )]); + let outputs = build_outputs([Account { + amount: 1_000_000, + account_id: account_id_2, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: Some(Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap()), + }]); let selected = InputSelection::new( inputs, @@ -805,24 +823,25 @@ fn missing_nft_sender() { let account_id_2 = AccountId::from_str(ACCOUNT_ID_2).unwrap(); let inputs = build_inputs( - [Account( - 1_000_000, - account_id_2, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, + [( + Account { + amount: 1_000_000, + account_id: account_id_2, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + }, None, )], None, ); - let outputs = build_outputs([Account( - 1_000_000, - account_id_2, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some(Address::try_from_bech32(BECH32_ADDRESS_NFT_1).unwrap()), - None, - None, - )]); + let outputs = build_outputs([Account { + amount: 1_000_000, + account_id: account_id_2, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: Some(Address::try_from_bech32(BECH32_ADDRESS_NFT_1).unwrap()), + issuer: None, + }]); let selected = InputSelection::new( inputs, @@ -845,26 +864,27 @@ fn missing_nft_issuer_created() { let account_id_0 = AccountId::from_str(ACCOUNT_ID_0).unwrap(); let inputs = build_inputs( - [Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + [( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, )], None, ); - let outputs = build_outputs([Account( - 1_000_000, - account_id_0, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - Some(Address::try_from_bech32(BECH32_ADDRESS_NFT_1).unwrap()), - None, - )]); + let outputs = build_outputs([Account { + amount: 1_000_000, + account_id: account_id_0, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: Some(Address::try_from_bech32(BECH32_ADDRESS_NFT_1).unwrap()), + }]); let selected = InputSelection::new( inputs, @@ -887,24 +907,25 @@ fn missing_nft_issuer_transition() { let account_id_1 = AccountId::from_str(ACCOUNT_ID_1).unwrap(); let inputs = build_inputs( - [Account( - 1_000_000, - account_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - Some(Address::try_from_bech32(BECH32_ADDRESS_NFT_1).unwrap()), + [( + Account { + amount: 1_000_000, + account_id: account_id_1, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: Some(Address::try_from_bech32(BECH32_ADDRESS_NFT_1).unwrap()), + }, None, )], Some(SLOT_INDEX), ); - let outputs = build_outputs([Account( - 1_000_000, - account_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - Some(Address::try_from_bech32(BECH32_ADDRESS_NFT_1).unwrap()), - None, - )]); + let outputs = build_outputs([Account { + amount: 1_000_000, + account_id: account_id_1, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: Some(Address::try_from_bech32(BECH32_ADDRESS_NFT_1).unwrap()), + }]); let selected = InputSelection::new( inputs, @@ -925,35 +946,38 @@ fn increase_account_amount() { let inputs = build_inputs( [ - Account( - 2_000_000, - account_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, + ( + Account { + amount: 2_000_000, + account_id: account_id_1, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + }, None, ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Account( - 3_000_000, - account_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - )]); + let outputs = build_outputs([Account { + amount: 3_000_000, + account_id: account_id_1, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -976,35 +1000,38 @@ fn decrease_account_amount() { let inputs = build_inputs( [ - Account( - 2_000_000, - account_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, + ( + Account { + amount: 2_000_000, + account_id: account_id_1, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + }, None, ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Account( - 1_000_000, - account_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - )]); + let outputs = build_outputs([Account { + amount: 1_000_000, + account_id: account_id_1, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -1039,37 +1066,40 @@ fn prefer_basic_to_account() { let inputs = build_inputs( [ - Account( - 1_000_000, - account_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, + ( + Account { + amount: 1_000_000, + account_id: account_id_1, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + }, None, ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -1093,37 +1123,40 @@ fn take_amount_from_account_to_fund_basic() { let inputs = build_inputs( [ - Account( - 2_000_000, - account_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, + ( + Account { + amount: 2_000_000, + account_id: account_id_1, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + }, None, ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 1_200_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 1_200_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -1161,37 +1194,40 @@ fn account_burn_should_validate_account_sender() { let inputs = build_inputs( [ - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Account( - 1_000_000, - account_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, + ( + Account { + amount: 1_000_000, + account_id: account_id_1, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - Some(Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap()), - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: Some(Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap()), + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -1227,37 +1263,40 @@ fn account_burn_should_validate_account_address() { let inputs = build_inputs( [ - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Account( - 1_000_000, - account_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, + ( + Account { + amount: 1_000_000, + account_id: account_id_1, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -1292,26 +1331,27 @@ fn transitioned_zero_account_id_no_longer_is_zero() { let account_id_0 = AccountId::from_str(ACCOUNT_ID_0).unwrap(); let inputs = build_inputs( - [Account( - 2_000_000, - account_id_0, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, + [( + Account { + amount: 2_000_000, + account_id: account_id_0, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + }, None, )], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -1350,35 +1390,38 @@ fn two_accounts_required() { let inputs = build_inputs( [ - Account( - 2_000_000, - account_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, + ( + Account { + amount: 2_000_000, + account_id: account_id_1, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + }, None, ), - Account( - 2_000_000, - account_id_2, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, + ( + Account { + amount: 2_000_000, + account_id: account_id_2, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 3_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 3_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -1421,26 +1464,27 @@ fn state_controller_sender_required() { let account_id_1 = AccountId::from_str(ACCOUNT_ID_1).unwrap(); let inputs = build_inputs( - [Account( - 2_000_000, - account_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, + [( + Account { + amount: 2_000_000, + account_id: account_id_1, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + }, None, )], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - Some(Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()), - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: Some(Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()), + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -1463,35 +1507,35 @@ fn state_controller_sender_required_already_selected() { let account_id_1 = AccountId::from_str(ACCOUNT_ID_1).unwrap(); let inputs = build_inputs( - [Account( - 2_000_000, - account_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, + [( + Account { + amount: 2_000_000, + account_id: account_id_1, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + }, None, )], Some(SLOT_INDEX), ); let outputs = build_outputs([ - 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, - Some(Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()), - None, - None, - None, - None, - ), + Account { + amount: 1_000_000, + account_id: account_id_1, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + }, + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: Some(Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()), + sdruc: None, + timelock: None, + expiration: None, + }, ]); let selected = InputSelection::new( @@ -1515,24 +1559,25 @@ fn state_transition_and_required() { let account_id_1 = AccountId::from_str(ACCOUNT_ID_1).unwrap(); let inputs = build_inputs( - [Account( - 2_000_000, - account_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, + [( + Account { + amount: 2_000_000, + account_id: account_id_1, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + }, None, )], Some(SLOT_INDEX), ); - let outputs = build_outputs([Account( - 2_000_000, - account_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - )]); + let outputs = build_outputs([Account { + amount: 2_000_000, + account_id: account_id_1, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -1555,24 +1600,25 @@ fn remainder_address_in_state_controller() { let account_id_1 = AccountId::from_str(ACCOUNT_ID_1).unwrap(); let inputs = build_inputs( - [Account( - 2_000_000, - account_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, + [( + Account { + amount: 2_000_000, + account_id: account_id_1, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + }, None, )], Some(SLOT_INDEX), ); - let outputs = build_outputs([Account( - 1_000_000, - account_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - )]); + let outputs = build_outputs([Account { + amount: 1_000_000, + account_id: account_id_1, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + }]); let selected = InputSelection::new( inputs.clone(), diff --git a/sdk/tests/client/input_selection/basic_outputs.rs b/sdk/tests/client/input_selection/basic_outputs.rs index 5689848353..0e86c5f178 100644 --- a/sdk/tests/client/input_selection/basic_outputs.rs +++ b/sdk/tests/client/input_selection/basic_outputs.rs @@ -25,28 +25,29 @@ fn input_amount_equal_output_amount() { let protocol_parameters = protocol_parameters(); let inputs = build_inputs( - [Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + [( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, )], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -67,28 +68,29 @@ fn input_amount_lower_than_output_amount() { let protocol_parameters = protocol_parameters(); let inputs = build_inputs( - [Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + [( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, )], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs, @@ -114,39 +116,42 @@ fn input_amount_lower_than_output_amount_2() { let inputs = build_inputs( [ - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 3_500_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 3_500_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs, @@ -171,28 +176,29 @@ fn input_amount_greater_than_output_amount() { let protocol_parameters = protocol_parameters(); let inputs = build_inputs( - [Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + [( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, )], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 500_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 500_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -226,28 +232,29 @@ fn input_amount_greater_than_output_amount_with_remainder_address() { let remainder_address = Address::try_from_bech32(BECH32_ADDRESS_REMAINDER).unwrap(); let inputs = build_inputs( - [Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + [( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, )], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 500_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 500_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -282,39 +289,42 @@ fn two_same_inputs_one_needed() { let inputs = build_inputs( [ - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 500_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 500_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs, @@ -349,39 +359,42 @@ fn two_inputs_one_needed() { let inputs = build_inputs( [ - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -403,39 +416,42 @@ fn two_inputs_one_needed_reversed() { let inputs = build_inputs( [ - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -457,39 +473,42 @@ fn two_inputs_both_needed() { let inputs = build_inputs( [ - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 3_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 3_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -511,39 +530,42 @@ fn two_inputs_remainder() { let inputs = build_inputs( [ - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 2_500_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 2_500_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -620,69 +642,78 @@ fn ed25519_sender() { let inputs = build_inputs( [ - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - Some(Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()), - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: Some(Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()), + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs, @@ -714,28 +745,29 @@ fn missing_ed25519_sender() { let protocol_parameters = protocol_parameters(); let inputs = build_inputs( - [Basic( - 5_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + [( + Basic { + amount: 5_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, )], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - Some(Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()), - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: Some(Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()), + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs, @@ -759,67 +791,76 @@ fn account_sender() { let inputs = build_inputs( [ - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Account( - 1_000_000, - account_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, + ( + Account { + amount: 1_000_000, + account_id: account_id_1, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + }, None, ), - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - Some(Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap()), - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: Some(Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap()), + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs, @@ -851,38 +892,41 @@ fn account_sender_zero_id() { let inputs = build_inputs( [ - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Account( - 1_000_000, - account_id_0, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, + ( + Account { + amount: 1_000_000, + account_id: account_id_0, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + }, None, ), ], Some(SLOT_INDEX), ); let account_id = AccountId::from(inputs[1].output_id()); - let outputs = build_outputs([Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - Some(Address::from(account_id)), - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: Some(Address::from(account_id)), + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -909,28 +953,29 @@ fn missing_account_sender() { let protocol_parameters = protocol_parameters(); let inputs = build_inputs( - [Basic( - 5_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + [( + Basic { + amount: 5_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, )], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - Some(Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap()), - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: Some(Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap()), + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs, @@ -954,69 +999,78 @@ fn nft_sender() { let inputs = build_inputs( [ - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Nft( - 1_000_000, - nft_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, + ( + Nft { + amount: 1_000_000, + nft_id: nft_id_1, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + sdruc: None, + expiration: None, + }, None, ), - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - Some(Address::try_from_bech32(BECH32_ADDRESS_NFT_1).unwrap()), - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: Some(Address::try_from_bech32(BECH32_ADDRESS_NFT_1).unwrap()), + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -1049,40 +1103,43 @@ fn nft_sender_zero_id() { let inputs = build_inputs( [ - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Nft( - 1_000_000, - nft_id_0, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, + ( + Nft { + amount: 1_000_000, + nft_id: nft_id_0, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + sdruc: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); let nft_id = NftId::from(inputs[1].output_id()); - let outputs = build_outputs([Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - Some(Address::from(nft_id)), - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: Some(Address::from(nft_id)), + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -1109,28 +1166,29 @@ fn missing_nft_sender() { let protocol_parameters = protocol_parameters(); let inputs = build_inputs( - [Basic( - 5_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + [( + Basic { + amount: 5_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, )], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - Some(Address::try_from_bech32(BECH32_ADDRESS_NFT_1).unwrap()), - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: Some(Address::try_from_bech32(BECH32_ADDRESS_NFT_1).unwrap()), + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs, @@ -1152,28 +1210,29 @@ fn simple_remainder() { let protocol_parameters = protocol_parameters(); let inputs = build_inputs( - [Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + [( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, )], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 500_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 500_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -1285,28 +1344,29 @@ fn one_provided_one_needed() { let protocol_parameters = protocol_parameters(); let inputs = build_inputs( - [Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + [( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, )], - Some(SLOT_INDEX), - ); - let outputs = build_outputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + Some(SLOT_INDEX), + ); + let outputs = build_outputs([Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -1327,28 +1387,29 @@ fn insufficient_amount() { let protocol_parameters = protocol_parameters(); let inputs = build_inputs( - [Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + [( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, )], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 1_250_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 1_250_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs, @@ -1374,39 +1435,42 @@ fn two_inputs_remainder_2() { let inputs = build_inputs( [ - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 500_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 500_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -1440,39 +1504,42 @@ fn two_inputs_remainder_3() { let inputs = build_inputs( [ - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 1_750_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 1_750_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -1544,28 +1611,29 @@ fn sender_already_selected() { let protocol_parameters = protocol_parameters(); let inputs = build_inputs( - [Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), - None, - None, - None, - None, - None, + [( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, )], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - Some(Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()), - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: Some(Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()), + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -1590,28 +1658,29 @@ fn single_mandatory_input() { let protocol_parameters = protocol_parameters(); let inputs = build_inputs( - [Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), - None, - None, - None, - None, - None, + [( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, )], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -1638,30 +1707,31 @@ 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, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ) }) .take(129), None, ); - let outputs = build_outputs([Basic( - 129_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 129_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs, @@ -1685,14 +1755,16 @@ 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, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ) }) @@ -1701,30 +1773,31 @@ fn more_than_max_inputs_only_one_needed() { ); // Add the needed input let needed_input = build_inputs( - [Basic( - 129_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + [( + Basic { + amount: 129_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, )], Some(SLOT_INDEX), ); inputs.push(needed_input[0].clone()); - let outputs = build_outputs([Basic( - 129_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 129_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs, @@ -1745,30 +1818,29 @@ fn too_many_outputs() { let protocol_parameters = protocol_parameters(); let inputs = build_inputs( - [Basic( - 2_000_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + [( + Basic { + amount: 2_000_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, )], Some(SLOT_INDEX), ); let outputs = build_outputs( - std::iter::repeat_with(|| { - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ) + std::iter::repeat_with(|| Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, }) .take(129), ); @@ -1793,31 +1865,30 @@ fn too_many_outputs_with_remainder() { let protocol_parameters = protocol_parameters(); let inputs = build_inputs( - [Basic( - 2_000_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + [( + Basic { + amount: 2_000_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, )], Some(SLOT_INDEX), ); let outputs = build_outputs( - std::iter::repeat_with(|| { - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ) + std::iter::repeat_with(|| Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, }) .take(128), ); @@ -1846,60 +1917,78 @@ fn restricted_ed25519() { let inputs = build_inputs( [ - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: 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, + ( + Basic { + amount: 1_000_000, + address: restricted, + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, + ), + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -1925,30 +2014,42 @@ fn restricted_nft() { let inputs = build_inputs( [ - Basic(2_000_000, restricted, None, None, None, None, None, None), - Nft( - 2_000_000, - nft_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, + ( + Basic { + amount: 2_000_000, + address: restricted, + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, + ), + ( + Nft { + amount: 2_000_000, + nft_id: nft_id_1, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + sdruc: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 3_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 3_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -1974,28 +2075,40 @@ fn restricted_account() { let inputs = build_inputs( [ - Basic(3_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, + ( + Basic { + amount: 3_000_000, + address: restricted, + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, + ), + ( + Account { + amount: 2_000_000, + account_id: account_id_1, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 3_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 3_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -2020,69 +2133,78 @@ fn restricted_ed25519_sender() { let inputs = build_inputs( [ - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - Some(restricted_sender), - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: Some(restricted_sender), + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -2129,49 +2251,54 @@ fn multi_address_sender_already_fulfilled() { let inputs = build_inputs( [ - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_2).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_2).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 3_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - Some(multi), - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 3_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: Some(multi), + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -2204,41 +2331,52 @@ fn ed25519_backed_available_address() { let inputs = build_inputs( [ - Basic( - 1_000_000, - restricted_address.clone(), - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: restricted_address.clone(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, + ), + ( + Basic { + amount: 1_000_000, + address: ed25519.clone(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Basic(1_000_000, ed25519.clone(), None, None, None, None, None, None), ], Some(SLOT_INDEX), ); let outputs = build_outputs([ - 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, - Some(restricted_address.clone()), - None, - None, - None, - None, - ), + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: Some(restricted_address.clone()), + sdruc: None, + timelock: None, + expiration: None, + }, ]); let selected = InputSelection::new( diff --git a/sdk/tests/client/input_selection/burn.rs b/sdk/tests/client/input_selection/burn.rs index 1a450bdfa2..98a1ebad26 100644 --- a/sdk/tests/client/input_selection/burn.rs +++ b/sdk/tests/client/input_selection/burn.rs @@ -30,37 +30,40 @@ fn burn_account_present() { let inputs = build_inputs( [ - Account( - 1_000_000, - account_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, + ( + Account { + amount: 1_000_000, + account_id: account_id_1, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + }, None, ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -85,37 +88,40 @@ fn burn_account_present_and_required() { let inputs = build_inputs( [ - Account( - 1_000_000, - account_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, + ( + Account { + amount: 1_000_000, + account_id: account_id_1, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + }, None, ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -141,39 +147,42 @@ fn burn_account_id_zero() { let inputs = build_inputs( [ - Nft( - 1_000_000, - nft_id_0, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, + ( + Nft { + amount: 1_000_000, + nft_id: nft_id_0, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + sdruc: None, + expiration: None, + }, None, ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let nft_id = NftId::from(inputs[0].output_id()); let selected = InputSelection::new( @@ -198,28 +207,29 @@ fn burn_account_absent() { let account_id_1 = AccountId::from_str(ACCOUNT_ID_1).unwrap(); let inputs = build_inputs( - [Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + [( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, )], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs, @@ -245,45 +255,50 @@ fn burn_accounts_present() { let inputs = build_inputs( [ - Account( - 1_000_000, - account_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, + ( + Account { + amount: 1_000_000, + account_id: account_id_1, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + }, None, ), - Account( - 1_000_000, - account_id_2, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, + ( + Account { + amount: 1_000_000, + account_id: account_id_2, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + }, None, ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 3_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 3_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -307,46 +322,48 @@ fn burn_account_in_outputs() { let inputs = build_inputs( [ - Account( - 1_000_000, - account_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, + ( + Account { + amount: 1_000_000, + account_id: account_id_1, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + }, None, ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); let outputs = build_outputs([ - 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, - ), + Account { + amount: 1_000_000, + account_id: account_id_1, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + }, + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, ]); let selected = InputSelection::new( @@ -372,39 +389,42 @@ fn burn_nft_present() { let inputs = build_inputs( [ - Nft( - 1_000_000, - nft_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, + ( + Nft { + amount: 1_000_000, + nft_id: nft_id_1, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + sdruc: None, + expiration: None, + }, None, ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -429,39 +449,42 @@ fn burn_nft_present_and_required() { let inputs = build_inputs( [ - Nft( - 1_000_000, - nft_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, + ( + Nft { + amount: 1_000_000, + nft_id: nft_id_1, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + sdruc: None, + expiration: None, + }, None, ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -487,37 +510,40 @@ fn burn_nft_id_zero() { let inputs = build_inputs( [ - Account( - 1_000_000, - account_id_0, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, + ( + Account { + amount: 1_000_000, + account_id: account_id_0, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + }, None, ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let account_id = AccountId::from(inputs[0].output_id()); let selected = InputSelection::new( @@ -542,28 +568,29 @@ fn burn_nft_absent() { let nft_id_1 = NftId::from_str(NFT_ID_1).unwrap(); let inputs = build_inputs( - [Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + [( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, )], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs, @@ -589,49 +616,54 @@ fn burn_nfts_present() { let inputs = build_inputs( [ - Nft( - 1_000_000, - nft_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, + ( + Nft { + amount: 1_000_000, + nft_id: nft_id_1, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + sdruc: None, + expiration: None, + }, None, ), - Nft( - 1_000_000, - nft_id_2, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, + ( + Nft { + amount: 1_000_000, + nft_id: nft_id_2, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + sdruc: None, + expiration: None, + }, None, ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 3_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 3_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -655,50 +687,52 @@ fn burn_nft_in_outputs() { let inputs = build_inputs( [ - Nft( - 1_000_000, - nft_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, + ( + Nft { + amount: 1_000_000, + nft_id: nft_id_1, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + sdruc: None, + expiration: None, + }, None, ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); let outputs = build_outputs([ - Nft( - 1_000_000, - nft_id_1, - 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, - ), + Nft { + amount: 1_000_000, + nft_id: nft_id_1, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + sdruc: None, + expiration: None, + }, + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, ]); let selected = InputSelection::new( @@ -724,44 +758,50 @@ fn burn_foundry_present() { let inputs = build_inputs( [ - Foundry( - 1_000_000, - account_id_1, - 1, - SimpleTokenScheme::new(0, 0, 10).unwrap(), + ( + Foundry { + amount: 1_000_000, + account_id: account_id_1, + serial_number: 1, + token_scheme: SimpleTokenScheme::new(0, 0, 10).unwrap(), + native_token: None, + }, None, ), - Account( - 1_000_000, - account_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, + ( + Account { + amount: 1_000_000, + account_id: account_id_1, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + }, None, ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 500_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 500_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -810,11 +850,14 @@ fn burn_foundry_absent() { let protocol_parameters = protocol_parameters(); let account_id_1 = AccountId::from_str(ACCOUNT_ID_1).unwrap(); let foundry_id_1 = build_inputs( - [Foundry( - 1_000_000, - account_id_1, - 1, - SimpleTokenScheme::new(0, 0, 10).unwrap(), + [( + Foundry { + amount: 1_000_000, + account_id: account_id_1, + serial_number: 1, + token_scheme: SimpleTokenScheme::new(0, 0, 10).unwrap(), + native_token: None, + }, None, )], Some(SLOT_INDEX), @@ -825,37 +868,40 @@ fn burn_foundry_absent() { let inputs = build_inputs( [ - Account( - 1_000_000, - account_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, + ( + Account { + amount: 1_000_000, + account_id: account_id_1, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + }, None, ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs, @@ -880,41 +926,48 @@ fn burn_foundries_present() { let inputs = build_inputs( [ - Foundry( - 1_000_000, - account_id_1, - 1, - SimpleTokenScheme::new(0, 0, 10).unwrap(), + ( + Foundry { + amount: 1_000_000, + account_id: account_id_1, + serial_number: 1, + token_scheme: SimpleTokenScheme::new(0, 0, 10).unwrap(), + native_token: None, + }, None, ), - Foundry( - 1_000_000, - account_id_1, - 2, - SimpleTokenScheme::new(0, 0, 10).unwrap(), + ( + Foundry { + amount: 1_000_000, + account_id: account_id_1, + serial_number: 2, + token_scheme: SimpleTokenScheme::new(0, 0, 10).unwrap(), + native_token: None, + }, None, ), - Account( - 1_000_000, - account_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, + ( + Account { + amount: 1_000_000, + account_id: account_id_1, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -956,44 +1009,48 @@ fn burn_foundry_in_outputs() { let inputs = build_inputs( [ - Foundry( - 1_000_000, - account_id_1, - 1, - SimpleTokenScheme::new(0, 0, 10).unwrap(), + ( + Foundry { + amount: 1_000_000, + account_id: account_id_1, + serial_number: 1, + token_scheme: SimpleTokenScheme::new(0, 0, 10).unwrap(), + native_token: None, + }, None, ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); let outputs = build_outputs([ - Foundry( - 1_000_000, - account_id_1, - 1, - SimpleTokenScheme::new(0, 0, 10).unwrap(), - None, - ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - ), + Foundry { + amount: 1_000_000, + account_id: account_id_1, + serial_number: 1, + token_scheme: SimpleTokenScheme::new(0, 0, 10).unwrap(), + native_token: None, + }, + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, ]); let foundry_id_1 = inputs[0].output.as_foundry().id(); @@ -1019,24 +1076,28 @@ fn burn_native_tokens() { let inputs = build_inputs( [ - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_1, 100)), - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_1, 100)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_2, 100)), - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_2, 100)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], @@ -1082,44 +1143,50 @@ fn burn_foundry_and_its_account() { let inputs = build_inputs( [ - Foundry( - 1_000_000, - account_id_1, - 1, - SimpleTokenScheme::new(0, 0, 10).unwrap(), + ( + Foundry { + amount: 1_000_000, + account_id: account_id_1, + serial_number: 1, + token_scheme: SimpleTokenScheme::new(0, 0, 10).unwrap(), + native_token: None, + }, None, ), - Account( - 1_000_000, - account_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, + ( + Account { + amount: 1_000_000, + account_id: account_id_1, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + }, None, ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 500_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 500_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), diff --git a/sdk/tests/client/input_selection/expiration.rs b/sdk/tests/client/input_selection/expiration.rs index 82c56051c5..42fbbffcd7 100644 --- a/sdk/tests/client/input_selection/expiration.rs +++ b/sdk/tests/client/input_selection/expiration.rs @@ -26,28 +26,29 @@ fn one_output_expiration_not_expired() { let protocol_parameters = protocol_parameters(); let inputs = build_inputs( - [Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), - None, - None, - None, - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 200)), + [( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 200)), + }, None, )], Some(SlotIndex::from(100)), ); - let outputs = build_outputs([Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs, @@ -66,28 +67,29 @@ fn expiration_equal_timestamp() { let protocol_parameters = protocol_parameters(); let inputs = build_inputs( - [Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), - None, - None, - None, - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 200)), + [( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 200)), + }, None, )], Some(SlotIndex::from(200)), ); - let outputs = build_outputs([Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -108,28 +110,29 @@ fn one_output_expiration_expired() { let protocol_parameters = protocol_parameters(); let inputs = build_inputs( - [Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), - None, - None, - None, - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 50)), + [( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 50)), + }, None, )], Some(SlotIndex::from(100)), ); - let outputs = build_outputs([Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -151,39 +154,42 @@ fn two_outputs_one_expiration_expired() { let inputs = build_inputs( [ - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), - None, - None, - None, - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 200)), + ( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 200)), + }, None, ), - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), - None, - None, - None, - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 50)), + ( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 50)), + }, None, ), ], Some(SlotIndex::from(100)), ); - let outputs = build_outputs([Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -206,39 +212,42 @@ fn two_outputs_one_unexpired_one_missing() { let inputs = build_inputs( [ - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), - None, - None, - None, - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 200)), + ( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: 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, + ( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], Some(SlotIndex::from(100)), ); - let outputs = build_outputs([Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -261,49 +270,54 @@ fn two_outputs_two_expired() { let inputs = build_inputs( [ - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), - None, - None, - None, - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 100)), + ( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: 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((Address::try_from_bech32(BECH32_ADDRESS_ED25519_2).unwrap(), 100)), + ( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_2).unwrap(), 100)), + }, None, ), - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], Some(SlotIndex::from(200)), ); - let outputs = build_outputs([Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -326,39 +340,42 @@ fn two_outputs_two_expired_2() { let inputs = build_inputs( [ - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), - None, - None, - None, - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 100)), + ( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 100)), + }, None, ), - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), - None, - None, - None, - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_2).unwrap(), 100)), + ( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_2).unwrap(), 100)), + }, None, ), ], Some(SlotIndex::from(200)), ); - let outputs = build_outputs([Basic( - 4_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 4_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -382,28 +399,29 @@ fn expiration_expired_with_sdr() { let protocol_parameters = protocol_parameters(); let inputs = build_inputs( - [Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), - None, - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 50)), + [( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + native_token: None, + sender: None, + sdruc: Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), + timelock: None, + expiration: Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 50)), + }, None, )], Some(SlotIndex::from(100)), ); - let outputs = build_outputs([Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -424,28 +442,29 @@ fn expiration_expired_with_sdr_2() { let protocol_parameters = protocol_parameters(); let inputs = build_inputs( - [Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 50)), + [( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), + timelock: None, + expiration: Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 50)), + }, None, )], Some(SlotIndex::from(100)), ); - let outputs = build_outputs([Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -466,28 +485,29 @@ fn expiration_expired_with_sdr_and_timelock() { let protocol_parameters = protocol_parameters(); let inputs = build_inputs( - [Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), - None, - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 1_000_000)), - Some(50), - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 50)), + [( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + native_token: None, + sender: None, + sdruc: Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 1_000_000)), + timelock: Some(50), + expiration: Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 50)), + }, None, )], Some(SlotIndex::from(100)), ); - let outputs = build_outputs([Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -508,28 +528,29 @@ fn expiration_expired_with_sdr_and_timelock_2() { let protocol_parameters = protocol_parameters(); let inputs = build_inputs( - [Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), - None, - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), - Some(50), - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 50)), + [( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + native_token: None, + sender: None, + sdruc: Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), + timelock: Some(50), + expiration: Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 50)), + }, None, )], Some(SlotIndex::from(100)), ); - let outputs = build_outputs([Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -551,69 +572,78 @@ fn sender_in_expiration() { let inputs = build_inputs( [ - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: 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)), + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: 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, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], Some(SlotIndex::from(100)), ); - let outputs = build_outputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - Some(Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()), - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: Some(Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()), + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -638,28 +668,29 @@ fn sender_in_expiration_already_selected() { let protocol_parameters = protocol_parameters(); let inputs = build_inputs( - [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)), + [( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 50)), + }, None, )], Some(SlotIndex::from(100)), ); - let outputs = build_outputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - Some(Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()), - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: Some(Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()), + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -684,28 +715,29 @@ fn remainder_in_expiration() { let protocol_parameters = protocol_parameters(); let inputs = build_inputs( - [Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap(), - None, - None, - None, - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 50)), + [( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 50)), + }, None, )], Some(SlotIndex::from(100)), ); - let outputs = build_outputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - Some(Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()), - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: Some(Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()), + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -740,28 +772,29 @@ fn expiration_expired_non_ed25519_in_address_unlock_condition() { let protocol_parameters = protocol_parameters(); let inputs = build_inputs( - [Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap(), - None, - None, - None, - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 50)), + [( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 50)), + }, None, )], Some(SlotIndex::from(100)), ); - let outputs = build_outputs([Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -784,38 +817,41 @@ fn expiration_expired_only_account_addresses() { let inputs = build_inputs( [ - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap(), - None, - None, - None, - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap(), 50)), + ( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: 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, + ( + Account { + amount: 1_000_000, + account_id: account_id_1, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + }, None, ), ], Some(SlotIndex::from(100)), ); - let outputs = build_outputs([Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -837,28 +873,29 @@ fn one_nft_output_expiration_unexpired() { let nft_id_1 = NftId::from_str(NFT_ID_1).unwrap(); let inputs = build_inputs( - [Nft( - 2_000_000, - nft_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), - None, - None, - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 150)), + [( + Nft { + amount: 2_000_000, + nft_id: nft_id_1, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + sender: None, + issuer: None, + sdruc: None, + expiration: Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 150)), + }, None, )], Some(SlotIndex::from(100)), ); - let outputs = build_outputs([Nft( - 2_000_000, - nft_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Nft { + amount: 2_000_000, + nft_id: nft_id_1, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + sender: None, + issuer: None, + sdruc: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -880,28 +917,29 @@ fn one_nft_output_expiration_expired() { let nft_id_1 = NftId::from_str(NFT_ID_1).unwrap(); let inputs = build_inputs( - [Nft( - 2_000_000, - nft_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), - None, - None, - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 50)), + [( + Nft { + amount: 2_000_000, + nft_id: nft_id_1, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + sender: None, + issuer: None, + sdruc: None, + expiration: Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), 50)), + }, None, )], Some(SlotIndex::from(100)), ); - let outputs = build_outputs([Nft( - 2_000_000, - nft_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Nft { + amount: 2_000_000, + nft_id: nft_id_1, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + sender: None, + issuer: None, + sdruc: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), diff --git a/sdk/tests/client/input_selection/foundry_outputs.rs b/sdk/tests/client/input_selection/foundry_outputs.rs index 7ec2d88494..77a6536f1d 100644 --- a/sdk/tests/client/input_selection/foundry_outputs.rs +++ b/sdk/tests/client/input_selection/foundry_outputs.rs @@ -32,25 +32,27 @@ fn missing_input_account_for_foundry() { let account_id_2 = AccountId::from_str(ACCOUNT_ID_2).unwrap(); let inputs = build_inputs( - [Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + [( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, )], Some(SLOT_INDEX), ); - let outputs = build_outputs([Foundry( - 1_000_000, - account_id_2, - 1, - SimpleTokenScheme::new(0, 0, 10).unwrap(), - None, - )]); + let outputs = build_outputs([Foundry { + amount: 1_000_000, + account_id: account_id_2, + serial_number: 1, + token_scheme: SimpleTokenScheme::new(0, 0, 10).unwrap(), + native_token: None, + }]); let selected = InputSelection::new( inputs, @@ -112,34 +114,38 @@ fn minted_native_tokens_in_new_remainder() { let inputs = build_inputs( [ - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Account( - 1_000_000, - account_id_2, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, + ( + Account { + amount: 1_000_000, + account_id: account_id_2, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Foundry( - 1_000_000, - account_id_2, - 1, - SimpleTokenScheme::new(10, 0, 10).unwrap(), - None, - )]); + let outputs = build_outputs([Foundry { + amount: 1_000_000, + account_id: account_id_2, + serial_number: 1, + token_scheme: SimpleTokenScheme::new(10, 0, 10).unwrap(), + native_token: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -172,45 +178,48 @@ fn minted_native_tokens_in_provided_output() { let inputs = build_inputs( [ - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Account( - 1_000_000, - account_id_2, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, + ( + Account { + amount: 1_000_000, + account_id: account_id_2, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + }, None, ), ], Some(SLOT_INDEX), ); let outputs = build_outputs([ - Foundry( - 1_000_000, - account_id_2, - 1, - SimpleTokenScheme::new(100, 0, 100).unwrap(), - None, - ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((&token_id.to_string(), 100)), - None, - None, - None, - None, - None, - ), + Foundry { + amount: 1_000_000, + account_id: account_id_2, + serial_number: 1, + token_scheme: SimpleTokenScheme::new(100, 0, 100).unwrap(), + native_token: None, + }, + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((&token_id.to_string(), 100)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, ]); let selected = InputSelection::new( @@ -237,25 +246,30 @@ fn melt_native_tokens() { let mut inputs = build_inputs( [ - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Foundry( - 1_000_000, - account_id_1, - 1, - SimpleTokenScheme::new(10, 0, 10).unwrap(), - Some(( - "0x0811111111111111111111111111111111111111111111111111111111111111110100000000", - 10, - )), + ( + Foundry { + amount: 1_000_000, + account_id: account_id_1, + serial_number: 1, + token_scheme: SimpleTokenScheme::new(10, 0, 10).unwrap(), + native_token: Some(( + "0x0811111111111111111111111111111111111111111111111111111111111111110100000000", + 10, + )), + }, + None, ), ], Some(SLOT_INDEX), @@ -272,14 +286,13 @@ fn melt_native_tokens() { output_metadata: rand_output_metadata_with_id(rand_output_id_with_slot_index(SLOT_INDEX)), chain: None, }); - let outputs = build_outputs([Foundry( - 1_000_000, - account_id_1, - 1, - // Melt 5 native tokens - SimpleTokenScheme::new(10, 5, 10).unwrap(), - None, - )]); + let outputs = build_outputs([Foundry { + amount: 1_000_000, + account_id: account_id_1, + serial_number: 1, + token_scheme: SimpleTokenScheme::new(10, 5, 10).unwrap(), + native_token: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -310,19 +323,24 @@ fn destroy_foundry_with_account_state_transition() { let inputs = build_inputs( [ - Account( - 50_300, - account_id_2, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, + ( + Account { + amount: 50_300, + account_id: account_id_2, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + }, None, ), - Foundry( - 52_800, - account_id_2, - 1, - SimpleTokenScheme::new(10, 10, 10).unwrap(), + ( + Foundry { + amount: 52_800, + account_id: account_id_2, + serial_number: 1, + token_scheme: SimpleTokenScheme::new(10, 10, 10).unwrap(), + native_token: None, + }, None, ), ], @@ -358,34 +376,38 @@ fn destroy_foundry_with_account_burn() { let inputs = build_inputs( [ - Account( - 1_000_000, - account_id_2, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, + ( + Account { + amount: 1_000_000, + account_id: account_id_2, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + }, None, ), - Foundry( - 1_000_000, - account_id_2, - 1, - SimpleTokenScheme::new(10, 10, 10).unwrap(), + ( + Foundry { + amount: 1_000_000, + account_id: account_id_2, + serial_number: 1, + token_scheme: SimpleTokenScheme::new(10, 10, 10).unwrap(), + native_token: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -424,44 +446,50 @@ fn prefer_basic_to_foundry() { let inputs = build_inputs( [ - Account( - 1_000_000, - account_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, + ( + Account { + amount: 1_000_000, + account_id: account_id_1, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + }, None, ), - Foundry( - 1_000_000, - account_id_1, - 1, - SimpleTokenScheme::new(10, 10, 10).unwrap(), + ( + Foundry { + amount: 1_000_000, + account_id: account_id_1, + serial_number: 1, + token_scheme: SimpleTokenScheme::new(10, 10, 10).unwrap(), + native_token: None, + }, None, ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -485,21 +513,26 @@ fn simple_foundry_transition_basic_not_needed() { let mut inputs = build_inputs( [ - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Foundry( - 1_000_000, - account_id_1, - 1, - SimpleTokenScheme::new(10, 10, 10).unwrap(), + ( + Foundry { + amount: 1_000_000, + account_id: account_id_1, + serial_number: 1, + token_scheme: SimpleTokenScheme::new(10, 10, 10).unwrap(), + native_token: None, + }, None, ), ], @@ -518,13 +551,13 @@ fn simple_foundry_transition_basic_not_needed() { chain: None, }); - let outputs = build_outputs([Foundry( - 1_000_000, - account_id_1, - 1, - SimpleTokenScheme::new(10, 10, 10).unwrap(), - None, - )]); + let outputs = build_outputs([Foundry { + amount: 1_000_000, + account_id: account_id_1, + serial_number: 1, + token_scheme: SimpleTokenScheme::new(10, 10, 10).unwrap(), + native_token: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -564,21 +597,26 @@ fn simple_foundry_transition_basic_not_needed_with_remainder() { let mut inputs = build_inputs( [ - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Foundry( - 2_000_000, - account_id_1, - 1, - SimpleTokenScheme::new(10, 10, 10).unwrap(), + ( + Foundry { + amount: 2_000_000, + account_id: account_id_1, + serial_number: 1, + token_scheme: SimpleTokenScheme::new(10, 10, 10).unwrap(), + native_token: None, + }, None, ), ], @@ -596,13 +634,13 @@ fn simple_foundry_transition_basic_not_needed_with_remainder() { output_metadata: rand_output_metadata_with_id(rand_output_id_with_slot_index(SLOT_INDEX)), chain: None, }); - let outputs = build_outputs([Foundry( - 1_000_000, - account_id_1, - 1, - SimpleTokenScheme::new(10, 10, 10).unwrap(), - None, - )]); + let outputs = build_outputs([Foundry { + amount: 1_000_000, + account_id: account_id_1, + serial_number: 1, + token_scheme: SimpleTokenScheme::new(10, 10, 10).unwrap(), + native_token: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -720,12 +758,15 @@ fn mint_and_burn_at_the_same_time() { let token_id = TokenId::from(foundry_id); let mut inputs = build_inputs( - [Foundry( - 1_000_000, - account_id_1, - 1, - SimpleTokenScheme::new(100, 0, 200).unwrap(), - Some((&token_id.to_string(), 100)), + [( + Foundry { + amount: 1_000_000, + account_id: account_id_1, + serial_number: 1, + token_scheme: SimpleTokenScheme::new(100, 0, 200).unwrap(), + native_token: Some((&token_id.to_string(), 100)), + }, + None, )], Some(SLOT_INDEX), ); @@ -742,13 +783,13 @@ fn mint_and_burn_at_the_same_time() { chain: None, }); - let outputs = build_outputs([Foundry( - 1_000_000, - account_id_1, - 1, - SimpleTokenScheme::new(120, 0, 200).unwrap(), - Some((&token_id.to_string(), 110)), - )]); + let outputs = build_outputs([Foundry { + amount: 1_000_000, + account_id: account_id_1, + serial_number: 1, + token_scheme: SimpleTokenScheme::new(120, 0, 200).unwrap(), + native_token: Some((&token_id.to_string(), 110)), + }]); let selected = InputSelection::new( inputs.clone(), @@ -775,22 +816,27 @@ fn take_amount_from_account_and_foundry_to_fund_basic() { let mut inputs = build_inputs( [ - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Foundry( - 1_000_000, - account_id_1, - 1, - SimpleTokenScheme::new(100, 0, 200).unwrap(), - Some((&token_id.to_string(), 100)), + ( + Foundry { + amount: 1_000_000, + account_id: account_id_1, + serial_number: 1, + token_scheme: SimpleTokenScheme::new(100, 0, 200).unwrap(), + native_token: Some((&token_id.to_string(), 100)), + }, + None, ), ], Some(SLOT_INDEX), @@ -807,16 +853,15 @@ fn take_amount_from_account_and_foundry_to_fund_basic() { output_metadata: rand_output_metadata_with_id(rand_output_id_with_slot_index(SLOT_INDEX)), chain: None, }); - let outputs = build_outputs([Basic( - 3_200_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 3_200_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -848,31 +893,36 @@ fn create_native_token_but_burn_account() { let inputs = build_inputs( [ - Account( - 2_000_000, - account_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, + ( + Account { + amount: 2_000_000, + account_id: account_id_1, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + }, None, ), - Foundry( - 1_000_000, - account_id_1, - 1, - SimpleTokenScheme::new(0, 0, 100).unwrap(), + ( + Foundry { + amount: 1_000_000, + account_id: account_id_1, + serial_number: 1, + token_scheme: SimpleTokenScheme::new(0, 0, 100).unwrap(), + native_token: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Foundry( - 1_000_000, - account_id_1, - 1, - SimpleTokenScheme::new(100, 0, 100).unwrap(), - Some((&token_id.to_string(), 100)), - )]); + let outputs = build_outputs([Foundry { + amount: 1_000_000, + account_id: account_id_1, + serial_number: 1, + token_scheme: SimpleTokenScheme::new(100, 0, 100).unwrap(), + native_token: Some((&token_id.to_string(), 100)), + }]); let selected = InputSelection::new( inputs.clone(), @@ -910,31 +960,36 @@ fn melted_tokens_not_provided() { let inputs = build_inputs( [ - Account( - 2_000_000, - account_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, + ( + Account { + amount: 2_000_000, + account_id: account_id_1, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + }, None, ), - Foundry( - 1_000_000, - account_id_1, - 1, - SimpleTokenScheme::new(100, 0, 100).unwrap(), + ( + Foundry { + amount: 1_000_000, + account_id: account_id_1, + serial_number: 1, + token_scheme: SimpleTokenScheme::new(100, 0, 100).unwrap(), + native_token: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Foundry( - 1_000_000, - account_id_1, - 1, - SimpleTokenScheme::new(100, 100, 100).unwrap(), - None, - )]); + let outputs = build_outputs([Foundry { + amount: 1_000_000, + account_id: account_id_1, + serial_number: 1, + token_scheme: SimpleTokenScheme::new(100, 100, 100).unwrap(), + native_token: None, + }]); let selected = InputSelection::new( inputs, @@ -963,31 +1018,36 @@ fn burned_tokens_not_provided() { let inputs = build_inputs( [ - Account( - 2_000_000, - account_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, + ( + Account { + amount: 2_000_000, + account_id: account_id_1, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + }, None, ), - Foundry( - 1_000_000, - account_id_1, - 1, - SimpleTokenScheme::new(100, 0, 100).unwrap(), + ( + Foundry { + amount: 1_000_000, + account_id: account_id_1, + serial_number: 1, + token_scheme: SimpleTokenScheme::new(100, 0, 100).unwrap(), + native_token: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Foundry( - 1_000_000, - account_id_1, - 1, - SimpleTokenScheme::new(100, 0, 100).unwrap(), - None, - )]); + let outputs = build_outputs([Foundry { + amount: 1_000_000, + account_id: account_id_1, + serial_number: 1, + token_scheme: SimpleTokenScheme::new(100, 0, 100).unwrap(), + native_token: None, + }]); let selected = InputSelection::new( inputs, @@ -1014,11 +1074,14 @@ fn foundry_in_outputs_and_required() { let account_id_2 = AccountId::from_str(ACCOUNT_ID_2).unwrap(); let mut inputs = build_inputs( - [Foundry( - 1_000_000, - account_id_2, - 1, - SimpleTokenScheme::new(0, 0, 10).unwrap(), + [( + Foundry { + amount: 1_000_000, + account_id: account_id_2, + serial_number: 1, + token_scheme: SimpleTokenScheme::new(0, 0, 10).unwrap(), + native_token: None, + }, None, )], Some(SLOT_INDEX), @@ -1035,13 +1098,13 @@ fn foundry_in_outputs_and_required() { output_metadata: rand_output_metadata_with_id(rand_output_id_with_slot_index(SLOT_INDEX)), chain: None, }); - let outputs = build_outputs([Foundry( - 1_000_000, - account_id_2, - 1, - SimpleTokenScheme::new(0, 0, 10).unwrap(), - None, - )]); + let outputs = build_outputs([Foundry { + amount: 1_000_000, + account_id: account_id_2, + serial_number: 1, + token_scheme: SimpleTokenScheme::new(0, 0, 10).unwrap(), + native_token: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -1073,22 +1136,27 @@ fn melt_and_burn_native_tokens() { let mut inputs = build_inputs( [ - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Foundry( - 1_000_000, - account_id, - 1, - SimpleTokenScheme::new(1000, 0, 1000).unwrap(), - Some((&token_id.to_string(), 1000)), + ( + Foundry { + amount: 1_000_000, + account_id, + serial_number: 1, + token_scheme: SimpleTokenScheme::new(1000, 0, 1000).unwrap(), + native_token: Some((&token_id.to_string(), 1000)), + }, + None, ), ], Some(SLOT_INDEX), @@ -1105,14 +1173,13 @@ fn melt_and_burn_native_tokens() { output_metadata: rand_output_metadata_with_id(rand_output_id_with_slot_index(SLOT_INDEX)), chain: None, }); - let outputs = build_outputs([Foundry( - 1_000_000, + let outputs = build_outputs([Foundry { + amount: 1_000_000, account_id, - 1, - // Melt 123 native tokens - SimpleTokenScheme::new(1000, 123, 1000).unwrap(), - None, - )]); + serial_number: 1, + token_scheme: SimpleTokenScheme::new(1000, 123, 1000).unwrap(), + native_token: None, + }]); let selected = InputSelection::new( inputs.clone(), diff --git a/sdk/tests/client/input_selection/native_tokens.rs b/sdk/tests/client/input_selection/native_tokens.rs index 688b2f893c..ce62dbd0e1 100644 --- a/sdk/tests/client/input_selection/native_tokens.rs +++ b/sdk/tests/client/input_selection/native_tokens.rs @@ -21,39 +21,42 @@ fn two_native_tokens_one_needed() { let inputs = build_inputs( [ - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_1, 150)), - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_1, 150)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_2, 100)), - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_2, 100)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_1, 150)), - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_1, 150)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -76,50 +79,52 @@ fn two_native_tokens_both_needed_plus_remainder() { let inputs = build_inputs( [ - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_1, 100)), - None, - None, - None, - None, + ( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_1, 100)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_2, 150)), - None, - None, - None, - None, + ( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_2, 150)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); let outputs = build_outputs([ - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_1, 100)), - None, - None, - None, - None, - None, - ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_2, 100)), - None, - None, - None, - None, - None, - ), + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_1, 100)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_2, 100)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, ]); let selected = InputSelection::new( @@ -153,49 +158,54 @@ fn three_inputs_two_needed_plus_remainder() { let inputs = build_inputs( [ - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_1, 100)), - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_1, 100)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_1, 100)), - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_1, 100)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_1, 100)), - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_1, 100)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_1, 120)), - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_1, 120)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs, @@ -228,49 +238,54 @@ fn three_inputs_two_needed_no_remainder() { let inputs = build_inputs( [ - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_1, 100)), - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_1, 100)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_1, 100)), - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_1, 100)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_1, 100)), - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_1, 100)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_1, 200)), - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_1, 200)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs, @@ -291,28 +306,29 @@ fn insufficient_native_tokens_one_input() { let protocol_parameters = protocol_parameters(); let inputs = build_inputs( - [Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_1, 100)), - None, - None, - None, - None, + [( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_1, 100)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, )], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_1, 150)), - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_1, 150)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs, @@ -338,49 +354,54 @@ fn insufficient_native_tokens_three_inputs() { let inputs = build_inputs( [ - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_1, 100)), - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_1, 100)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_1, 100)), - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_1, 100)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_1, 100)), - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_1, 100)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_1, 301)), - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_1, 301)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs, @@ -406,39 +427,42 @@ fn burn_and_send_at_the_same_time() { let inputs = build_inputs( [ - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_1, 100)), - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_1, 100)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_2, 100)), - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_2, 100)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_1, 50)), - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_1, 50)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -475,14 +499,16 @@ fn burn_one_input_no_output() { let protocol_parameters = protocol_parameters(); let inputs = build_inputs( - [Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_1, 100)), - None, - None, - None, - None, + [( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_1, 100)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, )], Some(SLOT_INDEX), @@ -515,39 +541,42 @@ fn multiple_native_tokens() { let inputs = build_inputs( [ - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_1, 100)), - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_1, 100)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_2, 100)), - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_2, 100)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_1, 100)), - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_1, 100)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -569,28 +598,29 @@ fn insufficient_native_tokens() { let protocol_parameters = protocol_parameters(); let inputs = build_inputs( - [Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + [( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, )], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_1, 150)), - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_1, 150)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs, @@ -615,28 +645,29 @@ fn insufficient_native_tokens_2() { let protocol_parameters = protocol_parameters(); let inputs = build_inputs( - [Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_1, 100)), - None, - None, - None, - None, + [( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_1, 100)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, )], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_1, 150)), - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_1, 150)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs, @@ -661,28 +692,29 @@ fn insufficient_amount_for_remainder() { let protocol_parameters = protocol_parameters(); let inputs = build_inputs( - [Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_1, 100)), - None, - None, - None, - None, + [( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_1, 100)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, )], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_1, 50)), - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_1, 50)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs, @@ -707,28 +739,29 @@ fn single_output_native_token_no_remainder() { let protocol_parameters = protocol_parameters(); let inputs = build_inputs( - [Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_1, 100)), - None, - None, - None, - None, + [( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_1, 100)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, )], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_1, 100)), - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_1, 100)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -749,28 +782,29 @@ fn single_output_native_token_remainder_1() { let protocol_parameters = protocol_parameters(); let inputs = build_inputs( - [Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_1, 100)), - None, - None, - None, - None, + [( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_1, 100)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, )], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 500_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_1, 50)), - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 500_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_1, 50)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -798,28 +832,29 @@ fn single_output_native_token_remainder_2() { let protocol_parameters = protocol_parameters(); let inputs = build_inputs( - [Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_1, 100)), - None, - None, - None, - None, + [( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_1, 100)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, )], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 500_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_1, 100)), - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 500_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_1, 100)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -848,39 +883,42 @@ fn two_basic_outputs_1() { let inputs = build_inputs( [ - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_1, 100)), - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_1, 100)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_1, 200)), - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_1, 200)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 500_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 500_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -910,39 +948,42 @@ fn two_basic_outputs_2() { let inputs = build_inputs( [ - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_1, 100)), - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_1, 100)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_1, 200)), - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_1, 200)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 500_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_1, 50)), - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 500_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_1, 50)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -972,39 +1013,42 @@ fn two_basic_outputs_3() { let inputs = build_inputs( [ - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_1, 100)), - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_1, 100)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_1, 200)), - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_1, 200)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 500_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_1, 75)), - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 500_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_1, 75)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -1034,39 +1078,42 @@ fn two_basic_outputs_4() { let inputs = build_inputs( [ - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_1, 100)), - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_1, 100)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_1, 200)), - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_1, 200)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 500_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_1, 100)), - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 500_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_1, 100)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -1096,39 +1143,42 @@ fn two_basic_outputs_5() { let inputs = build_inputs( [ - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_1, 100)), - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_1, 100)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_1, 200)), - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_1, 200)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 500_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_1, 100)), - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 500_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_1, 100)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -1158,39 +1208,42 @@ fn two_basic_outputs_6() { let inputs = build_inputs( [ - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_1, 100)), - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_1, 100)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_1, 200)), - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_1, 200)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 500_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_1, 250)), - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 500_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_1, 250)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -1219,39 +1272,42 @@ fn two_basic_outputs_7() { let inputs = build_inputs( [ - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_1, 100)), - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_1, 100)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_1, 200)), - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_1, 200)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 500_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_1, 300)), - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 500_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_1, 300)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -1280,39 +1336,42 @@ fn two_basic_outputs_8() { let inputs = build_inputs( [ - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_1, 100)), - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_1, 100)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_1, 200)), - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_1, 200)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 500_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_1, 350)), - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 500_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_1, 350)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs, @@ -1338,39 +1397,42 @@ fn two_basic_outputs_native_tokens_not_needed() { let inputs = build_inputs( [ - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_1, 100)), - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_1, 100)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 500_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 500_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -1400,59 +1462,66 @@ fn multiple_remainders() { let inputs = build_inputs( [ - Basic( - 5_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_1, 100)), - None, - None, - None, - None, + ( + Basic { + amount: 5_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_1, 100)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Basic( - 5_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_1, 100)), - None, - None, - None, - None, + ( + Basic { + amount: 5_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_1, 100)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Basic( - 5_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_1, 100)), - None, - None, - None, - None, + ( + Basic { + amount: 5_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_1, 100)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Basic( - 5_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some((TOKEN_ID_2, 100)), - None, - None, - None, - None, + ( + Basic { + amount: 5_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: Some((TOKEN_ID_2, 100)), + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 15_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 15_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), diff --git a/sdk/tests/client/input_selection/nft_outputs.rs b/sdk/tests/client/input_selection/nft_outputs.rs index 9c6748a316..115604d631 100644 --- a/sdk/tests/client/input_selection/nft_outputs.rs +++ b/sdk/tests/client/input_selection/nft_outputs.rs @@ -30,28 +30,29 @@ fn input_nft_eq_output_nft() { let nft_id_2 = NftId::from_str(NFT_ID_2).unwrap(); let inputs = build_inputs( - [Nft( - 1_000_000, - nft_id_2, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, + [( + Nft { + amount: 1_000_000, + nft_id: nft_id_2, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + sdruc: None, + expiration: None, + }, None, )], Some(SLOT_INDEX), ); - let outputs = build_outputs([Nft( - 1_000_000, - nft_id_2, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Nft { + amount: 1_000_000, + nft_id: nft_id_2, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + sdruc: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -73,29 +74,30 @@ fn transition_nft_id_zero() { let nft_id_0 = NftId::from_str(NFT_ID_0).unwrap(); let inputs = build_inputs( - [Nft( - 1_000_000, - nft_id_0, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, + [( + Nft { + amount: 1_000_000, + nft_id: nft_id_0, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + sdruc: None, + expiration: None, + }, None, )], Some(SLOT_INDEX), ); let nft_id = NftId::from(inputs[0].output_id()); - let outputs = build_outputs([Nft( - 1_000_000, + let outputs = build_outputs([Nft { + amount: 1_000_000, nft_id, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - )]); + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + sdruc: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -205,28 +207,29 @@ fn mint_nft() { let nft_id_0 = NftId::from_str(NFT_ID_0).unwrap(); let inputs = build_inputs( - [Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + [( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, )], Some(SLOT_INDEX), ); - let outputs = build_outputs([Nft( - 1_000_000, - nft_id_0, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Nft { + amount: 1_000_000, + nft_id: nft_id_0, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + sdruc: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -257,28 +260,29 @@ fn burn_nft() { let nft_id_2 = NftId::from_str(NFT_ID_2).unwrap(); let inputs = build_inputs( - [Nft( - 2_000_000, - nft_id_2, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, + [( + Nft { + amount: 2_000_000, + nft_id: nft_id_2, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + sdruc: None, + expiration: None, + }, None, )], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -346,28 +350,29 @@ fn missing_input_for_nft_output() { let nft_id_2 = NftId::from_str(NFT_ID_2).unwrap(); let inputs = build_inputs( - [Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + [( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, )], Some(SLOT_INDEX), ); - let outputs = build_outputs([Nft( - 1_000_000, - nft_id_2, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Nft { + amount: 1_000_000, + nft_id: nft_id_2, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + sdruc: None, + expiration: None, + }]); let selected = InputSelection::new( inputs, @@ -390,28 +395,29 @@ fn missing_input_for_nft_output_but_created() { let nft_id_0 = NftId::from_str(NFT_ID_0).unwrap(); let inputs = build_inputs( - [Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + [( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, )], Some(SLOT_INDEX), ); - let outputs = build_outputs([Nft( - 1_000_000, - nft_id_0, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Nft { + amount: 1_000_000, + nft_id: nft_id_0, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + sdruc: None, + expiration: None, + }]); let selected = InputSelection::new( inputs, @@ -432,50 +438,52 @@ fn nft_in_output_and_sender() { let inputs = build_inputs( [ - Nft( - 1_000_000, - nft_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, + ( + Nft { + amount: 1_000_000, + nft_id: nft_id_1, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + sdruc: None, + expiration: None, + }, None, ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); let outputs = build_outputs([ - Nft( - 1_000_000, - nft_id_1, - 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, - Some(Address::try_from_bech32(BECH32_ADDRESS_NFT_1).unwrap()), - None, - None, - None, - None, - ), + Nft { + amount: 1_000_000, + nft_id: nft_id_1, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + sdruc: None, + expiration: None, + }, + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: Some(Address::try_from_bech32(BECH32_ADDRESS_NFT_1).unwrap()), + sdruc: None, + timelock: None, + expiration: None, + }, ]); let selected = InputSelection::new( @@ -506,28 +514,29 @@ fn missing_ed25519_sender() { let nft_id_2 = NftId::from_str(NFT_ID_2).unwrap(); let inputs = build_inputs( - [Nft( - 1_000_000, - nft_id_2, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, + [( + Nft { + amount: 1_000_000, + nft_id: nft_id_2, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + sdruc: None, + expiration: None, + }, None, )], Some(SLOT_INDEX), ); - let outputs = build_outputs([Nft( - 1_000_000, - nft_id_2, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some(Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()), - None, - None, - None, - None, - )]); + let outputs = build_outputs([Nft { + amount: 1_000_000, + nft_id: nft_id_2, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: Some(Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()), + issuer: None, + sdruc: None, + expiration: None, + }]); let selected = InputSelection::new( inputs, @@ -550,28 +559,29 @@ fn missing_ed25519_issuer_created() { let nft_id_0 = NftId::from_str(NFT_ID_0).unwrap(); let inputs = build_inputs( - [Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + [( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, )], Some(SLOT_INDEX), ); - let outputs = build_outputs([Nft( - 1_000_000, - nft_id_0, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - Some(Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()), - None, - None, - None, - )]); + let outputs = build_outputs([Nft { + amount: 1_000_000, + nft_id: nft_id_0, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: Some(Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()), + sdruc: None, + expiration: None, + }]); let selected = InputSelection::new( inputs, @@ -594,28 +604,29 @@ fn missing_ed25519_issuer_transition() { let nft_id_1 = NftId::from_str(NFT_ID_1).unwrap(); let inputs = build_inputs( - [Nft( - 1_000_000, - nft_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - Some(Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()), - None, - None, + [( + Nft { + amount: 1_000_000, + nft_id: nft_id_1, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: Some(Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()), + sdruc: None, + expiration: None, + }, None, )], Some(SLOT_INDEX), ); - let outputs = build_outputs([Nft( - 1_000_000, - nft_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - Some(Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()), - None, - None, - None, - )]); + let outputs = build_outputs([Nft { + amount: 1_000_000, + nft_id: nft_id_1, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: Some(Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap()), + sdruc: None, + expiration: None, + }]); let selected = InputSelection::new( inputs, @@ -635,28 +646,29 @@ fn missing_account_sender() { let nft_id_2 = NftId::from_str(NFT_ID_2).unwrap(); let inputs = build_inputs( - [Nft( - 1_000_000, - nft_id_2, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, + [( + Nft { + amount: 1_000_000, + nft_id: nft_id_2, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + sdruc: None, + expiration: None, + }, None, )], Some(SLOT_INDEX), ); - let outputs = build_outputs([Nft( - 1_000_000, - nft_id_2, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some(Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap()), - None, - None, - None, - None, - )]); + let outputs = build_outputs([Nft { + amount: 1_000_000, + nft_id: nft_id_2, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: Some(Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap()), + issuer: None, + sdruc: None, + expiration: None, + }]); let selected = InputSelection::new( inputs, @@ -679,28 +691,29 @@ fn missing_account_issuer_created() { let nft_id_0 = NftId::from_str(NFT_ID_0).unwrap(); let inputs = build_inputs( - [Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + [( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, )], Some(SLOT_INDEX), ); - let outputs = build_outputs([Nft( - 1_000_000, - nft_id_0, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - Some(Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap()), - None, - None, - None, - )]); + let outputs = build_outputs([Nft { + amount: 1_000_000, + nft_id: nft_id_0, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: Some(Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap()), + sdruc: None, + expiration: None, + }]); let selected = InputSelection::new( inputs, @@ -723,28 +736,29 @@ fn missing_account_issuer_transition() { let nft_id_2 = NftId::from_str(NFT_ID_2).unwrap(); let inputs = build_inputs( - [Nft( - 1_000_000, - nft_id_2, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - Some(Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap()), - None, - None, + [( + Nft { + amount: 1_000_000, + nft_id: nft_id_2, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: Some(Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap()), + sdruc: None, + expiration: None, + }, None, )], Some(SLOT_INDEX), ); - let outputs = build_outputs([Nft( - 1_000_000, - nft_id_2, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - Some(Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap()), - None, - None, - None, - )]); + let outputs = build_outputs([Nft { + amount: 1_000_000, + nft_id: nft_id_2, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: Some(Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap()), + sdruc: None, + expiration: None, + }]); let selected = InputSelection::new( inputs, @@ -764,28 +778,29 @@ fn missing_nft_sender() { let nft_id_2 = NftId::from_str(NFT_ID_2).unwrap(); let inputs = build_inputs( - [Nft( - 1_000_000, - nft_id_2, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, + [( + Nft { + amount: 1_000_000, + nft_id: nft_id_2, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + sdruc: None, + expiration: None, + }, None, )], Some(SLOT_INDEX), ); - let outputs = build_outputs([Nft( - 1_000_000, - nft_id_2, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - Some(Address::try_from_bech32(BECH32_ADDRESS_NFT_1).unwrap()), - None, - None, - None, - None, - )]); + let outputs = build_outputs([Nft { + amount: 1_000_000, + nft_id: nft_id_2, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: Some(Address::try_from_bech32(BECH32_ADDRESS_NFT_1).unwrap()), + issuer: None, + sdruc: None, + expiration: None, + }]); let selected = InputSelection::new( inputs, @@ -808,28 +823,29 @@ fn missing_nft_issuer_created() { let nft_id_0 = NftId::from_str(NFT_ID_0).unwrap(); let inputs = build_inputs( - [Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + [( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, )], Some(SLOT_INDEX), ); - let outputs = build_outputs([Nft( - 1_000_000, - nft_id_0, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - Some(Address::try_from_bech32(BECH32_ADDRESS_NFT_1).unwrap()), - None, - None, - None, - )]); + let outputs = build_outputs([Nft { + amount: 1_000_000, + nft_id: nft_id_0, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: Some(Address::try_from_bech32(BECH32_ADDRESS_NFT_1).unwrap()), + sdruc: None, + expiration: None, + }]); let selected = InputSelection::new( inputs, @@ -852,28 +868,29 @@ fn missing_nft_issuer_transition() { let nft_id_2 = NftId::from_str(NFT_ID_2).unwrap(); let inputs = build_inputs( - [Nft( - 1_000_000, - nft_id_2, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - Some(Address::try_from_bech32(BECH32_ADDRESS_NFT_1).unwrap()), - None, - None, + [( + Nft { + amount: 1_000_000, + nft_id: nft_id_2, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: Some(Address::try_from_bech32(BECH32_ADDRESS_NFT_1).unwrap()), + sdruc: None, + expiration: None, + }, None, )], Some(SLOT_INDEX), ); - let outputs = build_outputs([Nft( - 1_000_000, - nft_id_2, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - Some(Address::try_from_bech32(BECH32_ADDRESS_NFT_1).unwrap()), - None, - None, - None, - )]); + let outputs = build_outputs([Nft { + amount: 1_000_000, + nft_id: nft_id_2, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: Some(Address::try_from_bech32(BECH32_ADDRESS_NFT_1).unwrap()), + sdruc: None, + expiration: None, + }]); let selected = InputSelection::new( inputs, @@ -894,39 +911,42 @@ fn increase_nft_amount() { let inputs = build_inputs( [ - Nft( - 2_000_000, - nft_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, + ( + Nft { + amount: 2_000_000, + nft_id: nft_id_1, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + sdruc: None, + expiration: None, + }, None, ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Nft( - 3_000_000, - nft_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Nft { + amount: 3_000_000, + nft_id: nft_id_1, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + sdruc: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -949,39 +969,42 @@ fn decrease_nft_amount() { let inputs = build_inputs( [ - Nft( - 2_000_000, - nft_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, + ( + Nft { + amount: 2_000_000, + nft_id: nft_id_1, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + sdruc: None, + expiration: None, + }, None, ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Nft( - 1_000_000, - nft_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Nft { + amount: 1_000_000, + nft_id: nft_id_1, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + sdruc: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -1016,39 +1039,42 @@ fn prefer_basic_to_nft() { let inputs = build_inputs( [ - Nft( - 2_000_000, - nft_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, + ( + Nft { + amount: 2_000_000, + nft_id: nft_id_1, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + sdruc: None, + expiration: None, + }, None, ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -1072,39 +1098,42 @@ fn take_amount_from_nft_to_fund_basic() { let inputs = build_inputs( [ - Nft( - 2_000_000, - nft_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, + ( + Nft { + amount: 2_000_000, + nft_id: nft_id_1, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + sdruc: None, + expiration: None, + }, None, ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 1_200_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 1_200_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -1140,39 +1169,42 @@ fn nft_burn_should_validate_nft_sender() { let inputs = build_inputs( [ - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Nft( - 1_000_000, - nft_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, + ( + Nft { + amount: 1_000_000, + nft_id: nft_id_1, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + sdruc: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 3_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - Some(Address::try_from_bech32(BECH32_ADDRESS_NFT_1).unwrap()), - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 3_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: Some(Address::try_from_bech32(BECH32_ADDRESS_NFT_1).unwrap()), + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -1196,39 +1228,42 @@ fn nft_burn_should_validate_nft_address() { let inputs = build_inputs( [ - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_NFT_1).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_NFT_1).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Nft( - 1_000_000, - nft_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, + ( + Nft { + amount: 1_000_000, + nft_id: nft_id_1, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + sdruc: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 3_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 3_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -1251,28 +1286,29 @@ fn transitioned_zero_nft_id_no_longer_is_zero() { let nft_id_0 = NftId::from_str(NFT_ID_0).unwrap(); let inputs = build_inputs( - [Nft( - 2_000_000, - nft_id_0, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, + [( + Nft { + amount: 2_000_000, + nft_id: nft_id_0, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + sdruc: None, + expiration: None, + }, None, )], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), diff --git a/sdk/tests/client/input_selection/outputs.rs b/sdk/tests/client/input_selection/outputs.rs index 4d2a94ba0a..d04deec221 100644 --- a/sdk/tests/client/input_selection/outputs.rs +++ b/sdk/tests/client/input_selection/outputs.rs @@ -20,16 +20,15 @@ fn no_inputs() { let protocol_parameters = protocol_parameters(); let inputs = Vec::new(); - let outputs = build_outputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs, @@ -48,14 +47,16 @@ fn no_outputs() { let protocol_parameters = protocol_parameters(); let inputs = build_inputs( - [Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + [( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, )], None, @@ -79,14 +80,16 @@ fn no_outputs_but_required_input() { let protocol_parameters = protocol_parameters(); let inputs = build_inputs( - [Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + [( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, )], Some(SLOT_INDEX), @@ -121,12 +124,14 @@ fn no_outputs_but_burn() { let account_id_2 = AccountId::from_str(ACCOUNT_ID_2).unwrap(); let inputs = build_inputs( - [Account( - 2_000_000, - account_id_2, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, + [( + Account { + amount: 2_000_000, + account_id: account_id_2, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + }, None, )], Some(SLOT_INDEX), @@ -159,28 +164,29 @@ fn no_address_provided() { let protocol_parameters = protocol_parameters(); let inputs = build_inputs( - [Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + [( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, )], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new(inputs, outputs, [], SLOT_INDEX, protocol_parameters).select(); @@ -192,28 +198,29 @@ fn no_matching_address_provided() { let protocol_parameters = protocol_parameters(); let inputs = build_inputs( - [Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + [( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, )], None, ); - let outputs = build_outputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs, @@ -233,39 +240,42 @@ fn two_addresses_one_missing() { let inputs = build_inputs( [ - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs, @@ -291,39 +301,42 @@ fn two_addresses() { let inputs = build_inputs( [ - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), diff --git a/sdk/tests/client/input_selection/storage_deposit_return.rs b/sdk/tests/client/input_selection/storage_deposit_return.rs index 3b451de41a..9d44ae17b5 100644 --- a/sdk/tests/client/input_selection/storage_deposit_return.rs +++ b/sdk/tests/client/input_selection/storage_deposit_return.rs @@ -21,28 +21,29 @@ fn sdruc_output_not_provided_no_remainder() { let protocol_parameters = protocol_parameters(); let inputs = build_inputs( - [Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), - None, - None, + [( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), + timelock: None, + expiration: None, + }, None, )], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -74,39 +75,39 @@ fn sdruc_output_provided_no_remainder() { let protocol_parameters = protocol_parameters(); let inputs = build_inputs( - [Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), - None, - None, + [( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), + timelock: None, + expiration: None, + }, None, )], Some(SLOT_INDEX), ); let outputs = build_outputs([ - 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, - ), + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, ]); let selected = InputSelection::new( @@ -128,28 +129,29 @@ fn sdruc_output_provided_remainder() { let protocol_parameters = protocol_parameters(); let inputs = build_inputs( - [Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), - None, - None, + [( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), + timelock: None, + expiration: None, + }, None, )], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -182,39 +184,42 @@ fn two_sdrucs_to_the_same_address_both_needed() { let inputs = build_inputs( [ - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), - None, - None, + ( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), + timelock: None, + expiration: None, + }, None, ), - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), - None, - None, + ( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), + timelock: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -247,39 +252,42 @@ fn two_sdrucs_to_the_same_address_one_needed() { let inputs = build_inputs( [ - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), - None, - None, + ( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), + timelock: None, + expiration: None, + }, None, ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), + timelock: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -313,39 +321,42 @@ fn two_sdrucs_to_different_addresses_both_needed() { let inputs = build_inputs( [ - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), - None, - None, + ( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), + timelock: None, + expiration: None, + }, None, ), - Basic( - 2_000_000, - 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, + ( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_2).unwrap(), 1_000_000)), + timelock: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -384,39 +395,42 @@ fn two_sdrucs_to_different_addresses_one_needed() { let inputs = build_inputs( [ - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), - None, - None, + ( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), + timelock: None, + expiration: None, + }, None, ), - Basic( - 1_000_000, - 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, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_2).unwrap(), 1_000_000)), + timelock: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -449,28 +463,29 @@ fn insufficient_amount_because_of_sdruc() { let protocol_parameters = protocol_parameters(); let inputs = build_inputs( - [Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), - None, - None, + [( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), 1_000_000)), + timelock: None, + expiration: None, + }, None, )], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs, @@ -496,39 +511,42 @@ fn useless_sdruc_required_for_sender_feature() { let inputs = build_inputs( [ - Basic( - 1_000_000, - 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, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_2).unwrap(), 1_000_000)), + timelock: None, + expiration: None, + }, None, ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - Some(Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()), - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: Some(Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap()), + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -565,37 +583,40 @@ fn sdruc_required_non_ed25519_in_address_unlock() { let inputs = build_inputs( [ - Basic( - 2_000_000, - 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, + ( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap(), + native_token: None, + sender: None, + sdruc: Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_2).unwrap(), 1_000_000)), + timelock: None, + expiration: None, + }, None, ), - Account( - 1_000_000, - account_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, + ( + Account { + amount: 1_000_000, + account_id: account_id_1, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_2).unwrap(), - None, - Some(Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap()), - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_2).unwrap(), + native_token: None, + sender: Some(Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap()), + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -629,47 +650,52 @@ fn useless_sdruc_non_ed25519_in_address_unlock() { let inputs = build_inputs( [ - Basic( - 1_000_000, - 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, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap(), + native_token: None, + sender: None, + sdruc: Some((Address::try_from_bech32(BECH32_ADDRESS_ED25519_2).unwrap(), 1_000_000)), + timelock: None, + expiration: None, + }, None, ), - Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ACCOUNT_1).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), - Account( - 1_000_000, - account_id_1, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, + ( + Account { + amount: 1_000_000, + account_id: account_id_1, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + sender: None, + issuer: None, + }, None, ), ], Some(SLOT_INDEX), ); - let outputs = build_outputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_2).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_2).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), diff --git a/sdk/tests/client/input_selection/timelock.rs b/sdk/tests/client/input_selection/timelock.rs index a57655846c..d1decc4387 100644 --- a/sdk/tests/client/input_selection/timelock.rs +++ b/sdk/tests/client/input_selection/timelock.rs @@ -16,28 +16,29 @@ fn one_output_timelock_not_expired() { let protocol_parameters = protocol_parameters(); let inputs = build_inputs( - [Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - Some(200), - None, + [( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: Some(200), + expiration: None, + }, None, )], None, ); - let outputs = build_outputs([Basic( - 1_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 1_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs, @@ -56,28 +57,29 @@ fn timelock_equal_timestamp() { let protocol_parameters = protocol_parameters(); let inputs = build_inputs( - [Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - Some(200), - None, + [( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: Some(200), + expiration: None, + }, None, )], Some(SlotIndex::from(200)), ); - let outputs = build_outputs([Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -99,39 +101,42 @@ fn two_outputs_one_timelock_expired() { let inputs = build_inputs( [ - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - Some(200), - None, + ( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: Some(200), + expiration: None, + }, None, ), - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - Some(50), - None, + ( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: Some(50), + expiration: None, + }, None, ), ], Some(SlotIndex::from(100)), ); - let outputs = build_outputs([Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -154,39 +159,42 @@ fn two_outputs_one_timelocked_one_missing() { let inputs = build_inputs( [ - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - Some(200), - None, + ( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: Some(200), + expiration: None, + }, None, ), - Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, ), ], Some(SlotIndex::from(100)), ); - let outputs = build_outputs([Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), @@ -208,28 +216,29 @@ fn one_output_timelock_expired() { let protocol_parameters = protocol_parameters(); let inputs = build_inputs( - [Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), - None, - None, - None, - Some(50), - None, + [( + Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_0).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: Some(50), + expiration: None, + }, None, )], Some(SlotIndex::from(100)), ); - let outputs = build_outputs([Basic( - 2_000_000, - Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), - None, - None, - None, - None, - None, - None, - )]); + let outputs = build_outputs([Basic { + amount: 2_000_000, + address: Address::try_from_bech32(BECH32_ADDRESS_ED25519_1).unwrap(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let selected = InputSelection::new( inputs.clone(), diff --git a/sdk/tests/client/mod.rs b/sdk/tests/client/mod.rs index ff7e2d1bb7..c09a695be5 100644 --- a/sdk/tests/client/mod.rs +++ b/sdk/tests/client/mod.rs @@ -28,8 +28,9 @@ use iota_sdk::{ AddressUnlockCondition, ExpirationUnlockCondition, ImmutableAccountAddressUnlockCondition, StorageDepositReturnUnlockCondition, TimelockUnlockCondition, UnlockCondition, }, - AccountId, AccountOutputBuilder, BasicOutputBuilder, Feature, FoundryOutputBuilder, NativeToken, NftId, - NftOutputBuilder, Output, OutputId, SimpleTokenScheme, TokenId, TokenScheme, + AccountId, AccountOutputBuilder, BasicOutputBuilder, DelegationId, DelegationOutputBuilder, Feature, + FoundryOutputBuilder, NativeToken, NftId, NftOutputBuilder, Output, OutputId, SimpleTokenScheme, TokenId, + TokenScheme, }, rand::{ output::rand_output_metadata_with_id, @@ -61,166 +62,188 @@ const SLOT_INDEX: SlotIndex = SlotIndex(10); #[derive(Debug, Clone)] enum Build<'a> { - Basic( - u64, - Address, - Option<(&'a str, u64)>, - Option
, - Option<(Address, u64)>, - Option, - Option<(Address, u32)>, - Option, - ), - Nft( - u64, - NftId, - Address, - Option
, - Option
, - Option<(Address, u64)>, - Option<(Address, u32)>, - Option, - ), - Account(u64, AccountId, Address, Option
, Option
, Option), - Foundry(u64, AccountId, u32, SimpleTokenScheme, Option<(&'a str, u64)>), -} - -fn build_basic_output( - amount: u64, - address: Address, - native_token: Option<(&str, u64)>, - sender: Option
, - sdruc: Option<(Address, u64)>, - timelock: Option, - expiration: Option<(Address, u32)>, -) -> Output { - let mut builder = - 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(sender) = sender { - builder = builder.add_feature(SenderFeature::new(sender.clone())); - } - - if let Some((address, amount)) = sdruc { - builder = - builder.add_unlock_condition(StorageDepositReturnUnlockCondition::new(address.clone(), amount).unwrap()); - } - - if let Some(timelock) = timelock { - builder = builder.add_unlock_condition(TimelockUnlockCondition::new(timelock).unwrap()); - } - - if let Some((address, timestamp)) = expiration { - builder = builder.add_unlock_condition(ExpirationUnlockCondition::new(address.clone(), timestamp).unwrap()); - } - - builder.finish_output().unwrap() -} - -fn build_nft_output( - amount: u64, - nft_id: NftId, - 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(address.clone())); - - if let Some(sender) = sender { - builder = builder.add_feature(SenderFeature::new(sender.clone())); - } - - 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.clone(), amount).unwrap()); - } - - if let Some((address, timestamp)) = expiration { - builder = builder.add_unlock_condition(ExpirationUnlockCondition::new(address.clone(), timestamp).unwrap()); - } - - builder.finish_output().unwrap() -} - -fn build_account_output( - amount: u64, - account_id: AccountId, - address: Address, - sender: Option
, - issuer: Option
, -) -> Output { - let mut builder = AccountOutputBuilder::new_with_amount(amount, account_id) - .add_unlock_condition(AddressUnlockCondition::new(address.clone())); - - if let Some(sender) = sender { - builder = builder.add_feature(SenderFeature::new(sender.clone())); - } - - if let Some(issuer) = issuer { - builder = builder.add_immutable_feature(IssuerFeature::new(issuer.clone())); - } - - builder.finish_output().unwrap() -} - -fn build_foundry_output( - amount: u64, - account_id: AccountId, - serial_number: u32, - token_scheme: SimpleTokenScheme, - native_token: Option<(&str, u64)>, -) -> Output { - let mut builder = FoundryOutputBuilder::new_with_amount(amount, serial_number, TokenScheme::Simple(token_scheme)) - .add_unlock_condition(ImmutableAccountAddressUnlockCondition::new(AccountAddress::new( - account_id, - ))); - - if let Some((id, amount)) = native_token { - builder = builder.with_native_token(NativeToken::new(TokenId::from_str(id).unwrap(), amount).unwrap()); - } - - builder.finish_output().unwrap() + Basic { + amount: u64, + address: Address, + native_token: Option<(&'a str, u64)>, + sender: Option
, + sdruc: Option<(Address, u64)>, + timelock: Option, + expiration: Option<(Address, u32)>, + }, + Nft { + amount: u64, + nft_id: NftId, + address: Address, + sender: Option
, + issuer: Option
, + sdruc: Option<(Address, u64)>, + expiration: Option<(Address, u32)>, + }, + Account { + amount: u64, + account_id: AccountId, + address: Address, + sender: Option
, + issuer: Option
, + }, + Foundry { + amount: u64, + account_id: AccountId, + serial_number: u32, + token_scheme: SimpleTokenScheme, + native_token: Option<(&'a str, u64)>, + }, + Delegation { + amount: u64, + delegation_amount: u64, + delegation_id: DelegationId, + address: Address, + validator_address: AccountAddress, + start_epoch: u32, + end_epoch: u32, + }, } -fn build_output_inner(build: Build) -> (Output, Option) { - match build { - Build::Basic(amount, address, native_token, sender, sdruc, timelock, expiration, chain) => ( - build_basic_output(amount, address, native_token, sender, sdruc, timelock, expiration), - chain, - ), - Build::Nft(amount, nft_id, address, sender, issuer, sdruc, expiration, chain) => ( - build_nft_output(amount, nft_id, address, sender, issuer, sdruc, expiration), - chain, - ), - Build::Account(amount, account_id, address, sender, issuer, chain) => { - (build_account_output(amount, account_id, address, sender, issuer), chain) +impl<'a> Build<'a> { + fn build(self) -> Output { + match self { + Build::Basic { + amount, + address, + native_token, + sender, + sdruc, + timelock, + expiration, + } => { + let mut builder = 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(sender) = sender { + builder = builder.add_feature(SenderFeature::new(sender.clone())); + } + + if let Some((address, amount)) = sdruc { + builder = builder.add_unlock_condition( + StorageDepositReturnUnlockCondition::new(address.clone(), amount).unwrap(), + ); + } + + if let Some(timelock) = timelock { + builder = builder.add_unlock_condition(TimelockUnlockCondition::new(timelock).unwrap()); + } + + if let Some((address, timestamp)) = expiration { + builder = builder + .add_unlock_condition(ExpirationUnlockCondition::new(address.clone(), timestamp).unwrap()); + } + + builder.finish_output().unwrap() + } + Build::Nft { + amount, + nft_id, + address, + sender, + issuer, + sdruc, + expiration, + } => { + let mut builder = NftOutputBuilder::new_with_amount(amount, nft_id) + .add_unlock_condition(AddressUnlockCondition::new(address)); + + if let Some(sender) = sender { + builder = builder.add_feature(SenderFeature::new(sender)); + } + + if let Some(issuer) = issuer { + builder = builder.add_immutable_feature(IssuerFeature::new(issuer)); + } + + if let Some((address, amount)) = sdruc { + builder = builder + .add_unlock_condition(StorageDepositReturnUnlockCondition::new(address, amount).unwrap()); + } + + if let Some((address, timestamp)) = expiration { + builder = builder.add_unlock_condition(ExpirationUnlockCondition::new(address, timestamp).unwrap()); + } + + builder.finish_output().unwrap() + } + Build::Account { + amount, + account_id, + address, + sender, + issuer, + } => { + let mut builder = AccountOutputBuilder::new_with_amount(amount, account_id) + .add_unlock_condition(AddressUnlockCondition::new(address)); + + if let Some(sender) = sender { + builder = builder.add_feature(SenderFeature::new(sender)); + } + + if let Some(issuer) = issuer { + builder = builder.add_immutable_feature(IssuerFeature::new(issuer)); + } + + builder.finish_output().unwrap() + } + Build::Foundry { + amount, + account_id, + serial_number, + token_scheme, + native_token, + } => { + let mut builder = + FoundryOutputBuilder::new_with_amount(amount, serial_number, TokenScheme::Simple(token_scheme)) + .add_unlock_condition(ImmutableAccountAddressUnlockCondition::new(AccountAddress::new( + account_id, + ))); + + if let Some((id, amount)) = native_token { + builder = + builder.with_native_token(NativeToken::new(TokenId::from_str(id).unwrap(), amount).unwrap()); + } + + builder.finish_output().unwrap() + } + Build::Delegation { + amount, + delegation_amount, + delegation_id, + address, + validator_address, + start_epoch, + end_epoch, + } => DelegationOutputBuilder::new_with_amount(delegation_amount, delegation_id, validator_address) + .with_amount(amount) + .add_unlock_condition(AddressUnlockCondition::new(address)) + .with_start_epoch(start_epoch) + .with_end_epoch(end_epoch) + .finish_output() + .unwrap(), } - Build::Foundry(amount, account_id, serial_number, token_scheme, native_token) => ( - build_foundry_output(amount, account_id, serial_number, token_scheme, native_token), - None, - ), } } fn build_inputs<'a>( - outputs: impl IntoIterator>, + outputs: impl IntoIterator, Option)>, slot_index: Option, ) -> Vec { outputs .into_iter() - .map(|build| { - let (output, chain) = build_output_inner(build); + .map(|(build, chain)| { + let output = build.build(); let transaction_id = slot_index.map_or_else(rand_transaction_id, rand_transaction_id_with_slot_index); InputSigningData { @@ -233,7 +256,7 @@ fn build_inputs<'a>( } fn build_outputs<'a>(outputs: impl IntoIterator>) -> Vec { - outputs.into_iter().map(|build| build_output_inner(build).0).collect() + outputs.into_iter().map(|build| build.build()).collect() } fn unsorted_eq(a: &[T], b: &[T]) -> bool diff --git a/sdk/tests/client/node_api/mod.rs b/sdk/tests/client/node_api/mod.rs index f47af0dae6..6b36cde54c 100644 --- a/sdk/tests/client/node_api/mod.rs +++ b/sdk/tests/client/node_api/mod.rs @@ -98,7 +98,7 @@ pub async fn setup_transaction_block(client: &Client) -> (BlockId, TransactionId .transaction() .id(); - // TODO reenable but `reissue_transaction_until_included` is on Wallet and not on Client. + // TODO reenable but `wait_for_transaction_acceptance` is on Wallet and not on Client. // let retried_blocks = client.retry_until_included(&block.id(), None, None).await.unwrap(); // (retried_blocks[0].0, transaction_id) diff --git a/sdk/tests/client/signing/account.rs b/sdk/tests/client/signing/account.rs index ba32f9bfd6..f485646c99 100644 --- a/sdk/tests/client/signing/account.rs +++ b/sdk/tests/client/signing/account.rs @@ -51,18 +51,26 @@ async fn sign_account_state_transition() -> Result<()> { let slot_index = SlotIndex::from(10); let inputs = build_inputs( - [Account( - 1_000_000, - account_id, - address.clone(), - None, - None, + [( + Account { + amount: 1_000_000, + account_id: account_id, + address: address.clone(), + sender: None, + issuer: None, + }, Some(Bip44::new(SHIMMER_COIN_TYPE)), )], Some(slot_index), ); - let outputs = build_outputs([Account(1_000_000, account_id, address.clone(), None, None, None)]); + let outputs = build_outputs([Account { + amount: 1_000_000, + account_id: account_id, + address: address.clone(), + sender: None, + issuer: None, + }]); let transaction = Transaction::builder(protocol_parameters.network_id()) .with_inputs( @@ -128,23 +136,61 @@ async fn account_reference_unlocks() -> Result<()> { let inputs = build_inputs( [ - Account( - 1_000_000, - account_id, - address.clone(), + ( + Account { + amount: 1_000_000, + account_id: account_id, + address: address.clone(), + sender: None, + issuer: None, + }, + Some(Bip44::new(SHIMMER_COIN_TYPE)), + ), + ( + Basic { + amount: 1_000_000, + address: account_address.clone(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, + ), + ( + Basic { + amount: 1_000_000, + address: account_address.clone(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, - Some(Bip44::new(SHIMMER_COIN_TYPE)), ), - Basic(1_000_000, account_address.clone(), None, None, None, None, None, None), - Basic(1_000_000, account_address.clone(), None, None, None, None, None, None), ], Some(slot_index), ); let outputs = build_outputs([ - Account(1_000_000, account_id, address, None, None, None), - Basic(2_000_000, account_address, None, None, None, None, None, None), + Account { + amount: 1_000_000, + account_id: account_id, + address: address, + sender: None, + issuer: None, + }, + Basic { + amount: 2_000_000, + address: account_address, + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: 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 8379d311f7..9fa7e3f3bb 100644 --- a/sdk/tests/client/signing/basic.rs +++ b/sdk/tests/client/signing/basic.rs @@ -42,29 +42,30 @@ async fn single_ed25519_unlock() -> Result<()> { let slot_index = SlotIndex::from(10); let inputs = build_inputs( - [Basic( - 1_000_000, - address_0.clone(), - None, - None, - None, - None, - None, + [( + Basic { + amount: 1_000_000, + address: address_0.clone(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, Some(Bip44::new(SHIMMER_COIN_TYPE)), )], Some(slot_index), ); - let outputs = build_outputs([Basic( - 1_000_000, - address_0, - None, - None, - None, - None, - None, - Some(Bip44::new(SHIMMER_COIN_TYPE)), - )]); + let outputs = build_outputs([Basic { + amount: 1_000_000, + address: address_0, + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let transaction = Transaction::builder(protocol_parameters.network_id()) .with_inputs( @@ -128,50 +129,55 @@ async fn ed25519_reference_unlocks() -> Result<()> { let inputs = build_inputs( [ - Basic( - 1_000_000, - address_0.clone(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: address_0.clone(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, Some(Bip44::new(SHIMMER_COIN_TYPE)), ), - Basic( - 1_000_000, - address_0.clone(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: address_0.clone(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, Some(Bip44::new(SHIMMER_COIN_TYPE)), ), - Basic( - 1_000_000, - address_0.clone(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: address_0.clone(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, Some(Bip44::new(SHIMMER_COIN_TYPE)), ), ], Some(slot_index), ); - let outputs = build_outputs([Basic( - 3_000_000, - address_0, - None, - None, - None, - None, - None, - Some(Bip44::new(SHIMMER_COIN_TYPE)), - )]); + let outputs = build_outputs([Basic { + amount: 3_000_000, + address: address_0, + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let transaction = Transaction::builder(protocol_parameters.network_id()) .with_inputs( @@ -256,40 +262,43 @@ async fn two_signature_unlocks() -> Result<()> { let inputs = build_inputs( [ - Basic( - 1_000_000, - address_0.clone(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: address_0.clone(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, Some(Bip44::new(SHIMMER_COIN_TYPE)), ), - Basic( - 1_000_000, - address_1, - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: address_1, + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, Some(Bip44::new(SHIMMER_COIN_TYPE).with_address_index(1)), ), ], Some(slot_index), ); - let outputs = build_outputs([Basic( - 2_000_000, - address_0, - None, - None, - None, - None, - None, - Some(Bip44::new(SHIMMER_COIN_TYPE)), - )]); + let outputs = build_outputs([Basic { + amount: 2_000_000, + address: address_0, + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); let transaction = Transaction::builder(protocol_parameters.network_id()) .with_inputs( diff --git a/sdk/tests/client/signing/delegation.rs b/sdk/tests/client/signing/delegation.rs new file mode 100644 index 0000000000..8fcb872c29 --- /dev/null +++ b/sdk/tests/client/signing/delegation.rs @@ -0,0 +1,1230 @@ +// Copyright 2024 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +use std::collections::BTreeMap; + +use crypto::keys::bip44::Bip44; +use iota_sdk::{ + client::{ + api::{ + transaction::validate_signed_transaction_payload_length, verify_semantic, GetAddressesOptions, + PreparedTransactionData, + }, + constants::SHIMMER_COIN_TYPE, + secret::{SecretManage, SecretManager}, + Client, Result, + }, + types::block::{ + context_input::{CommitmentContextInput, RewardContextInput}, + input::{Input, UtxoInput}, + output::DelegationId, + payload::{signed_transaction::Transaction, SignedTransactionPayload}, + protocol::protocol_parameters, + rand::{address::rand_account_address, output::rand_delegation_id, slot::rand_slot_commitment_id}, + semantic::TransactionFailureReason, + unlock::SignatureUnlock, + }, +}; +use pretty_assertions::assert_eq; + +use crate::client::{ + build_inputs, build_outputs, + Build::{Basic, Delegation}, +}; + +#[tokio::test] +async fn valid_creation() -> Result<()> { + let secret_manager = SecretManager::try_from_mnemonic(Client::generate_mnemonic()?)?; + + let address = secret_manager + .generate_ed25519_addresses( + GetAddressesOptions::default() + .with_coin_type(SHIMMER_COIN_TYPE) + .with_range(0..1), + ) + .await?[0] + .clone() + .into_inner(); + + let protocol_parameters = protocol_parameters(); + let slot_commitment_id = rand_slot_commitment_id(); + let slot_index = slot_commitment_id.slot_index(); + + let inputs = build_inputs( + [( + Basic { + amount: 1_000_000, + address: address.clone(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, + Some(Bip44::new(SHIMMER_COIN_TYPE)), + )], + Some(slot_index), + ); + + let outputs = build_outputs([Delegation { + amount: 1_000_000, + delegation_amount: 1_000_000, + delegation_id: DelegationId::null(), + address: address.clone(), + validator_address: rand_account_address(), + start_epoch: *protocol_parameters.delegation_start_epoch(slot_commitment_id), + end_epoch: 0, + }]); + + let transaction = Transaction::builder(protocol_parameters.network_id()) + .with_inputs( + inputs + .iter() + .map(|i| Input::Utxo(UtxoInput::from(*i.output_metadata.output_id()))) + .collect::>(), + ) + .with_outputs(outputs) + .with_creation_slot(slot_index + 1) + .with_context_inputs([CommitmentContextInput::new(slot_commitment_id).into()]) + .finish_with_params(&protocol_parameters)?; + + let prepared_transaction_data = PreparedTransactionData { + transaction, + inputs_data: inputs, + remainders: Vec::new(), + mana_rewards: Default::default(), + }; + + let unlocks = secret_manager + .transaction_unlocks(&prepared_transaction_data, &protocol_parameters) + .await?; + + assert_eq!(unlocks.len(), 1); + assert_eq!((*unlocks).first().unwrap().kind(), SignatureUnlock::KIND); + + let tx_payload = SignedTransactionPayload::new(prepared_transaction_data.transaction.clone(), unlocks)?; + + validate_signed_transaction_payload_length(&tx_payload)?; + + let conflict = verify_semantic( + &prepared_transaction_data.inputs_data, + &tx_payload, + prepared_transaction_data.mana_rewards, + protocol_parameters, + )?; + + if let Some(conflict) = conflict { + panic!("{conflict:?}, with {tx_payload:#?}"); + } + + Ok(()) +} + +#[tokio::test] +async fn creation_missing_commitment_input() -> Result<()> { + let secret_manager = SecretManager::try_from_mnemonic(Client::generate_mnemonic()?)?; + + let address = secret_manager + .generate_ed25519_addresses( + GetAddressesOptions::default() + .with_coin_type(SHIMMER_COIN_TYPE) + .with_range(0..1), + ) + .await?[0] + .clone() + .into_inner(); + + let protocol_parameters = protocol_parameters(); + let slot_commitment_id = rand_slot_commitment_id(); + let slot_index = slot_commitment_id.slot_index(); + + let inputs = build_inputs( + [( + Basic { + amount: 1_000_000, + address: address.clone(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, + Some(Bip44::new(SHIMMER_COIN_TYPE)), + )], + Some(slot_index), + ); + + let outputs = build_outputs([Delegation { + amount: 1_000_000, + delegation_amount: 1_000_000, + delegation_id: DelegationId::null(), + address: address.clone(), + validator_address: rand_account_address(), + start_epoch: *protocol_parameters.delegation_start_epoch(slot_commitment_id), + end_epoch: 0, + }]); + + let transaction = Transaction::builder(protocol_parameters.network_id()) + .with_inputs( + inputs + .iter() + .map(|i| Input::Utxo(UtxoInput::from(*i.output_metadata.output_id()))) + .collect::>(), + ) + .with_outputs(outputs) + .with_creation_slot(slot_index + 1) + .finish_with_params(&protocol_parameters)?; + + let prepared_transaction_data = PreparedTransactionData { + transaction, + inputs_data: inputs, + remainders: Vec::new(), + mana_rewards: Default::default(), + }; + + let unlocks = secret_manager + .transaction_unlocks(&prepared_transaction_data, &protocol_parameters) + .await?; + + assert_eq!(unlocks.len(), 1); + assert_eq!((*unlocks).first().unwrap().kind(), SignatureUnlock::KIND); + + let tx_payload = SignedTransactionPayload::new(prepared_transaction_data.transaction.clone(), unlocks)?; + + validate_signed_transaction_payload_length(&tx_payload)?; + + let conflict = verify_semantic( + &prepared_transaction_data.inputs_data, + &tx_payload, + prepared_transaction_data.mana_rewards, + protocol_parameters, + )?; + + assert_eq!( + conflict, + Some(TransactionFailureReason::DelegationCommitmentInputMissing) + ); + + Ok(()) +} + +#[tokio::test] +async fn non_null_id_creation() -> Result<()> { + let secret_manager = SecretManager::try_from_mnemonic(Client::generate_mnemonic()?)?; + + let address = secret_manager + .generate_ed25519_addresses( + GetAddressesOptions::default() + .with_coin_type(SHIMMER_COIN_TYPE) + .with_range(0..1), + ) + .await?[0] + .clone() + .into_inner(); + + let protocol_parameters = protocol_parameters(); + let slot_commitment_id = rand_slot_commitment_id(); + let slot_index = slot_commitment_id.slot_index(); + + let inputs = build_inputs( + [( + Basic { + amount: 1_000_000, + address: address.clone(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, + Some(Bip44::new(SHIMMER_COIN_TYPE)), + )], + Some(slot_index), + ); + + let outputs = build_outputs([Delegation { + amount: 1_000_000, + delegation_amount: 1_000_000, + delegation_id: rand_delegation_id(), + address: address, + validator_address: rand_account_address(), + start_epoch: *protocol_parameters.delegation_start_epoch(slot_commitment_id), + end_epoch: 0, + }]); + + let transaction = Transaction::builder(protocol_parameters.network_id()) + .with_inputs( + inputs + .iter() + .map(|i| Input::Utxo(UtxoInput::from(*i.output_metadata.output_id()))) + .collect::>(), + ) + .with_outputs(outputs) + .with_creation_slot(slot_index + 1) + .finish_with_params(&protocol_parameters)?; + + let prepared_transaction_data = PreparedTransactionData { + transaction, + inputs_data: inputs, + remainders: Vec::new(), + mana_rewards: Default::default(), + }; + + let unlocks = secret_manager + .transaction_unlocks(&prepared_transaction_data, &protocol_parameters) + .await?; + + assert_eq!(unlocks.len(), 1); + assert_eq!((*unlocks).first().unwrap().kind(), SignatureUnlock::KIND); + + let tx_payload = SignedTransactionPayload::new(prepared_transaction_data.transaction.clone(), unlocks)?; + + validate_signed_transaction_payload_length(&tx_payload)?; + + let conflict = verify_semantic( + &prepared_transaction_data.inputs_data, + &tx_payload, + prepared_transaction_data.mana_rewards, + protocol_parameters, + )?; + + assert_eq!(conflict, Some(TransactionFailureReason::NewChainOutputHasNonZeroedId)); + + Ok(()) +} + +#[tokio::test] +async fn mismatch_amount_creation() -> Result<()> { + let secret_manager = SecretManager::try_from_mnemonic(Client::generate_mnemonic()?)?; + + let address = secret_manager + .generate_ed25519_addresses( + GetAddressesOptions::default() + .with_coin_type(SHIMMER_COIN_TYPE) + .with_range(0..1), + ) + .await?[0] + .clone() + .into_inner(); + + let protocol_parameters = protocol_parameters(); + let slot_commitment_id = rand_slot_commitment_id(); + let slot_index = slot_commitment_id.slot_index(); + + let inputs = build_inputs( + [( + Basic { + amount: 1_000_000, + address: address.clone(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, + Some(Bip44::new(SHIMMER_COIN_TYPE)), + )], + Some(slot_index), + ); + + let outputs = build_outputs([Delegation { + amount: 1_000_000, + delegation_amount: 1_500_000, + delegation_id: DelegationId::null(), + address: address, + validator_address: rand_account_address(), + start_epoch: *protocol_parameters.delegation_start_epoch(slot_commitment_id), + end_epoch: 0, + }]); + + let transaction = Transaction::builder(protocol_parameters.network_id()) + .with_inputs( + inputs + .iter() + .map(|i| Input::Utxo(UtxoInput::from(*i.output_metadata.output_id()))) + .collect::>(), + ) + .with_outputs(outputs) + .with_creation_slot(slot_index + 1) + .finish_with_params(&protocol_parameters)?; + + let prepared_transaction_data = PreparedTransactionData { + transaction, + inputs_data: inputs, + remainders: Vec::new(), + mana_rewards: Default::default(), + }; + + let unlocks = secret_manager + .transaction_unlocks(&prepared_transaction_data, &protocol_parameters) + .await?; + + assert_eq!(unlocks.len(), 1); + assert_eq!((*unlocks).first().unwrap().kind(), SignatureUnlock::KIND); + + let tx_payload = SignedTransactionPayload::new(prepared_transaction_data.transaction.clone(), unlocks)?; + + validate_signed_transaction_payload_length(&tx_payload)?; + + let conflict = verify_semantic( + &prepared_transaction_data.inputs_data, + &tx_payload, + prepared_transaction_data.mana_rewards, + protocol_parameters, + )?; + + assert_eq!(conflict, Some(TransactionFailureReason::DelegationAmountMismatch)); + + Ok(()) +} + +#[tokio::test] +async fn non_zero_end_epoch_creation() -> Result<()> { + let secret_manager = SecretManager::try_from_mnemonic(Client::generate_mnemonic()?)?; + + let address = secret_manager + .generate_ed25519_addresses( + GetAddressesOptions::default() + .with_coin_type(SHIMMER_COIN_TYPE) + .with_range(0..1), + ) + .await?[0] + .clone() + .into_inner(); + + let protocol_parameters = protocol_parameters(); + let slot_commitment_id = rand_slot_commitment_id(); + let slot_index = slot_commitment_id.slot_index(); + + let inputs = build_inputs( + [( + Basic { + amount: 1_000_000, + address: address.clone(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, + Some(Bip44::new(SHIMMER_COIN_TYPE)), + )], + Some(slot_index), + ); + + let outputs = build_outputs([Delegation { + amount: 1_000_000, + delegation_amount: 1_000_000, + delegation_id: DelegationId::null(), + address: address, + validator_address: rand_account_address(), + start_epoch: *protocol_parameters.delegation_start_epoch(slot_commitment_id), + end_epoch: 100, + }]); + + let transaction = Transaction::builder(protocol_parameters.network_id()) + .with_inputs( + inputs + .iter() + .map(|i| Input::Utxo(UtxoInput::from(*i.output_metadata.output_id()))) + .collect::>(), + ) + .with_outputs(outputs) + .with_creation_slot(slot_index + 1) + .finish_with_params(&protocol_parameters)?; + + let prepared_transaction_data = PreparedTransactionData { + transaction, + inputs_data: inputs, + remainders: Vec::new(), + mana_rewards: Default::default(), + }; + + let unlocks = secret_manager + .transaction_unlocks(&prepared_transaction_data, &protocol_parameters) + .await?; + + assert_eq!(unlocks.len(), 1); + assert_eq!((*unlocks).first().unwrap().kind(), SignatureUnlock::KIND); + + let tx_payload = SignedTransactionPayload::new(prepared_transaction_data.transaction.clone(), unlocks)?; + + validate_signed_transaction_payload_length(&tx_payload)?; + + let conflict = verify_semantic( + &prepared_transaction_data.inputs_data, + &tx_payload, + prepared_transaction_data.mana_rewards, + protocol_parameters, + )?; + + assert_eq!(conflict, Some(TransactionFailureReason::DelegationEndEpochNotZero)); + + Ok(()) +} + +#[tokio::test] +async fn invalid_start_epoch_creation() -> Result<()> { + let secret_manager = SecretManager::try_from_mnemonic(Client::generate_mnemonic()?)?; + + let address = secret_manager + .generate_ed25519_addresses( + GetAddressesOptions::default() + .with_coin_type(SHIMMER_COIN_TYPE) + .with_range(0..1), + ) + .await?[0] + .clone() + .into_inner(); + + let protocol_parameters = protocol_parameters(); + let slot_commitment_id = rand_slot_commitment_id(); + let slot_index = slot_commitment_id.slot_index(); + + let inputs = build_inputs( + [( + Basic { + amount: 1_000_000, + address: address.clone(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, + Some(Bip44::new(SHIMMER_COIN_TYPE)), + )], + Some(slot_index), + ); + + let outputs = build_outputs([Delegation { + amount: 1_000_000, + delegation_amount: 1_000_000, + delegation_id: DelegationId::null(), + address: address, + validator_address: rand_account_address(), + start_epoch: *protocol_parameters.delegation_start_epoch(slot_commitment_id) + 5, + end_epoch: 0, + }]); + + let transaction = Transaction::builder(protocol_parameters.network_id()) + .with_inputs( + inputs + .iter() + .map(|i| Input::Utxo(UtxoInput::from(*i.output_metadata.output_id()))) + .collect::>(), + ) + .with_outputs(outputs) + .with_creation_slot(slot_index + 1) + .with_context_inputs([CommitmentContextInput::new(slot_commitment_id).into()]) + .finish_with_params(&protocol_parameters)?; + + let prepared_transaction_data = PreparedTransactionData { + transaction, + inputs_data: inputs, + remainders: Vec::new(), + mana_rewards: Default::default(), + }; + + let unlocks = secret_manager + .transaction_unlocks(&prepared_transaction_data, &protocol_parameters) + .await?; + + assert_eq!(unlocks.len(), 1); + assert_eq!((*unlocks).first().unwrap().kind(), SignatureUnlock::KIND); + + let tx_payload = SignedTransactionPayload::new(prepared_transaction_data.transaction.clone(), unlocks)?; + + validate_signed_transaction_payload_length(&tx_payload)?; + + let conflict = verify_semantic( + &prepared_transaction_data.inputs_data, + &tx_payload, + prepared_transaction_data.mana_rewards, + protocol_parameters, + )?; + + assert_eq!(conflict, Some(TransactionFailureReason::DelegationStartEpochInvalid)); + + Ok(()) +} + +#[tokio::test] +async fn delay_not_null_id() -> Result<()> { + let secret_manager = SecretManager::try_from_mnemonic(Client::generate_mnemonic()?)?; + + let address = secret_manager + .generate_ed25519_addresses( + GetAddressesOptions::default() + .with_coin_type(SHIMMER_COIN_TYPE) + .with_range(0..1), + ) + .await?[0] + .clone() + .into_inner(); + + let protocol_parameters = protocol_parameters(); + let slot_commitment_id_1 = rand_slot_commitment_id(); + let slot_index_1 = slot_commitment_id_1.slot_index(); + let slot_commitment_id_2 = rand_slot_commitment_id() + .hash() + .into_slot_commitment_id(slot_index_1 + 100); + let slot_index_2 = slot_commitment_id_2.slot_index(); + + let validator_address = rand_account_address(); + + let delegation_id = rand_delegation_id(); + + let inputs = build_inputs( + [( + Delegation { + amount: 1_000_000, + delegation_amount: 1_000_000, + delegation_id, + address: address.clone(), + validator_address, + start_epoch: *protocol_parameters.delegation_start_epoch(slot_commitment_id_1), + end_epoch: *protocol_parameters.delegation_end_epoch(slot_commitment_id_1), + }, + Some(Bip44::new(SHIMMER_COIN_TYPE)), + )], + Some(slot_index_1), + ); + + let outputs = build_outputs([Delegation { + amount: 1_000_000, + delegation_amount: 1_000_000, + delegation_id, + address: address, + validator_address, + start_epoch: *protocol_parameters.delegation_start_epoch(slot_commitment_id_1), + end_epoch: *protocol_parameters.delegation_end_epoch(slot_commitment_id_2), + }]); + + let transaction = Transaction::builder(protocol_parameters.network_id()) + .with_inputs( + inputs + .iter() + .map(|i| Input::Utxo(UtxoInput::from(*i.output_metadata.output_id()))) + .collect::>(), + ) + .with_outputs(outputs) + .with_creation_slot(slot_index_2 + 1) + .with_context_inputs([ + CommitmentContextInput::new(slot_commitment_id_2).into(), + RewardContextInput::new(0)?.into(), + ]) + .finish_with_params(&protocol_parameters)?; + + let prepared_transaction_data = PreparedTransactionData { + transaction, + inputs_data: inputs, + remainders: Vec::new(), + mana_rewards: Default::default(), + }; + + let unlocks = secret_manager + .transaction_unlocks(&prepared_transaction_data, &protocol_parameters) + .await?; + + assert_eq!(unlocks.len(), 1); + assert_eq!((*unlocks).first().unwrap().kind(), SignatureUnlock::KIND); + + let tx_payload = SignedTransactionPayload::new(prepared_transaction_data.transaction.clone(), unlocks)?; + + validate_signed_transaction_payload_length(&tx_payload)?; + + let conflict = verify_semantic( + &prepared_transaction_data.inputs_data, + &tx_payload, + prepared_transaction_data.mana_rewards, + protocol_parameters, + )?; + + assert_eq!( + conflict, + Some(TransactionFailureReason::DelegationOutputTransitionedTwice) + ); + + Ok(()) +} + +#[tokio::test] +async fn delay_modified_amount() -> Result<()> { + let secret_manager = SecretManager::try_from_mnemonic(Client::generate_mnemonic()?)?; + + let address = secret_manager + .generate_ed25519_addresses( + GetAddressesOptions::default() + .with_coin_type(SHIMMER_COIN_TYPE) + .with_range(0..1), + ) + .await?[0] + .clone() + .into_inner(); + + let protocol_parameters = protocol_parameters(); + let slot_commitment_id_1 = rand_slot_commitment_id(); + let slot_index_1 = slot_commitment_id_1.slot_index(); + let slot_commitment_id_2 = rand_slot_commitment_id() + .hash() + .into_slot_commitment_id(slot_index_1 + 100); + let slot_index_2 = slot_commitment_id_2.slot_index(); + + let validator_address = rand_account_address(); + + let inputs = build_inputs( + [( + Delegation { + amount: 1_000_000, + delegation_amount: 1_000_000, + delegation_id: DelegationId::null(), + address: address.clone(), + validator_address, + start_epoch: *protocol_parameters.delegation_start_epoch(slot_commitment_id_1), + end_epoch: 0, + }, + Some(Bip44::new(SHIMMER_COIN_TYPE)), + )], + Some(slot_index_1), + ); + + let delegation_id = DelegationId::from(inputs[0].output_id()); + + let outputs = build_outputs([Delegation { + amount: 1_000_000, + delegation_amount: 900_000, + delegation_id, + address: address, + validator_address, + start_epoch: *protocol_parameters.delegation_start_epoch(slot_commitment_id_1), + end_epoch: *protocol_parameters.delegation_end_epoch(slot_commitment_id_2), + }]); + + let transaction = Transaction::builder(protocol_parameters.network_id()) + .with_inputs( + inputs + .iter() + .map(|i| Input::Utxo(UtxoInput::from(*i.output_metadata.output_id()))) + .collect::>(), + ) + .with_outputs(outputs) + .with_creation_slot(slot_index_2 + 1) + .with_context_inputs([ + CommitmentContextInput::new(slot_commitment_id_2).into(), + RewardContextInput::new(0)?.into(), + ]) + .finish_with_params(&protocol_parameters)?; + + let prepared_transaction_data = PreparedTransactionData { + transaction, + inputs_data: inputs, + remainders: Vec::new(), + mana_rewards: Default::default(), + }; + + let unlocks = secret_manager + .transaction_unlocks(&prepared_transaction_data, &protocol_parameters) + .await?; + + assert_eq!(unlocks.len(), 1); + assert_eq!((*unlocks).first().unwrap().kind(), SignatureUnlock::KIND); + + let tx_payload = SignedTransactionPayload::new(prepared_transaction_data.transaction.clone(), unlocks)?; + + validate_signed_transaction_payload_length(&tx_payload)?; + + let conflict = verify_semantic( + &prepared_transaction_data.inputs_data, + &tx_payload, + prepared_transaction_data.mana_rewards, + protocol_parameters, + )?; + + assert_eq!(conflict, Some(TransactionFailureReason::DelegationModified)); + + Ok(()) +} + +#[tokio::test] +async fn delay_modified_validator() -> Result<()> { + let secret_manager = SecretManager::try_from_mnemonic(Client::generate_mnemonic()?)?; + + let address = secret_manager + .generate_ed25519_addresses( + GetAddressesOptions::default() + .with_coin_type(SHIMMER_COIN_TYPE) + .with_range(0..1), + ) + .await?[0] + .clone() + .into_inner(); + + let protocol_parameters = protocol_parameters(); + let slot_commitment_id_1 = rand_slot_commitment_id(); + let slot_index_1 = slot_commitment_id_1.slot_index(); + let slot_commitment_id_2 = rand_slot_commitment_id() + .hash() + .into_slot_commitment_id(slot_index_1 + 100); + let slot_index_2 = slot_commitment_id_2.slot_index(); + + let validator_address = rand_account_address(); + + let inputs = build_inputs( + [( + Delegation { + amount: 1_000_000, + delegation_amount: 1_000_000, + delegation_id: DelegationId::null(), + address: address.clone(), + validator_address, + start_epoch: *protocol_parameters.delegation_start_epoch(slot_commitment_id_1), + end_epoch: 0, + }, + Some(Bip44::new(SHIMMER_COIN_TYPE)), + )], + Some(slot_index_1), + ); + + let delegation_id = DelegationId::from(inputs[0].output_id()); + + let outputs = build_outputs([Delegation { + amount: 1_000_000, + delegation_amount: 1_000_000, + delegation_id, + address: address, + validator_address: rand_account_address(), + start_epoch: *protocol_parameters.delegation_start_epoch(slot_commitment_id_1), + end_epoch: *protocol_parameters.delegation_end_epoch(slot_commitment_id_2), + }]); + + let transaction = Transaction::builder(protocol_parameters.network_id()) + .with_inputs( + inputs + .iter() + .map(|i| Input::Utxo(UtxoInput::from(*i.output_metadata.output_id()))) + .collect::>(), + ) + .with_outputs(outputs) + .with_creation_slot(slot_index_2 + 1) + .with_context_inputs([ + CommitmentContextInput::new(slot_commitment_id_2).into(), + RewardContextInput::new(0)?.into(), + ]) + .finish_with_params(&protocol_parameters)?; + + let prepared_transaction_data = PreparedTransactionData { + transaction, + inputs_data: inputs, + remainders: Vec::new(), + mana_rewards: Default::default(), + }; + + let unlocks = secret_manager + .transaction_unlocks(&prepared_transaction_data, &protocol_parameters) + .await?; + + assert_eq!(unlocks.len(), 1); + assert_eq!((*unlocks).first().unwrap().kind(), SignatureUnlock::KIND); + + let tx_payload = SignedTransactionPayload::new(prepared_transaction_data.transaction.clone(), unlocks)?; + + validate_signed_transaction_payload_length(&tx_payload)?; + + let conflict = verify_semantic( + &prepared_transaction_data.inputs_data, + &tx_payload, + prepared_transaction_data.mana_rewards, + protocol_parameters, + )?; + + assert_eq!(conflict, Some(TransactionFailureReason::DelegationModified)); + + Ok(()) +} + +#[tokio::test] +async fn delay_modified_start_epoch() -> Result<()> { + let secret_manager = SecretManager::try_from_mnemonic(Client::generate_mnemonic()?)?; + + let address = secret_manager + .generate_ed25519_addresses( + GetAddressesOptions::default() + .with_coin_type(SHIMMER_COIN_TYPE) + .with_range(0..1), + ) + .await?[0] + .clone() + .into_inner(); + + let protocol_parameters = protocol_parameters(); + let slot_commitment_id_1 = rand_slot_commitment_id(); + let slot_index_1 = slot_commitment_id_1.slot_index(); + let slot_commitment_id_2 = rand_slot_commitment_id() + .hash() + .into_slot_commitment_id(slot_index_1 + 100); + let slot_index_2 = slot_commitment_id_2.slot_index(); + + let validator_address = rand_account_address(); + + let inputs = build_inputs( + [( + Delegation { + amount: 1_000_000, + delegation_amount: 1_000_000, + delegation_id: DelegationId::null(), + address: address.clone(), + validator_address, + start_epoch: *protocol_parameters.delegation_start_epoch(slot_commitment_id_1), + end_epoch: 0, + }, + Some(Bip44::new(SHIMMER_COIN_TYPE)), + )], + Some(slot_index_1), + ); + + let delegation_id = DelegationId::from(inputs[0].output_id()); + + let outputs = build_outputs([Delegation { + amount: 1_000_000, + delegation_amount: 1_000_000, + delegation_id, + address: address, + validator_address, + start_epoch: *protocol_parameters.delegation_start_epoch(slot_commitment_id_1) + 1, + end_epoch: *protocol_parameters.delegation_end_epoch(slot_commitment_id_2), + }]); + + let transaction = Transaction::builder(protocol_parameters.network_id()) + .with_inputs( + inputs + .iter() + .map(|i| Input::Utxo(UtxoInput::from(*i.output_metadata.output_id()))) + .collect::>(), + ) + .with_outputs(outputs) + .with_creation_slot(slot_index_2 + 1) + .with_context_inputs([ + CommitmentContextInput::new(slot_commitment_id_2).into(), + RewardContextInput::new(0)?.into(), + ]) + .finish_with_params(&protocol_parameters)?; + + let prepared_transaction_data = PreparedTransactionData { + transaction, + inputs_data: inputs, + remainders: Vec::new(), + mana_rewards: Default::default(), + }; + + let unlocks = secret_manager + .transaction_unlocks(&prepared_transaction_data, &protocol_parameters) + .await?; + + assert_eq!(unlocks.len(), 1); + assert_eq!((*unlocks).first().unwrap().kind(), SignatureUnlock::KIND); + + let tx_payload = SignedTransactionPayload::new(prepared_transaction_data.transaction.clone(), unlocks)?; + + validate_signed_transaction_payload_length(&tx_payload)?; + + let conflict = verify_semantic( + &prepared_transaction_data.inputs_data, + &tx_payload, + prepared_transaction_data.mana_rewards, + protocol_parameters, + )?; + + assert_eq!(conflict, Some(TransactionFailureReason::DelegationModified)); + + Ok(()) +} + +#[tokio::test] +async fn delay_pre_registration_slot_end_epoch() -> Result<()> { + let secret_manager = SecretManager::try_from_mnemonic(Client::generate_mnemonic()?)?; + + let address = secret_manager + .generate_ed25519_addresses( + GetAddressesOptions::default() + .with_coin_type(SHIMMER_COIN_TYPE) + .with_range(0..1), + ) + .await?[0] + .clone() + .into_inner(); + + let protocol_parameters = protocol_parameters(); + let slot_commitment_id_1 = rand_slot_commitment_id(); + let slot_index_1 = slot_commitment_id_1.slot_index(); + let slot_commitment_id_2 = rand_slot_commitment_id() + .hash() + .into_slot_commitment_id(slot_index_1 + 100); + let slot_index_2 = slot_commitment_id_2.slot_index(); + + let validator_address = rand_account_address(); + + let inputs = build_inputs( + [( + Delegation { + amount: 1_000_000, + delegation_amount: 1_000_000, + delegation_id: DelegationId::null(), + address: address.clone(), + validator_address, + start_epoch: *protocol_parameters.delegation_start_epoch(slot_commitment_id_1), + end_epoch: 0, + }, + Some(Bip44::new(SHIMMER_COIN_TYPE)), + )], + Some(slot_index_1), + ); + + let delegation_id = DelegationId::from(inputs[0].output_id()); + + let outputs = build_outputs([Delegation { + amount: 1_000_000, + delegation_amount: 1_000_000, + delegation_id, + address: address, + validator_address, + start_epoch: *protocol_parameters.delegation_start_epoch(slot_commitment_id_1), + end_epoch: *protocol_parameters.delegation_start_epoch(slot_commitment_id_1) + 1, + }]); + + let transaction = Transaction::builder(protocol_parameters.network_id()) + .with_inputs( + inputs + .iter() + .map(|i| Input::Utxo(UtxoInput::from(*i.output_metadata.output_id()))) + .collect::>(), + ) + .with_outputs(outputs) + .with_creation_slot(slot_index_2 + 1) + .with_context_inputs([ + CommitmentContextInput::new(slot_commitment_id_2).into(), + RewardContextInput::new(0)?.into(), + ]) + .finish_with_params(&protocol_parameters)?; + + let prepared_transaction_data = PreparedTransactionData { + transaction, + inputs_data: inputs, + remainders: Vec::new(), + mana_rewards: Default::default(), + }; + + let unlocks = secret_manager + .transaction_unlocks(&prepared_transaction_data, &protocol_parameters) + .await?; + + assert_eq!(unlocks.len(), 1); + assert_eq!((*unlocks).first().unwrap().kind(), SignatureUnlock::KIND); + + let tx_payload = SignedTransactionPayload::new(prepared_transaction_data.transaction.clone(), unlocks)?; + + validate_signed_transaction_payload_length(&tx_payload)?; + + let conflict = verify_semantic( + &prepared_transaction_data.inputs_data, + &tx_payload, + prepared_transaction_data.mana_rewards, + protocol_parameters, + )?; + + assert_eq!(conflict, Some(TransactionFailureReason::DelegationEndEpochInvalid)); + + Ok(()) +} + +#[tokio::test] +async fn destroy_null_id() -> Result<()> { + let secret_manager = SecretManager::try_from_mnemonic(Client::generate_mnemonic()?)?; + + let address = secret_manager + .generate_ed25519_addresses( + GetAddressesOptions::default() + .with_coin_type(SHIMMER_COIN_TYPE) + .with_range(0..1), + ) + .await?[0] + .clone() + .into_inner(); + + let protocol_parameters = protocol_parameters(); + let slot_commitment_id_1 = rand_slot_commitment_id(); + let slot_index_1 = slot_commitment_id_1.slot_index(); + let slot_commitment_id_2 = rand_slot_commitment_id() + .hash() + .into_slot_commitment_id(slot_index_1 + 100); + let slot_index_2 = slot_commitment_id_2.slot_index(); + + let validator_address = rand_account_address(); + + let inputs = build_inputs( + [( + Delegation { + amount: 1_000_000, + delegation_amount: 1_000_000, + delegation_id: DelegationId::null(), + address: address.clone(), + validator_address, + start_epoch: *protocol_parameters.delegation_start_epoch(slot_commitment_id_1), + end_epoch: 0, + }, + Some(Bip44::new(SHIMMER_COIN_TYPE)), + )], + Some(slot_index_1), + ); + + let outputs = build_outputs([Basic { + amount: 1_000_000, + address, + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); + + let transaction = Transaction::builder(protocol_parameters.network_id()) + .with_inputs( + inputs + .iter() + .map(|i| Input::Utxo(UtxoInput::from(*i.output_metadata.output_id()))) + .collect::>(), + ) + .with_outputs(outputs) + .with_creation_slot(slot_index_2 + 1) + .with_context_inputs([ + CommitmentContextInput::new(slot_commitment_id_2).into(), + RewardContextInput::new(0)?.into(), + ]) + .finish_with_params(&protocol_parameters)?; + + let mut mana_rewards = BTreeMap::default(); + mana_rewards.insert(*inputs[0].output_id(), 0); + + let prepared_transaction_data = PreparedTransactionData { + transaction, + inputs_data: inputs, + remainders: Vec::new(), + mana_rewards, + }; + + let unlocks = secret_manager + .transaction_unlocks(&prepared_transaction_data, &protocol_parameters) + .await?; + + assert_eq!(unlocks.len(), 1); + assert_eq!((*unlocks).first().unwrap().kind(), SignatureUnlock::KIND); + + let tx_payload = SignedTransactionPayload::new(prepared_transaction_data.transaction.clone(), unlocks)?; + + validate_signed_transaction_payload_length(&tx_payload)?; + + let conflict = verify_semantic( + &prepared_transaction_data.inputs_data, + &tx_payload, + prepared_transaction_data.mana_rewards, + protocol_parameters, + )?; + + if let Some(conflict) = conflict { + panic!("{conflict:?}, with {tx_payload:#?}"); + } + + Ok(()) +} + +#[tokio::test] +async fn destroy_reward_missing() -> Result<()> { + let secret_manager = SecretManager::try_from_mnemonic(Client::generate_mnemonic()?)?; + + let address = secret_manager + .generate_ed25519_addresses( + GetAddressesOptions::default() + .with_coin_type(SHIMMER_COIN_TYPE) + .with_range(0..1), + ) + .await?[0] + .clone() + .into_inner(); + + let protocol_parameters = protocol_parameters(); + let slot_commitment_id_1 = rand_slot_commitment_id(); + let slot_index_1 = slot_commitment_id_1.slot_index(); + let slot_commitment_id_2 = rand_slot_commitment_id() + .hash() + .into_slot_commitment_id(slot_index_1 + 100); + let slot_index_2 = slot_commitment_id_2.slot_index(); + + let validator_address = rand_account_address(); + + let inputs = build_inputs( + [( + Delegation { + amount: 1_000_000, + delegation_amount: 1_000_000, + delegation_id: DelegationId::null(), + address: address.clone(), + validator_address, + start_epoch: *protocol_parameters.delegation_start_epoch(slot_commitment_id_1), + end_epoch: 0, + }, + Some(Bip44::new(SHIMMER_COIN_TYPE)), + )], + Some(slot_index_1), + ); + + let outputs = build_outputs([Basic { + amount: 1_000_000, + address, + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }]); + + let transaction = Transaction::builder(protocol_parameters.network_id()) + .with_inputs( + inputs + .iter() + .map(|i| Input::Utxo(UtxoInput::from(*i.output_metadata.output_id()))) + .collect::>(), + ) + .with_outputs(outputs) + .with_creation_slot(slot_index_2 + 1) + .with_context_inputs([CommitmentContextInput::new(slot_commitment_id_2).into()]) + .finish_with_params(&protocol_parameters)?; + + let prepared_transaction_data = PreparedTransactionData { + transaction, + inputs_data: inputs, + remainders: Vec::new(), + mana_rewards: Default::default(), + }; + + let unlocks = secret_manager + .transaction_unlocks(&prepared_transaction_data, &protocol_parameters) + .await?; + + assert_eq!(unlocks.len(), 1); + assert_eq!((*unlocks).first().unwrap().kind(), SignatureUnlock::KIND); + + let tx_payload = SignedTransactionPayload::new(prepared_transaction_data.transaction.clone(), unlocks)?; + + validate_signed_transaction_payload_length(&tx_payload)?; + + let conflict = verify_semantic( + &prepared_transaction_data.inputs_data, + &tx_payload, + prepared_transaction_data.mana_rewards, + protocol_parameters, + )?; + + assert_eq!(conflict, Some(TransactionFailureReason::DelegationRewardInputMissing)); + + Ok(()) +} diff --git a/sdk/tests/client/signing/mod.rs b/sdk/tests/client/signing/mod.rs index 530c1d36e7..6f69f01dbd 100644 --- a/sdk/tests/client/signing/mod.rs +++ b/sdk/tests/client/signing/mod.rs @@ -3,6 +3,7 @@ mod account; mod basic; +mod delegation; mod nft; use std::str::FromStr; @@ -75,121 +76,229 @@ async fn all_combined() -> Result<()> { let inputs = build_inputs( [ - Account(1_000_000, account_id_1, nft_1.clone(), None, None, None), - Account( - 1_000_000, - account_id_2, - ed25519_0.clone(), - None, + ( + Account { + amount: 1_000_000, + account_id: account_id_1, + address: nft_1.clone(), + sender: None, + issuer: None, + }, None, + ), + ( + Account { + amount: 1_000_000, + account_id: account_id_2, + address: ed25519_0.clone(), + sender: None, + issuer: None, + }, Some(Bip44::new(SHIMMER_COIN_TYPE)), ), - Basic(1_000_000, account_1.clone(), None, None, None, None, None, None), - Basic(1_000_000, account_2.clone(), None, None, None, None, None, None), - Basic(1_000_000, account_2, None, None, None, None, None, None), - Basic(1_000_000, nft_2.clone(), None, None, None, None, None, None), - Basic(1_000_000, nft_2, None, None, None, None, None, None), - Basic(1_000_000, nft_4.clone(), None, None, None, None, None, None), - Basic( - 1_000_000, - ed25519_0.clone(), - None, - None, + ( + Basic { + amount: 1_000_000, + address: account_1.clone(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, - None, - None, - Some(Bip44::new(SHIMMER_COIN_TYPE)), ), - Basic( - 1_000_000, - ed25519_1.clone(), + ( + Basic { + amount: 1_000_000, + address: account_2.clone(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, + ), + ( + Basic { + amount: 1_000_000, + address: account_2, + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, + ), + ( + Basic { + amount: 1_000_000, + address: nft_2.clone(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, + ), + ( + Basic { + amount: 1_000_000, + address: nft_2, + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, + ), + ( + Basic { + amount: 1_000_000, + address: nft_4.clone(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, + ), + ( + Basic { + amount: 1_000_000, + address: ed25519_0.clone(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, + Some(Bip44::new(SHIMMER_COIN_TYPE)), + ), + ( + Basic { + amount: 1_000_000, + address: ed25519_1.clone(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, Some(Bip44::new(SHIMMER_COIN_TYPE).with_address_index(1)), ), - Basic( - 1_000_000, - ed25519_2.clone(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: ed25519_2.clone(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, Some(Bip44::new(SHIMMER_COIN_TYPE).with_address_index(2)), ), - Basic( - 1_000_000, - ed25519_2.clone(), - None, - None, - None, - None, - None, + ( + Basic { + amount: 1_000_000, + address: ed25519_2.clone(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, Some(Bip44::new(SHIMMER_COIN_TYPE).with_address_index(2)), ), - Nft( - 1_000_000, - nft_id_1, - ed25519_0.clone(), - None, - None, - None, - None, + ( + Nft { + amount: 1_000_000, + nft_id: nft_id_1, + address: ed25519_0.clone(), + sender: None, + issuer: None, + sdruc: None, + expiration: None, + }, Some(Bip44::new(SHIMMER_COIN_TYPE)), ), - Nft(1_000_000, nft_id_2, account_1.clone(), None, None, None, None, None), - // Expirations - Basic( - 2_000_000, - ed25519_0.clone(), - None, - None, - None, - None, - Some((account_1.clone(), 50)), + ( + Nft { + amount: 1_000_000, + nft_id: nft_id_2, + address: account_1.clone(), + sender: None, + issuer: None, + sdruc: None, + expiration: None, + }, None, ), - Basic( - 2_000_000, - ed25519_0.clone(), - None, - None, - None, - None, - Some((nft_3.clone(), 50)), + // Expirations + ( + Basic { + amount: 2_000_000, + address: ed25519_0.clone(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: Some((account_1.clone(), 50)), + }, None, ), - Basic( - 2_000_000, - ed25519_0.clone(), - None, + ( + Basic { + amount: 2_000_000, + address: ed25519_0.clone(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: Some((nft_3.clone(), 50)), + }, None, - None, - None, - Some((nft_3.clone(), 150)), + ), + ( + Basic { + amount: 2_000_000, + address: ed25519_0.clone(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: Some((nft_3.clone(), 150)), + }, Some(Bip44::new(SHIMMER_COIN_TYPE)), ), - Nft( - 1_000_000, - nft_id_3, - account_1.clone(), - None, - None, - None, - Some((nft_4, 50)), + ( + Nft { + amount: 1_000_000, + nft_id: nft_id_3, + address: account_1.clone(), + sender: None, + issuer: None, + sdruc: None, + expiration: Some((nft_4, 50)), + }, None, ), - Nft( - 1_000_000, - nft_id_4, - account_1, - None, - None, - None, - Some((nft_3, 150)), + ( + Nft { + amount: 1_000_000, + nft_id: nft_id_4, + address: account_1, + sender: None, + issuer: None, + sdruc: None, + expiration: Some((nft_3, 150)), + }, None, ), ], @@ -197,13 +306,65 @@ async fn all_combined() -> Result<()> { ); let outputs = build_outputs([ - Account(1_000_000, account_id_1, nft_1, None, None, None), - Account(1_000_000, account_id_2, ed25519_0.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), + Account { + amount: 1_000_000, + account_id: account_id_1, + address: nft_1, + sender: None, + issuer: None, + }, + Account { + amount: 1_000_000, + account_id: account_id_2, + address: ed25519_0.clone(), + sender: None, + issuer: None, + }, + Basic { + amount: 10_000_000, + address: ed25519_0.clone(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, + Nft { + amount: 1_000_000, + nft_id: nft_id_1, + address: ed25519_0.clone(), + sender: None, + issuer: None, + sdruc: None, + expiration: None, + }, + Nft { + amount: 1_000_000, + nft_id: nft_id_2, + address: ed25519_0.clone(), + sender: None, + issuer: None, + sdruc: None, + expiration: None, + }, + Nft { + amount: 1_000_000, + nft_id: nft_id_3, + address: ed25519_0.clone(), + sender: None, + issuer: None, + sdruc: None, + expiration: None, + }, + Nft { + amount: 1_000_000, + nft_id: nft_id_4, + address: ed25519_0.clone(), + sender: None, + issuer: None, + sdruc: None, + expiration: None, + }, ]); let selected = InputSelection::new( diff --git a/sdk/tests/client/signing/nft.rs b/sdk/tests/client/signing/nft.rs index b797a3e29d..b42c300f8e 100644 --- a/sdk/tests/client/signing/nft.rs +++ b/sdk/tests/client/signing/nft.rs @@ -53,25 +53,65 @@ async fn nft_reference_unlocks() -> Result<()> { let inputs = build_inputs( [ - Nft( - 1_000_000, - nft_id, - address_0.clone(), - None, - None, + ( + Nft { + amount: 1_000_000, + nft_id: nft_id, + address: address_0.clone(), + sender: None, + issuer: None, + sdruc: None, + expiration: None, + }, + Some(Bip44::new(SHIMMER_COIN_TYPE)), + ), + ( + Basic { + amount: 1_000_000, + address: nft_address.clone(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, + ), + ( + Basic { + amount: 1_000_000, + address: nft_address.clone(), + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, None, - Some(Bip44::new(SHIMMER_COIN_TYPE)), ), - Basic(1_000_000, nft_address.clone(), None, None, None, None, None, None), - Basic(1_000_000, nft_address.clone(), None, None, None, None, None, None), ], Some(slot_index), ); let outputs = build_outputs([ - Nft(1_000_000, nft_id, address_0, None, None, None, None, None), - Basic(2_000_000, nft_address, None, None, None, None, None, None), + Nft { + amount: 1_000_000, + nft_id: nft_id, + address: address_0, + sender: None, + issuer: None, + sdruc: None, + expiration: None, + }, + Basic { + amount: 2_000_000, + address: nft_address, + native_token: None, + sender: None, + sdruc: None, + timelock: None, + expiration: None, + }, ]); let transaction = Transaction::builder(protocol_parameters.network_id()) diff --git a/sdk/tests/wallet/balance.rs b/sdk/tests/wallet/balance.rs index c5ea02a410..8e10ed9773 100644 --- a/sdk/tests/wallet/balance.rs +++ b/sdk/tests/wallet/balance.rs @@ -164,7 +164,7 @@ async fn balance_expiration() -> Result<()> { assert_eq!(balance_after_tx.base_coin().available(), 0); wallet_0 - .reissue_transaction_until_included(&tx.transaction_id, None, None) + .wait_for_transaction_acceptance(&tx.transaction_id, None, None) .await?; // Wallet 1 balance before expiration @@ -243,7 +243,7 @@ async fn balance_transfer() -> Result<()> { assert_eq!(balance_0, balance_0_sync); wallet_0 - .reissue_transaction_until_included(&tx.transaction_id, None, None) + .wait_for_transaction_acceptance(&tx.transaction_id, None, None) .await?; // Balance should have transferred entirely @@ -277,7 +277,7 @@ async fn balance_transfer() -> Result<()> { // // Only use a part as voting power // let tx = wallet.increase_voting_power(voting_power).await?; // wallet -// .reissue_transaction_until_included(&tx.transaction_id, None, None) +// .wait_for_transaction_acceptance(&tx.transaction_id, None, None) // .await?; // let balance = wallet.sync(None).await?; // assert_eq!(balance.base_coin().total(), faucet_amount); @@ -288,7 +288,7 @@ async fn balance_transfer() -> Result<()> { // // Increase voting power to total amount // let tx = wallet.increase_voting_power(faucet_amount - voting_power).await?; // wallet -// .reissue_transaction_until_included(&tx.transaction_id, None, None) +// .wait_for_transaction_acceptance(&tx.transaction_id, None, None) // .await?; // let balance = wallet.sync(None).await?; // assert_eq!(balance.base_coin().total(), faucet_amount); diff --git a/sdk/tests/wallet/burn_outputs.rs b/sdk/tests/wallet/burn_outputs.rs index 33c3367d1d..4676de5a62 100644 --- a/sdk/tests/wallet/burn_outputs.rs +++ b/sdk/tests/wallet/burn_outputs.rs @@ -33,7 +33,7 @@ async fn mint_and_burn_nft() -> Result<()> { let transaction = wallet.mint_nfts(nft_options, None).await.unwrap(); wallet - .reissue_transaction_until_included(&transaction.transaction_id, None, None) + .wait_for_transaction_acceptance(&transaction.transaction_id, None, None) .await?; let balance = wallet.sync(None).await.unwrap(); @@ -47,7 +47,7 @@ async fn mint_and_burn_nft() -> Result<()> { let transaction = wallet.burn(nft_id, None).await.unwrap(); wallet - .reissue_transaction_until_included(&transaction.transaction_id, None, None) + .wait_for_transaction_acceptance(&transaction.transaction_id, None, None) .await?; let balance = wallet.sync(None).await.unwrap(); let search = balance.nfts().iter().find(|&balance_nft_id| *balance_nft_id == nft_id); @@ -78,7 +78,7 @@ async fn mint_and_burn_expired_nft() -> Result<()> { let transaction = wallet_0.send_outputs(outputs, None).await?; wallet_0 - .reissue_transaction_until_included(&transaction.transaction_id, None, None) + .wait_for_transaction_acceptance(&transaction.transaction_id, None, None) .await?; let output_id = OutputId::new(transaction.transaction_id, 0u16); @@ -87,7 +87,7 @@ async fn mint_and_burn_expired_nft() -> Result<()> { wallet_1.sync(None).await?; let transaction = wallet_1.burn(nft_id, None).await?; wallet_1 - .reissue_transaction_until_included(&transaction.transaction_id, None, None) + .wait_for_transaction_acceptance(&transaction.transaction_id, None, None) .await?; let balance = wallet_1.sync(None).await?; // After burning the amount is available on account_1 @@ -108,9 +108,9 @@ async fn create_and_melt_native_token() -> Result<()> { // First create an account output, this needs to be done only once, because an account can have many foundry outputs let transaction = wallet.create_account_output(None, None).await?; - // Wait for transaction to get included + // Wait for transaction to get accepted wallet - .reissue_transaction_until_included(&transaction.transaction_id, None, None) + .wait_for_transaction_acceptance(&transaction.transaction_id, None, None) .await?; wallet.sync(None).await?; @@ -125,7 +125,7 @@ async fn create_and_melt_native_token() -> Result<()> { let create_transaction = wallet.create_native_token(params, None).await.unwrap(); wallet - .reissue_transaction_until_included(&create_transaction.transaction.transaction_id, None, None) + .wait_for_transaction_acceptance(&create_transaction.transaction.transaction_id, None, None) .await?; let balance = wallet.sync(None).await.unwrap(); @@ -144,7 +144,7 @@ async fn create_and_melt_native_token() -> Result<()> { .unwrap(); wallet - .reissue_transaction_until_included(&transaction.transaction_id, None, None) + .wait_for_transaction_acceptance(&transaction.transaction_id, None, None) .await?; let balance = wallet.sync(None).await.unwrap(); println!("wallet balance -> {}", serde_json::to_string(&balance).unwrap()); @@ -163,7 +163,7 @@ async fn create_and_melt_native_token() -> Result<()> { .unwrap(); wallet - .reissue_transaction_until_included(&transaction.transaction_id, None, None) + .wait_for_transaction_acceptance(&transaction.transaction_id, None, None) .await?; let balance = wallet.sync(None).await.unwrap(); println!("wallet balance -> {}", serde_json::to_string(&balance).unwrap()); @@ -188,7 +188,7 @@ async fn destroy_foundry(wallet: &Wallet) -> Result<()> { let transaction = wallet.burn(foundry_id, None).await.unwrap(); wallet - .reissue_transaction_until_included(&transaction.transaction_id, None, None) + .wait_for_transaction_acceptance(&transaction.transaction_id, None, None) .await?; let balance = wallet.sync(None).await.unwrap(); let search = balance @@ -210,7 +210,7 @@ async fn destroy_account(wallet: &Wallet) -> Result<()> { println!("account_id -> {account_id}"); let transaction = wallet.burn(account_id, None).await.unwrap(); wallet - .reissue_transaction_until_included(&transaction.transaction_id, None, None) + .wait_for_transaction_acceptance(&transaction.transaction_id, None, None) .await?; let balance = wallet.sync(None).await.unwrap(); let search = balance @@ -237,7 +237,7 @@ async fn create_and_burn_native_tokens() -> Result<()> { let tx = wallet.create_account_output(None, None).await?; wallet - .reissue_transaction_until_included(&tx.transaction_id, None, None) + .wait_for_transaction_acceptance(&tx.transaction_id, None, None) .await?; wallet.sync(None).await?; @@ -253,7 +253,7 @@ async fn create_and_burn_native_tokens() -> Result<()> { ) .await?; wallet - .reissue_transaction_until_included(&create_tx.transaction.transaction_id, None, None) + .wait_for_transaction_acceptance(&create_tx.transaction.transaction_id, None, None) .await?; wallet.sync(None).await?; @@ -261,7 +261,7 @@ async fn create_and_burn_native_tokens() -> Result<()> { .burn(NativeToken::new(create_tx.token_id, native_token_amount)?, None) .await?; wallet - .reissue_transaction_until_included(&tx.transaction_id, None, None) + .wait_for_transaction_acceptance(&tx.transaction_id, None, None) .await?; let balance = wallet.sync(None).await?; @@ -281,7 +281,7 @@ async fn mint_and_burn_nft_with_account() -> Result<()> { let tx = wallet.create_account_output(None, None).await?; wallet - .reissue_transaction_until_included(&tx.transaction_id, None, None) + .wait_for_transaction_acceptance(&tx.transaction_id, None, None) .await?; wallet.sync(None).await?; @@ -292,7 +292,7 @@ async fn mint_and_burn_nft_with_account() -> Result<()> { )]; let nft_tx = wallet.mint_nfts(nft_options, None).await.unwrap(); wallet - .reissue_transaction_until_included(&nft_tx.transaction_id, None, None) + .wait_for_transaction_acceptance(&nft_tx.transaction_id, None, None) .await?; let output_id = OutputId::new(nft_tx.transaction_id, 0u16); let nft_id = NftId::from(&output_id); @@ -304,7 +304,7 @@ async fn mint_and_burn_nft_with_account() -> Result<()> { .burn(Burn::new().add_nft(nft_id).add_account(*account_id), None) .await?; wallet - .reissue_transaction_until_included(&burn_tx.transaction_id, None, None) + .wait_for_transaction_acceptance(&burn_tx.transaction_id, None, None) .await?; let balance = wallet.sync(None).await?; diff --git a/sdk/tests/wallet/claim_outputs.rs b/sdk/tests/wallet/claim_outputs.rs index f582e7c3eb..946db76f53 100644 --- a/sdk/tests/wallet/claim_outputs.rs +++ b/sdk/tests/wallet/claim_outputs.rs @@ -42,7 +42,7 @@ async fn claim_2_basic_micro_outputs() -> Result<()> { .await?; wallet_1 - .reissue_transaction_until_included(&tx.transaction_id, None, None) + .wait_for_transaction_acceptance(&tx.transaction_id, None, None) .await?; // Claim with account 0 @@ -54,7 +54,7 @@ async fn claim_2_basic_micro_outputs() -> Result<()> { .claim_outputs(wallet_0.claimable_outputs(OutputsToClaim::MicroTransactions).await?) .await?; wallet_0 - .reissue_transaction_until_included(&tx.transaction_id, None, None) + .wait_for_transaction_acceptance(&tx.transaction_id, None, None) .await?; let balance = wallet_0.sync(None).await.unwrap(); @@ -99,7 +99,7 @@ async fn claim_1_of_2_basic_outputs() -> Result<()> { .await?; wallet_1 - .reissue_transaction_until_included(&tx.transaction_id, None, None) + .wait_for_transaction_acceptance(&tx.transaction_id, None, None) .await?; // Claim with account 0 @@ -111,7 +111,7 @@ async fn claim_1_of_2_basic_outputs() -> Result<()> { .claim_outputs(wallet_0.claimable_outputs(OutputsToClaim::Amount).await?) .await?; wallet_0 - .reissue_transaction_until_included(&tx.transaction_id, None, None) + .wait_for_transaction_acceptance(&tx.transaction_id, None, None) .await?; let balance = wallet_0.sync(None).await.unwrap(); @@ -158,7 +158,7 @@ async fn claim_2_basic_outputs_no_outputs_in_claim_account() -> Result<()> { let tx = wallet_0.send_outputs(outputs, None).await?; wallet_0 - .reissue_transaction_until_included(&tx.transaction_id, None, None) + .wait_for_transaction_acceptance(&tx.transaction_id, None, None) .await?; // Claim with wallet 1 @@ -170,7 +170,7 @@ async fn claim_2_basic_outputs_no_outputs_in_claim_account() -> Result<()> { .claim_outputs(wallet_1.claimable_outputs(OutputsToClaim::All).await?) .await?; wallet_1 - .reissue_transaction_until_included(&tx.transaction_id, None, None) + .wait_for_transaction_acceptance(&tx.transaction_id, None, None) .await?; let balance = wallet_1.sync(None).await.unwrap(); @@ -201,7 +201,7 @@ async fn claim_2_native_tokens() -> Result<()> { let tx = wallet_1.create_account_output(None, None).await?; wallet_1 - .reissue_transaction_until_included(&tx.transaction_id, None, None) + .wait_for_transaction_acceptance(&tx.transaction_id, None, None) .await?; wallet_1.sync(None).await?; @@ -217,7 +217,7 @@ async fn claim_2_native_tokens() -> Result<()> { ) .await?; wallet_1 - .reissue_transaction_until_included(&create_tx_0.transaction.transaction_id, None, None) + .wait_for_transaction_acceptance(&create_tx_0.transaction.transaction_id, None, None) .await?; wallet_1.sync(None).await?; @@ -233,7 +233,7 @@ async fn claim_2_native_tokens() -> Result<()> { ) .await?; wallet_1 - .reissue_transaction_until_included(&create_tx_1.transaction.transaction_id, None, None) + .wait_for_transaction_acceptance(&create_tx_1.transaction.transaction_id, None, None) .await?; wallet_1.sync(None).await?; @@ -247,7 +247,7 @@ async fn claim_2_native_tokens() -> Result<()> { ) .await?; wallet_1 - .reissue_transaction_until_included(&tx.transaction_id, None, None) + .wait_for_transaction_acceptance(&tx.transaction_id, None, None) .await?; // Claim with account 0 @@ -258,7 +258,7 @@ async fn claim_2_native_tokens() -> Result<()> { .claim_outputs(wallet_0.claimable_outputs(OutputsToClaim::NativeTokens).await?) .await?; wallet_0 - .reissue_transaction_until_included(&tx.transaction_id, None, None) + .wait_for_transaction_acceptance(&tx.transaction_id, None, None) .await?; let balance = wallet_0.sync(None).await.unwrap(); @@ -292,7 +292,7 @@ async fn claim_2_native_tokens_no_outputs_in_claim_account() -> Result<()> { let tx = wallet_0.create_account_output(None, None).await?; wallet_0 - .reissue_transaction_until_included(&tx.transaction_id, None, None) + .wait_for_transaction_acceptance(&tx.transaction_id, None, None) .await?; wallet_0.sync(None).await?; @@ -308,7 +308,7 @@ async fn claim_2_native_tokens_no_outputs_in_claim_account() -> Result<()> { ) .await?; wallet_0 - .reissue_transaction_until_included(&create_tx_0.transaction.transaction_id, None, None) + .wait_for_transaction_acceptance(&create_tx_0.transaction.transaction_id, None, None) .await?; wallet_0.sync(None).await?; @@ -324,7 +324,7 @@ async fn claim_2_native_tokens_no_outputs_in_claim_account() -> Result<()> { ) .await?; wallet_0 - .reissue_transaction_until_included(&create_tx_1.transaction.transaction_id, None, None) + .wait_for_transaction_acceptance(&create_tx_1.transaction.transaction_id, None, None) .await?; wallet_0.sync(None).await?; @@ -354,7 +354,7 @@ async fn claim_2_native_tokens_no_outputs_in_claim_account() -> Result<()> { ) .await?; wallet_0 - .reissue_transaction_until_included(&tx.transaction_id, None, None) + .wait_for_transaction_acceptance(&tx.transaction_id, None, None) .await?; // Claim with account 1 @@ -365,7 +365,7 @@ async fn claim_2_native_tokens_no_outputs_in_claim_account() -> Result<()> { .claim_outputs(wallet_1.claimable_outputs(OutputsToClaim::NativeTokens).await?) .await?; wallet_1 - .reissue_transaction_until_included(&tx.transaction_id, None, None) + .wait_for_transaction_acceptance(&tx.transaction_id, None, None) .await?; let balance = wallet_1.sync(None).await.unwrap(); @@ -420,7 +420,7 @@ async fn claim_2_nft_outputs() -> Result<()> { let tx = wallet_1.send_outputs(outputs, None).await?; wallet_1 - .reissue_transaction_until_included(&tx.transaction_id, None, None) + .wait_for_transaction_acceptance(&tx.transaction_id, None, None) .await?; // Claim with account 0 @@ -431,7 +431,7 @@ async fn claim_2_nft_outputs() -> Result<()> { .claim_outputs(wallet_0.claimable_outputs(OutputsToClaim::Nfts).await?) .await?; wallet_0 - .reissue_transaction_until_included(&tx.transaction_id, None, None) + .wait_for_transaction_acceptance(&tx.transaction_id, None, None) .await?; let balance = wallet_0.sync(None).await.unwrap(); @@ -481,7 +481,7 @@ async fn claim_2_nft_outputs_no_outputs_in_claim_account() -> Result<()> { let tx = wallet_0.send_outputs(outputs, None).await?; wallet_0 - .reissue_transaction_until_included(&tx.transaction_id, None, None) + .wait_for_transaction_acceptance(&tx.transaction_id, None, None) .await?; // Claim with wallet 1 @@ -492,7 +492,7 @@ async fn claim_2_nft_outputs_no_outputs_in_claim_account() -> Result<()> { .claim_outputs(wallet_1.claimable_outputs(OutputsToClaim::Nfts).await?) .await?; wallet_1 - .reissue_transaction_until_included(&tx.transaction_id, None, None) + .wait_for_transaction_acceptance(&tx.transaction_id, None, None) .await?; let balance = wallet_1.sync(None).await.unwrap(); @@ -530,7 +530,7 @@ async fn claim_basic_micro_output_error() -> Result<()> { .await?; wallet_0 - .reissue_transaction_until_included(&tx.transaction_id, None, None) + .wait_for_transaction_acceptance(&tx.transaction_id, None, None) .await?; // Try claim with account 1 will fail since it has no funds to cover the storage deposit diff --git a/sdk/tests/wallet/consolidation.rs b/sdk/tests/wallet/consolidation.rs index b428c2377c..cb0341dcd6 100644 --- a/sdk/tests/wallet/consolidation.rs +++ b/sdk/tests/wallet/consolidation.rs @@ -26,7 +26,7 @@ async fn consolidation() -> Result<()> { .await?; wallet_0 - .reissue_transaction_until_included(&tx.transaction_id, None, None) + .wait_for_transaction_acceptance(&tx.transaction_id, None, None) .await?; let balance = wallet_1.sync(None).await.unwrap(); @@ -37,7 +37,7 @@ async fn consolidation() -> Result<()> { .consolidate_outputs(ConsolidationParams::new().with_force(true)) .await?; wallet_1 - .reissue_transaction_until_included(&tx.transaction_id, None, None) + .wait_for_transaction_acceptance(&tx.transaction_id, None, None) .await?; let balance = wallet_1.sync(None).await.unwrap(); diff --git a/sdk/tests/wallet/native_tokens.rs b/sdk/tests/wallet/native_tokens.rs index 89466bc9bd..71bdeda795 100644 --- a/sdk/tests/wallet/native_tokens.rs +++ b/sdk/tests/wallet/native_tokens.rs @@ -22,7 +22,7 @@ async fn create_and_mint_native_token() -> Result<()> { let tx = wallet.create_account_output(None, None).await?; wallet - .reissue_transaction_until_included(&tx.transaction_id, None, None) + .wait_for_transaction_acceptance(&tx.transaction_id, None, None) .await?; wallet.sync(None).await?; @@ -38,7 +38,7 @@ async fn create_and_mint_native_token() -> Result<()> { ) .await?; wallet - .reissue_transaction_until_included(&create_tx.transaction.transaction_id, None, None) + .wait_for_transaction_acceptance(&create_tx.transaction.transaction_id, None, None) .await?; let balance = wallet.sync(None).await?; assert_eq!(balance.native_tokens().len(), 1); @@ -49,7 +49,7 @@ async fn create_and_mint_native_token() -> Result<()> { let tx = wallet.mint_native_token(create_tx.token_id, 50, None).await?; wallet - .reissue_transaction_until_included(&tx.transaction_id, None, None) + .wait_for_transaction_acceptance(&tx.transaction_id, None, None) .await?; let balance = wallet.sync(None).await?; assert_eq!(balance.native_tokens().len(), 1); @@ -73,7 +73,7 @@ async fn native_token_foundry_metadata() -> Result<()> { let tx = wallet.create_account_output(None, None).await?; wallet - .reissue_transaction_until_included(&tx.transaction_id, None, None) + .wait_for_transaction_acceptance(&tx.transaction_id, None, None) .await?; wallet.sync(None).await?; @@ -91,7 +91,7 @@ async fn native_token_foundry_metadata() -> Result<()> { ) .await?; wallet - .reissue_transaction_until_included(&create_tx.transaction.transaction_id, None, None) + .wait_for_transaction_acceptance(&create_tx.transaction.transaction_id, None, None) .await?; // Sync native_token_foundries to get the metadata let balance = wallet diff --git a/sdk/tests/wallet/output_preparation.rs b/sdk/tests/wallet/output_preparation.rs index c966f3a434..d4343fb8c2 100644 --- a/sdk/tests/wallet/output_preparation.rs +++ b/sdk/tests/wallet/output_preparation.rs @@ -560,7 +560,7 @@ async fn prepare_nft_output_features_update() -> Result<()> { let transaction = wallet.mint_nfts(nft_options, None).await.unwrap(); wallet - .reissue_transaction_until_included(&transaction.transaction_id, None, None) + .wait_for_transaction_acceptance(&transaction.transaction_id, None, None) .await?; let nft_id = *wallet.sync(None).await?.nfts().first().unwrap(); @@ -647,7 +647,7 @@ async fn prepare_output_remainder_dust() -> Result<()> { .await?; let transaction = wallet_0.send_outputs(vec![output], None).await?; wallet_0 - .reissue_transaction_until_included(&transaction.transaction_id, None, None) + .wait_for_transaction_acceptance(&transaction.transaction_id, None, None) .await?; let balance = wallet_0.sync(None).await?; @@ -775,7 +775,7 @@ async fn prepare_output_only_single_nft() -> Result<()> { .mint_nfts([MintNftParams::new().try_with_address(wallet_1_address)?], None) .await?; wallet_0 - .reissue_transaction_until_included(&tx.transaction_id, None, None) + .wait_for_transaction_acceptance(&tx.transaction_id, None, None) .await?; let balance = wallet_1.sync(None).await?; @@ -807,7 +807,7 @@ async fn prepare_output_only_single_nft() -> Result<()> { .await?; let tx = wallet_1.send_outputs([output], None).await?; wallet_1 - .reissue_transaction_until_included(&tx.transaction_id, None, None) + .wait_for_transaction_acceptance(&tx.transaction_id, None, None) .await?; // wallet_0 now has the NFT @@ -845,7 +845,7 @@ async fn prepare_existing_nft_output_gift() -> Result<()> { let transaction = wallet.mint_nfts(nft_options, None).await.unwrap(); wallet - .reissue_transaction_until_included(&transaction.transaction_id, None, None) + .wait_for_transaction_acceptance(&transaction.transaction_id, None, None) .await?; let nft_id = *wallet.sync(None).await?.nfts().first().unwrap(); diff --git a/sdk/tests/wallet/syncing.rs b/sdk/tests/wallet/syncing.rs index 6a417f379d..cbafe71189 100644 --- a/sdk/tests/wallet/syncing.rs +++ b/sdk/tests/wallet/syncing.rs @@ -110,7 +110,7 @@ // let tx = wallet_0.send_outputs(outputs, None).await?; // wallet_0 -// .reissue_transaction_until_included(&tx.transaction_id, None, None) +// .wait_for_transaction_acceptance(&tx.transaction_id, None, None) // .await?; // // Sync with sync_only_most_basic_outputs: true, only the first output should be synced @@ -169,7 +169,7 @@ // let tx = wallet_0.send_outputs(outputs, None).await?; // wallet_0 -// .reissue_transaction_until_included(&tx.transaction_id, None, None) +// .wait_for_transaction_acceptance(&tx.transaction_id, None, None) // .await?; // wallet_1 diff --git a/sdk/tests/wallet/transactions.rs b/sdk/tests/wallet/transactions.rs index 86d9776ce5..30c7943c2b 100644 --- a/sdk/tests/wallet/transactions.rs +++ b/sdk/tests/wallet/transactions.rs @@ -25,7 +25,7 @@ use crate::wallet::common::{make_wallet, request_funds, setup, tear_down}; // .await?; // wallet_0 -// .reissue_transaction_until_included(&tx.transaction_id, None, None) +// .wait_for_transaction_acceptance(&tx.transaction_id, None, None) // .await?; // let balance = wallet_1.sync(None).await.unwrap(); @@ -63,7 +63,7 @@ use crate::wallet::common::{make_wallet, request_funds, setup, tear_down}; // .await?; // wallet_0 -// .reissue_transaction_until_included(&tx.transaction_id, None, None) +// .wait_for_transaction_acceptance(&tx.transaction_id, None, None) // .await?; // let balance = wallet_1.sync(None).await.unwrap(); @@ -95,7 +95,7 @@ use crate::wallet::common::{make_wallet, request_funds, setup, tear_down}; // .await?; // wallet_0 -// .reissue_transaction_until_included(&tx.transaction_id, None, None) +// .wait_for_transaction_acceptance(&tx.transaction_id, None, None) // .await?; // let balance = wallet_1.sync(None).await.unwrap(); @@ -139,7 +139,7 @@ use crate::wallet::common::{make_wallet, request_funds, setup, tear_down}; // let transaction = wallet_0.mint_nfts(nft_options, None).await.unwrap(); // wallet_0 -// .reissue_transaction_until_included(&transaction.transaction_id, None, None) +// .wait_for_transaction_acceptance(&transaction.transaction_id, None, None) // .await?; // let nft_id = *wallet_0.sync(None).await?.nfts().first().unwrap(); @@ -152,7 +152,7 @@ use crate::wallet::common::{make_wallet, request_funds, setup, tear_down}; // .await // .unwrap(); // wallet_0 -// .reissue_transaction_until_included(&transaction.transaction_id, None, None) +// .wait_for_transaction_acceptance(&transaction.transaction_id, None, None) // .await?; // let balance = wallet_1.sync(None).await?; @@ -219,7 +219,7 @@ use crate::wallet::common::{make_wallet, request_funds, setup, tear_down}; // ) // .await?; // wallet_0 -// .reissue_transaction_until_included(&tx.transaction_id, None, None) +// .wait_for_transaction_acceptance(&tx.transaction_id, None, None) // .await?; // // Second transaction will be conflicting // let tx = wallet_1 @@ -235,16 +235,16 @@ use crate::wallet::common::{make_wallet, request_funds, setup, tear_down}; // .await?; // // Should return an error since the tx is conflicting // match wallet_1 -// .reissue_transaction_until_included(&tx.transaction_id, None, None) +// .wait_for_transaction_acceptance(&tx.transaction_id, None, None) // .await // .unwrap_err() // { // iota_sdk::wallet::Error::Client(client_error) => { -// let iota_sdk::client::Error::TangleInclusion(_) = *client_error else { -// panic!("Expected TangleInclusion error"); +// let iota_sdk::client::Error::TransactionAcceptance(_) = *client_error else { +// panic!("Expected TransactionAcceptance error"); // }; // } -// _ => panic!("Expected TangleInclusion error"), +// _ => panic!("Expected TransactionAcceptance error"), // } // // After syncing the balance is still equal