Adapt calls to queryContractSmart

This commit is contained in:
Simon Warta 2020-05-20 15:15:10 +02:00
parent 82b23c87b5
commit 36b8fe74af
2 changed files with 3 additions and 7 deletions

View File

@ -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<Amount> => {
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,

View File

@ -60,9 +60,8 @@ const connect = async (mnemonic: string, opts: Partial<Options>): Promise<{
};
// smartQuery assumes the content is proper JSON data and parses before returning it
const smartQuery = async (client: CosmWasmClient, addr: string, query: object): Promise<any> => {
const bin = await client.queryContractSmart(addr, query);
return JSON.parse(fromUtf8(bin));
async function smartQuery(client: CosmWasmClient, addr: string, query: object): Promise<any> {
return client.queryContractSmart(addr, query);
}
// loadOrCreateMnemonic will try to load a mnemonic from the file.