Skip to content

Commit

Permalink
Revert msg decoding
Browse files Browse the repository at this point in the history
  • Loading branch information
0xFirekeeper committed Apr 10, 2024
1 parent 10c954a commit 1e71139
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Thirdweb/Thirdweb.RPC/RpcError.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,8 @@ public class RpcError

[JsonProperty("message")]
public string Message { get; set; }

[JsonProperty("data")]
public object Data { get; set; }
}
}
14 changes: 13 additions & 1 deletion Thirdweb/Thirdweb.RPC/ThirdwebRPC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,19 @@ private async Task SendBatchAsync(List<RpcRequest> batch)
{
if (rpcResponse.Error != null)
{
tcs.SetException(new Exception($"RPC Error for request {rpcResponse.Id}: {rpcResponse.Error.Message}"));
var revertMsg = "";
if (rpcResponse.Error.Data != null)
{
try
{
revertMsg = new Nethereum.ABI.FunctionEncoding.FunctionCallDecoder().DecodeFunctionErrorMessage(Utils.StringToHex(rpcResponse.Error.Data.ToString()));
}
catch
{
revertMsg = rpcResponse.Error.Data.ToString();
}
}
tcs.SetException(new Exception($"RPC Error for request {rpcResponse.Id}: {rpcResponse.Error.Message} {revertMsg}"));
}
else
{
Expand Down

0 comments on commit 1e71139

Please sign in to comment.