Skip to content

Commit

Permalink
fix: second half of audit reponses (#144)
Browse files Browse the repository at this point in the history
  • Loading branch information
seanmcgary authored Dec 12, 2024
2 parents 8f4b3e9 + b0661d2 commit aef17c3
Show file tree
Hide file tree
Showing 22 changed files with 239 additions and 264 deletions.
9 changes: 4 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ require (
github.com/wealdtech/go-merkletree/v2 v2.6.0
github.com/wk8/go-ordered-map/v2 v2.1.8
go.uber.org/zap v1.27.0
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028
google.golang.org/grpc v1.65.0
gorm.io/driver/postgres v1.5.9
gorm.io/gorm v1.25.10
Expand Down Expand Up @@ -87,12 +86,12 @@ require (
github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
go.uber.org/multierr v1.10.0 // indirect
golang.org/x/crypto v0.24.0 // indirect
golang.org/x/crypto v0.31.0 // indirect
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect
golang.org/x/net v0.26.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/text v0.17.0 // indirect
golang.org/x/sync v0.10.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/text v0.21.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect
google.golang.org/protobuf v1.35.1 // indirect
Expand Down
42 changes: 8 additions & 34 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -41,30 +41,6 @@ github.com/Layr-Labs/eigenlayer-contracts v0.4.1-holesky-pepe.0.20240813143901-0
github.com/Layr-Labs/eigenlayer-contracts v0.4.1-holesky-pepe.0.20240813143901-00fc4b95e9c1/go.mod h1:Ie8YE3EQkTHqG6/tnUS0He7/UPMkXPo/3OFXwSy0iRo=
github.com/Layr-Labs/eigenlayer-rewards-proofs v0.2.13 h1:Blb4AE+jC/vddV71w4/MQAPooM+8EVqv9w2bL4OytgY=
github.com/Layr-Labs/eigenlayer-rewards-proofs v0.2.13/go.mod h1:PD/HoyzZjxDw1tAcZw3yD0yGddo+yhmwQAi+lk298r4=
github.com/Layr-Labs/protocol-apis v0.1.0-beta.3.0.20241122223729-1734c60ac737 h1:I/0YAw2ue150YuLNavErIQ4t7yoTDuH3nqZkOS7RTjg=
github.com/Layr-Labs/protocol-apis v0.1.0-beta.3.0.20241122223729-1734c60ac737/go.mod h1:prNA2/mLO5vpMZ2q78Nsn0m97wm28uiRnwO+/yOxigk=
github.com/Layr-Labs/protocol-apis v0.1.0-beta.3.0.20241203213718-bda8083a30b9 h1:tvBtFPGqMw1Hwp++cGP/otFTC2OQrJMtVjkH/vNbttE=
github.com/Layr-Labs/protocol-apis v0.1.0-beta.3.0.20241203213718-bda8083a30b9/go.mod h1:prNA2/mLO5vpMZ2q78Nsn0m97wm28uiRnwO+/yOxigk=
github.com/Layr-Labs/protocol-apis v0.1.0-beta.3.0.20241203213920-e35bed7723dc h1:P7S3ijgAQ4Xdpdocfl7rGgaTsPAurHsSCYHfhWm9au4=
github.com/Layr-Labs/protocol-apis v0.1.0-beta.3.0.20241203213920-e35bed7723dc/go.mod h1:prNA2/mLO5vpMZ2q78Nsn0m97wm28uiRnwO+/yOxigk=
github.com/Layr-Labs/protocol-apis v0.1.0-beta.3.0.20241203214053-44b580f4ea84 h1:BLF8GHMmXSC1YtjlqBRC7pVBDVK0QwEJpwXYjZO7t1w=
github.com/Layr-Labs/protocol-apis v0.1.0-beta.3.0.20241203214053-44b580f4ea84/go.mod h1:prNA2/mLO5vpMZ2q78Nsn0m97wm28uiRnwO+/yOxigk=
github.com/Layr-Labs/protocol-apis v1.0.0-rc.1 h1:N3OAsdZ5V/QVAjsJbJa1kruocoi50jfLquyVk4bL9HQ=
github.com/Layr-Labs/protocol-apis v1.0.0-rc.1/go.mod h1:prNA2/mLO5vpMZ2q78Nsn0m97wm28uiRnwO+/yOxigk=
github.com/Layr-Labs/protocol-apis v1.0.0-rc.1.0.20241203225729-619c724a75e3 h1:kc3jPZzgTsXWTPDzEi9iB9DAc2+soPHsGd41KTVhC04=
github.com/Layr-Labs/protocol-apis v1.0.0-rc.1.0.20241203225729-619c724a75e3/go.mod h1:prNA2/mLO5vpMZ2q78Nsn0m97wm28uiRnwO+/yOxigk=
github.com/Layr-Labs/protocol-apis v1.0.0-rc.1.0.20241204030420-83d31161930e h1:h6ptdsDTKiTldAyel+XXfbusrarpF2+arhPlaFUeq7M=
github.com/Layr-Labs/protocol-apis v1.0.0-rc.1.0.20241204030420-83d31161930e/go.mod h1:prNA2/mLO5vpMZ2q78Nsn0m97wm28uiRnwO+/yOxigk=
github.com/Layr-Labs/protocol-apis v1.0.0-rc.1.0.20241204194134-d3c82f365d7a h1:KgeRP8HuUI6OR7v3oe8l4vXbhBiZfu4htao4yiHlbsk=
github.com/Layr-Labs/protocol-apis v1.0.0-rc.1.0.20241204194134-d3c82f365d7a/go.mod h1:prNA2/mLO5vpMZ2q78Nsn0m97wm28uiRnwO+/yOxigk=
github.com/Layr-Labs/protocol-apis v1.0.0-rc.1.0.20241205194457-0df3820dae69 h1:OIdv/BZIDU8Olkpo80aOZGZ9TpgLYdKYcU8BicMD61M=
github.com/Layr-Labs/protocol-apis v1.0.0-rc.1.0.20241205194457-0df3820dae69/go.mod h1:prNA2/mLO5vpMZ2q78Nsn0m97wm28uiRnwO+/yOxigk=
github.com/Layr-Labs/protocol-apis v1.0.0-rc.1.0.20241206170231-3505e222b408 h1:yUA+KbV/uZUkwf6EjlmOvyp1FA3tYOgtwp9NqoZra7w=
github.com/Layr-Labs/protocol-apis v1.0.0-rc.1.0.20241206170231-3505e222b408/go.mod h1:prNA2/mLO5vpMZ2q78Nsn0m97wm28uiRnwO+/yOxigk=
github.com/Layr-Labs/protocol-apis v1.0.0-rc.1.0.20241206170400-42069f3d8ad6 h1:W7jhyGCXRs4OK+MkbzQhGlj0E+O6+rJi74VPyikNaDQ=
github.com/Layr-Labs/protocol-apis v1.0.0-rc.1.0.20241206170400-42069f3d8ad6/go.mod h1:prNA2/mLO5vpMZ2q78Nsn0m97wm28uiRnwO+/yOxigk=
github.com/Layr-Labs/protocol-apis v1.0.0-rc.1.0.20241206171033-dc9bce2085c6 h1:Qg6fhCB2no7QWuPAZEIX1GwnX2ayDbgCqenYAQxaA6U=
github.com/Layr-Labs/protocol-apis v1.0.0-rc.1.0.20241206171033-dc9bce2085c6/go.mod h1:prNA2/mLO5vpMZ2q78Nsn0m97wm28uiRnwO+/yOxigk=
github.com/Layr-Labs/protocol-apis v1.0.0-rc.1.0.20241206171209-6484d433345c h1:m9xRDJR9ItBQmiOBhsx64Bemi4W5/2pkXru75evpEGI=
github.com/Layr-Labs/protocol-apis v1.0.0-rc.1.0.20241206171209-6484d433345c/go.mod h1:prNA2/mLO5vpMZ2q78Nsn0m97wm28uiRnwO+/yOxigk=
github.com/Microsoft/go-winio v0.5.0/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84=
Expand Down Expand Up @@ -486,8 +462,8 @@ golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8U
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI=
golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM=
golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U=
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
Expand Down Expand Up @@ -574,8 +550,8 @@ golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ=
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
Expand Down Expand Up @@ -630,17 +606,17 @@ golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc=
golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
Expand Down Expand Up @@ -694,8 +670,6 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 h1:+cNy6SZtPcJQH3LJVLOSmiC7MMxXNOb3PU/VUEz+EhU=
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028/go.mod h1:NDW/Ps6MPRej6fsCIbMTohpP40sJ/P/vI1MoTEGwX90=
google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M=
google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
Expand Down
33 changes: 16 additions & 17 deletions pkg/clients/ethereum/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethclient"
"go.uber.org/zap"
"golang.org/x/xerrors"
)

const (
Expand Down Expand Up @@ -292,54 +291,54 @@ func (c *Client) batchCall(ctx context.Context, requests []*RPCRequest) ([]*RPCR
}
requestBody, err := json.Marshal(requests)
if err != nil {
return nil, xerrors.Errorf("Failed to marshal requests: %s", err)
return nil, fmt.Errorf("Failed to marshal requests: %s", err)
}

ctx, cancel := context.WithTimeout(ctx, time.Second*20)
defer cancel()

request, err := http.NewRequestWithContext(ctx, http.MethodPost, c.clientConfig.BaseUrl, bytes.NewReader(requestBody))
if err != nil {
return nil, xerrors.Errorf("Failed to make request: %s", err)
return nil, fmt.Errorf("Failed to make request: %s", err)
}

request.Header.Set("Content-Type", "application/json")
request.Header.Set("Accept", "application/json")

response, err := c.httpClient.Do(request)
if err != nil {
return nil, xerrors.Errorf("Request failed %v", err)
return nil, fmt.Errorf("Request failed %v", err)
}

responseBody, err := io.ReadAll(response.Body)
if err != nil {
return nil, xerrors.Errorf("Failed to read body %v", err)
return nil, fmt.Errorf("Failed to read body %v", err)
}

if response.StatusCode != http.StatusOK {
return nil, xerrors.Errorf("received http error code %+v", response.StatusCode)
return nil, fmt.Errorf("received http error code %+v", response.StatusCode)
}

destination := []*RPCResponse{}

if strings.HasPrefix(string(responseBody), "{") {
errorResponse := RPCResponse{}
if err := json.Unmarshal(responseBody, &errorResponse); err != nil {
return nil, xerrors.Errorf("failed to unmarshal error response: %s", err)
return nil, fmt.Errorf("failed to unmarshal error response: %s", err)
}
c.Logger.Sugar().Debugw("Error payload returned from batch call",
zap.String("error", string(responseBody)),
)
if errorResponse.Error.Message != "empty batch" {
return nil, xerrors.Errorf("Error payload returned from batch call: %s", string(responseBody))
return nil, fmt.Errorf("Error payload returned from batch call: %s", string(responseBody))
}
} else {
if err := json.Unmarshal(responseBody, &destination); err != nil {
c.Logger.Sugar().Errorw("failed to unmarshal batch call response",
zap.Error(err),
zap.String("response", string(responseBody)),
)
return nil, xerrors.Errorf("failed to unmarshal response: %s", err)
return nil, fmt.Errorf("failed to unmarshal response: %s", err)
}
}
response.Body.Close()
Expand Down Expand Up @@ -492,7 +491,7 @@ func (c *Client) chunkedBatchCall(ctx context.Context, requests []*RPCRequest) (
}

if len(allResults) != len(requests) {
return nil, xerrors.Errorf("Failed to fetch results for all requests. Expected %d, got %d", len(requests), len(allResults))
return nil, fmt.Errorf("Failed to fetch results for all requests. Expected %d, got %d", len(requests), len(allResults))
}
return allResults, nil
}
Expand All @@ -517,32 +516,32 @@ func (c *Client) call(ctx context.Context, rpcRequest *RPCRequest) (*RPCResponse

request, err := http.NewRequestWithContext(ctx, http.MethodPost, c.clientConfig.BaseUrl, bytes.NewReader(requestBody))
if err != nil {
return nil, xerrors.Errorf("Failed to make request %s", err)
return nil, fmt.Errorf("Failed to make request %s", err)
}

request.Header.Set("Content-Type", "application/json")
request.Header.Set("Accept", "application/json")

response, err := c.httpClient.Do(request)
if err != nil {
return nil, xerrors.Errorf("Request failed %s", err)
return nil, fmt.Errorf("Request failed %s", err)
}

responseBody, err := io.ReadAll(response.Body)
if err != nil {
return nil, xerrors.Errorf("Failed to read body %s", err)
return nil, fmt.Errorf("Failed to read body %s", err)
}
if response.StatusCode != http.StatusOK {
return nil, xerrors.Errorf("received http error code %+v", response.StatusCode)
return nil, fmt.Errorf("received http error code %+v", response.StatusCode)
}

destination := &RPCResponse{}
if err := json.Unmarshal(responseBody, destination); err != nil {
return nil, xerrors.Errorf("failed to unmarshal response: %s", err)
return nil, fmt.Errorf("failed to unmarshal response: %s", err)
}

if destination.Error != nil {
return nil, xerrors.Errorf("received error response: %+v", destination.Error)
return nil, fmt.Errorf("received error response: %+v", destination.Error)
}

response.Body.Close()
Expand Down Expand Up @@ -572,5 +571,5 @@ func (c *Client) Call(ctx context.Context, rpcRequest *RPCRequest) (*RPCResponse
time.Sleep(time.Second * time.Duration(backoff))
}
c.Logger.Sugar().Errorw("Exceeded retries for Call", zap.Any("rpcRequest", rpcRequest))
return nil, xerrors.Errorf("Exceeded retries for Call")
return nil, fmt.Errorf("Exceeded retries for Call")
}
19 changes: 9 additions & 10 deletions pkg/clients/ethereum/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"strings"

"github.com/ethereum/go-ethereum/common/hexutil"
"golang.org/x/xerrors"
)

type (
Expand Down Expand Up @@ -158,7 +157,7 @@ func (v EthereumHexString) MarshalJSON() ([]byte, error) {
func (v *EthereumHexString) UnmarshalJSON(input []byte) error {
var s string
if err := json.Unmarshal(input, &s); err != nil {
return xerrors.Errorf("failed to unmarshal EthereumHexString: %w", err)
return fmt.Errorf("failed to unmarshal EthereumHexString: %w", err)
}
s = strings.ToLower(s)

Expand All @@ -179,7 +178,7 @@ func (v *EthereumQuantity) UnmarshalJSON(input []byte) error {
if len(input) > 0 && input[0] != '"' {
var i uint64
if err := json.Unmarshal(input, &i); err != nil {
return xerrors.Errorf("failed to unmarshal EthereumQuantity into uint64: %w", err)
return fmt.Errorf("failed to unmarshal EthereumQuantity into uint64: %w", err)
}

*v = EthereumQuantity(i)
Expand All @@ -188,7 +187,7 @@ func (v *EthereumQuantity) UnmarshalJSON(input []byte) error {

var s string
if err := json.Unmarshal(input, &s); err != nil {
return xerrors.Errorf("failed to unmarshal EthereumQuantity into string: %w", err)
return fmt.Errorf("failed to unmarshal EthereumQuantity into string: %w", err)
}

if s == "" {
Expand All @@ -198,7 +197,7 @@ func (v *EthereumQuantity) UnmarshalJSON(input []byte) error {

i, err := hexutil.DecodeUint64(s)
if err != nil {
return xerrors.Errorf("failed to decode EthereumQuantity %v: %w", s, err)
return fmt.Errorf("failed to decode EthereumQuantity %v: %w", s, err)
}

*v = EthereumQuantity(i)
Expand All @@ -222,7 +221,7 @@ func (v EthereumBigQuantity) MarshalJSON() ([]byte, error) {
func (v *EthereumBigQuantity) UnmarshalJSON(input []byte) error {
var s string
if err := json.Unmarshal(input, &s); err != nil {
return xerrors.Errorf("failed to unmarshal EthereumBigQuantity: %w", err)
return fmt.Errorf("failed to unmarshal EthereumBigQuantity: %w", err)
}

if s == "" {
Expand All @@ -232,7 +231,7 @@ func (v *EthereumBigQuantity) UnmarshalJSON(input []byte) error {

i, err := hexutil.DecodeBig(s)
if err != nil {
return xerrors.Errorf("failed to decode EthereumBigQuantity %v: %w", s, err)
return fmt.Errorf("failed to decode EthereumBigQuantity %v: %w", s, err)
}

*v = EthereumBigQuantity(*i)
Expand All @@ -247,7 +246,7 @@ func (v EthereumBigQuantity) Value() string {
func (v EthereumBigQuantity) Uint64() (uint64, error) {
i := big.Int(v)
if !i.IsUint64() {
return 0, xerrors.Errorf("failed to parse EthereumBigQuantity to uint64 %v", v.Value())
return 0, fmt.Errorf("failed to parse EthereumBigQuantity to uint64 %v", v.Value())
}
return i.Uint64(), nil
}
Expand All @@ -261,7 +260,7 @@ func (v EthereumBigFloat) MarshalJSON() ([]byte, error) {
func (v *EthereumBigFloat) UnmarshalJSON(input []byte) error {
var s string
if err := json.Unmarshal(input, &s); err != nil {
return xerrors.Errorf("failed to unmarshal EthereumBigFloat: %w", err)
return fmt.Errorf("failed to unmarshal EthereumBigFloat: %w", err)
}

if s == "" {
Expand All @@ -272,7 +271,7 @@ func (v *EthereumBigFloat) UnmarshalJSON(input []byte) error {
scalar := new(big.Float)
scalar, ok := scalar.SetString(s)
if !ok {
return xerrors.Errorf("cannot parse EthereumBigFloat")
return fmt.Errorf("cannot parse EthereumBigFloat")
}

*v = EthereumBigFloat(*scalar)
Expand Down
Loading

0 comments on commit aef17c3

Please sign in to comment.