-
Notifications
You must be signed in to change notification settings - Fork 0
/
genesis.go
51 lines (43 loc) · 1.76 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
package keeper
import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/percosis-labs/percosis/v16/x/superfluid/types"
)
// InitGenesis initializes the capability module's state from a provided genesis
// state.
func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState) {
k.SetParams(ctx, genState.Params)
// initialize superfluid assets
for _, asset := range genState.SuperfluidAssets {
k.SetSuperfluidAsset(ctx, asset)
}
// initialize perco equivalent multipliers
for _, multiplierRecord := range genState.PercoEquivalentMultipliers {
k.SetPercoEquivalentMultiplier(ctx, multiplierRecord.EpochNumber, multiplierRecord.Denom, multiplierRecord.Multiplier)
}
for _, intermediaryAcc := range genState.IntermediaryAccounts {
k.SetIntermediaryAccount(ctx, intermediaryAcc)
}
// initialize lock id and intermediary connections
for _, connection := range genState.IntemediaryAccountConnections {
acc, err := sdk.AccAddressFromBech32(connection.IntermediaryAccount)
if err != nil {
panic(err)
}
intermediaryAcc := k.GetIntermediaryAccount(ctx, acc)
if intermediaryAcc.Denom == "" {
panic("connection to invalid intermediary account found")
}
k.SetLockIdIntermediaryAccountConnection(ctx, connection.LockId, intermediaryAcc)
}
}
// ExportGenesis returns the capability module's exported genesis.
func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState {
return &types.GenesisState{
Params: k.GetParams(ctx),
SuperfluidAssets: k.GetAllSuperfluidAssets(ctx),
PercoEquivalentMultipliers: k.GetAllPercoEquivalentMultipliers(ctx),
IntermediaryAccounts: k.GetAllIntermediaryAccounts(ctx),
IntemediaryAccountConnections: k.GetAllLockIdIntermediaryAccountConnections(ctx),
}
}