-
Notifications
You must be signed in to change notification settings - Fork 56
/
genesis.go
35 lines (28 loc) · 992 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
package keeper
import (
"fmt"
"github.com/cosmos/ibc-apps/modules/async-icq/v5/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)
// InitGenesis initializes the icq state and binds to PortID.
func (k Keeper) InitGenesis(ctx sdk.Context, state types.GenesisState) {
k.SetPort(ctx, state.HostPort)
// Only try to bind to port if it is not already bound, since we may already own
// port capability from capability InitGenesis
if !k.IsBound(ctx, state.HostPort) {
// transfer module binds to the transfer port on InitChain
// and claims the returned capability
err := k.BindPort(ctx, state.HostPort)
if err != nil {
panic(fmt.Sprintf("could not claim port capability: %v", err))
}
}
k.SetParams(ctx, state.Params)
}
// ExportGenesis exports icq module's portID and denom trace info into its genesis state.
func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState {
return &types.GenesisState{
HostPort: k.GetPort(ctx),
Params: k.GetParams(ctx),
}
}