Skip to content

Commit 471a0c0

Browse files
committed
check gasless response success
1 parent 9ab1f58 commit 471a0c0

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

Assets/Thirdweb/Core/Scripts/TransactionManager.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff 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!\nError: {req.downloadHandler.text}\nRelayer URL: {relayerUrl}\nRelayer Forwarder Address: {forwarderAddress}\nRequest: {request}\nSignature: {signature}\nPost 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
}

0 commit comments

Comments
 (0)