github.com/fibonacci-chain/fbc@v0.0.0-20231124064014-c7636198c1e9/libs/ibc-go/modules/apps/27-interchain-accounts/controller/keeper/genesis.go (about) 1 package keeper 2 3 import ( 4 "fmt" 5 6 sdk "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/types" 7 icatypes "github.com/fibonacci-chain/fbc/libs/ibc-go/modules/apps/27-interchain-accounts/types" 8 host "github.com/fibonacci-chain/fbc/libs/ibc-go/modules/core/24-host" 9 ) 10 11 // InitGenesis initializes the interchain accounts controller application state from a provided genesis state 12 func InitGenesis(ctx sdk.Context, keeper Keeper, state icatypes.ControllerGenesisState) { 13 for _, portID := range state.Ports { 14 if !keeper.IsBound(ctx, portID) { 15 cap := keeper.BindPort(ctx, portID) 16 if err := keeper.ClaimCapability(ctx, cap, host.PortPath(portID)); err != nil { 17 panic(fmt.Sprintf("could not claim port capability: %v", err)) 18 } 19 } 20 } 21 22 for _, ch := range state.ActiveChannels { 23 keeper.SetActiveChannelID(ctx, ch.ConnectionId, ch.PortId, ch.ChannelId) 24 } 25 26 for _, acc := range state.InterchainAccounts { 27 keeper.SetInterchainAccountAddress(ctx, acc.ConnectionId, acc.PortId, acc.AccountAddress) 28 } 29 30 keeper.SetParams(ctx, state.Params) 31 } 32 33 // ExportGenesis returns the interchain accounts controller exported genesis 34 func ExportGenesis(ctx sdk.Context, keeper Keeper) icatypes.ControllerGenesisState { 35 return icatypes.NewControllerGenesisState( 36 keeper.GetAllActiveChannels(ctx), 37 keeper.GetAllInterchainAccounts(ctx), 38 keeper.GetAllPorts(ctx), 39 keeper.GetParams(ctx), 40 ) 41 }