rpc: protocol version (#575)

* evm: protocol version

* changelog

* version

* fix

* support latest version only
This commit is contained in:
Federico Kunze
2020-12-08 20:51:26 +01:00
committed by GitHub
parent 3bb76e8533
commit ef1bef16e5
10 changed files with 20 additions and 60 deletions
-15
View File
@@ -10,11 +10,9 @@ import (
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/ethermint/utils"
"github.com/cosmos/ethermint/version"
"github.com/cosmos/ethermint/x/evm/types"
ethcmn "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
abci "github.com/tendermint/tendermint/abci/types"
)
@@ -23,8 +21,6 @@ import (
func NewQuerier(keeper Keeper) sdk.Querier {
return func(ctx sdk.Context, path []string, _ abci.RequestQuery) ([]byte, error) {
switch path[0] {
case types.QueryProtocolVersion:
return queryProtocolVersion(keeper)
case types.QueryBalance:
return queryBalance(ctx, path, keeper)
case types.QueryBlockNumber:
@@ -51,17 +47,6 @@ func NewQuerier(keeper Keeper) sdk.Querier {
}
}
func queryProtocolVersion(keeper Keeper) ([]byte, error) {
vers := version.ProtocolVersion
bz, err := codec.MarshalJSONIndent(keeper.cdc, hexutil.Uint(vers))
if err != nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error())
}
return bz, nil
}
func queryBalance(ctx sdk.Context, path []string, keeper Keeper) ([]byte, error) {
addr := ethcmn.HexToAddress(path[1])
balance := keeper.GetBalance(ctx, addr)
-1
View File
@@ -17,7 +17,6 @@ func (suite *KeeperTestSuite) TestQuerier() {
malleate func()
expPass bool
}{
{"protocol version", []string{types.QueryProtocolVersion}, func() {}, true},
{"balance", []string{types.QueryBalance, addrHex}, func() {
suite.app.EvmKeeper.SetBalance(suite.ctx, suite.address, big.NewInt(5))
}, true},