-
Notifications
You must be signed in to change notification settings - Fork 169
/
genesis.go
36 lines (31 loc) · 948 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
package types
import sdk "github.com/cosmos/cosmos-sdk/types"
// NewGenesisState creates a new genesis state.
func NewGenesisState(params Params, feePayContracts []FeePayContract) GenesisState {
return GenesisState{
Params: params,
FeePayContracts: feePayContracts,
}
}
// DefaultGenesisState sets default genesis state with empty accounts and
// default params and chain config values.
func DefaultGenesisState() *GenesisState {
return &GenesisState{
Params: Params{
EnableFeepay: true,
},
FeePayContracts: []FeePayContract{},
}
}
// Validate performs basic genesis state validation returning an error upon any
// failure.
func (gs GenesisState) Validate() error {
// Loop through all fee pay contracts and validate they
// have a valid bech32 address
for _, contract := range gs.FeePayContracts {
if _, err := sdk.AccAddressFromBech32(contract.ContractAddress); err != nil {
return err
}
}
return nil
}