mirror of
https://github.com/cosmos/cosmjs.git
synced 2025-03-11 14:09:15 +00:00
stargate: Return gas used
This commit is contained in:
parent
b25171cfef
commit
a98c310e83
@ -332,7 +332,8 @@ describe("StargateClient", () => {
|
||||
const txResult = await client.broadcastTx(txRawBytes);
|
||||
assertIsBroadcastTxSuccess(txResult);
|
||||
|
||||
const { rawLog, transactionHash } = txResult;
|
||||
const { gasUsed, rawLog, transactionHash } = txResult;
|
||||
expect(gasUsed).toBeGreaterThan(0);
|
||||
expect(rawLog).toMatch(/{"key":"amount","value":"1234567ucosm"}/);
|
||||
expect(transactionHash).toMatch(/^[0-9A-F]{64}$/);
|
||||
|
||||
|
@ -1,11 +1,7 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
import { toHex } from "@cosmjs/encoding";
|
||||
import { Uint53 } from "@cosmjs/math";
|
||||
import {
|
||||
BroadcastTxSyncResponse,
|
||||
Tendermint34Client,
|
||||
toRfc3339WithNanoseconds,
|
||||
} from "@cosmjs/tendermint-rpc";
|
||||
import { Tendermint34Client, toRfc3339WithNanoseconds } from "@cosmjs/tendermint-rpc";
|
||||
import { sleep } from "@cosmjs/utils";
|
||||
|
||||
import { Account, accountFromAny } from "./accounts";
|
||||
@ -63,6 +59,8 @@ export interface IndexedTx {
|
||||
readonly code: number;
|
||||
readonly rawLog: string;
|
||||
readonly tx: Uint8Array;
|
||||
readonly gasUsed: number;
|
||||
readonly gasWanted: number;
|
||||
}
|
||||
|
||||
export interface SequenceResponse {
|
||||
@ -83,6 +81,8 @@ export interface BroadcastTxSuccess {
|
||||
readonly transactionHash: string;
|
||||
readonly rawLog?: string;
|
||||
readonly data?: readonly MsgData[];
|
||||
readonly gasUsed: number;
|
||||
readonly gasWanted: number;
|
||||
}
|
||||
|
||||
export type BroadcastTxResponse = BroadcastTxSuccess | BroadcastTxFailure;
|
||||
@ -303,6 +303,8 @@ export class StargateClient {
|
||||
height: result.height,
|
||||
rawLog: result.rawLog,
|
||||
transactionHash: txId,
|
||||
gasUsed: result.gasUsed,
|
||||
gasWanted: result.gasWanted,
|
||||
}
|
||||
: pollForTx(txId);
|
||||
};
|
||||
@ -310,7 +312,7 @@ export class StargateClient {
|
||||
return new Promise((resolve, reject) =>
|
||||
this.forceGetTmClient()
|
||||
.broadcastTxSync({ tx })
|
||||
.then(({ hash }: BroadcastTxSyncResponse) => pollForTx(toHex(hash).toUpperCase()))
|
||||
.then(({ hash }) => pollForTx(toHex(hash).toUpperCase()))
|
||||
.then(resolve, reject)
|
||||
.finally(() => clearTimeout(txPollTimeout)),
|
||||
);
|
||||
@ -325,6 +327,8 @@ export class StargateClient {
|
||||
code: tx.result.code,
|
||||
rawLog: tx.result.log || "",
|
||||
tx: tx.tx,
|
||||
gasUsed: tx.result.gasUsed,
|
||||
gasWanted: tx.result.gasWanted,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user