-
Notifications
You must be signed in to change notification settings - Fork 3.6k
/
genesis.go
46 lines (39 loc) · 1003 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
42
43
44
45
46
package feegrant
import (
"github.com/cosmos/cosmos-sdk/codec/types"
)
var _ types.UnpackInterfacesMessage = GenesisState{}
// NewGenesisState creates new GenesisState object
func NewGenesisState(entries []Grant) *GenesisState {
return &GenesisState{
Allowances: entries,
}
}
// ValidateGenesis ensures all grants in the genesis state are valid
func ValidateGenesis(data GenesisState) error {
for _, f := range data.Allowances {
grant, err := f.GetGrant()
if err != nil {
return err
}
err = grant.ValidateBasic()
if err != nil {
return err
}
}
return nil
}
// DefaultGenesisState returns default state for feegrant module.
func DefaultGenesisState() *GenesisState {
return &GenesisState{}
}
// UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces
func (data GenesisState) UnpackInterfaces(unpacker types.AnyUnpacker) error {
for _, f := range data.Allowances {
err := f.UnpackInterfaces(unpacker)
if err != nil {
return err
}
}
return nil
}