Skip to content

Commit

Permalink
fix(wasm): add back stargate queries
Browse files Browse the repository at this point in the history
  • Loading branch information
k-yang committed Nov 1, 2023
1 parent b764895 commit 209874a
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
9 changes: 8 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ import (
"github.com/prometheus/client_golang/prometheus"
"github.com/rakyll/statik/fs"
"github.com/spf13/cast"

"github.com/NibiruChain/nibiru/wasmbinding"
)

const (
Expand Down Expand Up @@ -107,12 +109,17 @@ func init() {
}

// GetWasmOpts build wasm options
func GetWasmOpts(appOpts servertypes.AppOptions) []wasm.Option {
func GetWasmOpts(appOpts servertypes.AppOptions, nibiruApp NibiruApp) []wasm.Option {
var wasmOpts []wasm.Option
if cast.ToBool(appOpts.Get("telemetry.enabled")) {
wasmOpts = append(wasmOpts, wasmkeeper.WithVMCacheMetrics(prometheus.DefaultRegisterer))
}

wasmOpts = append(wasmOpts, wasmbinding.NibiruWasmOptions(
nibiruApp.GRPCQueryRouter(),
nibiruApp.AppCodec(),
nibiruApp.SudoKeeper,
)...)
// Add the bindings to the app's set of []wasm.Option.
return wasmOpts
}
Expand Down
2 changes: 1 addition & 1 deletion app/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ func (app *NibiruApp) InitKeepers(
wasmConfig,
supportedFeatures,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
GetWasmOpts(appOpts)...,
GetWasmOpts(appOpts, *app)...,
)

// DevGas uses WasmKeeper
Expand Down
28 changes: 28 additions & 0 deletions wasmbinding/wasm.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package wasmbinding

import (
"github.com/CosmWasm/wasmd/x/wasm"
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/codec"

"github.com/NibiruChain/nibiru/x/sudo/keeper"
)

// NibiruWasmOptions: Wasm Options are extension points to instantiate the Wasm
// keeper with non-default values
func NibiruWasmOptions(
grpcQueryRouter *baseapp.GRPCQueryRouter,
appCodec codec.Codec,
sudoKeeper keeper.Keeper,
) []wasm.Option {
wasmQueryOption := wasmkeeper.WithQueryPlugins(&wasmkeeper.QueryPlugins{
Stargate: wasmkeeper.AcceptListStargateQuerier(
WasmAcceptedStargateQueries(),
grpcQueryRouter,
appCodec,
),
})

return []wasm.Option{wasmQueryOption}
}

0 comments on commit 209874a

Please sign in to comment.