Create parseAndPopulateTxResponseUnsigned
This commit is contained in:
parent
580ce6bfaa
commit
84c9ac4406
@ -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> {
|
||||
|
||||
3
packages/bcp/types/cosmwasmconnection.d.ts
vendored
3
packages/bcp/types/cosmwasmconnection.d.ts
vendored
@ -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;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user