Basic RPC and CLI Queries (#77)

- Adds ethermint query command (`emintcli query ethermint <query>`)
    - Supports block number, storage, code, balance lookups
- Implements RPC API methods `eth_blockNumber`, `eth_getStorageAt`, `eth_getBalance`, and `eth_getCode`
- Adds tester utility for RPC calls
    - Adheres to go test format, but should not be run with regular suite
    - Requires daemon and RPC server to be running
    - Excluded from `make test`, available with `make test-rpc`
- Implemented AppModule interface and added EVM module to app
    - Required for routing
- Implements `InitGenesis` (`x/evm/genesis.go`) and stubs `ExportGenesis`
- Modifies GenesisAccount to match expected format
This commit is contained in:
David Ansermino
2019-07-25 16:38:55 -04:00
committed by GitHub
parent d9d45b48b9
commit 92dc7d9a59
18 changed files with 545 additions and 250 deletions
+21 -2
View File
@@ -1,6 +1,8 @@
package main
import (
"github.com/cosmos/ethermint/rpc"
"github.com/tendermint/go-amino"
"os"
"path"
@@ -10,7 +12,6 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
emintapp "github.com/cosmos/ethermint/app"
"github.com/cosmos/ethermint/rpc"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/tendermint/tendermint/libs/cli"
@@ -43,7 +44,7 @@ func main() {
rootCmd.AddCommand(
sdkrpc.StatusCommand(),
client.ConfigCmd(emintapp.DefaultCLIHome),
// TODO: Set up query command
queryCmd(cdc),
// TODO: Set up tx command
// TODO: Set up rest routes (if included, different from web3 api)
rpc.Web3RpcCmd(cdc),
@@ -59,6 +60,24 @@ func main() {
}
}
func queryCmd(cdc *amino.Codec) *cobra.Command {
queryCmd := &cobra.Command{
Use: "query",
Aliases: []string{"q"},
Short: "Querying subcommands",
}
// TODO: Possibly add these query commands from other modules
//queryCmd.AddCommand(
// ...
//)
// add modules' query commands
emintapp.ModuleBasics.AddQueryCommands(queryCmd, cdc)
return queryCmd
}
func initConfig(cmd *cobra.Command) error {
home, err := cmd.PersistentFlags().GetString(cli.HomeFlag)
if err != nil {