This repository was archived by the owner on Nov 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 161
Adds AppModuleBasic and Genesis Functions #62
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,3 +14,6 @@ | |
| .glide/ | ||
| vendor/ | ||
| build/ | ||
|
|
||
| # Goland | ||
| .idea/ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| package evm | ||
|
|
||
| import ( | ||
| "fmt" | ||
| sdk "github.com/cosmos/cosmos-sdk/types" | ||
| "github.com/cosmos/ethermint/types" | ||
| ) | ||
|
|
||
| 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 sdk.AccAddress `json:"address"` | ||
| Coins sdk.Coins `json:"coins"` | ||
| Code []byte `json:"code,omitempty"` | ||
| Storage types.Storage `json:"storage,omitempty"` | ||
| } | ||
| ) | ||
|
|
||
| func ValidateGenesis(data GenesisState) error { | ||
| for _, acct := range data.Accounts { | ||
| if acct.Address == nil { | ||
| return fmt.Errorf("Invalid GenesisAccount Error: Missing Address") | ||
| } | ||
| if acct.Coins == nil { | ||
| return fmt.Errorf("Invalid GenesisAccount Error: Missing Coins") | ||
| } | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| func DefaultGenesisState() GenesisState { | ||
| return GenesisState{ | ||
| Accounts: []GenesisAccount{}, | ||
| } | ||
| } | ||
|
|
||
| // TODO: Implement these once keeper is established | ||
| //func InitGenesis(ctx sdk.Context, keeper Keeper, data GenesisState) []abci.ValidatorUpdate { | ||
| // for _, record := range data.Accounts { | ||
| // // TODO: Add to keeper | ||
| // } | ||
| // return []abci.ValidatorUpdate{} | ||
| //} | ||
| // | ||
| //func ExportGenesis(ctx sdk.Context, k Keeper) GenesisState { | ||
| // return GenesisState{Accounts: nil} | ||
| //} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| package evm | ||
|
|
||
| import ( | ||
| "encoding/json" | ||
| "github.com/cosmos/cosmos-sdk/client/context" | ||
| "github.com/cosmos/cosmos-sdk/codec" | ||
| "github.com/cosmos/ethermint/x/evm/types" | ||
| "github.com/gorilla/mux" | ||
| "github.com/spf13/cobra" | ||
| ) | ||
|
|
||
| // app module Basics object | ||
| type AppModuleBasic struct{} | ||
|
|
||
| func (AppModuleBasic) Name() string { | ||
| return types.ModuleName | ||
| } | ||
|
|
||
| func (AppModuleBasic) RegisterCodec(cdc *codec.Codec) { | ||
| types.RegisterCodec(cdc) | ||
| } | ||
|
|
||
| func (AppModuleBasic) DefaultGenesis() json.RawMessage { | ||
| return types.ModuleCdc.MustMarshalJSON(DefaultGenesisState()) | ||
| } | ||
|
|
||
| // Validation check of the Genesis | ||
| func (AppModuleBasic) ValidateGenesis(bz json.RawMessage) error { | ||
| var data GenesisState | ||
| err := types.ModuleCdc.UnmarshalJSON(bz, &data) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| // Once json successfully marshalled, passes along to genesis.go | ||
| return ValidateGenesis(data) | ||
| } | ||
|
|
||
| // Register rest routes | ||
ansermino marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| func (AppModuleBasic) RegisterRESTRoutes(ctx context.CLIContext, rtr *mux.Router) { | ||
| //rpc.RegisterRoutes(ctx, rtr, StoreKey) | ||
| } | ||
|
|
||
| // Get the root query command of this module | ||
| func (AppModuleBasic) GetQueryCmd(cdc *codec.Codec) *cobra.Command { | ||
| return nil // cli.GetQueryCmd(StoreKey, cdc) | ||
| } | ||
|
|
||
| // Get the root tx command of this module | ||
| func (AppModuleBasic) GetTxCmd(cdc *codec.Codec) *cobra.Command { | ||
| return nil // cli.GetTxCmd(StoreKey, cdc) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package types | ||
|
|
||
| const ( | ||
| // module name | ||
| ModuleName = "ethermint" | ||
|
|
||
| // TODO: Use this | ||
| // StoreKey to be used when creating the KVStore | ||
| StoreKey = ModuleName | ||
ansermino marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.