From c9ca6ca721672becb94e0e8c9f9ac351f2a1586f Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Thu, 15 Sep 2022 09:58:31 +0200 Subject: [PATCH] Accept non-ASCII inputs in query requests of queryContractSmart --- CHANGELOG.md | 3 +++ packages/cosmwasm-stargate/src/modules/wasm/queries.ts | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b2ce9142..8d5a94f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -57,12 +57,15 @@ and this project adheres to - @cosmjs/tendermint-rpc: Fix decoding events without attributes ([#1198]). - @cosmjs/amino, @cosmjs/proto-signing: Support amounts larger than the uint64 range in `parseCoins` ([#1268]). +- @cosmjs/cosmwasm-stargate: Accept non-ASCII inputs in query requests of + `{CosmWasmClient,WasmExtension}.queryContractSmart` ([#1269]). [#1170]: https://github.com/cosmos/cosmjs/issues/1170 [#1177]: https://github.com/cosmos/cosmjs/issues/1177 [#1188]: https://github.com/cosmos/cosmjs/pull/1188 [#1198]: https://github.com/cosmos/cosmjs/pull/1198 [#1268]: https://github.com/cosmos/cosmjs/issues/1268 +[#1269]: https://github.com/cosmos/cosmjs/issues/1269 ### Changed diff --git a/packages/cosmwasm-stargate/src/modules/wasm/queries.ts b/packages/cosmwasm-stargate/src/modules/wasm/queries.ts index 1f851f70..f9b5d20f 100644 --- a/packages/cosmwasm-stargate/src/modules/wasm/queries.ts +++ b/packages/cosmwasm-stargate/src/modules/wasm/queries.ts @@ -1,4 +1,4 @@ -import { fromUtf8, toAscii } from "@cosmjs/encoding"; +import { fromUtf8, toUtf8 } from "@cosmjs/encoding"; import { createPagination, createProtobufRpcClient, QueryClient } from "@cosmjs/stargate"; import { QueryAllContractStateResponse, @@ -117,7 +117,7 @@ export function setupWasmExtension(base: QueryClient): WasmExtension { }, queryContractSmart: async (address: string, query: Record) => { - const request = { address: address, queryData: toAscii(JSON.stringify(query)) }; + const request = { address: address, queryData: toUtf8(JSON.stringify(query)) }; const { data } = await queryService.SmartContractState(request); // By convention, smart queries must return a valid JSON document (see https://github.com/CosmWasm/cosmwasm/issues/144) let responseText: string;