-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
genesis.go
49 lines (40 loc) · 1.3 KB
/
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
47
48
49
package types
import "bytes"
// this line is used by starport scaffolding # genesis/types/import
// DefaultIndex is the default capability global index
const DefaultIndex uint64 = 1
// DefaultGenesis returns the default Capability genesis state
func DefaultGenesis() *GenesisState {
return &GenesisState{
DefaultParams(),
[]PostedPrice{},
// this line is used by starport scaffolding # genesis/types/default
}
}
// Validate performs basic genesis state validation returning an error upon any
// failure.
func (gs GenesisState) Validate() error {
// this line is used by starport scaffolding # genesis/types/validate
// return nil
if err := gs.Params.Validate(); err != nil {
return err
}
return PostedPrices(gs.PostedPrices).Validate()
}
// NewGenesisState creates a new genesis state for the pricefeed module
func NewGenesisState(p Params, pp []PostedPrice) GenesisState {
return GenesisState{
Params: p,
PostedPrices: pp,
}
}
// Equal checks whether two gov GenesisState structs are equivalent
func (gs GenesisState) Equal(gs2 GenesisState) bool {
b1 := ModuleCdc.MustMarshalBinaryBare(&gs)
b2 := ModuleCdc.MustMarshalBinaryBare(&gs2)
return bytes.Equal(b1, b2)
}
// IsEmpty returns true if a GenesisState is empty
func (gs GenesisState) IsEmpty() bool {
return gs.Equal(GenesisState{})
}