Skip to content

Commit fcfac09

Browse files
committed
fix(STX-340): use medium fee for gas fee in submission
1 parent 5db273f commit fcfac09

File tree

3 files changed

+39
-5
lines changed

3 files changed

+39
-5
lines changed

packages/bridge-status-controller/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
- Bump `@metamask/controller-utils` from `^11.17.0` to `^11.18.0` ([#7583](https://github.com/MetaMask/core/pull/7583))
1313
- Bump `@metamask/network-controller` from `^27.1.0` to `^27.2.0` ([#7583](https://github.com/MetaMask/core/pull/7583))
1414

15+
### Fixed
16+
17+
- Use `BRIDGE_PREFERRED_GAS_ESTIMATE` from `@metamask/bridge-controller` for gas price estimates to align with validation ([#7582](https://github.com/MetaMask/core/pull/7582))
18+
1519
## [64.3.0]
1620

1721
### Changed

packages/bridge-status-controller/src/utils/gas.test.ts

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { BRIDGE_PREFERRED_GAS_ESTIMATE } from '@metamask/bridge-controller';
12
import type { GasFeeState } from '@metamask/gas-fee-controller';
23
import type { FeeMarketGasFeeEstimates } from '@metamask/transaction-controller';
34
import { GasFeeEstimateLevel } from '@metamask/transaction-controller';
@@ -45,23 +46,50 @@ describe('gas calculation utils', () => {
4546
});
4647
});
4748

48-
it('should handle missing high property in txGasFeeEstimates', () => {
49-
// Call the function
49+
it('should handle missing property in txGasFeeEstimates', () => {
5050
const result = getTxGasEstimates({
5151
txGasFeeEstimates: {} as never,
5252
networkGasFeeEstimates: {
5353
estimatedBaseFee: '0.00000001',
5454
} as GasFeeState['gasFeeEstimates'],
5555
});
5656

57-
// Verify the result
5857
expect(result).toStrictEqual({
5958
baseAndPriorityFeePerGas: undefined,
6059
maxFeePerGas: undefined,
6160
maxPriorityFeePerGas: undefined,
6261
});
6362
});
6463

64+
it('should use Bridge preferred gas estimate as gas estimates', () => {
65+
const estimates = {
66+
type: 'fee-market',
67+
[GasFeeEstimateLevel.Low]: {
68+
maxFeePerGas: '0xLOW',
69+
maxPriorityFeePerGas: '0xLOW_PRIORITY',
70+
},
71+
[GasFeeEstimateLevel.Medium]: {
72+
maxFeePerGas: '0xMEDIUM',
73+
maxPriorityFeePerGas: '0xMEDIUM_PRIORITY',
74+
},
75+
[GasFeeEstimateLevel.High]: {
76+
maxFeePerGas: '0xHIGH',
77+
maxPriorityFeePerGas: '0xHIGH_PRIORITY',
78+
},
79+
} as FeeMarketGasFeeEstimates;
80+
const result = getTxGasEstimates({
81+
txGasFeeEstimates: estimates,
82+
networkGasFeeEstimates: mockNetworkGasFeeEstimates,
83+
});
84+
85+
expect(result.maxFeePerGas).toBe(
86+
estimates[BRIDGE_PREFERRED_GAS_ESTIMATE]?.maxFeePerGas,
87+
);
88+
expect(result.maxPriorityFeePerGas).toBe(
89+
estimates[BRIDGE_PREFERRED_GAS_ESTIMATE]?.maxPriorityFeePerGas,
90+
);
91+
});
92+
6593
it('should use default estimatedBaseFee when not provided in networkGasFeeEstimates', () => {
6694
// Mock data
6795

@@ -143,7 +171,7 @@ describe('gas calculation utils', () => {
143171
});
144172
const mockEstimateGasFeeFn = jest.fn().mockResolvedValueOnce({
145173
estimates: {
146-
[GasFeeEstimateLevel.High]: {
174+
[GasFeeEstimateLevel.Medium]: {
147175
maxFeePerGas: '0x1234567890',
148176
maxPriorityFeePerGas: '0x1234567890',
149177
},

packages/bridge-status-controller/src/utils/gas.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { BRIDGE_PREFERRED_GAS_ESTIMATE } from '@metamask/bridge-controller';
12
import type { TokenAmountValues, TxData } from '@metamask/bridge-controller';
23
import { toHex } from '@metamask/controller-utils';
34
import type {
@@ -21,7 +22,8 @@ const getTransaction1559GasFeeEstimates = (
2122
txGasFeeEstimates: FeeMarketGasFeeEstimates,
2223
estimatedBaseFee: string,
2324
) => {
24-
const { maxFeePerGas, maxPriorityFeePerGas } = txGasFeeEstimates?.high ?? {};
25+
const { maxFeePerGas, maxPriorityFeePerGas } =
26+
txGasFeeEstimates?.[BRIDGE_PREFERRED_GAS_ESTIMATE] ?? {};
2527

2628
const baseAndPriorityFeePerGas = maxPriorityFeePerGas
2729
? new BigNumber(estimatedBaseFee, 10)

0 commit comments

Comments
 (0)