@@ -100,25 +100,24 @@ public static async Task<EngineWallet> Create(
100
100
101
101
#region Wallet Specific
102
102
103
- private async Task < string > WaitForQueueId ( string queueId )
103
+ public static async Task < string > WaitForQueueId ( IThirdwebHttpClient httpClient , string engineUrl , string queueId )
104
104
{
105
105
var transactionHash = string . Empty ;
106
106
while ( string . IsNullOrEmpty ( transactionHash ) )
107
107
{
108
108
await ThirdwebTask . Delay ( 100 ) ;
109
109
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 } ") ;
112
111
var content = await statusResponse . Content . ReadAsStringAsync ( ) ;
113
- var status = JObject . Parse ( content ) ;
112
+ var response = JObject . Parse ( content ) ;
114
113
115
- var isErrored = status [ "result" ] ? [ "status" ] ? . ToString ( ) is "errored" or "cancelled" ;
114
+ var isErrored = response [ "result" ] ? [ "status" ] ? . ToString ( ) is "errored" or "cancelled" ;
116
115
if ( isErrored )
117
116
{
118
- throw new Exception ( "Transaction errored or cancelled ") ;
117
+ throw new Exception ( $ "Failed to send transaction: { response [ "result" ] ? [ "errorMessage" ] ? . ToString ( ) } ") ;
119
118
}
120
119
121
- transactionHash = status [ "result" ] ? [ "transactionHash" ] ? . ToString ( ) ;
120
+ transactionHash = response [ "result" ] ? [ "transactionHash" ] ? . ToString ( ) ;
122
121
}
123
122
return transactionHash ;
124
123
}
@@ -318,7 +317,7 @@ public async Task<string> SendTransaction(ThirdwebTransactionInput transaction)
318
317
319
318
var content = await response . Content . ReadAsStringAsync ( ) . ConfigureAwait ( false ) ;
320
319
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 ) ;
322
321
}
323
322
324
323
public async Task < ThirdwebTransactionReceipt > ExecuteTransaction ( ThirdwebTransactionInput transactionInput )
0 commit comments