Skip to content

Commit

Permalink
move Code and Contract to genesis.go
Browse files Browse the repository at this point in the history
  • Loading branch information
sunnya97 committed Jan 11, 2020
1 parent 0ce1b42 commit 1956070
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
15 changes: 15 additions & 0 deletions x/wasm/internal/types/genesis.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
package types

import sdk "github.com/cosmos/cosmos-sdk/types"

// GenesisState is the struct representation of the export genesis
type GenesisState struct {
Codes []Code `json:"codes"`
Contracts []Contract `json:"contracts"`
}

// Code struct encompasses CodeInfo and CodeBytes
type Code struct {
CodeInfo CodeInfo `json:"code_info"`
CodesBytes []byte `json:"code_bytes"`
}

// Contract struct encompasses ContractAddress, ContractInfo, and ContractState
type Contract struct {
ContractAddress sdk.AccAddress `json:"contract_address"`
ContractInfo ContractInfo `json:"contract_info"`
ContractState []Model `json:"contract_state"`
}

// ValidateGenesis performs basic validation of supply genesis data returning an
// error for any failed validation criteria.
func ValidateGenesis(data GenesisState) error {
Expand Down
15 changes: 1 addition & 14 deletions x/wasm/internal/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ type Model struct {
Value string `json:"value"`
}

// CodeData struct encompasses CodeInfo and CodeBytes
type Code struct {
CodeInfo CodeInfo `json:"code_info"`
CodesBytes []byte `json:"code_bytes"`
}

// CodeInfo is data for the uploaded contract WASM code
type CodeInfo struct {
CodeHash []byte `json:"code_hash"`
Expand All @@ -32,14 +26,7 @@ func NewCodeInfo(codeHash []byte, creator sdk.AccAddress) CodeInfo {
}
}

// ContractData struct encompasses ContractAddress, ContractInfo, and ContractState
type Contract struct {
ContractAddress sdk.AccAddress `json:"contract_address"`
ContractInfo ContractInfo `json:"contract_info"`
ContractState []Model `json:"contract_state"`
}

// Contract stores a WASM contract instance
// ContractInfo stores a WASM contract instance
type ContractInfo struct {
CodeID uint64 `json:"code_id"`
Creator sdk.AccAddress `json:"creator"`
Expand Down

0 comments on commit 1956070

Please sign in to comment.