Skip to content

Commit 29c0a6a

Browse files
infiniteflowermikespositobfullam
authored
chore: update bridge config to v2 (#5837)
## Explanation <!-- Thanks for your contribution! Take a moment to answer these questions so that reviewers have the information they need to properly understand your changes: * What is the current state of things and why does it need to change? * What is the solution your changes offer and how does it work? * Are there any changes whose purpose might not obvious to those unfamiliar with the domain? * If your primary goal was to update one package but you found you had to update another one along the way, why did you do so? * If you had to upgrade a dependency, why did you do so? --> This PR consumes the new `bridgeConfigV2` field from LaunchDarkly. ## References <!-- Are there any issues that this pull request is tied to? Are there other links that reviewers should consult to understand these changes better? Are there client or consumer pull requests to adopt any breaking changes? For example: * Fixes #12345 * Related to #67890 --> Related to #5834, #5835 ## Changelog <!-- THIS SECTION IS NO LONGER NEEDED. The process for updating changelogs has changed. Please consult the "Updating changelogs" section of the Contributing doc for more. --> ## 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 - [x] 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 --------- Co-authored-by: Michele Esposito <[email protected]> Co-authored-by: Bryan Fullam <[email protected]>
1 parent 5d5ba48 commit 29c0a6a

File tree

4 files changed

+119
-1
lines changed

4 files changed

+119
-1
lines changed

packages/bridge-controller/CHANGELOG.md

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

1212
- **BREAKING:** Added a required `minimumVersion` to feature flag response schema ([#5834](https://github.com/MetaMask/core/pull/5834))
1313

14+
### Changed
15+
16+
- Consume `bridgeConfigV2` in the feature flag response schema for Mobile and export `DEFAULT_FEATURE_FLAG_CONFIG` ([#5837](https://github.com/MetaMask/core/pull/5837))
17+
1418
## [25.1.0]
1519

1620
### Added

packages/bridge-controller/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,3 +133,5 @@ export {
133133
selectIsQuoteExpired,
134134
selectBridgeFeatureFlags,
135135
} from './selectors';
136+
137+
export { DEFAULT_FEATURE_FLAG_CONFIG } from './constants/bridge';

packages/bridge-controller/src/utils/feature-flags.test.ts

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,5 +356,107 @@ describe('feature-flags', () => {
356356
};
357357
expect(result).toStrictEqual(expectedBridgeConfig);
358358
});
359+
360+
it('should prioritize bridgeConfigV2 over bridgeConfig', async () => {
361+
const bridgeConfigV2 = {
362+
refreshRate: 5,
363+
maxRefreshCount: 2,
364+
support: true,
365+
minimumVersion: '1.0.0',
366+
chains: {
367+
'1': {
368+
isActiveSrc: true,
369+
isActiveDest: true,
370+
},
371+
},
372+
};
373+
374+
const bridgeConfig = {
375+
refreshRate: 3,
376+
maxRefreshCount: 1,
377+
support: true,
378+
minimumVersion: '0.0.0',
379+
chains: {
380+
'1': {
381+
isActiveSrc: true,
382+
isActiveDest: true,
383+
},
384+
},
385+
};
386+
387+
const remoteFeatureFlagControllerState = {
388+
cacheTimestamp: 1745515389440,
389+
remoteFeatureFlags: {
390+
bridgeConfigV2,
391+
bridgeConfig,
392+
assetsNotificationsEnabled: false,
393+
},
394+
};
395+
396+
(mockMessenger.call as jest.Mock).mockImplementation(() => {
397+
return remoteFeatureFlagControllerState;
398+
});
399+
400+
const result = getBridgeFeatureFlags(mockMessenger);
401+
402+
const expectedBridgeConfig = {
403+
refreshRate: 5,
404+
maxRefreshCount: 2,
405+
support: true,
406+
minimumVersion: '1.0.0',
407+
chains: {
408+
'eip155:1': {
409+
isActiveSrc: true,
410+
isActiveDest: true,
411+
},
412+
},
413+
};
414+
415+
expect(result).toStrictEqual(expectedBridgeConfig);
416+
});
417+
418+
it('should fallback to bridgeConfig when bridgeConfigV2 is not available', async () => {
419+
const bridgeConfig = {
420+
refreshRate: 3,
421+
maxRefreshCount: 1,
422+
support: true,
423+
minimumVersion: '0.0.0',
424+
chains: {
425+
'1': {
426+
isActiveSrc: true,
427+
isActiveDest: true,
428+
},
429+
},
430+
};
431+
432+
const remoteFeatureFlagControllerState = {
433+
cacheTimestamp: 1745515389440,
434+
remoteFeatureFlags: {
435+
bridgeConfig,
436+
assetsNotificationsEnabled: false,
437+
},
438+
};
439+
440+
(mockMessenger.call as jest.Mock).mockImplementation(() => {
441+
return remoteFeatureFlagControllerState;
442+
});
443+
444+
const result = getBridgeFeatureFlags(mockMessenger);
445+
446+
const expectedBridgeConfig = {
447+
refreshRate: 3,
448+
maxRefreshCount: 1,
449+
support: true,
450+
minimumVersion: '0.0.0',
451+
chains: {
452+
'eip155:1': {
453+
isActiveSrc: true,
454+
isActiveDest: true,
455+
},
456+
},
457+
};
458+
459+
expect(result).toStrictEqual(expectedBridgeConfig);
460+
});
359461
});
360462
});

packages/bridge-controller/src/utils/feature-flags.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,18 @@ export function getBridgeFeatureFlags(
4747
const remoteFeatureFlagControllerState = messenger.call(
4848
'RemoteFeatureFlagController:getState',
4949
);
50+
51+
// bridgeConfigV2 is the feature flag for the mobile app
52+
// bridgeConfig for Mobile has been deprecated since release of bridge and Solana in 7.46.0 was pushed back
53+
// and there's no way to turn on bridgeConfig for 7.47.0 without affecting 7.46.0 as well.
54+
// You will still get bridgeConfig returned from remoteFeatureFlagControllerState but you should use bridgeConfigV2 instead
55+
// Mobile's bridgeConfig will be permanently serving the disabled variation, so falling back to it in Mobile will be ok
56+
const rawMobileFlags =
57+
remoteFeatureFlagControllerState?.remoteFeatureFlags?.bridgeConfigV2;
58+
59+
// Extension LaunchDarkly will not have the bridgeConfigV2 field, so we'll continue to use bridgeConfig
5060
const rawBridgeConfig =
5161
remoteFeatureFlagControllerState?.remoteFeatureFlags?.bridgeConfig;
5262

53-
return processFeatureFlags(rawBridgeConfig);
63+
return processFeatureFlags(rawMobileFlags || rawBridgeConfig);
5464
}

0 commit comments

Comments
 (0)