From 36b8fe74af5d4114c9c40502635fc295051a78bb Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Wed, 20 May 2020 15:15:10 +0200 Subject: [PATCH] Adapt calls to queryContractSmart --- packages/bcp/src/cosmwasmconnection.ts | 5 +---- packages/cli/examples/helpers.ts | 5 ++--- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/packages/bcp/src/cosmwasmconnection.ts b/packages/bcp/src/cosmwasmconnection.ts index a6bce215..f458413c 100644 --- a/packages/bcp/src/cosmwasmconnection.ts +++ b/packages/bcp/src/cosmwasmconnection.ts @@ -43,8 +43,6 @@ import { decodeAmount, decodePubkey, parseTxsResponseSigned, parseTxsResponseUns import { buildSignedTx } from "./encode"; import { accountToNonce, BankToken, Erc20Token } from "./types"; -const { fromAscii } = Encoding; - // poll every 0.5 seconds (block time 1s) const defaultPollInterval = 500; @@ -170,8 +168,7 @@ export class CosmWasmConnection implements BlockchainConnection { this.erc20Tokens.map( async (erc20): Promise => { const queryMsg = { balance: { address: address } }; - const smart = await this.cosmWasmClient.queryContractSmart(erc20.contractAddress, queryMsg); - const response = JSON.parse(fromAscii(smart)); + const response = await this.cosmWasmClient.queryContractSmart(erc20.contractAddress, queryMsg); const normalizedBalance = new BN(response.balance).toString(); return { fractionalDigits: erc20.fractionalDigits, diff --git a/packages/cli/examples/helpers.ts b/packages/cli/examples/helpers.ts index deb27c58..8b15fde4 100644 --- a/packages/cli/examples/helpers.ts +++ b/packages/cli/examples/helpers.ts @@ -60,9 +60,8 @@ const connect = async (mnemonic: string, opts: Partial): Promise<{ }; // smartQuery assumes the content is proper JSON data and parses before returning it -const smartQuery = async (client: CosmWasmClient, addr: string, query: object): Promise => { - const bin = await client.queryContractSmart(addr, query); - return JSON.parse(fromUtf8(bin)); +async function smartQuery(client: CosmWasmClient, addr: string, query: object): Promise { + return client.queryContractSmart(addr, query); } // loadOrCreateMnemonic will try to load a mnemonic from the file.