From d8e8d7b6dbbd9a26c0efdeb6f570b0cec38a8862 Mon Sep 17 00:00:00 2001 From: Confucian Date: Tue, 22 Oct 2024 17:26:56 +0800 Subject: [PATCH] feat: return revert data --- rpc/client.go | 3 +-- rpc/json.go | 3 +++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/rpc/client.go b/rpc/client.go index 23c1716632..f9a8f1116b 100644 --- a/rpc/client.go +++ b/rpc/client.go @@ -365,8 +365,7 @@ func (c *Client) CallContext(ctx context.Context, result interface{}, method str resp := batchresp[0] switch { case resp.Error != nil: - errMsg := fmt.Sprintf("%s: %s", resp.Error.Message, resp.Error.Data) - return errors.New(errMsg) + return resp.Error case len(resp.Result) == 0: return ErrNoResult default: diff --git a/rpc/json.go b/rpc/json.go index e932389d17..687a7ed5b6 100644 --- a/rpc/json.go +++ b/rpc/json.go @@ -146,6 +146,9 @@ func (err *jsonError) Error() string { if err.Message == "" { return fmt.Sprintf("json-rpc error %d", err.Code) } + if err.Message == "execution reverted" && err.Data != "" { + return fmt.Sprintf("%s: %s", err.Message, err.Data) + } return err.Message }