Skip to content

Commit

Permalink
chore: godocs, rm ClientStore from expected keeper, rename events arg…
Browse files Browse the repository at this point in the history
… to initialHeight
  • Loading branch information
damiannolan committed Mar 14, 2024
1 parent c1c70ae commit 696f852
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 13 deletions.
4 changes: 2 additions & 2 deletions modules/core/02-client/keeper/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ import (
)

// emitCreateClientEvent emits a create client event
func emitCreateClientEvent(ctx sdk.Context, clientID, clientType string, latestHeight exported.Height) {
func emitCreateClientEvent(ctx sdk.Context, clientID, clientType string, initialHeight exported.Height) {
ctx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
types.EventTypeCreateClient,
sdk.NewAttribute(types.AttributeKeyClientID, clientID),
sdk.NewAttribute(types.AttributeKeyClientType, clientType),
sdk.NewAttribute(types.AttributeKeyConsensusHeight, latestHeight.String()),
sdk.NewAttribute(types.AttributeKeyConsensusHeight, initialHeight.String()),
),
sdk.NewEvent(
sdk.EventTypeMessage,
Expand Down
8 changes: 4 additions & 4 deletions modules/core/02-client/types/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ func NewRouter(key storetypes.StoreKey) *Router {
// - or a module is already registered for the provided client type,
// - or the client type is invalid.
func (rtr *Router) AddRoute(clientType string, module exported.LightClientModule) *Router {
if err := ValidateClientType(clientType); err != nil {
panic(err)
}

if rtr.HasRoute(clientType) {
panic(fmt.Errorf("route %s has already been registered", module))
}

if err := ValidateClientType(clientType); err != nil {
panic(fmt.Errorf("failed to add route: %w", err))
}

rtr.routes[clientType] = module

module.RegisterStoreProvider(rtr.storeProvider)
Expand Down
7 changes: 3 additions & 4 deletions modules/core/02-client/types/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,13 @@ func NewStoreProvider(storeKey storetypes.StoreKey) exported.ClientStoreProvider
}
}

// 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
// ClientStore returns isolated prefix store for each client so they can read/write in separate namespaces.
func (s storeProvider) ClientStore(ctx sdk.Context, clientID string) storetypes.KVStore {
clientPrefix := []byte(fmt.Sprintf("%s/%s/", host.KeyClientStorePrefix, clientID))
return prefix.NewStore(ctx.KVStore(s.storeKey), clientPrefix)
}

// ModuleStore returns the 02-client module store
func (s storeProvider) ModuleStore(ctx sdk.Context, clientType string) storetypes.KVStore {
// ClientModuleStore returns the module store for a provided client type.
func (s storeProvider) ClientModuleStore(ctx sdk.Context, clientType string) storetypes.KVStore {
return prefix.NewStore(ctx.KVStore(s.storeKey), host.PrefixedClientStoreKey([]byte(clientType)))
}
3 changes: 0 additions & 3 deletions modules/core/04-channel/types/expected_keepers.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package types

import (
storetypes "cosmossdk.io/store/types"

sdk "github.com/cosmos/cosmos-sdk/types"

capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types"
Expand All @@ -13,7 +11,6 @@ import (

// ClientKeeper expected account IBC client keeper
type ClientKeeper interface {
ClientStore(ctx sdk.Context, clientID string) storetypes.KVStore
GetClientStatus(ctx sdk.Context, clientID string) exported.Status
GetClientState(ctx sdk.Context, clientID string) (exported.ClientState, bool)
GetClientConsensusState(ctx sdk.Context, clientID string, height exported.Height) (exported.ConsensusState, bool)
Expand Down

0 comments on commit 696f852

Please sign in to comment.