forked from cosmos/ibc-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
genesis.go
32 lines (28 loc) · 1.2 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
package connection
import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/ibc-go/v3/modules/core/03-connection/keeper"
"github.com/cosmos/ibc-go/v3/modules/core/03-connection/types"
)
// InitGenesis initializes the ibc connection submodule's state from a provided genesis
// state.
func InitGenesis(ctx sdk.Context, k keeper.Keeper, gs types.GenesisState) {
for _, connection := range gs.Connections {
conn := types.NewConnectionEnd(connection.State, connection.ClientId, connection.Counterparty, connection.Versions, connection.DelayPeriod)
k.SetConnection(ctx, connection.Id, conn)
}
for _, connPaths := range gs.ClientConnectionPaths {
k.SetClientConnectionPaths(ctx, connPaths.ClientId, connPaths.Paths)
}
k.SetNextConnectionSequence(ctx, gs.NextConnectionSequence)
k.SetParams(ctx, gs.Params)
}
// ExportGenesis returns the ibc connection submodule's exported genesis.
func ExportGenesis(ctx sdk.Context, k keeper.Keeper) types.GenesisState {
return types.GenesisState{
Connections: k.GetAllConnections(ctx),
ClientConnectionPaths: k.GetAllClientConnectionPaths(ctx),
NextConnectionSequence: k.GetNextConnectionSequence(ctx),
Params: k.GetParams(ctx),
}
}