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

fix: wasm permission #703

Merged
merged 1 commit into from
Sep 26, 2023
Merged
Changes from all 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
27 changes: 18 additions & 9 deletions app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,11 @@ type AppKeepers struct {
TransferKeeper ibctransferkeeper.Keeper
WasmKeeper wasm.Keeper
// IBC hooks
IBCHooksKeeper ibchookskeeper.Keeper
IBCHooksKeeper ibchookskeeper.Keeper
Ics20WasmHooks ibchooks.WasmHooks
ContractKeeper *wasmkeeper.PermissionedKeeper
HooksTransferIBCModule ibchooks.IBCMiddleware
HooksICS4Wrapper ibchooks.ICS4Middleware

NftbackedloanKeeper nftbackedloankeeper.Keeper
NftfactoryKeeper nftfactorykeeper.Keeper
Expand Down Expand Up @@ -377,18 +381,14 @@ func NewAppKeeper(
appKeepers.IBCHooksKeeper = ibchookskeeper.NewKeeper(
appKeepers.keys[ibchookstypes.StoreKey],
)
ics20WasmHooks := ibchooks.NewWasmHooks(&appKeepers.IBCHooksKeeper, nil, accountAddressPrefix) // The contract keeper needs to be set later
hooksICS4Wrapper := ibchooks.NewICS4Middleware(
appKeepers.IBCKeeper.ChannelKeeper,
ics20WasmHooks,
)
appKeepers.Ics20WasmHooks = ibchooks.NewWasmHooks(&appKeepers.IBCHooksKeeper, nil, accountAddressPrefix) // The contract keeper needs to be set later

// Create Transfer Keepers
appKeepers.TransferKeeper = ibctransferkeeper.NewKeeper(
appCodec,
appKeepers.keys[ibctransfertypes.StoreKey],
appKeepers.GetSubspace(ibctransfertypes.ModuleName),
hooksICS4Wrapper,
appKeepers.HooksICS4Wrapper, // essentially still app.IBCKeeper.ChannelKeeper under the hood because no hook overrides
appKeepers.IBCKeeper.ChannelKeeper,
&appKeepers.IBCKeeper.PortKeeper,
appKeepers.AccountKeeper,
Expand Down Expand Up @@ -451,6 +451,17 @@ func NewAppKeeper(
wasmOpts...,
)

// Pass the contract keeper to all the structs (generally ICS4Wrappers for ibc middlewares) that need it
appKeepers.ContractKeeper = wasmkeeper.NewDefaultPermissionKeeper(appKeepers.WasmKeeper)
appKeepers.Ics20WasmHooks.ContractKeeper = &appKeepers.WasmKeeper
appKeepers.HooksICS4Wrapper = ibchooks.NewICS4Middleware(
appKeepers.IBCKeeper.ChannelKeeper,
appKeepers.Ics20WasmHooks,
)
// Hooks Middleware
transferIBCModule := transfer.NewIBCModule(appKeepers.TransferKeeper)
appKeepers.HooksTransferIBCModule = ibchooks.NewIBCMiddleware(&transferIBCModule, &appKeepers.HooksICS4Wrapper)

// Instantiate the builder keeper, store keys, and module manager
appKeepers.BuilderKeeper = builderkeeper.NewKeeper(
appCodec,
Expand Down Expand Up @@ -635,8 +646,6 @@ func NewAppKeeper(
transferStack = transfer.NewIBCModule(appKeepers.TransferKeeper)
transferStack = records.NewIBCModule(appKeepers.RecordsKeeper, transferStack)
transferStack = ibcfee.NewIBCMiddleware(transferStack, appKeepers.IBCFeeKeeper)
// Hooks Middleware
transferStack = ibchooks.NewIBCMiddleware(transferStack, &hooksICS4Wrapper)

// RecvPacket, message that originates from core IBC and goes down to app, the flow is:
// channel.RecvPacket -> fee.OnRecvPacket -> icaHost.OnRecvPacket
Expand Down