Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

imp: use storetypes instead of sdk types #4009

Merged
merged 4 commits into from
Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (k Keeper) GetConnectionID(ctx sdk.Context, portID, channelID string) (stri
// GetAllPorts returns all ports to which the interchain accounts controller module is bound. Used in ExportGenesis
func (k Keeper) GetAllPorts(ctx sdk.Context) []string {
store := ctx.KVStore(k.storeKey)
iterator := sdk.KVStorePrefixIterator(store, []byte(icatypes.PortKeyPrefix))
iterator := storetypes.KVStorePrefixIterator(store, []byte(icatypes.PortKeyPrefix))
defer sdk.LogDeferred(ctx.Logger(), func() error { return iterator.Close() })

var ports []string
Expand Down Expand Up @@ -167,7 +167,7 @@ func (k Keeper) IsActiveChannelClosed(ctx sdk.Context, connectionID, portID stri
// GetAllActiveChannels returns a list of all active interchain accounts controller channels and their associated connection and port identifiers
func (k Keeper) GetAllActiveChannels(ctx sdk.Context) []genesistypes.ActiveChannel {
store := ctx.KVStore(k.storeKey)
iterator := sdk.KVStorePrefixIterator(store, []byte(icatypes.ActiveChannelKeyPrefix))
iterator := storetypes.KVStorePrefixIterator(store, []byte(icatypes.ActiveChannelKeyPrefix))
defer sdk.LogDeferred(ctx.Logger(), func() error { return iterator.Close() })

var activeChannels []genesistypes.ActiveChannel
Expand Down Expand Up @@ -218,7 +218,7 @@ func (k Keeper) GetInterchainAccountAddress(ctx sdk.Context, connectionID, portI
// GetAllInterchainAccounts returns a list of all registered interchain account addresses and their associated connection and controller port identifiers
func (k Keeper) GetAllInterchainAccounts(ctx sdk.Context) []genesistypes.RegisteredInterchainAccount {
store := ctx.KVStore(k.storeKey)
iterator := sdk.KVStorePrefixIterator(store, []byte(icatypes.OwnerKeyPrefix))
iterator := storetypes.KVStorePrefixIterator(store, []byte(icatypes.OwnerKeyPrefix))

var interchainAccounts []genesistypes.RegisteredInterchainAccount
for ; iterator.Valid(); iterator.Next() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func MigrateICS27ChannelCapability(
) error {
// construct a prefix store using the x/capability index prefix: index->capability owners
prefixStore := prefix.NewStore(ctx.KVStore(capabilityStoreKey), capabilitytypes.KeyPrefixIndexCapability)
iterator := sdk.KVStorePrefixIterator(prefixStore, nil)
iterator := storetypes.KVStorePrefixIterator(prefixStore, nil)
defer sdk.LogDeferred(ctx.Logger(), func() error { return iterator.Close() })

for ; iterator.Valid(); iterator.Next() {
Expand Down
4 changes: 2 additions & 2 deletions modules/apps/27-interchain-accounts/host/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func (k Keeper) GetOpenActiveChannel(ctx sdk.Context, connectionID, portID strin
// GetAllActiveChannels returns a list of all active interchain accounts host channels and their associated connection and port identifiers
func (k Keeper) GetAllActiveChannels(ctx sdk.Context) []genesistypes.ActiveChannel {
store := ctx.KVStore(k.storeKey)
iterator := sdk.KVStorePrefixIterator(store, []byte(icatypes.ActiveChannelKeyPrefix))
iterator := storetypes.KVStorePrefixIterator(store, []byte(icatypes.ActiveChannelKeyPrefix))
defer sdk.LogDeferred(ctx.Logger(), func() error { return iterator.Close() })

var activeChannels []genesistypes.ActiveChannel
Expand Down Expand Up @@ -202,7 +202,7 @@ func (k Keeper) GetInterchainAccountAddress(ctx sdk.Context, connectionID, portI
// GetAllInterchainAccounts returns a list of all registered interchain account addresses and their associated connection and controller port identifiers
func (k Keeper) GetAllInterchainAccounts(ctx sdk.Context) []genesistypes.RegisteredInterchainAccount {
store := ctx.KVStore(k.storeKey)
iterator := sdk.KVStorePrefixIterator(store, []byte(icatypes.OwnerKeyPrefix))
iterator := storetypes.KVStorePrefixIterator(store, []byte(icatypes.OwnerKeyPrefix))

var interchainAccounts []genesistypes.RegisteredInterchainAccount
for ; iterator.Valid(); iterator.Next() {
Expand Down
12 changes: 6 additions & 6 deletions modules/apps/29-fee/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func (k Keeper) IsFeeEnabled(ctx sdk.Context, portID, channelID string) bool {
// GetAllFeeEnabledChannels returns a list of all ics29 enabled channels containing portID & channelID that are stored in state
func (k Keeper) GetAllFeeEnabledChannels(ctx sdk.Context) []types.FeeEnabledChannel {
store := ctx.KVStore(k.storeKey)
iterator := sdk.KVStorePrefixIterator(store, []byte(types.FeeEnabledKeyPrefix))
iterator := storetypes.KVStorePrefixIterator(store, []byte(types.FeeEnabledKeyPrefix))
defer sdk.LogDeferred(ctx.Logger(), func() error { return iterator.Close() })

var enabledChArr []types.FeeEnabledChannel
Expand Down Expand Up @@ -171,7 +171,7 @@ func (k Keeper) SetPayeeAddress(ctx sdk.Context, relayerAddr, payeeAddr, channel
// GetAllPayees returns all registered payees addresses
func (k Keeper) GetAllPayees(ctx sdk.Context) []types.RegisteredPayee {
store := ctx.KVStore(k.storeKey)
iterator := sdk.KVStorePrefixIterator(store, []byte(types.PayeeKeyPrefix))
iterator := storetypes.KVStorePrefixIterator(store, []byte(types.PayeeKeyPrefix))
defer sdk.LogDeferred(ctx.Logger(), func() error { return iterator.Close() })

var registeredPayees []types.RegisteredPayee
Expand Down Expand Up @@ -216,7 +216,7 @@ func (k Keeper) GetCounterpartyPayeeAddress(ctx sdk.Context, address, channelID
// GetAllCounterpartyPayees returns all registered counterparty payee addresses
func (k Keeper) GetAllCounterpartyPayees(ctx sdk.Context) []types.RegisteredCounterpartyPayee {
store := ctx.KVStore(k.storeKey)
iterator := sdk.KVStorePrefixIterator(store, []byte(types.CounterpartyPayeeKeyPrefix))
iterator := storetypes.KVStorePrefixIterator(store, []byte(types.CounterpartyPayeeKeyPrefix))
defer sdk.LogDeferred(ctx.Logger(), func() error { return iterator.Close() })

var registeredCounterpartyPayees []types.RegisteredCounterpartyPayee
Expand Down Expand Up @@ -259,7 +259,7 @@ func (k Keeper) GetRelayerAddressForAsyncAck(ctx sdk.Context, packetID channelty
// GetAllForwardRelayerAddresses returns all forward relayer addresses stored for async acknowledgements
func (k Keeper) GetAllForwardRelayerAddresses(ctx sdk.Context) []types.ForwardRelayerAddress {
store := ctx.KVStore(k.storeKey)
iterator := sdk.KVStorePrefixIterator(store, []byte(types.ForwardRelayerPrefix))
iterator := storetypes.KVStorePrefixIterator(store, []byte(types.ForwardRelayerPrefix))
defer sdk.LogDeferred(ctx.Logger(), func() error { return iterator.Close() })

var forwardRelayerAddr []types.ForwardRelayerAddress
Expand Down Expand Up @@ -326,7 +326,7 @@ func (k Keeper) GetIdentifiedPacketFeesForChannel(ctx sdk.Context, portID, chann
var identifiedPacketFees []types.IdentifiedPacketFees

store := ctx.KVStore(k.storeKey)
iterator := sdk.KVStorePrefixIterator(store, types.KeyFeesInEscrowChannelPrefix(portID, channelID))
iterator := storetypes.KVStorePrefixIterator(store, types.KeyFeesInEscrowChannelPrefix(portID, channelID))

defer sdk.LogDeferred(ctx.Logger(), func() error { return iterator.Close() })
for ; iterator.Valid(); iterator.Next() {
Expand All @@ -347,7 +347,7 @@ func (k Keeper) GetIdentifiedPacketFeesForChannel(ctx sdk.Context, portID, chann
// GetAllIdentifiedPacketFees returns a list of all IdentifiedPacketFees that are stored in state
func (k Keeper) GetAllIdentifiedPacketFees(ctx sdk.Context) []types.IdentifiedPacketFees {
store := ctx.KVStore(k.storeKey)
iterator := sdk.KVStorePrefixIterator(store, []byte(types.FeesInEscrowPrefix))
iterator := storetypes.KVStorePrefixIterator(store, []byte(types.FeesInEscrowPrefix))
defer sdk.LogDeferred(ctx.Logger(), func() error { return iterator.Close() })

var identifiedFees []types.IdentifiedPacketFees
Expand Down
4 changes: 2 additions & 2 deletions modules/apps/transfer/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func (k Keeper) GetAllDenomTraces(ctx sdk.Context) types.Traces {
// and performs a callback function.
func (k Keeper) IterateDenomTraces(ctx sdk.Context, cb func(denomTrace types.DenomTrace) bool) {
store := ctx.KVStore(k.storeKey)
iterator := sdk.KVStorePrefixIterator(store, types.DenomTraceKey)
iterator := storetypes.KVStorePrefixIterator(store, types.DenomTraceKey)

defer sdk.LogDeferred(ctx.Logger(), func() error { return iterator.Close() })
for ; iterator.Valid(); iterator.Next() {
Expand Down Expand Up @@ -237,7 +237,7 @@ func (k Keeper) GetAllTotalEscrowed(ctx sdk.Context) sdk.Coins {
// (i.e. not integer) is stored, will be skipped.
func (k Keeper) IterateTokensInEscrow(ctx sdk.Context, prefix []byte, cb func(denomEscrow sdk.Coin) bool) {
store := ctx.KVStore(k.storeKey)
iterator := sdk.KVStorePrefixIterator(store, prefix)
iterator := storetypes.KVStorePrefixIterator(store, prefix)

defer sdk.LogDeferred(ctx.Logger(), func() error { return iterator.Close() })
for ; iterator.Valid(); iterator.Next() {
Expand Down
2 changes: 1 addition & 1 deletion modules/capability/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func (k *Keeper) InitMemStore(ctx sdk.Context) {
// check if memory store has not been initialized yet by checking if initialized flag is nil.
if !k.IsInitialized(noGasCtx) {
prefixStore := prefix.NewStore(noGasCtx.KVStore(k.storeKey), types.KeyPrefixIndexCapability)
iterator := sdk.KVStorePrefixIterator(prefixStore, nil)
iterator := storetypes.KVStorePrefixIterator(prefixStore, nil)

// initialize the in-memory store for all persisted capabilities
defer iterator.Close()
Expand Down
6 changes: 3 additions & 3 deletions modules/core/02-client/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func (k Keeper) SetNextClientSequence(ctx sdk.Context, sequence uint64) {
// the iterator will close and stop.
func (k Keeper) IterateConsensusStates(ctx sdk.Context, cb func(clientID string, cs types.ConsensusStateWithHeight) bool) {
store := ctx.KVStore(k.storeKey)
iterator := sdk.KVStorePrefixIterator(store, host.KeyClientStorePrefix)
iterator := storetypes.KVStorePrefixIterator(store, host.KeyClientStorePrefix)

defer sdk.LogDeferred(ctx.Logger(), func() error { return iterator.Close() })
for ; iterator.Valid(); iterator.Next() {
Expand Down Expand Up @@ -370,7 +370,7 @@ func (k Keeper) SetUpgradedConsensusState(ctx sdk.Context, planHeight int64, bz
// the iterator will close and stop.
func (k Keeper) IterateClientStates(ctx sdk.Context, prefix []byte, cb func(clientID string, cs exported.ClientState) bool) {
store := ctx.KVStore(k.storeKey)
iterator := sdk.KVStorePrefixIterator(store, host.PrefixedClientStoreKey(prefix))
iterator := storetypes.KVStorePrefixIterator(store, host.PrefixedClientStoreKey(prefix))

defer sdk.LogDeferred(ctx.Logger(), func() error { return iterator.Close() })
for ; iterator.Valid(); iterator.Next() {
Expand Down Expand Up @@ -402,7 +402,7 @@ func (k Keeper) GetAllClients(ctx sdk.Context) []exported.ClientState {

// ClientStore returns isolated prefix store for each client so they can read/write in separate
// namespace without being able to read/write other client's data
func (k Keeper) ClientStore(ctx sdk.Context, clientID string) sdk.KVStore {
func (k Keeper) ClientStore(ctx sdk.Context, clientID string) storetypes.KVStore {
clientPrefix := []byte(fmt.Sprintf("%s/%s/", host.KeyClientStorePrefix, clientID))
return prefix.NewStore(ctx.KVStore(k.storeKey), clientPrefix)
}
Expand Down
3 changes: 2 additions & 1 deletion modules/core/02-client/migrations/v7/expected_keepers.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package v7

import (
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/cosmos/ibc-go/v7/modules/core/exported"
Expand All @@ -10,6 +11,6 @@ import (
type ClientKeeper interface {
GetClientState(ctx sdk.Context, clientID string) (exported.ClientState, bool)
SetClientState(ctx sdk.Context, clientID string, clientState exported.ClientState)
ClientStore(ctx sdk.Context, clientID string) sdk.KVStore
ClientStore(ctx sdk.Context, clientID string) storetypes.KVStore
CreateLocalhostClient(ctx sdk.Context) error
}
45 changes: 23 additions & 22 deletions modules/core/02-client/migrations/v7/solomachine.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/cosmos/ibc-go/v7/modules/core/exported"
Expand Down Expand Up @@ -59,7 +60,7 @@ func (cs ClientState) GetLatestHeight() exported.Height {
}

// Status panics!
func (cs ClientState) Status(_ sdk.Context, _ sdk.KVStore, _ codec.BinaryCodec) exported.Status {
func (cs ClientState) Status(_ sdk.Context, _ storetypes.KVStore, _ codec.BinaryCodec) exported.Status {
panic("legacy solo machine is deprecated!")
}

Expand All @@ -74,80 +75,80 @@ func (cs ClientState) ZeroCustomFields() exported.ClientState {
}

// Initialize panics!
func (cs ClientState) Initialize(_ sdk.Context, _ codec.BinaryCodec, _ sdk.KVStore, consState exported.ConsensusState) error {
func (cs ClientState) Initialize(_ sdk.Context, _ codec.BinaryCodec, _ storetypes.KVStore, consState exported.ConsensusState) error {
panic("legacy solo machine is deprecated!")
}

// ExportMetadata panics!
func (cs ClientState) ExportMetadata(_ sdk.KVStore) []exported.GenesisMetadata {
func (cs ClientState) ExportMetadata(_ storetypes.KVStore) []exported.GenesisMetadata {
panic("legacy solo machine is deprecated!")
}

// CheckForMisbehaviour panics!
func (cs ClientState) CheckForMisbehaviour(ctx sdk.Context, cdc codec.BinaryCodec, clientStore sdk.KVStore, msg exported.ClientMessage) bool {
func (cs ClientState) CheckForMisbehaviour(ctx sdk.Context, cdc codec.BinaryCodec, clientStore storetypes.KVStore, msg exported.ClientMessage) bool {
panic("legacy solo machine is deprecated!")
}

// UpdateStateOnMisbehaviour panics!
func (cs *ClientState) UpdateStateOnMisbehaviour(
_ sdk.Context, _ codec.BinaryCodec, _ sdk.KVStore, _ exported.ClientMessage,
_ sdk.Context, _ codec.BinaryCodec, _ storetypes.KVStore, _ exported.ClientMessage,
) {
panic("legacy solo machine is deprecated!")
}

// VerifyClientMessage panics!
func (cs *ClientState) VerifyClientMessage(
_ sdk.Context, _ codec.BinaryCodec, _ sdk.KVStore, _ exported.ClientMessage,
_ sdk.Context, _ codec.BinaryCodec, _ storetypes.KVStore, _ exported.ClientMessage,
) error {
panic("legacy solo machine is deprecated!")
}

// UpdateState panis!
func (cs *ClientState) UpdateState(_ sdk.Context, _ codec.BinaryCodec, _ sdk.KVStore, _ exported.ClientMessage) []exported.Height {
func (cs *ClientState) UpdateState(_ sdk.Context, _ codec.BinaryCodec, _ storetypes.KVStore, _ exported.ClientMessage) []exported.Height {
panic("legacy solo machine is deprecated!")
}

// CheckHeaderAndUpdateState panics!
func (cs *ClientState) CheckHeaderAndUpdateState(
_ sdk.Context, _ codec.BinaryCodec, _ sdk.KVStore, _ exported.ClientMessage,
_ sdk.Context, _ codec.BinaryCodec, _ storetypes.KVStore, _ exported.ClientMessage,
) (exported.ClientState, exported.ConsensusState, error) {
panic("legacy solo machine is deprecated!")
}

// CheckMisbehaviourAndUpdateState panics!
func (cs ClientState) CheckMisbehaviourAndUpdateState(
_ sdk.Context, _ codec.BinaryCodec, _ sdk.KVStore, _ exported.ClientMessage,
_ sdk.Context, _ codec.BinaryCodec, _ storetypes.KVStore, _ exported.ClientMessage,
) (exported.ClientState, error) {
panic("legacy solo machine is deprecated!")
}

// CheckSubstituteAndUpdateState panics!
func (cs ClientState) CheckSubstituteAndUpdateState(
ctx sdk.Context, _ codec.BinaryCodec, _, _ sdk.KVStore,
ctx sdk.Context, _ codec.BinaryCodec, _, _ storetypes.KVStore,
_ exported.ClientState,
) error {
panic("legacy solo machine is deprecated!")
}

// VerifyUpgradeAndUpdateState panics!
func (cs ClientState) VerifyUpgradeAndUpdateState(
_ sdk.Context, _ codec.BinaryCodec, _ sdk.KVStore,
_ sdk.Context, _ codec.BinaryCodec, _ storetypes.KVStore,
_ exported.ClientState, _ exported.ConsensusState, _, _ []byte,
) error {
panic("legacy solo machine is deprecated!")
}

// VerifyClientState panics!
func (cs ClientState) VerifyClientState(
store sdk.KVStore, cdc codec.BinaryCodec,
store storetypes.KVStore, cdc codec.BinaryCodec,
_ exported.Height, _ exported.Prefix, _ string, _ []byte, clientState exported.ClientState,
) error {
panic("legacy solo machine is deprecated!")
}

// VerifyClientConsensusState panics!
func (cs ClientState) VerifyClientConsensusState(
sdk.KVStore, codec.BinaryCodec,
storetypes.KVStore, codec.BinaryCodec,
exported.Height, string, exported.Height, exported.Prefix,
[]byte, exported.ConsensusState,
) error {
Expand All @@ -156,23 +157,23 @@ func (cs ClientState) VerifyClientConsensusState(

// VerifyConnectionState panics!
func (cs ClientState) VerifyConnectionState(
sdk.KVStore, codec.BinaryCodec, exported.Height,
storetypes.KVStore, codec.BinaryCodec, exported.Height,
exported.Prefix, []byte, string, exported.ConnectionI,
) error {
panic("legacy solo machine is deprecated!")
}

// VerifyChannelState panics!
func (cs ClientState) VerifyChannelState(
sdk.KVStore, codec.BinaryCodec, exported.Height, exported.Prefix,
storetypes.KVStore, codec.BinaryCodec, exported.Height, exported.Prefix,
[]byte, string, string, exported.ChannelI,
) error {
panic("legacy solo machine is deprecated!")
}

// VerifyPacketCommitment panics!
func (cs ClientState) VerifyPacketCommitment(
sdk.Context, sdk.KVStore, codec.BinaryCodec, exported.Height,
sdk.Context, storetypes.KVStore, codec.BinaryCodec, exported.Height,
uint64, uint64, exported.Prefix, []byte,
string, string, uint64, []byte,
) error {
Expand All @@ -181,7 +182,7 @@ func (cs ClientState) VerifyPacketCommitment(

// VerifyPacketAcknowledgement panics!
func (cs ClientState) VerifyPacketAcknowledgement(
sdk.Context, sdk.KVStore, codec.BinaryCodec, exported.Height,
sdk.Context, storetypes.KVStore, codec.BinaryCodec, exported.Height,
uint64, uint64, exported.Prefix, []byte,
string, string, uint64, []byte,
) error {
Expand All @@ -190,7 +191,7 @@ func (cs ClientState) VerifyPacketAcknowledgement(

// VerifyPacketReceiptAbsence panics!
func (cs ClientState) VerifyPacketReceiptAbsence(
sdk.Context, sdk.KVStore, codec.BinaryCodec, exported.Height,
sdk.Context, storetypes.KVStore, codec.BinaryCodec, exported.Height,
uint64, uint64, exported.Prefix, []byte,
string, string, uint64,
) error {
Expand All @@ -199,7 +200,7 @@ func (cs ClientState) VerifyPacketReceiptAbsence(

// VerifyNextSequenceRecv panics!
func (cs ClientState) VerifyNextSequenceRecv(
sdk.Context, sdk.KVStore, codec.BinaryCodec, exported.Height,
sdk.Context, storetypes.KVStore, codec.BinaryCodec, exported.Height,
uint64, uint64, exported.Prefix, []byte,
string, string, uint64,
) error {
Expand All @@ -208,15 +209,15 @@ func (cs ClientState) VerifyNextSequenceRecv(

// GetTimestampAtHeight panics!
func (cs ClientState) GetTimestampAtHeight(
sdk.Context, sdk.KVStore, codec.BinaryCodec, exported.Height,
sdk.Context, storetypes.KVStore, codec.BinaryCodec, exported.Height,
) (uint64, error) {
panic("legacy solo machine is deprecated!")
}

// VerifyMembership panics!
func (cs *ClientState) VerifyMembership(
ctx sdk.Context,
clientStore sdk.KVStore,
clientStore storetypes.KVStore,
cdc codec.BinaryCodec,
height exported.Height,
delayTimePeriod uint64,
Expand All @@ -231,7 +232,7 @@ func (cs *ClientState) VerifyMembership(
// VerifyNonMembership panics!
func (cs *ClientState) VerifyNonMembership(
ctx sdk.Context,
clientStore sdk.KVStore,
clientStore storetypes.KVStore,
cdc codec.BinaryCodec,
height exported.Height,
delayTimePeriod uint64,
Expand Down
Loading