-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ibc/04-channel: import export GenesisState (#6087)
* ibc/04-channel: import export GenesisState * update tests * add missing genesis fields * genesis tests * keeper tests * update genesis test * typo * rename types * address comments from review * minor updates * typo
- Loading branch information
Showing
15 changed files
with
603 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package channel | ||
|
||
import ( | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
) | ||
|
||
// InitGenesis initializes the ibc channel submodule's state from a provided genesis | ||
// state. | ||
func InitGenesis(ctx sdk.Context, k Keeper, gs GenesisState) { | ||
for _, channel := range gs.Channels { | ||
ch := NewChannel(channel.State, channel.Ordering, channel.Counterparty, channel.ConnectionHops, channel.Version) | ||
k.SetChannel(ctx, channel.PortID, channel.ID, ch) | ||
} | ||
for _, ack := range gs.Acknowledgements { | ||
k.SetPacketAcknowledgement(ctx, ack.PortID, ack.ChannelID, ack.Sequence, ack.Hash) | ||
} | ||
for _, commitment := range gs.Commitments { | ||
k.SetPacketCommitment(ctx, commitment.PortID, commitment.ChannelID, commitment.Sequence, commitment.Hash) | ||
} | ||
for _, ss := range gs.SendSequences { | ||
k.SetNextSequenceSend(ctx, ss.PortID, ss.ChannelID, ss.Sequence) | ||
} | ||
for _, rs := range gs.RecvSequences { | ||
k.SetNextSequenceRecv(ctx, rs.PortID, rs.ChannelID, rs.Sequence) | ||
} | ||
} | ||
|
||
// ExportGenesis returns the ibc channel submodule's exported genesis. | ||
func ExportGenesis(ctx sdk.Context, k Keeper) GenesisState { | ||
return GenesisState{ | ||
Channels: k.GetAllChannels(ctx), | ||
Acknowledgements: k.GetAllPacketAcks(ctx), | ||
Commitments: k.GetAllPacketCommitments(ctx), | ||
SendSequences: k.GetAllPacketSendSeqs(ctx), | ||
RecvSequences: k.GetAllPacketRecvSeqs(ctx), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.