Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/bridge-controller/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 7 additions & 8 deletions packages/bridge-controller/src/bridge-controller.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2625,7 +2625,7 @@ describe('BridgeController', function () {
[FeatureId.PERPS]: {
aggIds: ['debridge', 'socket'],
bridgeIds: ['bridge1', 'bridge2'],
noFee: true,
fee: 0,
},
},
});
Expand All @@ -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({
Expand All @@ -2656,7 +2656,7 @@ describe('BridgeController', function () {
bridgeIds: ['other', 'debridge'],
gasIncluded: false,
gasIncluded7702: false,
noFee: false,
fee: 0,
},
null,
FeatureId.PERPS,
Expand All @@ -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",
Expand Down Expand Up @@ -2722,7 +2722,6 @@ describe('BridgeController', function () {
bridgeIds: ['other', 'debridge'],
gasIncluded: false,
gasIncluded7702: false,
noFee: false,
} as never,
null,
FeatureId.PERPS,
Expand All @@ -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({
Expand Down Expand Up @@ -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",
Expand All @@ -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({
Expand Down
5 changes: 4 additions & 1 deletion packages/bridge-controller/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions packages/bridge-controller/src/utils/fetch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -371,7 +371,7 @@ describe('fetch', () => {
gasIncluded7702: false,
aggIds: ['socket', 'lifi'],
bridgeIds: ['bridge1', 'bridge2'],
noFee: true,
fee: 0,
},
signal,
BridgeClientId.EXTENSION,
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions packages/bridge-controller/src/utils/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion packages/bridge-controller/src/utils/validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Loading