From 84c9ac44065c26a614996b693569fd533993bf01 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Wed, 12 Feb 2020 14:58:56 +0100 Subject: [PATCH] Create parseAndPopulateTxResponseUnsigned --- packages/bcp/src/cosmwasmconnection.ts | 15 +++++++++++---- packages/bcp/types/cosmwasmconnection.d.ts | 3 ++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/packages/bcp/src/cosmwasmconnection.ts b/packages/bcp/src/cosmwasmconnection.ts index f1817fd5..7c7b6c98 100644 --- a/packages/bcp/src/cosmwasmconnection.ts +++ b/packages/bcp/src/cosmwasmconnection.ts @@ -38,7 +38,7 @@ import { Stream } from "xstream"; import { decodeCosmosPubkey, pubkeyToAddress } from "./address"; import { Caip5 } from "./caip5"; -import { decodeAmount, parseTxsResponseSigned } from "./decode"; +import { decodeAmount, parseTxsResponseSigned, parseTxsResponseUnsigned } from "./decode"; import { buildSignedTx } from "./encode"; import { accountToNonce, BankToken, Erc20Token } from "./types"; @@ -235,7 +235,7 @@ export class CosmWasmConnection implements BlockchainConnection { // tslint:disable-next-line: deprecation const response = await this.restClient.txsById(id); const chainId = this.chainId(); - return this.parseAndPopulateTxResponse(response, chainId); + return this.parseAndPopulateTxResponseSigned(response, chainId); } catch (error) { if (error.response.status === 404) { throw new Error("Transaction does not exist"); @@ -320,7 +320,7 @@ export class CosmWasmConnection implements BlockchainConnection { } const chainId = this.chainId(); - return Promise.all(txs.map(tx => this.parseAndPopulateTxResponse(tx, chainId))); + return txs.map(tx => this.parseAndPopulateTxResponseUnsigned(tx, chainId)); } public listenTx( @@ -357,7 +357,14 @@ export class CosmWasmConnection implements BlockchainConnection { }; } - private async parseAndPopulateTxResponse( + private parseAndPopulateTxResponseUnsigned( + response: TxsResponse, + chainId: ChainId, + ): ConfirmedTransaction | FailedTransaction { + return parseTxsResponseUnsigned(chainId, parseInt(response.height, 10), response, this.bankTokens); + } + + private async parseAndPopulateTxResponseSigned( response: TxsResponse, chainId: ChainId, ): Promise | FailedTransaction> { diff --git a/packages/bcp/types/cosmwasmconnection.d.ts b/packages/bcp/types/cosmwasmconnection.d.ts index e5afc441..7191fbab 100644 --- a/packages/bcp/types/cosmwasmconnection.d.ts +++ b/packages/bcp/types/cosmwasmconnection.d.ts @@ -85,5 +85,6 @@ export declare class CosmWasmConnection implements BlockchainConnection { liveTx(_query: TransactionQuery): Stream | FailedTransaction>; getFeeQuote(tx: UnsignedTransaction): Promise; withDefaultFee(tx: T): Promise; - private parseAndPopulateTxResponse; + private parseAndPopulateTxResponseUnsigned; + private parseAndPopulateTxResponseSigned; }