github.com/InjectiveLabs/sdk-go@v1.53.0/chain/permissions/types/genesis.go (about) 1 package types 2 3 import ( 4 "cosmossdk.io/errors" 5 ) 6 7 // this line is used by starport scaffolding # genesis/types/import 8 9 // DefaultIndex is the default capability global index 10 const DefaultIndex uint64 = 1 11 12 // DefaultGenesis returns the default Capability genesis state 13 func DefaultGenesis() *GenesisState { 14 return &GenesisState{ 15 Params: DefaultParams(), 16 Namespaces: []Namespace{}, 17 } 18 } 19 20 // Validate performs basic genesis state validation returning an error upon any 21 // failure. 22 func (gs GenesisState) Validate() error { 23 err := gs.Params.Validate() 24 if err != nil { 25 return err 26 } 27 28 seenDenoms := map[string]struct{}{} 29 30 for _, ns := range gs.GetNamespaces() { 31 if _, ok := seenDenoms[ns.GetDenom()]; ok { 32 return errors.Wrapf(ErrInvalidGenesis, "duplicate denom: %s", ns.GetDenom()) 33 } 34 seenDenoms[ns.GetDenom()] = struct{}{} 35 } 36 37 return nil 38 }