2020-04-24 08:52:07 -07:00
|
|
|
package connection
|
|
|
|
|
|
|
|
import (
|
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
2020-10-02 02:03:02 -07:00
|
|
|
"github.com/cosmos/cosmos-sdk/x/ibc/core/03-connection/keeper"
|
|
|
|
"github.com/cosmos/cosmos-sdk/x/ibc/core/03-connection/types"
|
2020-04-24 08:52:07 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
// InitGenesis initializes the ibc connection submodule's state from a provided genesis
|
|
|
|
// state.
|
2020-06-30 06:10:53 -07:00
|
|
|
func InitGenesis(ctx sdk.Context, k keeper.Keeper, gs types.GenesisState) {
|
2020-04-24 08:52:07 -07:00
|
|
|
for _, connection := range gs.Connections {
|
2020-08-14 01:55:54 -07:00
|
|
|
conn := types.NewConnectionEnd(connection.State, connection.ClientId, connection.Counterparty, connection.Versions)
|
|
|
|
k.SetConnection(ctx, connection.Id, conn)
|
2020-04-24 08:52:07 -07:00
|
|
|
}
|
|
|
|
for _, connPaths := range gs.ClientConnectionPaths {
|
2020-08-14 01:55:54 -07:00
|
|
|
k.SetClientConnectionPaths(ctx, connPaths.ClientId, connPaths.Paths)
|
2020-04-24 08:52:07 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ExportGenesis returns the ibc connection submodule's exported genesis.
|
2020-06-30 06:10:53 -07:00
|
|
|
func ExportGenesis(ctx sdk.Context, k keeper.Keeper) types.GenesisState {
|
|
|
|
return types.GenesisState{
|
2020-04-24 08:52:07 -07:00
|
|
|
Connections: k.GetAllConnections(ctx),
|
|
|
|
ClientConnectionPaths: k.GetAllClientConnectionPaths(ctx),
|
|
|
|
}
|
|
|
|
}
|