From cd473c9a7e4a8ebbeeff57ae2e6aa66e137cfc2c Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Tue, 7 Jan 2025 13:44:06 +0000 Subject: [PATCH 01/11] chore: update chagneset --- .changeset/short-bears-fry.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/short-bears-fry.md diff --git a/.changeset/short-bears-fry.md b/.changeset/short-bears-fry.md new file mode 100644 index 00000000000..7174265288b --- /dev/null +++ b/.changeset/short-bears-fry.md @@ -0,0 +1,5 @@ +--- +"@fuel-ts/account": patch +--- + +feat: remove redundant gas price call for tx summary From 87fbb2f294a33d8637694711f40e081adc2d9c35 Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Tue, 7 Jan 2025 13:44:23 +0000 Subject: [PATCH 02/11] feat: remove redundant gas price call for tx summary --- .../transaction-response.ts | 8 ++- .../assemble-transaction-summary.test.ts | 9 ++-- .../assemble-transaction-summary.ts | 43 ++++++++++------ .../calculate-tx-fee-for-summary.ts | 10 ---- .../get-transaction-summary.ts | 7 ++- .../src/transaction-response.test.ts | 50 +++++++++++++++++++ 6 files changed, 95 insertions(+), 32 deletions(-) diff --git a/packages/account/src/providers/transaction-response/transaction-response.ts b/packages/account/src/providers/transaction-response/transaction-response.ts index 1b02a5cec38..e017f6f8b47 100644 --- a/packages/account/src/providers/transaction-response/transaction-response.ts +++ b/packages/account/src/providers/transaction-response/transaction-response.ts @@ -36,6 +36,7 @@ import type Provider from '../provider'; import type { JsonAbisFromAllCalls, TransactionRequest } from '../transaction-request'; import { assembleTransactionSummary } from '../transaction-summary/assemble-transaction-summary'; import { processGqlReceipt } from '../transaction-summary/receipt'; +import { processGraphqlStatus } from '../transaction-summary/status'; import type { TransactionSummary, GqlTransaction, AbiMap } from '../transaction-summary/types'; import { extractTxError } from '../utils'; @@ -299,7 +300,11 @@ export class TransactionResponse { const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = await this.provider.getGasConfig(); - const gasPrice = await this.provider.getLatestGasPrice(); + + // If we have the total fee, we do not need to refetch the gas price + const { totalFee } = processGraphqlStatus(this.status ?? this.gqlTransaction?.status); + const gasPrice = totalFee ? bn(0) : await this.provider.getLatestGasPrice(); + const maxInputs = (await this.provider.getChain()).consensusParameters.txParameters.maxInputs; const baseAssetId = await this.provider.getBaseAssetId(); @@ -317,6 +322,7 @@ export class TransactionResponse { maxGasPerTx, gasPrice, baseAssetId, + totalFee, }); return transactionSummary; diff --git a/packages/account/src/providers/transaction-summary/assemble-transaction-summary.test.ts b/packages/account/src/providers/transaction-summary/assemble-transaction-summary.test.ts index ede6df68606..d4ebb2f27a4 100644 --- a/packages/account/src/providers/transaction-summary/assemble-transaction-summary.test.ts +++ b/packages/account/src/providers/transaction-summary/assemble-transaction-summary.test.ts @@ -56,7 +56,8 @@ describe('TransactionSummary', () => { const runTest = ( status: GraphqlTransactionStatus, expected: Record, - baseAssetId: string + baseAssetId: string, + calculateTransactionFeeCalls = 1 ) => { const { calculateTransactionFee } = mockCalculateTransactionFee(); @@ -77,7 +78,7 @@ describe('TransactionSummary', () => { }); expect(transactionSummary).toMatchObject(expected); - expect(calculateTransactionFee).toHaveBeenCalledTimes(1); + expect(calculateTransactionFee).toHaveBeenCalledTimes(calculateTransactionFeeCalls); }; it('should assemble transaction summary just fine (SUCCESS)', async () => { @@ -104,7 +105,7 @@ describe('TransactionSummary', () => { type: expect.any(String), }; - runTest(MOCK_SUCCESS_STATUS, expected, await provider.getBaseAssetId()); + runTest(MOCK_SUCCESS_STATUS, expected, await provider.getBaseAssetId(), 0); }); it('should assemble transaction summary just fine (FAILURE)', async () => { @@ -131,7 +132,7 @@ describe('TransactionSummary', () => { type: expect.any(String), }; - runTest(MOCK_FAILURE_STATUS, expected, await provider.getBaseAssetId()); + runTest(MOCK_FAILURE_STATUS, expected, await provider.getBaseAssetId(), 0); }); it('should assemble transaction summary just fine (SUBMITTED)', async () => { diff --git a/packages/account/src/providers/transaction-summary/assemble-transaction-summary.ts b/packages/account/src/providers/transaction-summary/assemble-transaction-summary.ts index a4c34921117..f3fdb2f4075 100644 --- a/packages/account/src/providers/transaction-summary/assemble-transaction-summary.ts +++ b/packages/account/src/providers/transaction-summary/assemble-transaction-summary.ts @@ -35,6 +35,7 @@ export interface AssembleTransactionSummaryParams { maxGasPerTx: BN; gasPrice: BN; baseAssetId: string; + totalFee?: BN; } /** @hidden */ @@ -55,6 +56,7 @@ export function assembleTransactionSummary( maxGasPerTx, gasPrice, baseAssetId, + totalFee, } = params; const gasUsed = getGasUsedFromReceipts(receipts); @@ -76,23 +78,32 @@ export function assembleTransactionSummary( const tip = bn(transaction.policies?.find((policy) => policy.type === PolicyType.Tip)?.data); - const { isStatusFailure, isStatusPending, isStatusSuccess, blockId, status, time, totalFee } = - processGraphqlStatus(gqlTransactionStatus); - - const fee = calculateTXFeeForSummary({ - totalFee, - gasPrice, - rawPayload, - tip, - consensusParameters: { - gasCosts, - maxGasPerTx, - feeParams: { - gasPerByte, - gasPriceFactor, + const { + isStatusFailure, + isStatusPending, + isStatusSuccess, + blockId, + status, + time, + totalFee: totalFeeFromStatus, + } = processGraphqlStatus(gqlTransactionStatus); + + const fee = + totalFee ?? + totalFeeFromStatus ?? + calculateTXFeeForSummary({ + gasPrice, + rawPayload, + tip, + consensusParameters: { + gasCosts, + maxGasPerTx, + feeParams: { + gasPerByte, + gasPriceFactor, + }, }, - }, - }); + }); const mintedAssets = extractMintedAssetsFromReceipts(receipts); const burnedAssets = extractBurnedAssetsFromReceipts(receipts); diff --git a/packages/account/src/providers/transaction-summary/calculate-tx-fee-for-summary.ts b/packages/account/src/providers/transaction-summary/calculate-tx-fee-for-summary.ts index 8a8c6bb5cfe..1ec23f7b749 100644 --- a/packages/account/src/providers/transaction-summary/calculate-tx-fee-for-summary.ts +++ b/packages/account/src/providers/transaction-summary/calculate-tx-fee-for-summary.ts @@ -25,7 +25,6 @@ export type CalculateTXFeeForSummaryParams = { gasPrice: BN; rawPayload: string; tip: BN; - totalFee?: BN; consensusParameters: Pick & { feeParams: FeeParams; maxGasPerTx: BN; @@ -37,18 +36,9 @@ export const calculateTXFeeForSummary = (params: CalculateTXFeeForSummaryParams) gasPrice, rawPayload, tip, - totalFee, consensusParameters: { gasCosts, feeParams, maxGasPerTx }, } = params; - /** - * If totalFee is provided it means that the TX was already processed and we could extract the fee - * from its status - */ - if (totalFee) { - return totalFee; - } - const gasPerByte = bn(feeParams.gasPerByte); const gasPriceFactor = bn(feeParams.gasPriceFactor); diff --git a/packages/account/src/providers/transaction-summary/get-transaction-summary.ts b/packages/account/src/providers/transaction-summary/get-transaction-summary.ts index 7c8fa136757..7693e9d3031 100644 --- a/packages/account/src/providers/transaction-summary/get-transaction-summary.ts +++ b/packages/account/src/providers/transaction-summary/get-transaction-summary.ts @@ -3,6 +3,7 @@ import { bn } from '@fuel-ts/math'; import { TransactionCoder } from '@fuel-ts/transactions'; import { arrayify } from '@fuel-ts/utils'; +import { processGraphqlStatus } from '../..'; import type { GqlGetTransactionsByOwnerQueryVariables, GqlReceiptFragment, @@ -61,7 +62,10 @@ export async function getTransactionSummary( }, } = await provider.getChain(); - const gasPrice = await provider.getLatestGasPrice(); + // If we have the total fee, we do not need to refetch the gas price + const { totalFee } = processGraphqlStatus(gqlTransaction.status); + const gasPrice = totalFee ? bn(0) : await provider.getLatestGasPrice(); + const baseAssetId = await provider.getBaseAssetId(); const transactionInfo = assembleTransactionSummary({ @@ -78,6 +82,7 @@ export async function getTransactionSummary( maxGasPerTx, gasPrice, baseAssetId, + totalFee, }); return { diff --git a/packages/fuel-gauge/src/transaction-response.test.ts b/packages/fuel-gauge/src/transaction-response.test.ts index 4ca32f8c800..fc75155bd16 100644 --- a/packages/fuel-gauge/src/transaction-response.test.ts +++ b/packages/fuel-gauge/src/transaction-response.test.ts @@ -306,4 +306,54 @@ describe('TransactionResponse', () => { ); } ); + + it('builds response and awaits result [uses fee from status]', async () => { + using launched = await launchTestNode(); + + const { + provider, + wallets: [genesisWallet], + } = launched; + + const getLatestGasPriceSpy = vi.spyOn(provider, 'getLatestGasPrice'); + + const request = new ScriptTransactionRequest(); + request.addCoinOutput(Wallet.generate(), 100, await provider.getBaseAssetId()); + await request.autoCost(genesisWallet); + + const tx = await genesisWallet.sendTransaction(request); + const result = await tx.waitForResult(); + + // fee is used from the success status, latest gas price not needed + expect(getLatestGasPriceSpy).toHaveBeenCalledTimes(0); + expect(result.fee.toNumber()).toBeGreaterThan(0); + expect(result.id).toBe(tx.id); + }); + + it('builds response and assembles result [fetches gas price then uses fee]', async () => { + using launched = await launchTestNode(); + + const { + provider, + wallets: [genesisWallet], + } = launched; + + const getLatestGasPriceSpy = vi.spyOn(provider, 'getLatestGasPrice'); + + const request = new ScriptTransactionRequest(); + request.addCoinOutput(Wallet.generate(), 100, await provider.getBaseAssetId()); + await request.autoCost(genesisWallet); + + const tx = await genesisWallet.sendTransaction(request); + const result = await tx.assembleResult(); + + // tx has not settled so response will fetch the gas price + expect(getLatestGasPriceSpy).toHaveBeenCalledTimes(1); + expect(result.id).toBe(tx.id); + + const finalisedResult = await tx.waitForResult(); + expect(finalisedResult.fee.toNumber()).toBeGreaterThan(0); + expect(getLatestGasPriceSpy).toHaveBeenCalledTimes(1); + expect(finalisedResult.id).toBe(tx.id); + }); }); From ad9922ecea8311c3ffd028d2b7c8d85ba28f4fa8 Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Tue, 7 Jan 2025 16:44:15 +0000 Subject: [PATCH 03/11] chore: fix cyclic dep and status tests --- .../transaction-response.ts | 4 ++-- .../get-transaction-summary.ts | 5 ++--- .../transaction-summary/status.test.ts | 19 ++++++++++++++++++- .../providers/transaction-summary/status.ts | 14 ++++++++++++-- 4 files changed, 34 insertions(+), 8 deletions(-) diff --git a/packages/account/src/providers/transaction-response/transaction-response.ts b/packages/account/src/providers/transaction-response/transaction-response.ts index e017f6f8b47..a900f267d0d 100644 --- a/packages/account/src/providers/transaction-response/transaction-response.ts +++ b/packages/account/src/providers/transaction-response/transaction-response.ts @@ -36,7 +36,7 @@ import type Provider from '../provider'; import type { JsonAbisFromAllCalls, TransactionRequest } from '../transaction-request'; import { assembleTransactionSummary } from '../transaction-summary/assemble-transaction-summary'; import { processGqlReceipt } from '../transaction-summary/receipt'; -import { processGraphqlStatus } from '../transaction-summary/status'; +import { getTotalFeeFromStatus } from '../transaction-summary/status'; import type { TransactionSummary, GqlTransaction, AbiMap } from '../transaction-summary/types'; import { extractTxError } from '../utils'; @@ -302,7 +302,7 @@ export class TransactionResponse { await this.provider.getGasConfig(); // If we have the total fee, we do not need to refetch the gas price - const { totalFee } = processGraphqlStatus(this.status ?? this.gqlTransaction?.status); + const totalFee = getTotalFeeFromStatus(this.status ?? this.gqlTransaction?.status); const gasPrice = totalFee ? bn(0) : await this.provider.getLatestGasPrice(); const maxInputs = (await this.provider.getChain()).consensusParameters.txParameters.maxInputs; diff --git a/packages/account/src/providers/transaction-summary/get-transaction-summary.ts b/packages/account/src/providers/transaction-summary/get-transaction-summary.ts index 7693e9d3031..102f9d65ee9 100644 --- a/packages/account/src/providers/transaction-summary/get-transaction-summary.ts +++ b/packages/account/src/providers/transaction-summary/get-transaction-summary.ts @@ -3,7 +3,6 @@ import { bn } from '@fuel-ts/math'; import { TransactionCoder } from '@fuel-ts/transactions'; import { arrayify } from '@fuel-ts/utils'; -import { processGraphqlStatus } from '../..'; import type { GqlGetTransactionsByOwnerQueryVariables, GqlReceiptFragment, @@ -16,8 +15,8 @@ import { validatePaginationArgs } from '../utils/validate-pagination-args'; import { assembleTransactionSummary } from './assemble-transaction-summary'; import { processGqlReceipt } from './receipt'; +import { getTotalFeeFromStatus } from './status'; import type { AbiMap, TransactionSummary } from './types'; - /** @hidden */ export interface GetTransactionSummaryParams { id: string; @@ -63,7 +62,7 @@ export async function getTransactionSummary( } = await provider.getChain(); // If we have the total fee, we do not need to refetch the gas price - const { totalFee } = processGraphqlStatus(gqlTransaction.status); + const totalFee = getTotalFeeFromStatus(gqlTransaction.status); const gasPrice = totalFee ? bn(0) : await provider.getLatestGasPrice(); const baseAssetId = await provider.getBaseAssetId(); diff --git a/packages/account/src/providers/transaction-summary/status.test.ts b/packages/account/src/providers/transaction-summary/status.test.ts index 100f73ae199..95c3687039d 100644 --- a/packages/account/src/providers/transaction-summary/status.test.ts +++ b/packages/account/src/providers/transaction-summary/status.test.ts @@ -1,3 +1,5 @@ +import { bn } from '@fuel-ts/math'; + import { MOCK_FAILURE_STATUS, MOCK_SQUEEZEDOUT_STATUS, @@ -5,7 +7,7 @@ import { MOCK_SUCCESS_STATUS, } from '../../../test/fixtures/transaction-summary'; -import { getTransactionStatusName, processGraphqlStatus } from './status'; +import { getTotalFeeFromStatus, getTransactionStatusName, processGraphqlStatus } from './status'; import type { GqlTransactionStatusesNames, GraphqlTransactionStatus } from './types'; import { TransactionStatus } from './types'; @@ -46,6 +48,8 @@ describe('status', () => { blockIdType: 'string', status: TransactionStatus.success, timeType: 'string', + totalFee: bn(1000), + totalGas: bn(1000), }, }, { @@ -58,6 +62,8 @@ describe('status', () => { blockIdType: 'string', status: TransactionStatus.failure, timeType: 'string', + totalFee: bn(1000), + totalGas: bn(1000), }, }, { @@ -95,6 +101,8 @@ describe('status', () => { blockId, status: resultStatus, time, + totalFee, + totalGas, } = processGraphqlStatus(status); expect(isStatusFailure).toBe(expected.isStatusFailure); @@ -103,6 +111,15 @@ describe('status', () => { expect(typeof blockId).toBe(expected.blockIdType); expect(resultStatus).toBe(expected.status); expect(typeof time).toBe(expected.timeType); + expect(totalFee).toStrictEqual(expected.totalFee); + expect(totalGas).toStrictEqual(expected.totalGas); + }); + }); + + statuses.forEach(({ name, status, expected }) => { + it(`should ensure getTotalFeeFromStatus works fine for ${name}`, () => { + const totalFee = getTotalFeeFromStatus(status); + expect(totalFee).toStrictEqual(expected.totalFee); }); }); }); diff --git a/packages/account/src/providers/transaction-summary/status.ts b/packages/account/src/providers/transaction-summary/status.ts index d919c6efb50..4d9d5831e28 100644 --- a/packages/account/src/providers/transaction-summary/status.ts +++ b/packages/account/src/providers/transaction-summary/status.ts @@ -1,6 +1,8 @@ import { ErrorCode, FuelError } from '@fuel-ts/errors'; -import { bn, type BN } from '@fuel-ts/math'; +import type { BN } from '@fuel-ts/math'; +import { bn } from '@fuel-ts/math'; +import { TransactionStatus } from './types'; import type { BlockId, GqlTransactionStatusesNames, @@ -8,7 +10,6 @@ import type { Time, TransactionSummary, } from './types'; -import { TransactionStatus } from './types'; /** @hidden */ export const getTransactionStatusName = (gqlStatus: GqlTransactionStatusesNames) => { @@ -87,3 +88,12 @@ export const processGraphqlStatus = (gqlTransactionStatus?: GraphqlTransactionSt return processedGraphqlStatus; }; + +/** + * Returns the total fee from the transaction status. + * + * @param status - The transaction status. + * @returns The total fee from the transaction status or undefined. + */ +export const getTotalFeeFromStatus = (status?: GraphqlTransactionStatus): BN | undefined => + status && 'totalFee' in status ? bn(status.totalFee) : undefined; From d44e4b94d397d1ba82f30a05421fb8be96428b2f Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Tue, 7 Jan 2025 16:48:03 +0000 Subject: [PATCH 04/11] chore: is breaking --- .changeset/short-bears-fry.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/short-bears-fry.md b/.changeset/short-bears-fry.md index 7174265288b..2aed2752cdf 100644 --- a/.changeset/short-bears-fry.md +++ b/.changeset/short-bears-fry.md @@ -2,4 +2,4 @@ "@fuel-ts/account": patch --- -feat: remove redundant gas price call for tx summary +feat!: remove redundant gas price call for tx summary From 60306cce4b5f21ee3bf435e7c39a2124a5757f04 Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Tue, 7 Jan 2025 17:02:42 +0000 Subject: [PATCH 05/11] chore: breaking changeset --- .changeset/short-bears-fry.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/short-bears-fry.md b/.changeset/short-bears-fry.md index 2aed2752cdf..5e6ea8d7f51 100644 --- a/.changeset/short-bears-fry.md +++ b/.changeset/short-bears-fry.md @@ -1,5 +1,5 @@ --- -"@fuel-ts/account": patch +"@fuel-ts/account": minor --- feat!: remove redundant gas price call for tx summary From 36c61909dc4fd9c5b880f61d35c1fdf9b7e1bf55 Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Tue, 7 Jan 2025 17:32:12 +0000 Subject: [PATCH 06/11] feat: pass down totalFee --- .../src/providers/transaction-response/transaction-response.ts | 2 +- .../providers/transaction-summary/get-transaction-summary.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/account/src/providers/transaction-response/transaction-response.ts b/packages/account/src/providers/transaction-response/transaction-response.ts index a900f267d0d..31bf04d707f 100644 --- a/packages/account/src/providers/transaction-response/transaction-response.ts +++ b/packages/account/src/providers/transaction-response/transaction-response.ts @@ -303,7 +303,7 @@ export class TransactionResponse { // If we have the total fee, we do not need to refetch the gas price const totalFee = getTotalFeeFromStatus(this.status ?? this.gqlTransaction?.status); - const gasPrice = totalFee ? bn(0) : await this.provider.getLatestGasPrice(); + const gasPrice = totalFee ?? (await this.provider.getLatestGasPrice()); const maxInputs = (await this.provider.getChain()).consensusParameters.txParameters.maxInputs; const baseAssetId = await this.provider.getBaseAssetId(); diff --git a/packages/account/src/providers/transaction-summary/get-transaction-summary.ts b/packages/account/src/providers/transaction-summary/get-transaction-summary.ts index 102f9d65ee9..6e069f999a4 100644 --- a/packages/account/src/providers/transaction-summary/get-transaction-summary.ts +++ b/packages/account/src/providers/transaction-summary/get-transaction-summary.ts @@ -63,7 +63,7 @@ export async function getTransactionSummary( // If we have the total fee, we do not need to refetch the gas price const totalFee = getTotalFeeFromStatus(gqlTransaction.status); - const gasPrice = totalFee ? bn(0) : await provider.getLatestGasPrice(); + const gasPrice = totalFee ?? (await provider.getLatestGasPrice()); const baseAssetId = await provider.getBaseAssetId(); From 055f0bbc8939aeff338c29e0c0af8d2604621ae9 Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Tue, 7 Jan 2025 17:33:07 +0000 Subject: [PATCH 07/11] Revert "feat: pass down totalFee" This reverts commit 36c61909dc4fd9c5b880f61d35c1fdf9b7e1bf55. --- .../src/providers/transaction-response/transaction-response.ts | 2 +- .../providers/transaction-summary/get-transaction-summary.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/account/src/providers/transaction-response/transaction-response.ts b/packages/account/src/providers/transaction-response/transaction-response.ts index 31bf04d707f..a900f267d0d 100644 --- a/packages/account/src/providers/transaction-response/transaction-response.ts +++ b/packages/account/src/providers/transaction-response/transaction-response.ts @@ -303,7 +303,7 @@ export class TransactionResponse { // If we have the total fee, we do not need to refetch the gas price const totalFee = getTotalFeeFromStatus(this.status ?? this.gqlTransaction?.status); - const gasPrice = totalFee ?? (await this.provider.getLatestGasPrice()); + const gasPrice = totalFee ? bn(0) : await this.provider.getLatestGasPrice(); const maxInputs = (await this.provider.getChain()).consensusParameters.txParameters.maxInputs; const baseAssetId = await this.provider.getBaseAssetId(); diff --git a/packages/account/src/providers/transaction-summary/get-transaction-summary.ts b/packages/account/src/providers/transaction-summary/get-transaction-summary.ts index 6e069f999a4..102f9d65ee9 100644 --- a/packages/account/src/providers/transaction-summary/get-transaction-summary.ts +++ b/packages/account/src/providers/transaction-summary/get-transaction-summary.ts @@ -63,7 +63,7 @@ export async function getTransactionSummary( // If we have the total fee, we do not need to refetch the gas price const totalFee = getTotalFeeFromStatus(gqlTransaction.status); - const gasPrice = totalFee ?? (await provider.getLatestGasPrice()); + const gasPrice = totalFee ? bn(0) : await provider.getLatestGasPrice(); const baseAssetId = await provider.getBaseAssetId(); From b9c811366f3faa70cd08c214c00d7ac732514036 Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Wed, 8 Jan 2025 12:45:00 +0000 Subject: [PATCH 08/11] feat: remove totalFee from assemble tx summary --- .../transaction-response/transaction-response.ts | 1 - .../assemble-transaction-summary.ts | 14 ++------------ 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/packages/account/src/providers/transaction-response/transaction-response.ts b/packages/account/src/providers/transaction-response/transaction-response.ts index a900f267d0d..64c106c672b 100644 --- a/packages/account/src/providers/transaction-response/transaction-response.ts +++ b/packages/account/src/providers/transaction-response/transaction-response.ts @@ -322,7 +322,6 @@ export class TransactionResponse { maxGasPerTx, gasPrice, baseAssetId, - totalFee, }); return transactionSummary; diff --git a/packages/account/src/providers/transaction-summary/assemble-transaction-summary.ts b/packages/account/src/providers/transaction-summary/assemble-transaction-summary.ts index f3fdb2f4075..99785b4bd2a 100644 --- a/packages/account/src/providers/transaction-summary/assemble-transaction-summary.ts +++ b/packages/account/src/providers/transaction-summary/assemble-transaction-summary.ts @@ -35,7 +35,6 @@ export interface AssembleTransactionSummaryParams { maxGasPerTx: BN; gasPrice: BN; baseAssetId: string; - totalFee?: BN; } /** @hidden */ @@ -56,7 +55,6 @@ export function assembleTransactionSummary( maxGasPerTx, gasPrice, baseAssetId, - totalFee, } = params; const gasUsed = getGasUsedFromReceipts(receipts); @@ -78,19 +76,11 @@ export function assembleTransactionSummary( const tip = bn(transaction.policies?.find((policy) => policy.type === PolicyType.Tip)?.data); - const { - isStatusFailure, - isStatusPending, - isStatusSuccess, - blockId, - status, - time, - totalFee: totalFeeFromStatus, - } = processGraphqlStatus(gqlTransactionStatus); + const { isStatusFailure, isStatusPending, isStatusSuccess, blockId, status, time, totalFee } = + processGraphqlStatus(gqlTransactionStatus); const fee = totalFee ?? - totalFeeFromStatus ?? calculateTXFeeForSummary({ gasPrice, rawPayload, From 65b3dce297fad2a40d1be3fab5106ac27c5162e4 Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Wed, 8 Jan 2025 12:48:52 +0000 Subject: [PATCH 09/11] chore: lint --- .../src/providers/transaction-summary/get-transaction-summary.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/account/src/providers/transaction-summary/get-transaction-summary.ts b/packages/account/src/providers/transaction-summary/get-transaction-summary.ts index 102f9d65ee9..a495f41dae8 100644 --- a/packages/account/src/providers/transaction-summary/get-transaction-summary.ts +++ b/packages/account/src/providers/transaction-summary/get-transaction-summary.ts @@ -81,7 +81,6 @@ export async function getTransactionSummary( maxGasPerTx, gasPrice, baseAssetId, - totalFee, }); return { From 0daa7963891bfa27de1d6fa7b7bd095341b62f54 Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Wed, 8 Jan 2025 14:49:22 +0000 Subject: [PATCH 10/11] chore: mitigate test flakiness MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Nedim Salkić --- packages/fuel-gauge/src/transaction-response.test.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/fuel-gauge/src/transaction-response.test.ts b/packages/fuel-gauge/src/transaction-response.test.ts index fc75155bd16..75aaf25d66c 100644 --- a/packages/fuel-gauge/src/transaction-response.test.ts +++ b/packages/fuel-gauge/src/transaction-response.test.ts @@ -331,7 +331,16 @@ describe('TransactionResponse', () => { }); it('builds response and assembles result [fetches gas price then uses fee]', async () => { - using launched = await launchTestNode(); + using launched = await launchTestNode({ + nodeOptions: { + args: [ + '--poa-instant', + 'false', + '--poa-interval-period', + '2sec', + ], + }, + }); const { provider, From 2e43f034ed81e8b6dbb08bc81897bc4a140349f0 Mon Sep 17 00:00:00 2001 From: Daniel Bate Date: Wed, 8 Jan 2025 15:15:12 +0000 Subject: [PATCH 11/11] chore: lint --- packages/fuel-gauge/src/transaction-response.test.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/packages/fuel-gauge/src/transaction-response.test.ts b/packages/fuel-gauge/src/transaction-response.test.ts index 75aaf25d66c..d4fb20427bf 100644 --- a/packages/fuel-gauge/src/transaction-response.test.ts +++ b/packages/fuel-gauge/src/transaction-response.test.ts @@ -333,12 +333,7 @@ describe('TransactionResponse', () => { it('builds response and assembles result [fetches gas price then uses fee]', async () => { using launched = await launchTestNode({ nodeOptions: { - args: [ - '--poa-instant', - 'false', - '--poa-interval-period', - '2sec', - ], + args: ['--poa-instant', 'false', '--poa-interval-period', '2sec'], }, });