-
Notifications
You must be signed in to change notification settings - Fork 208
/
genesis.go
60 lines (51 loc) · 1.68 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
50
51
52
53
54
55
56
57
58
59
60
package types
import (
"encoding/json"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/NibiruChain/nibiru/x/common/asset"
)
// NewGenesisState creates a new GenesisState object
func NewGenesisState(
params Params, rates []ExchangeRateTuple,
feederDelegations []FeederDelegation, missCounters []MissCounter,
aggregateExchangeRatePrevotes []AggregateExchangeRatePrevote,
aggregateExchangeRateVotes []AggregateExchangeRateVote,
pairs []asset.Pair,
rewards []Rewards,
) *GenesisState {
return &GenesisState{
Params: params,
FeederDelegations: feederDelegations,
ExchangeRates: rates,
MissCounters: missCounters,
AggregateExchangeRatePrevotes: aggregateExchangeRatePrevotes,
AggregateExchangeRateVotes: aggregateExchangeRateVotes,
Pairs: pairs,
Rewards: rewards,
}
}
// DefaultGenesisState - default GenesisState
func DefaultGenesisState() *GenesisState {
return NewGenesisState(
DefaultParams(),
[]ExchangeRateTuple{},
[]FeederDelegation{},
[]MissCounter{},
[]AggregateExchangeRatePrevote{},
[]AggregateExchangeRateVote{},
[]asset.Pair{},
[]Rewards{})
}
// ValidateGenesis validates the oracle genesis state
func ValidateGenesis(data *GenesisState) error {
return data.Params.Validate()
}
// GetGenesisStateFromAppState returns x/oracle 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
}