Skip to content

Commit

Permalink
fix: add useMultiRpcMigration
Browse files Browse the repository at this point in the history
  • Loading branch information
salimtb committed Oct 23, 2024
1 parent 3d44c2b commit c906452
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ describe('PreferencesController', () => {
showTestNetworks: false,
isIpfsGatewayEnabled: true,
useTransactionSimulations: true,
useMultiRpcMigration: true,
showIncomingTransactions: Object.values(
ETHERSCAN_SUPPORTED_CHAIN_IDS,
).reduce((acc, curr) => {
Expand Down Expand Up @@ -368,6 +369,12 @@ describe('PreferencesController', () => {
);
});

it('should set useMultiRpcMigration', () => {
const controller = setupPreferencesController();
controller.setUseMultiRpcMigration(true);
expect(controller.state.useMultiRpcMigration).toBe(true);
});

it('should set featureFlags', () => {
const controller = setupPreferencesController();
controller.setFeatureFlag('Feature A', true);
Expand Down
20 changes: 20 additions & 0 deletions packages/preferences-controller/src/PreferencesController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ export type PreferencesState = {
* Controls whether transaction simulations are enabled
*/
useTransactionSimulations: boolean;
/**
* Controls whether Multi rpc modal is displayed or not
*/
useMultiRpcMigration: boolean;
};

const metadata = {
Expand All @@ -128,6 +132,7 @@ const metadata = {
useTokenDetection: { persist: true, anonymous: true },
smartTransactionsOptInStatus: { persist: true, anonymous: false },
useTransactionSimulations: { persist: true, anonymous: true },
useMultiRpcMigration: { persist: true, anonymous: true },
};

const name = 'PreferencesController';
Expand Down Expand Up @@ -197,6 +202,7 @@ export function getDefaultPreferencesState() {
showTestNetworks: false,
useNftDetection: false,
useTokenDetection: true,
useMultiRpcMigration: true,
smartTransactionsOptInStatus: false,
useTransactionSimulations: true,
};
Expand Down Expand Up @@ -483,6 +489,20 @@ export class PreferencesController extends BaseController<
}
}

/**
* Toggle multi rpc migration modal.
*
* @param useMultiRpcMigration - Boolean indicating if the multi rpc modal will be displayed or not.
*/
setUseMultiRpcMigration(useMultiRpcMigration: boolean) {
this.update((state) => {
state.useMultiRpcMigration = useMultiRpcMigration;
if (!useMultiRpcMigration) {
state.useMultiRpcMigration = false;
}
});
}

/**
* A setter for the user to opt into smart transactions
*
Expand Down

0 comments on commit c906452

Please sign in to comment.