mirror of
https://github.com/cosmos/cosmjs.git
synced 2025-03-10 13:47:12 +00:00
Change gasWanted/gasUsed to bigint
This commit is contained in:
parent
9f33cd31de
commit
585338a3fa
@ -12,6 +12,8 @@ and this project adheres to
|
||||
changes all 64 bit int fields from type `long` to `bigint`. As part of the
|
||||
upgrade, the types do not require the `long` and `protobufjs` anymore.
|
||||
([#1484])
|
||||
- all: `gasWanted`/`gasUsed` fields were changed from type `number` to `bigint`
|
||||
to supported cases where users put very high gas values in there ([#1465]).
|
||||
- Drop support for Node.js 14 and add support for Node.js 20. ([#1421])
|
||||
- @cosmjs/tendermint-rpc: Remove `Adaptor` abstractions which are not needed
|
||||
anymore by haing a dedicated client for each backend.
|
||||
@ -34,6 +36,7 @@ and this project adheres to
|
||||
`.getCometClient`/`.forceGetCometClient`.
|
||||
|
||||
[#1421]: https://github.com/cosmos/cosmjs/issues/1421
|
||||
[#1465]: https://github.com/cosmos/cosmjs/issues/1465
|
||||
[#1484]: https://github.com/cosmos/cosmjs/pull/1484
|
||||
|
||||
### Deprecated
|
||||
|
@ -78,8 +78,8 @@ export interface UploadResult {
|
||||
/** Transaction hash (might be used as transaction ID). Guaranteed to be non-empty upper-case hex */
|
||||
readonly transactionHash: string;
|
||||
readonly events: readonly Event[];
|
||||
readonly gasWanted: number;
|
||||
readonly gasUsed: number;
|
||||
readonly gasWanted: bigint;
|
||||
readonly gasUsed: bigint;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -112,8 +112,8 @@ export interface InstantiateResult {
|
||||
/** Transaction hash (might be used as transaction ID). Guaranteed to be non-empty upper-case hex */
|
||||
readonly transactionHash: string;
|
||||
readonly events: readonly Event[];
|
||||
readonly gasWanted: number;
|
||||
readonly gasUsed: number;
|
||||
readonly gasWanted: bigint;
|
||||
readonly gasUsed: bigint;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -126,8 +126,8 @@ export interface ChangeAdminResult {
|
||||
/** Transaction hash (might be used as transaction ID). Guaranteed to be non-empty upper-case hex */
|
||||
readonly transactionHash: string;
|
||||
readonly events: readonly Event[];
|
||||
readonly gasWanted: number;
|
||||
readonly gasUsed: number;
|
||||
readonly gasWanted: bigint;
|
||||
readonly gasUsed: bigint;
|
||||
}
|
||||
|
||||
export interface MigrateResult {
|
||||
@ -137,8 +137,8 @@ export interface MigrateResult {
|
||||
/** Transaction hash (might be used as transaction ID). Guaranteed to be non-empty upper-case hex */
|
||||
readonly transactionHash: string;
|
||||
readonly events: readonly Event[];
|
||||
readonly gasWanted: number;
|
||||
readonly gasUsed: number;
|
||||
readonly gasWanted: bigint;
|
||||
readonly gasUsed: bigint;
|
||||
}
|
||||
|
||||
export interface ExecuteInstruction {
|
||||
@ -154,8 +154,8 @@ export interface ExecuteResult {
|
||||
/** Transaction hash (might be used as transaction ID). Guaranteed to be non-empty upper-case hex */
|
||||
readonly transactionHash: string;
|
||||
readonly events: readonly Event[];
|
||||
readonly gasWanted: number;
|
||||
readonly gasUsed: number;
|
||||
readonly gasWanted: bigint;
|
||||
readonly gasUsed: bigint;
|
||||
}
|
||||
|
||||
function createDeliverTxResponseErrorMessage(result: DeliverTxResponse): string {
|
||||
|
@ -366,9 +366,9 @@ describe("SigningStargateClient", () => {
|
||||
const result = await client.signAndBroadcast(faucet.address0, [msgAny], fee, memo);
|
||||
assertIsDeliverTxSuccess(result);
|
||||
expect(result.code).toEqual(0);
|
||||
expect(result.gasWanted).toEqual(222_000);
|
||||
expect(result.gasUsed).toBeLessThanOrEqual(222_000);
|
||||
expect(result.gasUsed).toBeGreaterThan(100_000);
|
||||
expect(result.gasWanted).toEqual(222_000n);
|
||||
expect(Number(result.gasUsed)).toBeLessThanOrEqual(222_000);
|
||||
expect(Number(result.gasUsed)).toBeGreaterThan(100_000);
|
||||
});
|
||||
|
||||
it("returns DeliverTxFailure on DeliverTx failure", async () => {
|
||||
@ -396,9 +396,9 @@ describe("SigningStargateClient", () => {
|
||||
const result = await client.signAndBroadcast(faucet.address0, [msgAny], fee);
|
||||
assertIsDeliverTxFailure(result);
|
||||
expect(result.code).toBeGreaterThan(0);
|
||||
expect(result.gasWanted).toEqual(99_000);
|
||||
expect(result.gasUsed).toBeLessThanOrEqual(99_000);
|
||||
expect(result.gasUsed).toBeGreaterThan(40_000);
|
||||
expect(result.gasWanted).toEqual(99_000n);
|
||||
expect(Number(result.gasUsed)).toBeLessThanOrEqual(99_000);
|
||||
expect(Number(result.gasUsed)).toBeGreaterThan(40_000);
|
||||
});
|
||||
|
||||
it("works with auto gas", async () => {
|
||||
|
@ -46,8 +46,8 @@ const resultFailure: DeliverTxResponse = {
|
||||
transactionHash: "FDC4FB701AABD465935F7D04AE490D1EF5F2BD4B227601C4E98B57EB077D9B7D",
|
||||
events: [],
|
||||
msgResponses: [],
|
||||
gasUsed: 54396,
|
||||
gasWanted: 200000,
|
||||
gasUsed: 54396n,
|
||||
gasWanted: 200000n,
|
||||
};
|
||||
const resultSuccess: DeliverTxResponse = {
|
||||
code: 0,
|
||||
@ -58,8 +58,8 @@ const resultSuccess: DeliverTxResponse = {
|
||||
transactionHash: "C0B416CA868C55C2B8C1BBB8F3CFA233854F13A5CB15D3E9599F50CAF7B3D161",
|
||||
events: [],
|
||||
msgResponses: [],
|
||||
gasUsed: 61556,
|
||||
gasWanted: 200000,
|
||||
gasUsed: 61556n,
|
||||
gasWanted: 200000n,
|
||||
};
|
||||
|
||||
describe("isDeliverTxFailure", () => {
|
||||
|
@ -91,8 +91,8 @@ export interface IndexedTx {
|
||||
* This field is an empty list for chains running Cosmos SDK < 0.46.
|
||||
*/
|
||||
readonly msgResponses: Array<{ readonly typeUrl: string; readonly value: Uint8Array }>;
|
||||
readonly gasUsed: number;
|
||||
readonly gasWanted: number;
|
||||
readonly gasUsed: bigint;
|
||||
readonly gasWanted: bigint;
|
||||
}
|
||||
|
||||
export interface SequenceResponse {
|
||||
@ -128,8 +128,8 @@ export interface DeliverTxResponse {
|
||||
* This field is an empty list for chains running Cosmos SDK < 0.46.
|
||||
*/
|
||||
readonly msgResponses: Array<{ readonly typeUrl: string; readonly value: Uint8Array }>;
|
||||
readonly gasUsed: number;
|
||||
readonly gasWanted: number;
|
||||
readonly gasUsed: bigint;
|
||||
readonly gasWanted: bigint;
|
||||
}
|
||||
|
||||
export function isDeliverTxFailure(result: DeliverTxResponse): boolean {
|
||||
|
@ -159,8 +159,8 @@ function decodeTxData(data: RpcTxData): responses.TxData {
|
||||
log: data.log,
|
||||
data: may(fromBase64, data.data),
|
||||
events: data.events ? decodeEvents(data.events) : [],
|
||||
gasWanted: apiToSmallInt(data.gas_wanted ?? "0"),
|
||||
gasUsed: apiToSmallInt(data.gas_used ?? "0"),
|
||||
gasWanted: apiToBigInt(data.gas_wanted ?? "0"),
|
||||
gasUsed: apiToBigInt(data.gas_used ?? "0"),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -203,8 +203,8 @@ export interface TxData {
|
||||
readonly log?: string;
|
||||
readonly data?: Uint8Array;
|
||||
readonly events: readonly Event[];
|
||||
readonly gasWanted: number;
|
||||
readonly gasUsed: number;
|
||||
readonly gasWanted: bigint;
|
||||
readonly gasUsed: bigint;
|
||||
}
|
||||
|
||||
export interface TxProof {
|
||||
|
@ -158,8 +158,8 @@ function decodeTxData(data: RpcTxData): responses.TxData {
|
||||
log: data.log,
|
||||
data: may(fromBase64, data.data),
|
||||
events: data.events ? decodeEvents(data.events) : [],
|
||||
gasWanted: apiToSmallInt(data.gas_wanted ?? "0"),
|
||||
gasUsed: apiToSmallInt(data.gas_used ?? "0"),
|
||||
gasWanted: apiToBigInt(data.gas_wanted ?? "0"),
|
||||
gasUsed: apiToBigInt(data.gas_used ?? "0"),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -196,8 +196,8 @@ export interface TxData {
|
||||
readonly log?: string;
|
||||
readonly data?: Uint8Array;
|
||||
readonly events: readonly Event[];
|
||||
readonly gasWanted: number;
|
||||
readonly gasUsed: number;
|
||||
readonly gasWanted: bigint;
|
||||
readonly gasUsed: bigint;
|
||||
}
|
||||
|
||||
export interface TxProof {
|
||||
|
@ -159,8 +159,8 @@ function decodeTxData(data: RpcTxData): responses.TxData {
|
||||
log: data.log,
|
||||
data: may(fromBase64, data.data),
|
||||
events: data.events ? decodeEvents(data.events) : [],
|
||||
gasWanted: apiToSmallInt(data.gas_wanted ?? "0"),
|
||||
gasUsed: apiToSmallInt(data.gas_used ?? "0"),
|
||||
gasWanted: apiToBigInt(data.gas_wanted ?? "0"),
|
||||
gasUsed: apiToBigInt(data.gas_used ?? "0"),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -201,8 +201,8 @@ export interface TxData {
|
||||
readonly log?: string;
|
||||
readonly data?: Uint8Array;
|
||||
readonly events: readonly Event[];
|
||||
readonly gasWanted: number;
|
||||
readonly gasUsed: number;
|
||||
readonly gasWanted: bigint;
|
||||
readonly gasUsed: bigint;
|
||||
}
|
||||
|
||||
export interface TxProof {
|
||||
|
Loading…
x
Reference in New Issue
Block a user