forked from cerc-io/laconicd-deprecated
evm: move Keeper and Querier to /keeper package (#182)
* evm: move Keeper and Querier to /keeper package * keeper: update keeper_test.go * fix format * evm: use aliased types * add comments from review * changelog
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/big"
|
||||
|
||||
"github.com/cosmos/ethermint/types"
|
||||
ethcmn "github.com/ethereum/go-ethereum/common"
|
||||
)
|
||||
|
||||
type (
|
||||
// GenesisState defines the application's genesis state. It contains all the
|
||||
// information required and accounts to initialize the blockchain.
|
||||
GenesisState struct {
|
||||
Accounts []GenesisAccount `json:"accounts"`
|
||||
}
|
||||
|
||||
// GenesisAccount defines an account to be initialized in the genesis state.
|
||||
GenesisAccount struct {
|
||||
Address ethcmn.Address `json:"address"`
|
||||
Balance *big.Int `json:"balance"`
|
||||
Code []byte `json:"code,omitempty"`
|
||||
Storage types.Storage `json:"storage,omitempty"`
|
||||
}
|
||||
)
|
||||
|
||||
// ValidateGenesis validates evm genesis config
|
||||
func ValidateGenesis(data GenesisState) error {
|
||||
for _, acct := range data.Accounts {
|
||||
if len(acct.Address.Bytes()) == 0 {
|
||||
return fmt.Errorf("Invalid GenesisAccount Error: Missing Address")
|
||||
}
|
||||
if acct.Balance == nil {
|
||||
return fmt.Errorf("Invalid GenesisAccount Error: Missing Balance")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DefaultGenesisState sets default evm genesis config
|
||||
func DefaultGenesisState() GenesisState {
|
||||
return GenesisState{
|
||||
Accounts: []GenesisAccount{},
|
||||
}
|
||||
}
|
||||
+16
-1
@@ -6,6 +6,21 @@ import (
|
||||
ethtypes "github.com/ethereum/go-ethereum/core/types"
|
||||
)
|
||||
|
||||
// Supported endpoints
|
||||
const (
|
||||
QueryProtocolVersion = "protocolVersion"
|
||||
QueryBalance = "balance"
|
||||
QueryBlockNumber = "blockNumber"
|
||||
QueryStorage = "storage"
|
||||
QueryCode = "code"
|
||||
QueryNonce = "nonce"
|
||||
QueryHashToHeight = "hashToHeight"
|
||||
QueryTxLogs = "txLogs"
|
||||
QueryLogsBloom = "logsBloom"
|
||||
QueryLogs = "logs"
|
||||
QueryAccount = "account"
|
||||
)
|
||||
|
||||
// QueryResProtocolVersion is response type for protocol version query
|
||||
type QueryResProtocolVersion struct {
|
||||
Version string `json:"version"`
|
||||
@@ -79,7 +94,7 @@ func (q QueryBloomFilter) String() string {
|
||||
}
|
||||
|
||||
// QueryAccount is response type for querying Ethereum state objects
|
||||
type QueryAccount struct {
|
||||
type QueryResAccount struct {
|
||||
Balance string `json:"balance"`
|
||||
CodeHash []byte `json:"codeHash"`
|
||||
Nonce uint64 `json:"nonce"`
|
||||
|
||||
Reference in New Issue
Block a user