@@ -3,6 +3,7 @@ package keepers
3
3
import (
4
4
"fmt"
5
5
"os"
6
+ "strings"
6
7
7
8
ratelimit "github.com/Stride-Labs/ibc-rate-limiting/ratelimit"
8
9
ratelimitkeeper "github.com/Stride-Labs/ibc-rate-limiting/ratelimit/keeper"
@@ -80,6 +81,11 @@ import (
80
81
"github.com/cosmos/cosmos-sdk/x/upgrade"
81
82
upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper"
82
83
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
84
+
85
+ wasmapp "github.com/CosmWasm/wasmd/app"
86
+ "github.com/CosmWasm/wasmd/x/wasm"
87
+ wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
88
+ wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
83
89
)
84
90
85
91
type AppKeepers struct {
@@ -100,6 +106,7 @@ type AppKeepers struct {
100
106
CrisisKeeper * crisiskeeper.Keeper
101
107
UpgradeKeeper * upgradekeeper.Keeper
102
108
ParamsKeeper paramskeeper.Keeper
109
+ WasmKeeper wasmkeeper.Keeper
103
110
// IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly
104
111
IBCKeeper * ibckeeper.Keeper
105
112
ICAHostKeeper icahostkeeper.Keeper
@@ -131,6 +138,7 @@ type AppKeepers struct {
131
138
ScopedICAHostKeeper capabilitykeeper.ScopedKeeper
132
139
ScopedICAControllerKeeper capabilitykeeper.ScopedKeeper
133
140
ScopedICSproviderkeeper capabilitykeeper.ScopedKeeper
141
+ scopedWasmKeeper capabilitykeeper.ScopedKeeper
134
142
}
135
143
136
144
func NewAppKeeper (
@@ -145,6 +153,7 @@ func NewAppKeeper(
145
153
invCheckPeriod uint ,
146
154
logger log.Logger ,
147
155
appOpts servertypes.AppOptions ,
156
+ wasmOpts []wasmkeeper.Option ,
148
157
) AppKeepers {
149
158
appKeepers := AppKeepers {}
150
159
@@ -189,6 +198,7 @@ func NewAppKeeper(
189
198
appKeepers .ScopedICAControllerKeeper = appKeepers .CapabilityKeeper .ScopeToModule (icacontrollertypes .SubModuleName )
190
199
appKeepers .ScopedTransferKeeper = appKeepers .CapabilityKeeper .ScopeToModule (ibctransfertypes .ModuleName )
191
200
appKeepers .ScopedICSproviderkeeper = appKeepers .CapabilityKeeper .ScopeToModule (providertypes .ModuleName )
201
+ appKeepers .scopedWasmKeeper = appKeepers .CapabilityKeeper .ScopeToModule (wasmtypes .ModuleName )
192
202
193
203
// Applications that wish to enforce statically created ScopedKeepers should call `Seal` after creating
194
204
// their scoped modules in `NewApp` with `ScopeToModule`
@@ -447,6 +457,31 @@ func NewAppKeeper(
447
457
// Must be called on PFMRouter AFTER TransferKeeper initialized
448
458
appKeepers .PFMRouterKeeper .SetTransferKeeper (appKeepers .TransferKeeper )
449
459
460
+ wasmConfig , err := wasm .ReadWasmConfig (appOpts )
461
+ if err != nil {
462
+ panic ("error while reading wasm config: " + err .Error ())
463
+ }
464
+
465
+ appKeepers .WasmKeeper = wasmkeeper .NewKeeper (
466
+ appCodec ,
467
+ appKeepers .keys [wasmtypes .StoreKey ],
468
+ appKeepers .AccountKeeper ,
469
+ appKeepers .BankKeeper ,
470
+ appKeepers .StakingKeeper ,
471
+ distrkeeper .NewQuerier (appKeepers .DistrKeeper ),
472
+ appKeepers .IBCKeeper .ChannelKeeper ,
473
+ appKeepers .IBCKeeper .ChannelKeeper ,
474
+ & appKeepers .IBCKeeper .PortKeeper ,
475
+ appKeepers .scopedWasmKeeper ,
476
+ appKeepers .TransferKeeper ,
477
+ bApp .MsgServiceRouter (),
478
+ bApp .GRPCQueryRouter (),
479
+ homePath ,
480
+ wasmConfig ,
481
+ strings .Join (wasmapp .AllCapabilities (), "," ),
482
+ authtypes .NewModuleAddress (govtypes .ModuleName ).String (),
483
+ )
484
+
450
485
// Middleware Stacks
451
486
appKeepers .ICAModule = ica .NewAppModule (& appKeepers .ICAControllerKeeper , & appKeepers .ICAHostKeeper )
452
487
appKeepers .TransferModule = transfer .NewAppModule (appKeepers .TransferKeeper )
@@ -484,12 +519,17 @@ func NewAppKeeper(
484
519
// Create Interchain Accounts Controller Stack
485
520
var icaControllerStack porttypes.IBCModule = icacontroller .NewIBCMiddleware (nil , appKeepers .ICAControllerKeeper )
486
521
522
+ var wasmStack porttypes.IBCModule
523
+ wasmStack = wasm .NewIBCHandler (appKeepers .WasmKeeper , appKeepers .IBCKeeper .ChannelKeeper , appKeepers .IBCFeeKeeper )
524
+ wasmStack = ibcfee .NewIBCMiddleware (wasmStack , appKeepers .IBCFeeKeeper )
525
+
487
526
// Create IBC Router & seal
488
527
ibcRouter := porttypes .NewRouter ().
489
528
AddRoute (icahosttypes .SubModuleName , icaHostStack ).
490
529
AddRoute (icacontrollertypes .SubModuleName , icaControllerStack ).
491
530
AddRoute (ibctransfertypes .ModuleName , transferStack ).
492
- AddRoute (providertypes .ModuleName , appKeepers .ProviderModule )
531
+ AddRoute (providertypes .ModuleName , appKeepers .ProviderModule ).
532
+ AddRoute (wasmtypes .ModuleName , wasmStack )
493
533
494
534
appKeepers .IBCKeeper .SetRouter (ibcRouter )
495
535
@@ -509,8 +549,7 @@ func (appKeepers *AppKeepers) GetSubspace(moduleName string) paramstypes.Subspac
509
549
func initParamsKeeper (appCodec codec.BinaryCodec , legacyAmino * codec.LegacyAmino , key , tkey storetypes.StoreKey ) paramskeeper.Keeper {
510
550
paramsKeeper := paramskeeper .NewKeeper (appCodec , legacyAmino , key , tkey )
511
551
512
- //nolint: staticcheck // SA1019: moduletypes.ParamKeyTable is deprecated
513
- paramsKeeper .Subspace (authtypes .ModuleName ).WithKeyTable (authtypes .ParamKeyTable ())
552
+ paramsKeeper .Subspace (authtypes .ModuleName ).WithKeyTable (authtypes .ParamKeyTable ()) //nolint: staticcheck // SA1019
514
553
paramsKeeper .Subspace (stakingtypes .ModuleName ).WithKeyTable (stakingtypes .ParamKeyTable ())
515
554
paramsKeeper .Subspace (banktypes .ModuleName ).WithKeyTable (banktypes .ParamKeyTable ()) //nolint: staticcheck // SA1019
516
555
paramsKeeper .Subspace (minttypes .ModuleName ).WithKeyTable (minttypes .ParamKeyTable ()) //nolint: staticcheck // SA1019
@@ -525,6 +564,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
525
564
paramsKeeper .Subspace (pfmroutertypes .ModuleName ).WithKeyTable (pfmroutertypes .ParamKeyTable ())
526
565
paramsKeeper .Subspace (ratelimittypes .ModuleName )
527
566
paramsKeeper .Subspace (providertypes .ModuleName )
567
+ paramsKeeper .Subspace (wasmtypes .ModuleName )
528
568
529
569
return paramsKeeper
530
570
}
0 commit comments