Skip to content

Commit 6aedb66

Browse files
(SWAPS3309): Replace noFee bridge api parameter with fee. (#6964)
## Explanation Bridge API used to have a `noFee` parameter that was changed to `fee` parameter. For some time api will support both, however to eventually sunset a less flexible `noFee` parameter controller had to be changed. ## References Associated bridge-api [PR](consensys-vertical-apps/va-mmcx-bridge-api#610). ## Checklist - [x] I've updated the test suite for new or updated code as appropriate - [x] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [ ] I've communicated my changes to consumers by [updating changelogs for packages I've changed](https://github.com/MetaMask/core/tree/main/docs/contributing.md#updating-changelogs), highlighting breaking changes as necessary - [x] I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Replaces `noFee` with numeric `fee` across request types, validators, request formatting, and tests, and documents the breaking change. > > - **Breaking change** > - Replace `noFee` flag with numeric `fee` in bridge API requests and feature flag overrides. > - **Core updates** > - Types: Update `QuoteRequest` to use optional `fee?: number` (`src/types.ts`). > - Validation: Update `GenericQuoteRequestSchema` to accept `fee` (`src/utils/validators.ts`). > - Request formatting: Map `fee` into normalized query params; remove `noFee` handling (`src/utils/fetch.ts`). > - **Tests** > - Update expectations and snapshots to use `fee` (e.g., URL query `fee=0`) and feature flag overrides (`src/bridge-controller.test.ts`, `src/utils/fetch.test.ts`). > - **Docs** > - Add changelog entry noting the breaking replacement (`CHANGELOG.md`). > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 9afac58. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: Bryan Fullam <[email protected]>
1 parent 2011648 commit 6aedb66

File tree

6 files changed

+21
-15
lines changed

6 files changed

+21
-15
lines changed

packages/bridge-controller/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Changed
11+
12+
- **BREAKING:** `noFee` flag was replaced with `fee` flag in bridge api requests ([#6964](https://github.com/MetaMask/core/pull/6964))
13+
1014
## [57.0.0]
1115

1216
### Changed

packages/bridge-controller/src/bridge-controller.test.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2625,7 +2625,7 @@ describe('BridgeController', function () {
26252625
[FeatureId.PERPS]: {
26262626
aggIds: ['debridge', 'socket'],
26272627
bridgeIds: ['bridge1', 'bridge2'],
2628-
noFee: true,
2628+
fee: 0,
26292629
},
26302630
},
26312631
});
@@ -2634,7 +2634,7 @@ describe('BridgeController', function () {
26342634
}));
26352635
});
26362636

