Skip to content

Commit 934b7ef

Browse files
committed
tw_getTransactionHash
1 parent 85df303 commit 934b7ef

File tree

3 files changed

+40
-20
lines changed

3 files changed

+40
-20
lines changed

Thirdweb/Thirdweb.Wallets/SmartWallet/Thirdweb.AccountAbstraction/AATypes.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,12 @@ public class TwExecuteResponse
246246
public string QueueId { get; set; }
247247
}
248248

249+
public class TwGetTransactionHashResponse
250+
{
251+
[JsonProperty("transactionHash")]
252+
public string TransactionHash { get; set; }
253+
}
254+
249255
public class EntryPointWrapper
250256
{
251257
[JsonProperty("entryPoint")]

Thirdweb/Thirdweb.Wallets/SmartWallet/Thirdweb.AccountAbstraction/BundlerClient.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ public static async Task<TwExecuteResponse> TwExecute(
4040
return JsonConvert.DeserializeObject<TwExecuteResponse>(response.Result.ToString());
4141
}
4242

43+
public static async Task<TwGetTransactionHashResponse> TwGetTransactionHash(ThirdwebClient client, string url, int requestId, string queueId)
44+
{
45+
var response = await BundlerRequest(client, url, requestId, "tw_getTransactionHash", queueId).ConfigureAwait(false);
46+
return JsonConvert.DeserializeObject<TwGetTransactionHashResponse>(response.Result.ToString());
47+
}
48+
4349
// Bundler requests
4450

4551
public static async Task<EthGetUserOperationReceiptResponse> EthGetUserOperationReceipt(ThirdwebClient client, string bundlerUrl, object requestId, string userOpHash)

Thirdweb/Thirdweb.Wallets/SmarterWallet.cs

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -160,26 +160,34 @@ public async Task<string> SendTransaction(ThirdwebTransactionInput transaction)
160160
signature: signature,
161161
authorization: this.Authorization != null && !await Utils.IsDelegatedAccount(this.Client, this.ChainId, userWalletAddress) ? this.Authorization : null
162162
);
163-
throw new NotImplementedException($"EIP-7702 transaction execution is not done, here's the queue id: {response.QueueId}");
164-
// string txHash = null;
165-
// var ct = new CancellationTokenSource(this.Client.FetchTimeoutOptions.GetTimeout(TimeoutType.Other));
166-
// try
167-
// {
168-
// while (txHash == null)
169-
// {
170-
// ct.Token.ThrowIfCancellationRequested();
171-
172-
// var txReceipt = await BundlerClient.TwGetTransactionReceipt(client: this.Client, url: $"{this.ChainId}.bundler.thirdweb.com", requestId: 7702, queueId).ConfigureAwait(false);
173-
174-
// txHash = txReceipt?.Receipt?.TransactionHash;
175-
// await ThirdwebTask.Delay(100, ct.Token).ConfigureAwait(false);
176-
// }
177-
// }
178-
// catch (OperationCanceledException)
179-
// {
180-
// throw new Exception($"EIP-7702 sponsored transaction timed out with queue id: {queueId}");
181-
// }
182-
// break;
163+
var queueId = response?.QueueId;
164+
string txHash = null;
165+
var ct = new CancellationTokenSource(this.Client.FetchTimeoutOptions.GetTimeout(TimeoutType.Other));
166+
try
167+
{
168+
while (txHash == null)
169+
{
170+
ct.Token.ThrowIfCancellationRequested();
171+
172+
var hashResponse = await BundlerClient
173+
.TwGetTransactionHash(
174+
client: this.Client,
175+
// url: $"{this.ChainId}.bundler.thirdweb.com",
176+
url: "http://localhost:8787?chain=11155111",
177+
requestId: 7702,
178+
queueId
179+
)
180+
.ConfigureAwait(false);
181+
182+
txHash = hashResponse?.TransactionHash;
183+
await ThirdwebTask.Delay(100, ct.Token).ConfigureAwait(false);
184+
}
185+
return txHash;
186+
}
187+
catch (OperationCanceledException)
188+
{
189+
throw new Exception($"EIP-7702 sponsored transaction timed out with queue id: {queueId}");
190+
}
183191
case ExecutionMode.EOA:
184192
// Add up values of all calls
185193
BigInteger totalValue = 0;

0 commit comments

Comments
 (0)