From bf97dea09325bade8646ee8f08b21be2dbd5089c Mon Sep 17 00:00:00 2001 From: TAKASE Ryo Date: Mon, 26 Feb 2024 19:16:58 +0900 Subject: [PATCH] fix: disable custom querier (#118) * fix: disable custom querier * docs: add this PR to CHANGELOG --- CHANGELOG.md | 1 + x/wasm/keeper/query_plugins.go | 26 +------------------------- x/wasm/types/encoder.go | 22 ---------------------- 3 files changed, 2 insertions(+), 47 deletions(-) delete mode 100644 x/wasm/types/encoder.go diff --git a/CHANGELOG.md b/CHANGELOG.md index b7ffb0c1cd..f9123ab7c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ ### Bug Fixes ### Breaking Changes +* [\#118](https://github.com/Finschia/wasmd/pull/118) disable custom query * [\#117](https://github.com/Finschia/wasmd/pull/117) version-up depending wasmvm to v1.1.1-0.12.0 ### Build, CI diff --git a/x/wasm/keeper/query_plugins.go b/x/wasm/keeper/query_plugins.go index 2bb7f9282a..a30e1162b0 100644 --- a/x/wasm/keeper/query_plugins.go +++ b/x/wasm/keeper/query_plugins.go @@ -106,7 +106,7 @@ func DefaultQueryPlugins( ) QueryPlugins { return QueryPlugins{ Bank: BankQuerier(bank), - Custom: CustomQuerierImpl(queryRouter), + Custom: NoCustomQuerier, IBC: IBCQuerier(wasm, channelKeeper), Staking: StakingQuerier(staking, distKeeper), Stargate: RejectStargateQuerier(), @@ -209,30 +209,6 @@ func NoCustomQuerier(sdk.Context, json.RawMessage) ([]byte, error) { return nil, wasmvmtypes.UnsupportedRequest{Kind: "custom"} } -func CustomQuerierImpl(queryRouter GRPCQueryRouter) func(ctx sdk.Context, querierJson json.RawMessage) ([]byte, error) { - return func(ctx sdk.Context, querierJson json.RawMessage) ([]byte, error) { - var linkQueryWrapper types.LinkQueryWrapper - err := json.Unmarshal(querierJson, &linkQueryWrapper) - if err != nil { - return nil, err - } - route := queryRouter.Route(linkQueryWrapper.Path) - if route == nil { - return nil, wasmvmtypes.UnsupportedRequest{Kind: "Unknown encode module"} - } - req := abci.RequestQuery{ - Data: linkQueryWrapper.Data, - Path: linkQueryWrapper.Path, - } - res, err := route(ctx, req) - if err != nil { - return nil, err - } - - return res.Value, nil - } -} - func IBCQuerier(wasm contractMetaDataSource, channelKeeper types.ChannelKeeper) func(ctx sdk.Context, caller sdk.AccAddress, request *wasmvmtypes.IBCQuery) ([]byte, error) { return func(ctx sdk.Context, caller sdk.AccAddress, request *wasmvmtypes.IBCQuery) ([]byte, error) { if request.PortID != nil { diff --git a/x/wasm/types/encoder.go b/x/wasm/types/encoder.go deleted file mode 100644 index 209cc7c1dc..0000000000 --- a/x/wasm/types/encoder.go +++ /dev/null @@ -1,22 +0,0 @@ -package types - -import ( - "encoding/json" -) - -type EncodingModule string - -const ( - TokenM = EncodingModule("token") - CollectionM = EncodingModule("collection") -) - -type LinkMsgWrapper struct { - Module string `json:"module"` - MsgData json.RawMessage `json:"msg_data"` -} - -type LinkQueryWrapper struct { - Path string `json:"path"` - Data []byte `json:"data"` -}