2637-
it('should override aggIds and noFee in perps request', async () => {
2637+
it('should override aggIds and fee in perps request', async () => {
26382638
const fetchBridgeQuotesSpy = jest
26392639
.spyOn(fetchUtils, 'fetchBridgeQuotes')
26402640
.mockResolvedValueOnce({
@@ -2656,7 +2656,7 @@ describe('BridgeController', function () {
26562656
bridgeIds: ['other', 'debridge'],
26572657
gasIncluded: false,
26582658
gasIncluded7702: false,
2659-
noFee: false,
2659+
fee: 0,
26602660
},
26612661
null,
26622662
FeatureId.PERPS,
@@ -2677,9 +2677,9 @@ describe('BridgeController', function () {
26772677
],
26782678
"destChainId": "1",
26792679
"destTokenAddress": "0x1234",
2680+
"fee": 0,
26802681
"gasIncluded": false,
26812682
"gasIncluded7702": false,
2682-
"noFee": true,
26832683
"slippage": 0.5,
26842684
"srcChainId": "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
26852685
"srcTokenAddress": "NATIVE",
@@ -2722,7 +2722,6 @@ describe('BridgeController', function () {
27222722
bridgeIds: ['other', 'debridge'],
27232723
gasIncluded: false,
27242724
gasIncluded7702: false,
2725-
noFee: false,
27262725
} as never,
27272726
null,
27282727
FeatureId.PERPS,
@@ -2733,7 +2732,7 @@ describe('BridgeController', function () {
27332732
expect(bridgeController.state).toStrictEqual(expectedControllerState);
27342733
});
27352734

2736-
it('should add aggIds and noFee to perps request', async () => {
2735+
it('should add aggIds and fee to perps request', async () => {
27372736
const fetchBridgeQuotesSpy = jest
27382737
.spyOn(fetchUtils, 'fetchBridgeQuotes')
27392738
.mockResolvedValueOnce({
@@ -2773,9 +2772,9 @@ describe('BridgeController', function () {
27732772
],
27742773
"destChainId": "1",
27752774
"destTokenAddress": "0x1234",
2775+
"fee": 0,
27762776
"gasIncluded": false,
27772777
"gasIncluded7702": false,
2778-
"noFee": true,
27792778
"slippage": 0.5,
27802779
"srcChainId": "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
27812780
"srcTokenAddress": "NATIVE",
@@ -2795,7 +2794,7 @@ describe('BridgeController', function () {
27952794
expect(bridgeController.state).toStrictEqual(expectedControllerState);
27962795
});
27972796

2798-
it('should not add aggIds and noFee if featureId is not specified', async () => {
2797+
it('should not add aggIds and fee if featureId is not specified', async () => {
27992798
const fetchBridgeQuotesSpy = jest
28002799
.spyOn(fetchUtils, 'fetchBridgeQuotes')
28012800
.mockResolvedValueOnce({

packages/bridge-controller/src/types.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,10 @@ export type QuoteRequest<
215215
* Whether to request quotes that use EIP-7702 delegated gasless execution
216216
*/
217217
gasIncluded7702: boolean;
218-
noFee?: boolean;
218+
/**
219+
* The fee that will be charged by MetaMask
220+
*/
221+
fee?: number;
219222
};
220223

221224
export enum StatusTypes {

packages/bridge-controller/src/utils/fetch.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ describe('fetch', () => {
354354
mockConsoleWarn.mockRestore();
355355
});
356356

357-
it('should fetch bridge quotes successfully, with aggIds, bridgeIds and noFee=true', async () => {
357+
it('should fetch bridge quotes successfully, with aggIds, bridgeIds and fee=0', async () => {
358358
mockFetchFn.mockResolvedValue(mockBridgeQuotesNativeErc20);
359359
const { signal } = new AbortController();
360360

@@ -371,7 +371,7 @@ describe('fetch', () => {
371371
gasIncluded7702: false,
372372
aggIds: ['socket', 'lifi'],
373373
bridgeIds: ['bridge1', 'bridge2'],
374-
noFee: true,
374+
fee: 0,
375375
},
376376
signal,
377377
BridgeClientId.EXTENSION,
@@ -382,7 +382,7 @@ describe('fetch', () => {
382382
);
383383

384384
expect(mockFetchFn).toHaveBeenCalledWith(
385-
'https://bridge.api.cx.metamask.io/getQuote?walletAddress=0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984&destWalletAddress=0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984&srcChainId=1&destChainId=10&srcTokenAddress=0x0000000000000000000000000000000000000000&destTokenAddress=0x0000000000000000000000000000000000000000&srcTokenAmount=20000&insufficientBal=false&resetApproval=false&gasIncluded=false&gasIncluded7702=false&slippage=0.5&noFee=true&aggIds=socket%2Clifi&bridgeIds=bridge1%2Cbridge2',
385+
'https://bridge.api.cx.metamask.io/getQuote?walletAddress=0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984&destWalletAddress=0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984&srcChainId=1&destChainId=10&srcTokenAddress=0x0000000000000000000000000000000000000000&destTokenAddress=0x0000000000000000000000000000000000000000&srcTokenAmount=20000&insufficientBal=false&resetApproval=false&gasIncluded=false&gasIncluded7702=false&slippage=0.5&fee=0&aggIds=socket%2Clifi&bridgeIds=bridge1%2Cbridge2',
386386
{
387387
headers: { 'X-Client-Id': 'extension', 'Client-Version': '1.0.0' },
388388
signal,

packages/bridge-controller/src/utils/fetch.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ const formatQueryParams = (request: GenericQuoteRequest): URLSearchParams => {
8282
if (request.slippage !== undefined) {
8383
normalizedRequest.slippage = request.slippage;
8484
}
85-
if (request.noFee !== undefined) {
86-
normalizedRequest.noFee = request.noFee;
85+
if (request.fee !== undefined) {
86+
normalizedRequest.fee = request.fee;
8787
}
8888
if (request.aggIds && request.aggIds.length > 0) {
8989
normalizedRequest.aggIds = request.aggIds;

packages/bridge-controller/src/utils/validators.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export const PriceImpactThresholdSchema = type({
122122
const GenericQuoteRequestSchema = type({
123123
aggIds: optional(array(string())),
124124
bridgeIds: optional(array(string())),
125-
noFee: optional(boolean()),
125+
fee: optional(number()),
126126
});
127127

128128
const FeatureIdSchema = enums(Object.values(FeatureId));

0 commit comments

Comments
 (0)