Skip to content

Commit f9eca66

Browse files
committed
Update EngineWallet.cs
1 parent 9f26659 commit f9eca66

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

Thirdweb/Thirdweb.Wallets/EngineWallet/EngineWallet.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,25 +100,24 @@ public static async Task<EngineWallet> Create(
100100

101101
#region Wallet Specific
102102

103-
private async Task<string> WaitForQueueId(string queueId)
103+
public static async Task<string> WaitForQueueId(IThirdwebHttpClient httpClient, string engineUrl, string queueId)
104104
{
105105
var transactionHash = string.Empty;
106106
while (string.IsNullOrEmpty(transactionHash))
107107
{
108108
await ThirdwebTask.Delay(100);
109109

110-
var statusResponse = await this._engineClient.GetAsync($"{this._engineUrl}/transaction/status/{queueId}");
111-
_ = statusResponse.EnsureSuccessStatusCode();
110+
var statusResponse = await httpClient.GetAsync($"{engineUrl}/transaction/status/{queueId}");
112111
var content = await statusResponse.Content.ReadAsStringAsync();
113-
var status = JObject.Parse(content);
112+
var response = JObject.Parse(content);
114113

115-
var isErrored = status["result"]?["status"]?.ToString() is "errored" or "cancelled";
114+
var isErrored = response["result"]?["status"]?.ToString() is "errored" or "cancelled";
116115
if (isErrored)
117116
{
118-
throw new Exception("Transaction errored or cancelled");
117+
throw new Exception($"Failed to send transaction: {response["result"]?["errorMessage"]?.ToString()}");
119118
}
120119

121-
transactionHash = status["result"]?["transactionHash"]?.ToString();
120+
transactionHash = response["result"]?["transactionHash"]?.ToString();
122121
}
123122
return transactionHash;
124123
}
@@ -318,7 +317,7 @@ public async Task<string> SendTransaction(ThirdwebTransactionInput transaction)
318317

319318
var content = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
320319
var queueId = JObject.Parse(content)["result"]?["queueId"]?.ToString() ?? throw new Exception("Failed to queue the transaction");
321-
return await this.WaitForQueueId(queueId).ConfigureAwait(false);
320+
return await WaitForQueueId(this._engineClient, this._engineUrl, queueId).ConfigureAwait(false);
322321
}
323322

324323
public async Task<ThirdwebTransactionReceipt> ExecuteTransaction(ThirdwebTransactionInput transactionInput)

0 commit comments

Comments
 (0)