From 6b4afc1f3d8529d25363bb1152fc5a5c6094b3b3 Mon Sep 17 00:00:00 2001 From: Firekeeper <0xFirekeeper@gmail.com> Date: Thu, 13 Feb 2025 01:26:53 +0700 Subject: [PATCH] Apply userop timeout based on client options (#128) --- .../SmartWallet/SmartWallet.cs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/Thirdweb/Thirdweb.Wallets/SmartWallet/SmartWallet.cs b/Thirdweb/Thirdweb.Wallets/SmartWallet/SmartWallet.cs index 8bdf1c8..7cc926a 100644 --- a/Thirdweb/Thirdweb.Wallets/SmartWallet/SmartWallet.cs +++ b/Thirdweb/Thirdweb.Wallets/SmartWallet/SmartWallet.cs @@ -798,11 +798,22 @@ private async Task SendUserOp(object userOperation, int? requestId = nul // Wait for the transaction to be mined string txHash = null; - while (txHash == null) + using var ct = new CancellationTokenSource(this.Client.FetchTimeoutOptions.GetTimeout(TimeoutType.Other)); + try + { + while (txHash == null) + { + ct.Token.ThrowIfCancellationRequested(); + + var userOpReceipt = await BundlerClient.EthGetUserOperationReceipt(this.Client, this._bundlerUrl, requestId, userOpHash).ConfigureAwait(false); + + txHash = userOpReceipt?.Receipt?.TransactionHash; + await ThirdwebTask.Delay(100, ct.Token).ConfigureAwait(false); + } + } + catch (OperationCanceledException) { - var userOpReceipt = await BundlerClient.EthGetUserOperationReceipt(this.Client, this._bundlerUrl, requestId, userOpHash).ConfigureAwait(false); - txHash = userOpReceipt?.Receipt?.TransactionHash; - await ThirdwebTask.Delay(100).ConfigureAwait(false); + throw new Exception($"User operation timed out with user op hash: {userOpHash}"); } this.IsDeploying = false;