From b44a08f29f8e2d4175ba0c7df3f996f6a5ca5ea0 Mon Sep 17 00:00:00 2001 From: Sertug17 Date: Tue, 2 Jun 2026 22:19:45 +0300 Subject: [PATCH] docs(prepareSpendCallData): replace Promise.all with sequential awaits in eth_sendTransaction example --- .../methods/prepareSpendCallData.ts | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/packages/account-sdk/src/interface/public-utilities/spend-permission/methods/prepareSpendCallData.ts b/packages/account-sdk/src/interface/public-utilities/spend-permission/methods/prepareSpendCallData.ts index 17e5160e..492b08ff 100644 --- a/packages/account-sdk/src/interface/public-utilities/spend-permission/methods/prepareSpendCallData.ts +++ b/packages/account-sdk/src/interface/public-utilities/spend-permission/methods/prepareSpendCallData.ts @@ -90,18 +90,21 @@ export type PrepareSpendCallDataResponseType = Call[]; * }], * }); * - * // Or send the calls using eth_sendTransaction to submit both calls in exact order - * const promises = spendCalls.map((call) => provider.request({ - * method: 'eth_sendTransaction', - * params: [ - * { - * ...call, - * from: permission.permission.spender, // Must be the spender! - * } - * ] - * })) - * - * await Promise.all(promises); + * // Or send the calls using eth_sendTransaction — note: calls must be submitted + * // sequentially and awaited one at a time. Using Promise.all here would submit + * // both concurrently and risk the spend call landing before approveWithSignature + * // is confirmed, causing a revert. wallet_sendCalls with atomicRequired is safer. + * for (const call of spendCalls) { + * await provider.request({ + * method: 'eth_sendTransaction', + * params: [ + * { + * ...call, + * from: permission.permission.spender, // Must be the spender! + * } + * ] + * }); + * } * ``` */ // ERC20 transfer function ABI for recipient transfers