File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed
Assets/Thirdweb/Core/Scripts Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -58,16 +58,16 @@ public static async Task<TransactionReceipt> ThirdwebWriteRawResult<TWFunction>(
5858 }
5959 else
6060 {
61- var gasEstimator = new Web3 ( ThirdwebManager . Instance . SDK . session . RPC ) . Eth . GetContractTransactionHandler < TWFunction > ( ) ;
62- functionMessage . Gas = 100000 ;
6361 try
6462 {
63+ var gasEstimator = new Web3 ( ThirdwebManager . Instance . SDK . session . RPC ) . Eth . GetContractTransactionHandler < TWFunction > ( ) ;
6564 var gas = await gasEstimator . EstimateGasAsync ( contractAddress , functionMessage ) ;
6665 functionMessage . Gas = gas . Value < 100000 ? 100000 : gas . Value ;
6766 }
6867 catch ( System . InvalidOperationException e )
6968 {
7069 Debug . LogWarning ( $ "Failed to estimate gas for transaction, proceeding with 100k gas: { e } ") ;
70+ functionMessage . Gas = 100000 ;
7171 }
7272 }
7373
@@ -130,11 +130,15 @@ public static async Task<TransactionReceipt> ThirdwebWriteRawResult<TWFunction>(
130130 }
131131 else
132132 {
133- Debug . Log ( "Relayer Response: " + req . downloadHandler . text ) ;
134133 var response = JsonConvert . DeserializeObject < RelayerResponse > ( req . downloadHandler . text ) ;
134+ if ( response . status != "success" )
135+ {
136+ throw new UnityException (
137+ $ "Forward Request Failed!\n Error: { req . downloadHandler . text } \n Relayer URL: { relayerUrl } \n Relayer Forwarder Address: { forwarderAddress } \n Request: { request } \n Signature: { signature } \n Post Data: { postData } "
138+ ) ;
139+ }
135140 var result = JsonConvert . DeserializeObject < RelayerResult > ( response . result ) ;
136141 txHash = result . txHash ;
137- Debug . Log ( txHash ) ;
138142 }
139143 }
140144 }
@@ -146,6 +150,9 @@ public static async Task<TransactionReceipt> ThirdwebWriteRawResult<TWFunction>(
146150 [ System . Serializable ]
147151 public struct RelayerResponse
148152 {
153+ [ JsonProperty ( "status" ) ]
154+ public string status ;
155+
149156 [ JsonProperty ( "result" ) ]
150157 public string result ;
151158 }
You can’t perform that action at this time.
0 commit comments