/
genesis.go
59 lines (52 loc) · 1.73 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
package cosmwasmpool
import (
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/osmosis-labs/osmosis/v19/x/cosmwasmpool/types"
)
// InitGenesis initializes the store state from a genesis state.
func (k *Keeper) InitGenesis(ctx sdk.Context, gen *types.GenesisState, unpacker codectypes.AnyUnpacker) {
k.SetParams(ctx, gen.Params)
// Add each genesis state pool to the x/cosmwasmpool module's state
for _, any := range gen.Pools {
var pool types.CosmWasmExtension
err := unpacker.UnpackAny(any, &pool)
if err != nil {
panic(err)
}
k.SetPool(ctx, pool)
}
}
// ExportGenesis returns the cosmwasm pool's exported genesis.
func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState {
params := k.GetParams(ctx)
// TODO: We remove this as there is an issue with resolving the
// type url for the cosmwasm pools.
// panic: unable to resolve type URL /
//pools, err := k.GetPools(ctx)
//if err != nil {
// panic(err)
//}
//poolAnys := []*codectypes.Any{}
//for _, poolI := range pools {
// cosmwasmPool, ok := poolI.(types.CosmWasmExtension)
// if !ok {
// panic("invalid pool type")
// }
// any, err := codectypes.NewAnyWithValue(cosmwasmPool)
// if err != nil {
// panic(err)
// }
// poolAnys = append(poolAnys, any)
//}
return &types.GenesisState{
Params: params,
// TODO: This is likely because amino is being used directly
// (instead of codec.LegacyAmino which is preferred) or
// UnpackInterfacesMessage is not defined for some type which
// contains a protobuf Any either directly or via one of its members.
// To see a stacktrace of where the error is coming from,
// set the var Debug = true in codec/types/compat.go
// Pools: poolAnys,
}
}