diff --git a/ethereum/rpc/namespaces/eth/api.go b/ethereum/rpc/namespaces/eth/api.go index b2b9c4ed9e..85ebce8949 100644 --- a/ethereum/rpc/namespaces/eth/api.go +++ b/ethereum/rpc/namespaces/eth/api.go @@ -5,11 +5,12 @@ import ( "context" "encoding/json" "fmt" + "math/big" + "strings" + "github.com/ethereum/go-ethereum/core/vm" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - "math/big" - "strings" "github.com/pkg/errors" "github.com/spf13/viper" diff --git a/x/evm/keeper/grpc_query.go b/x/evm/keeper/grpc_query.go index 510291ae7b..e4b065bdcb 100644 --- a/x/evm/keeper/grpc_query.go +++ b/x/evm/keeper/grpc_query.go @@ -418,7 +418,7 @@ func (k Keeper) EstimateGas(c context.Context, req *types.EthCallRequest) (*type // Binary search the gas requirement, as it may be higher than the amount used var ( - lo uint64 = ethparams.TxGas - 1 + lo = ethparams.TxGas - 1 hi uint64 cap uint64 ) diff --git a/x/evm/types/errors.go b/x/evm/types/errors.go index 9cf95e1f84..a255a79090 100644 --- a/x/evm/types/errors.go +++ b/x/evm/types/errors.go @@ -3,6 +3,7 @@ package types import ( "errors" "fmt" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/ethereum/go-ethereum/common" @@ -78,33 +79,33 @@ var ( // NewExecErrorWithReason unpacks the revert return bytes and returns a wrapped error // with the return reason. -func NewExecErrorWithReason(revertReason []byte) *revertError { +func NewExecErrorWithReason(revertReason []byte) *RevertError { var result = common.CopyBytes(revertReason) reason, errUnpack := abi.UnpackRevert(result) err := errors.New("execution reverted") if errUnpack == nil { err = fmt.Errorf("execution reverted: %v", reason) } - return &revertError{ + return &RevertError{ error: err, reason: hexutil.Encode(result), } } -// revertError is an API error that encompass an EVM revert with JSON error +// RevertError is an API error that encompass an EVM revert with JSON error // code and a binary data blob. -type revertError struct { +type RevertError struct { error reason string // revert reason hex encoded } // ErrorCode returns the JSON error code for a revert. // See: https://github.com/ethereum/wiki/wiki/JSON-RPC-Error-Codes-Improvement-Proposal -func (e *revertError) ErrorCode() int { +func (e *RevertError) ErrorCode() int { return 3 } // ErrorData returns the hex encoded revert reason. -func (e *revertError) ErrorData() interface{} { +func (e *RevertError) ErrorData() interface{} { return e.reason }