From 8a3933f84becd1dbea045fc8e6a5068ae266a643 Mon Sep 17 00:00:00 2001 From: Thoralf-M <46689931+Thoralf-M@users.noreply.github.com> Date: Mon, 12 Feb 2024 18:18:40 +0100 Subject: [PATCH] Replace reissue_transaction_until_included() with wait_for_transaction_acceptance() (#1979) * reissue_transaction_until_included -> await_transaction_acceptance * Update log * Change interval to ms, update error * Fix wasm * Apply suggestions from code review Co-authored-by: DaughterOfMars * Casing * Review suggestions * Don't build block, rename file, move failed code into TransactionState::Failed branch * Rename to wait_for * Apply suggestions from code review Co-authored-by: DaughterOfMars * fmt * Adapt to rename * Rename part 2 * Duration const, use block id from node response, move timeouts after first request * Rename const --------- Co-authored-by: DaughterOfMars --- bindings/core/src/method/wallet.rs | 6 +- bindings/core/src/method_handler/wallet.rs | 4 +- bindings/core/src/response.rs | 2 +- .../examples/how_tos/account_output/create.ts | 6 +- .../how_tos/account_output/destroy.ts | 6 +- .../how_tos/account_output/send-amount.ts | 2 +- .../advanced_transaction.ts | 4 +- .../claim_transaction.ts | 2 +- .../send_micro_transaction.ts | 2 +- .../examples/how_tos/native_tokens/burn.ts | 6 +- .../examples/how_tos/native_tokens/create.ts | 12 +- .../how_tos/native_tokens/destroy-foundry.ts | 6 +- .../examples/how_tos/native_tokens/melt.ts | 6 +- .../examples/how_tos/native_tokens/mint.ts | 6 +- .../examples/how_tos/native_tokens/send.ts | 6 +- .../nft_collection/00_mint_issuer_nft.ts | 6 +- .../nft_collection/01_mint_collection_nft.ts | 6 +- .../nodejs/examples/how_tos/nfts/burn_nft.ts | 6 +- .../nodejs/examples/how_tos/nfts/mint_nft.ts | 12 +- .../nodejs/examples/how_tos/nfts/send_nft.ts | 6 +- .../how_tos/wallet/consolidate-outputs.ts | 6 +- .../wallet/06-send-micro-transaction.ts | 6 +- bindings/nodejs/lib/types/error.ts | 2 +- .../nodejs/lib/types/wallet/bridge/index.ts | 4 +- .../nodejs/lib/types/wallet/bridge/wallet.ts | 4 +- .../nodejs/lib/types/wallet/transaction.ts | 4 + bindings/nodejs/lib/wallet/wallet.ts | 8 +- .../how_tos/account_output/send_amount.py | 8 +- .../advanced_transaction.py | 2 +- .../claim_transaction.py | 2 +- .../send_micro_transaction.py | 2 +- .../examples/how_tos/native_tokens/burn.py | 6 +- .../examples/how_tos/native_tokens/create.py | 13 +- .../how_tos/native_tokens/destroy_foundry.py | 6 +- .../examples/how_tos/native_tokens/melt.py | 6 +- .../examples/how_tos/native_tokens/mint.py | 6 +- .../examples/how_tos/native_tokens/send.py | 6 +- .../nft_collection/00_mint_issuer_nft.py | 4 +- .../nft_collection/01_mint_collection_nft.py | 4 +- .../how_tos/wallet/consolidate_outputs.py | 6 +- .../offline_signing/3_send_transaction.py | 4 +- .../types/transaction_with_metadata.py | 4 + bindings/python/iota_sdk/wallet/wallet.py | 8 +- cli/src/wallet_cli/mod.rs | 2 +- sdk/examples/how_tos/account_output/create.rs | 4 +- .../how_tos/account_output/destroy.rs | 4 +- .../how_tos/account_output/send_amount.rs | 2 +- .../advanced_transaction.rs | 4 +- .../claim_transaction.rs | 4 +- .../send_micro_transaction.rs | 6 +- sdk/examples/how_tos/native_tokens/burn.rs | 4 +- sdk/examples/how_tos/native_tokens/create.rs | 12 +- .../how_tos/native_tokens/destroy_foundry.rs | 8 +- sdk/examples/how_tos/native_tokens/melt.rs | 4 +- sdk/examples/how_tos/native_tokens/mint.rs | 4 +- sdk/examples/how_tos/native_tokens/send.rs | 6 +- .../nft_collection/00_mint_issuer_nft.rs | 6 +- .../nft_collection/01_mint_collection_nft.rs | 6 +- sdk/examples/how_tos/nfts/burn_nft.rs | 4 +- sdk/examples/how_tos/nfts/mint_nft.rs | 12 +- sdk/examples/how_tos/nfts/send_nft.rs | 6 +- .../simple_transaction/simple_transaction.rs | 6 +- .../how_tos/wallet/consolidate_outputs.rs | 6 +- sdk/examples/wallet/events.rs | 4 +- sdk/examples/wallet/ledger_nano.rs | 4 +- .../offline_signing/3_send_transaction.rs | 6 +- sdk/examples/wallet/participation.rs | 30 ++-- sdk/examples/wallet/spammer.rs | 6 +- sdk/examples/wallet/wallet.rs | 6 +- sdk/src/client/error.rs | 6 +- sdk/src/wallet/operations/mod.rs | 4 +- sdk/src/wallet/operations/reissue.rs | 141 ------------------ .../operations/wait_for_tx_acceptance.rs | 103 +++++++++++++ sdk/src/wallet/types/mod.rs | 2 + sdk/tests/client/node_api/mod.rs | 2 +- sdk/tests/wallet/balance.rs | 8 +- sdk/tests/wallet/burn_outputs.rs | 34 ++--- sdk/tests/wallet/claim_outputs.rs | 42 +++--- sdk/tests/wallet/consolidation.rs | 4 +- sdk/tests/wallet/native_tokens.rs | 10 +- sdk/tests/wallet/output_preparation.rs | 10 +- sdk/tests/wallet/syncing.rs | 4 +- sdk/tests/wallet/transactions.rs | 20 +-- 83 files changed, 382 insertions(+), 407 deletions(-) delete mode 100644 sdk/src/wallet/operations/reissue.rs create mode 100644 sdk/src/wallet/operations/wait_for_tx_acceptance.rs 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/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/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/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/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