diff --git a/packages/core/src/actions/smartAccount/types.ts b/packages/core/src/actions/smartAccount/types.ts index 361191380c..2f1d0216a9 100644 --- a/packages/core/src/actions/smartAccount/types.ts +++ b/packages/core/src/actions/smartAccount/types.ts @@ -86,6 +86,25 @@ export type DropAndReplaceUserOperationParameters< //#region WaitForUserOperationTxParameters export type WaitForUserOperationTxParameters = { hash: Hex; + /** + * Exponential backoff paramters that can be used to override + * the configuration on the client. If not provided, this method + * will use the paramters passed via the `opts` parameter on the + * smart account client. + */ + retries?: { + /** + * the base retry interval or delay between requests + */ + intervalMs: number; + /** + * the multiplier to exponentiate based on the number retries + * setting this to one will result in a linear backoff + */ + multiplier: number; + /** the maximum number of retries before failing */ + maxRetries: number; + }; }; //#endregion WaitForUserOperationTxParameters diff --git a/packages/core/src/actions/smartAccount/waitForUserOperationTransacation.ts b/packages/core/src/actions/smartAccount/waitForUserOperationTransacation.ts index be5026b787..7144cea96d 100644 --- a/packages/core/src/actions/smartAccount/waitForUserOperationTransacation.ts +++ b/packages/core/src/actions/smartAccount/waitForUserOperationTransacation.ts @@ -13,8 +13,6 @@ export const waitForUserOperationTransaction: < client: Client, args: WaitForUserOperationTxParameters ) => Promise = async (client, args) => { - const { hash } = args; - if (!isBaseSmartAccountClient(client)) { throw new IncompatibleClientError( "BaseSmartAccountClient", @@ -23,9 +21,18 @@ export const waitForUserOperationTransaction: < ); } - for (let i = 0; i < client.txMaxRetries; i++) { + const { + hash, + retries = { + maxRetries: client.txMaxRetries, + intervalMs: client.txRetryIntervalMs, + multiplier: client.txRetryMultiplier, + }, + } = args; + + for (let i = 0; i < retries.maxRetries; i++) { const txRetryIntervalWithJitterMs = - client.txRetryIntervalMs * Math.pow(client.txRetryMultiplier, i) + + retries.intervalMs * Math.pow(retries.multiplier, i) + Math.random() * 100; await new Promise((resolve) => diff --git a/packages/core/src/client/decorators/smartAccountClient.ts b/packages/core/src/client/decorators/smartAccountClient.ts index b6962b8daa..cb1ec10c67 100644 --- a/packages/core/src/client/decorators/smartAccountClient.ts +++ b/packages/core/src/client/decorators/smartAccountClient.ts @@ -6,7 +6,6 @@ import { type SendTransactionParameters, type Transport, type TypedData, - type WaitForTransactionReceiptParameters, } from "viem"; import type { GetAccountParameter, @@ -41,6 +40,7 @@ import type { SignUserOperationParameters, UpgradeAccountParams, UserOperationContext, + WaitForUserOperationTxParameters, } from "../../actions/smartAccount/types"; import { upgradeAccount } from "../../actions/smartAccount/upgradeAccount.js"; import { waitForUserOperationTransaction } from "../../actions/smartAccount/waitForUserOperationTransacation.js"; @@ -101,7 +101,7 @@ export type BaseSmartAccountClientActions< args: SendUserOperationParameters ) => Promise>; waitForUserOperationTransaction: ( - args: WaitForTransactionReceiptParameters + args: WaitForUserOperationTxParameters ) => Promise; upgradeAccount: ( args: UpgradeAccountParams