Create parseAndPopulateTxResponseUnsigned

This commit is contained in:
Simon Warta 2020-02-12 14:58:56 +01:00
parent 580ce6bfaa
commit 84c9ac4406
2 changed files with 13 additions and 5 deletions

View File

@ -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<UnsignedTransaction> | FailedTransaction {
return parseTxsResponseUnsigned(chainId, parseInt(response.height, 10), response, this.bankTokens);
}
private async parseAndPopulateTxResponseSigned(
response: TxsResponse,
chainId: ChainId,
): Promise<ConfirmedAndSignedTransaction<UnsignedTransaction> | FailedTransaction> {

View File

@ -85,5 +85,6 @@ export declare class CosmWasmConnection implements BlockchainConnection {
liveTx(_query: TransactionQuery): Stream<ConfirmedTransaction<UnsignedTransaction> | FailedTransaction>;
getFeeQuote(tx: UnsignedTransaction): Promise<Fee>;
withDefaultFee<T extends UnsignedTransaction>(tx: T): Promise<T>;
private parseAndPopulateTxResponse;
private parseAndPopulateTxResponseUnsigned;
private parseAndPopulateTxResponseSigned;
}