-
Notifications
You must be signed in to change notification settings - Fork 690
/
genesis.go
41 lines (31 loc) · 933 Bytes
/
genesis.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package types
import (
"encoding/json"
errorsmod "cosmossdk.io/errors"
"github.com/cosmos/cosmos-sdk/codec"
)
// NewGenesisState - Create a new genesis state
func NewGenesisState(params Params) *GenesisState {
return &GenesisState{
Params: params,
}
}
// DefaultGenesisState - Return a default genesis state
func DefaultGenesisState() *GenesisState {
return NewGenesisState(DefaultParams())
}
// GetGenesisStateFromAppState returns x/auth GenesisState given raw application
// genesis state.
func GetGenesisStateFromAppState(cdc codec.Codec, appState map[string]json.RawMessage) *GenesisState {
var genesisState GenesisState
if appState[ModuleName] != nil {
cdc.MustUnmarshalJSON(appState[ModuleName], &genesisState)
}
return &genesisState
}
func ValidateGenesis(data GenesisState) error {
if err := data.Params.ValidateBasic(); err != nil {
return errorsmod.Wrap(err, "globalfee params")
}
return nil
}