Adapt calls to queryContractSmart
This commit is contained in:
parent
82b23c87b5
commit
36b8fe74af
@ -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,
|
||||
|
||||
@ -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.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user