Skip to content

Commit 6b4afc1

Browse files
authored
Apply userop timeout based on client options (#128)
1 parent bee1518 commit 6b4afc1

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

Thirdweb/Thirdweb.Wallets/SmartWallet/SmartWallet.cs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -798,11 +798,22 @@ private async Task<string> SendUserOp(object userOperation, int? requestId = nul
798798
// Wait for the transaction to be mined
799799

800800
string txHash = null;
801-
while (txHash == null)
801+
using var ct = new CancellationTokenSource(this.Client.FetchTimeoutOptions.GetTimeout(TimeoutType.Other));
802+
try
803+
{
804+
while (txHash == null)
805+
{
806+
ct.Token.ThrowIfCancellationRequested();
807+
808+
var userOpReceipt = await BundlerClient.EthGetUserOperationReceipt(this.Client, this._bundlerUrl, requestId, userOpHash).ConfigureAwait(false);
809+
810+
txHash = userOpReceipt?.Receipt?.TransactionHash;
811+
await ThirdwebTask.Delay(100, ct.Token).ConfigureAwait(false);
812+
}
813+
}
814+
catch (OperationCanceledException)
802815
{
803-
var userOpReceipt = await BundlerClient.EthGetUserOperationReceipt(this.Client, this._bundlerUrl, requestId, userOpHash).ConfigureAwait(false);
804-
txHash = userOpReceipt?.Receipt?.TransactionHash;
805-
await ThirdwebTask.Delay(100).ConfigureAwait(false);
816+
throw new Exception($"User operation timed out with user op hash: {userOpHash}");
806817
}
807818

808819
this.IsDeploying = false;

0 commit comments

Comments
 (0)