-
Notifications
You must be signed in to change notification settings - Fork 105
/
genesis.go
33 lines (27 loc) · 877 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
package types
import (
"encoding/json"
"fmt"
"github.com/cosmos/cosmos-sdk/codec"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)
// DefaultGenesis represents the default genesis state
func DefaultGenesis() *GenesisState {
return &GenesisState{DefaultParams()}
}
// Validate validates the genesis state
func (m GenesisState) Validate() error {
if err := m.Params.Validate(); err != nil {
return sdkerrors.Wrap(err, fmt.Sprintf("genesis state for module %s is invalid", ModuleName))
}
return nil
}
// GetGenesisStateFromAppState returns x/tss GenesisState given raw application
// genesis state.
func GetGenesisStateFromAppState(cdc codec.JSONCodec, appState map[string]json.RawMessage) GenesisState {
var genesisState GenesisState
if appState[ModuleName] != nil {
cdc.MustUnmarshalJSON(appState[ModuleName], &genesisState)
}
return genesisState
}