Skip to content

Commit

Permalink
param space initialization for rate limiting (#4360)
Browse files Browse the repository at this point in the history
* param space initialization for rate limiting

* lint
  • Loading branch information
p0mvn authored Feb 17, 2023
1 parent fc9c7fa commit 637e692
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
9 changes: 4 additions & 5 deletions app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ import (
"github.com/cosmos/cosmos-sdk/x/upgrade"
upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
icq "github.com/strangelove-ventures/async-icq/v4"
icqtypes "github.com/strangelove-ventures/async-icq/v4/types"

downtimedetector "github.com/osmosis-labs/osmosis/v14/x/downtime-detector"
downtimetypes "github.com/osmosis-labs/osmosis/v14/x/downtime-detector/types"
"github.com/osmosis-labs/osmosis/v14/x/gamm"
Expand All @@ -44,8 +47,6 @@ import (
ibchooks "github.com/osmosis-labs/osmosis/x/ibc-hooks"
ibchookskeeper "github.com/osmosis-labs/osmosis/x/ibc-hooks/keeper"
ibchookstypes "github.com/osmosis-labs/osmosis/x/ibc-hooks/types"
icq "github.com/strangelove-ventures/async-icq/v4"
icqtypes "github.com/strangelove-ventures/async-icq/v4/types"

icahost "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/host"
icahostkeeper "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/host/keeper"
Expand Down Expand Up @@ -503,15 +504,13 @@ func (appKeepers *AppKeepers) WireICS20PreWasmKeeper(
)

// ChannelKeeper wrapper for rate limiting SendPacket(). The wasmKeeper needs to be added after it's created
rateLimitingParams := appKeepers.GetSubspace(ibcratelimittypes.ModuleName)
rateLimitingParams = rateLimitingParams.WithKeyTable(ibcratelimittypes.ParamKeyTable())
rateLimitingICS4Wrapper := ibcratelimit.NewICS4Middleware(
appKeepers.HooksICS4Wrapper,
appKeepers.AccountKeeper,
// wasm keeper we set later.
nil,
appKeepers.BankKeeper,
rateLimitingParams,
appKeepers.GetSubspace(ibcratelimittypes.ModuleName),
)
appKeepers.RateLimitingICS4Wrapper = &rateLimitingICS4Wrapper

Expand Down
5 changes: 5 additions & 0 deletions x/ibc-rate-limit/ics4_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
channeltypes "github.com/cosmos/ibc-go/v4/modules/core/04-channel/types"
porttypes "github.com/cosmos/ibc-go/v4/modules/core/05-port/types"
"github.com/cosmos/ibc-go/v4/modules/core/exported"

"github.com/osmosis-labs/osmosis/v14/x/ibc-rate-limit/types"
)

var (
Expand All @@ -35,6 +37,9 @@ func NewICS4Middleware(
accountKeeper *authkeeper.AccountKeeper, contractKeeper *wasmkeeper.PermissionedKeeper,
bankKeeper *bankkeeper.BaseKeeper, paramSpace paramtypes.Subspace,
) ICS4Wrapper {
if !paramSpace.HasKeyTable() {
paramSpace = paramSpace.WithKeyTable(types.ParamKeyTable())
}
return ICS4Wrapper{
channel: channel,
accountKeeper: accountKeeper,
Expand Down
1 change: 1 addition & 0 deletions x/ibc-rate-limit/rate_limit.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package ibc_rate_limit

import (
"encoding/json"

wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
Expand Down

0 comments on commit 637e692

Please sign in to comment.