forked from cerc-io/laconicd-deprecated
rpc: protocol version (#575)
* evm: protocol version * changelog * version * fix * support latest version only
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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},
|
||||
|
||||
Reference in New Issue
Block a user