diff --git a/packages/bridge-controller/CHANGELOG.md b/packages/bridge-controller/CHANGELOG.md index 705594d0005..7ed4623d1ad 100644 --- a/packages/bridge-controller/CHANGELOG.md +++ b/packages/bridge-controller/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Changed + +- **BREAKING:** `noFee` flag was replaced with `fee` flag in bridge api requests ([#6964](https://github.com/MetaMask/core/pull/6964)) + ## [57.0.0] ### Changed diff --git a/packages/bridge-controller/src/bridge-controller.test.ts b/packages/bridge-controller/src/bridge-controller.test.ts index 4cb7cd36a19..b44f2e4bd4d 100644 --- a/packages/bridge-controller/src/bridge-controller.test.ts +++ b/packages/bridge-controller/src/bridge-controller.test.ts @@ -2625,7 +2625,7 @@ describe('BridgeController', function () { [FeatureId.PERPS]: { aggIds: ['debridge', 'socket'], bridgeIds: ['bridge1', 'bridge2'], - noFee: true, + fee: 0, }, }, }); @@ -2634,7 +2634,7 @@ describe('BridgeController', function () { })); }); - it('should override aggIds and noFee in perps request', async () => { + it('should override aggIds and fee in perps request', async () => { const fetchBridgeQuotesSpy = jest .spyOn(fetchUtils, 'fetchBridgeQuotes') .mockResolvedValueOnce({ @@ -2656,7 +2656,7 @@ describe('BridgeController', function () { bridgeIds: ['other', 'debridge'], gasIncluded: false, gasIncluded7702: false, - noFee: false, + fee: 0, }, null, FeatureId.PERPS, @@ -2677,9 +2677,9 @@ describe('BridgeController', function () { ], "destChainId": "1", "destTokenAddress": "0x1234", + "fee": 0, "gasIncluded": false, "gasIncluded7702": false, - "noFee": true, "slippage": 0.5, "srcChainId": "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp", "srcTokenAddress": "NATIVE", @@ -2722,7 +2722,6 @@ describe('BridgeController', function () { bridgeIds: ['other', 'debridge'], gasIncluded: false, gasIncluded7702: false, - noFee: false, } as never, null, FeatureId.PERPS, @@ -2733,7 +2732,7 @@ describe('BridgeController', function () { expect(bridgeController.state).toStrictEqual(expectedControllerState); }); - it('should add aggIds and noFee to perps request', async () => { + it('should add aggIds and fee to perps request', async () => { const fetchBridgeQuotesSpy = jest .spyOn(fetchUtils, 'fetchBridgeQuotes') .mockResolvedValueOnce({ @@ -2773,9 +2772,9 @@ describe('BridgeController', function () { ], "destChainId": "1", "destTokenAddress": "0x1234", + "fee": 0, "gasIncluded": false, "gasIncluded7702": false, - "noFee": true, "slippage": 0.5, "srcChainId": "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp", "srcTokenAddress": "NATIVE", @@ -2795,7 +2794,7 @@ describe('BridgeController', function () { expect(bridgeController.state).toStrictEqual(expectedControllerState); }); - it('should not add aggIds and noFee if featureId is not specified', async () => { + it('should not add aggIds and fee if featureId is not specified', async () => { const fetchBridgeQuotesSpy = jest .spyOn(fetchUtils, 'fetchBridgeQuotes') .mockResolvedValueOnce({ diff --git a/packages/bridge-controller/src/types.ts b/packages/bridge-controller/src/types.ts index af2f293ed22..cc30e8b50e5 100644 --- a/packages/bridge-controller/src/types.ts +++ b/packages/bridge-controller/src/types.ts @@ -215,7 +215,10 @@ export type QuoteRequest< * Whether to request quotes that use EIP-7702 delegated gasless execution */ gasIncluded7702: boolean; - noFee?: boolean; + /** + * The fee that will be charged by MetaMask + */ + fee?: number; }; export enum StatusTypes { diff --git a/packages/bridge-controller/src/utils/fetch.test.ts b/packages/bridge-controller/src/utils/fetch.test.ts index 9627e9bec82..2411edeef49 100644 --- a/packages/bridge-controller/src/utils/fetch.test.ts +++ b/packages/bridge-controller/src/utils/fetch.test.ts @@ -354,7 +354,7 @@ describe('fetch', () => { mockConsoleWarn.mockRestore(); }); - it('should fetch bridge quotes successfully, with aggIds, bridgeIds and noFee=true', async () => { + it('should fetch bridge quotes successfully, with aggIds, bridgeIds and fee=0', async () => { mockFetchFn.mockResolvedValue(mockBridgeQuotesNativeErc20); const { signal } = new AbortController(); @@ -371,7 +371,7 @@ describe('fetch', () => { gasIncluded7702: false, aggIds: ['socket', 'lifi'], bridgeIds: ['bridge1', 'bridge2'], - noFee: true, + fee: 0, }, signal, BridgeClientId.EXTENSION, @@ -382,7 +382,7 @@ describe('fetch', () => { ); expect(mockFetchFn).toHaveBeenCalledWith( - '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', + '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', { headers: { 'X-Client-Id': 'extension', 'Client-Version': '1.0.0' }, signal, diff --git a/packages/bridge-controller/src/utils/fetch.ts b/packages/bridge-controller/src/utils/fetch.ts index 96e9311ad13..95f994d14de 100644 --- a/packages/bridge-controller/src/utils/fetch.ts +++ b/packages/bridge-controller/src/utils/fetch.ts @@ -82,8 +82,8 @@ const formatQueryParams = (request: GenericQuoteRequest): URLSearchParams => { if (request.slippage !== undefined) { normalizedRequest.slippage = request.slippage; } - if (request.noFee !== undefined) { - normalizedRequest.noFee = request.noFee; + if (request.fee !== undefined) { + normalizedRequest.fee = request.fee; } if (request.aggIds && request.aggIds.length > 0) { normalizedRequest.aggIds = request.aggIds; diff --git a/packages/bridge-controller/src/utils/validators.ts b/packages/bridge-controller/src/utils/validators.ts index 3082ae0f196..be950ab8564 100644 --- a/packages/bridge-controller/src/utils/validators.ts +++ b/packages/bridge-controller/src/utils/validators.ts @@ -122,7 +122,7 @@ export const PriceImpactThresholdSchema = type({ const GenericQuoteRequestSchema = type({ aggIds: optional(array(string())), bridgeIds: optional(array(string())), - noFee: optional(boolean()), + fee: optional(number()), }); const FeatureIdSchema = enums(Object.values(FeatureId));