From f8c4d6a488eff6bc0093e548066333485f84e6be Mon Sep 17 00:00:00 2001 From: 0xFirekeeper <0xFirekeeper@gmail.com> Date: Wed, 10 Apr 2024 19:06:34 +0300 Subject: [PATCH] decode reverts too and return raw data if fail --- Thirdweb/Thirdweb.RPC/RpcError.cs | 2 +- Thirdweb/Thirdweb.RPC/ThirdwebRPC.cs | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Thirdweb/Thirdweb.RPC/RpcError.cs b/Thirdweb/Thirdweb.RPC/RpcError.cs index 1d98691..88dc07f 100644 --- a/Thirdweb/Thirdweb.RPC/RpcError.cs +++ b/Thirdweb/Thirdweb.RPC/RpcError.cs @@ -11,6 +11,6 @@ public class RpcError public string Message { get; set; } [JsonProperty("data")] - public object Data { get; set; } + public string Data { get; set; } } } diff --git a/Thirdweb/Thirdweb.RPC/ThirdwebRPC.cs b/Thirdweb/Thirdweb.RPC/ThirdwebRPC.cs index 6d545d5..c38f7b4 100644 --- a/Thirdweb/Thirdweb.RPC/ThirdwebRPC.cs +++ b/Thirdweb/Thirdweb.RPC/ThirdwebRPC.cs @@ -175,11 +175,12 @@ private async Task SendBatchAsync(List batch) { try { - revertMsg = new Nethereum.ABI.FunctionEncoding.FunctionCallDecoder().DecodeFunctionErrorMessage(Utils.StringToHex(rpcResponse.Error.Data.ToString())); + revertMsg = new Nethereum.ABI.FunctionEncoding.FunctionCallDecoder().DecodeFunctionErrorMessage(rpcResponse.Error.Data); + revertMsg = string.IsNullOrWhiteSpace(revertMsg) ? rpcResponse.Error.Data : revertMsg; } catch { - revertMsg = rpcResponse.Error.Data.ToString(); + revertMsg = rpcResponse.Error.Data; } } tcs.SetException(new Exception($"RPC Error for request {rpcResponse.Id}: {rpcResponse.Error.Message} {revertMsg}"));