/
genesis.go
38 lines (30 loc) · 938 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
package token
import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/ixofoundation/ixo-blockchain/v2/x/token/keeper"
"github.com/ixofoundation/ixo-blockchain/v2/x/token/types"
abci "github.com/tendermint/tendermint/abci/types"
)
func InitGenesis(ctx sdk.Context, k keeper.Keeper, gs *types.GenesisState) []abci.ValidatorUpdate {
// save tokens to the store
for _, t := range gs.Tokens {
k.SetToken(ctx, t)
}
// save token properties to the store
for _, tp := range gs.TokenProperties {
k.SetTokenProperties(ctx, tp)
}
// Initialise params
k.SetParams(ctx, &gs.Params)
return []abci.ValidatorUpdate{}
}
func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState {
tokens := k.GetTokens(ctx)
tokenProperties := k.GetTokenPropertiesAll(ctx)
params := k.GetParams(ctx)
return &types.GenesisState{
Params: params,
Tokens: tokens,
TokenProperties: tokenProperties,
}
}