From d1cea85f3360801e9753d5ef126fd49797cd1ffe Mon Sep 17 00:00:00 2001 From: Mark Stacey Date: Tue, 2 May 2023 13:23:20 -0230 Subject: [PATCH] Rename `provider` to `providerConfig` (#18907) * Rename `provider` to `providerConfig` The network controller `provider` state has been renamed to `providerConfig`. This better reflects what this state is, and makes this controller more closely aligned with the core network controller. All references to the provider configuration have been updated to prefer `providerConfig` over `provider`, to make the distinction clear between a provider and provider config. Closes #18902 * Add migration --- .storybook/test-data.js | 2 +- app/scripts/background.js | 8 +- app/scripts/controllers/detect-tokens.js | 2 +- app/scripts/controllers/detect-tokens.test.js | 8 +- app/scripts/controllers/metametrics.test.js | 6 +- .../network/network-controller.test.ts | 246 +++++++++--------- .../controllers/network/network-controller.ts | 20 +- app/scripts/lib/setupSentry.js | 2 +- app/scripts/metamask-controller.js | 76 +++--- app/scripts/metamask-controller.test.js | 2 +- app/scripts/migrations/086.test.js | 88 +++++++ app/scripts/migrations/086.ts | 41 +++ app/scripts/migrations/index.js | 2 + development/states/navigate-txs.json | 2 +- test/data/mock-send-state.json | 2 +- test/data/mock-state.json | 2 +- test/e2e/fixture-builder.js | 4 +- test/e2e/tests/ens.spec.js | 2 +- test/jest/mock-store.js | 2 +- .../app/account-menu/account-menu.test.js | 2 +- .../advanced-gas-controls.test.js | 2 +- .../advanced-gas-inputs.test.js | 2 +- .../unconnected-account-alert.test.js | 2 +- .../confirm-legacy-gas-display.test.js | 6 +- .../confirm-detail-row.component.test.js | 2 +- ...m-page-container-content.component.test.js | 2 +- ...rm-page-container-header.component.test.js | 2 +- .../confirm-subtitle/confirm-subtitle.test.js | 2 +- .../app/contact-list/contact-list.test.js | 2 +- .../app/currency-input/currency-input.test.js | 2 +- .../app/dropdowns/network-dropdown.js | 30 ++- .../app/dropdowns/network-dropdown.test.js | 6 +- .../edit-gas-fee-popover.test.js | 2 +- .../edit-gas-item/edit-gas-item.test.js | 2 +- .../edit-gas-tooltip/edit-gas-tooltip.test.js | 2 +- .../gas-details-item-title.test.js | 2 +- .../import-token-link.test.js | 8 +- .../loading-network-screen.component.js | 12 +- .../loading-network-screen.container.js | 6 +- ui/components/app/menu-bar/menu-bar.test.js | 2 +- .../account-details-modal.test.js | 2 +- ...ncel-transaction-gas-fee.component.test.js | 2 +- .../confirm-remove-account.test.js | 2 +- .../app/nft-details/nft-details.test.js | 8 +- ui/components/app/nfts-tab/nfts-tab.test.js | 2 +- .../signature-request-original.component.js | 8 +- .../signature-request-original.container.js | 4 +- .../signature-request-original.stories.js | 2 +- .../signature-request-data.test.js | 2 +- .../signature-request.component.js | 8 +- .../signature-request.component.test.js | 2 +- .../signature-request.container.js | 8 +- .../signature-request.container.test.js | 4 +- .../signature-request.stories.js | 2 +- .../app/token-cell/token-cell.test.js | 2 +- ...transaction-activity-log.container.test.js | 4 +- .../transaction-alerts.stories.js | 2 +- .../transaction-breakdown.test.js | 2 +- .../user-preferenced-currency-display.test.js | 2 +- .../app/wallet-overview/eth-overview.test.js | 18 +- .../wallet-overview/token-overview.test.js | 18 +- .../compliance-settings.test.js | 2 +- .../custody-confirm-link-modal.stories.js | 2 +- .../custody-confirm-link-modal.test.js | 2 +- ...ractive-replacement-token-modal.stories.js | 2 +- ...nteractive-replacement-token-modal.test.js | 2 +- ...-replacement-token-notification.stories.js | 2 +- ...ive-replacement-token-notification.test.js | 2 +- .../jwt-url-form/jwt-url-form.test.js | 2 +- .../account-picker/account-picker.test.js | 2 +- .../multichain/app-header/app-header.test.js | 2 +- .../multichain-import-token-link.test.js | 8 +- .../multichain-token-list-item.test.js | 2 +- .../ui/identicon/identicon.component.test.js | 2 +- .../new-network-info/new-network-info.test.js | 4 +- .../confirm-transaction.duck.test.js | 4 +- ui/ducks/metamask/metamask.js | 4 +- ui/ducks/metamask/metamask.test.js | 2 +- ui/ducks/send/send.test.js | 48 ++-- ui/ducks/swaps/swaps.test.js | 10 +- ui/hooks/useAddressDetails.test.js | 2 +- ui/hooks/useAssetDetails.test.js | 2 +- ui/hooks/useTransactionInfo.test.js | 2 +- ui/index.js | 2 +- .../confirm-add-suggested-token.test.js | 2 +- .../confirm-approve-content.component.test.js | 2 +- .../confirm-import-token.test.js | 2 +- .../confirm-signature-request/index.test.js | 2 +- .../confirm-transaction-base.test.js | 4 +- .../connect-hardware/index.test.tsx | 2 +- ui/pages/import-token/import-token.test.js | 2 +- .../compliance-feature-page.test.js | 2 +- .../confirm-add-custodian-token.test.js | 4 +- ...nfirm-add-institutional-feature.stories.js | 2 +- .../confirm-add-institutional-feature.test.js | 2 +- .../connect-custody/account-list.stories.js | 1 - ui/pages/institutional/custody/custody.js | 3 - .../institutional/custody/custody.test.js | 2 +- .../institutional-entity-done-page.test.js | 2 +- .../creation-successful.test.js | 2 +- .../pin-extension/pin-extension.test.js | 2 +- .../privacy-settings/privacy-settings.test.js | 2 +- .../secure-your-wallet.test.js | 2 +- ui/pages/send/send.test.js | 2 +- .../add-contact/add-contact.test.js | 2 +- .../edit-contact/edit-contact.test.js | 2 +- .../networks-list-item.test.js | 2 +- .../networks-list/networks-list.test.js | 2 +- .../networks-tab-content.test.js | 2 +- .../networks-tab-subheader.test.js | 2 +- .../networks-tab/networks-tab.test.js | 2 +- .../view-quote-price-difference.test.js | 2 +- .../token-allowance/token-allowance.test.js | 2 +- .../token-details/token-details-page.test.js | 2 +- ui/selectors/confirm-transaction.test.js | 2 +- ui/selectors/institutional/selectors.test.js | 2 +- ...nonce-sorted-transactions-selector.test.js | 2 +- ui/selectors/permissions.test.js | 2 +- ui/selectors/selectors.test.js | 18 +- ui/selectors/transactions.test.js | 12 +- ui/store/actions.test.js | 8 +- ui/store/actions.ts | 2 +- .../institutional/institution-actions.test.js | 8 +- ui/store/store.ts | 2 +- 124 files changed, 550 insertions(+), 403 deletions(-) create mode 100644 app/scripts/migrations/086.test.js create mode 100644 app/scripts/migrations/086.ts diff --git a/.storybook/test-data.js b/.storybook/test-data.js index 496094a91..48013e303 100644 --- a/.storybook/test-data.js +++ b/.storybook/test-data.js @@ -599,7 +599,7 @@ const state = { connectedStatusPopoverHasBeenShown: true, swapsWelcomeMessageHasBeenShown: true, defaultHomeActiveTabName: 'Assets', - provider: { + providerConfig: { type: 'goerli', ticker: 'ETH', nickname: '', diff --git a/app/scripts/background.js b/app/scripts/background.js index cce8b1585..257113cea 100644 --- a/app/scripts/background.js +++ b/app/scripts/background.js @@ -219,9 +219,9 @@ browser.runtime.onConnectExternal.addListener(async (...args) => { * @property {object} featureFlags - An object for optional feature flags. * @property {boolean} welcomeScreen - True if welcome screen should be shown. * @property {string} currentLocale - A locale string matching the user's preferred display language. - * @property {object} provider - The current selected network provider. - * @property {string} provider.rpcUrl - The address for the RPC API, if using an RPC API. - * @property {string} provider.type - An identifier for the type of network selected, allows MetaMask to use custom provider strategies for known networks. + * @property {object} providerConfig - The current selected network provider. + * @property {string} providerConfig.rpcUrl - The address for the RPC API, if using an RPC API. + * @property {string} providerConfig.type - An identifier for the type of network selected, allows MetaMask to use custom provider strategies for known networks. * @property {string} networkId - The stringified number of the current network ID. * @property {string} networkStatus - Either "unknown", "available", "unavailable", or "blocked", depending on the status of the currently selected network. * @property {object} accounts - An object mapping lower-case hex addresses to objects with "balance" and "address" keys, both storing hex string values. @@ -462,7 +462,7 @@ export function setupController( setupEnsIpfsResolver({ getCurrentChainId: () => - controller.networkController.store.getState().provider.chainId, + controller.networkController.store.getState().providerConfig.chainId, getIpfsGateway: controller.preferencesController.getIpfsGateway.bind( controller.preferencesController, ), diff --git a/app/scripts/controllers/detect-tokens.js b/app/scripts/controllers/detect-tokens.js index 2b23dd71b..33e765f91 100644 --- a/app/scripts/controllers/detect-tokens.js +++ b/app/scripts/controllers/detect-tokens.js @@ -209,7 +209,7 @@ export default class DetectTokensController { } getChainIdFromNetworkStore(network) { - return network?.store.getState().provider.chainId; + return network?.store.getState().providerConfig.chainId; } /* eslint-disable accessor-pairs */ diff --git a/app/scripts/controllers/detect-tokens.test.js b/app/scripts/controllers/detect-tokens.test.js index d5f6eb7bd..8e7bddd28 100644 --- a/app/scripts/controllers/detect-tokens.test.js +++ b/app/scripts/controllers/detect-tokens.test.js @@ -235,7 +235,7 @@ describe('DetectTokensController', function () { const modifiedNetworkState = { ...networkState, providerConfig: { - ...networkState.provider, + ...networkState.providerConfig, }, }; return cb(modifiedNetworkState); @@ -254,8 +254,10 @@ describe('DetectTokensController', function () { const modifiedNetworkState = { ...networkState, providerConfig: { - ...networkState.provider, - chainId: convertHexToDecimal(networkState.provider.chainId), + ...networkState.providerConfig, + chainId: convertHexToDecimal( + networkState.providerConfig.chainId, + ), }, }; return cb(modifiedNetworkState); diff --git a/app/scripts/controllers/metametrics.test.js b/app/scripts/controllers/metametrics.test.js index dbd0e56c8..9e2a415e8 100644 --- a/app/scripts/controllers/metametrics.test.js +++ b/app/scripts/controllers/metametrics.test.js @@ -65,7 +65,7 @@ const DEFAULT_PAGE_PROPERTIES = { function getMockNetworkController() { let state = { - provider: { + providerConfig: { type: NETWORK_TYPES.GOERLI, chainId: FAKE_CHAIN_ID, }, @@ -134,7 +134,7 @@ function getMetaMetricsController({ return new MetaMetricsController({ segment: segmentInstance || segment, getCurrentChainId: () => - networkController.store.getState().provider.chainId, + networkController.store.getState().providerConfig.chainId, onNetworkDidChange: networkController.onNetworkDidChange.bind(networkController), preferencesStore, @@ -203,7 +203,7 @@ describe('MetaMetricsController', function () { networkController, }); networkController.store.updateState({ - provider: { + providerConfig: { type: 'NEW_NETWORK', chainId: '0xaab', }, diff --git a/app/scripts/controllers/network/network-controller.test.ts b/app/scripts/controllers/network/network-controller.test.ts index 37f8ac579..2099e427e 100644 --- a/app/scripts/controllers/network/network-controller.test.ts +++ b/app/scripts/controllers/network/network-controller.test.ts @@ -164,7 +164,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: 'rpc', rpcUrl: 'http://example-custom-rpc.metamask.io', chainId: '0x9999' as const, @@ -188,7 +188,7 @@ describe('NetworkController', () => { }, "networkId": null, "networkStatus": "unknown", - "provider": { + "providerConfig": { "chainId": "0x9999", "nickname": "Test initial state", "rpcUrl": "http://example-custom-rpc.metamask.io", @@ -212,7 +212,7 @@ describe('NetworkController', () => { }, "networkId": null, "networkStatus": "unknown", - "provider": { + "providerConfig": { "chainId": "0x539", "nickname": "Localhost 8545", "rpcUrl": "http://localhost:8545", @@ -260,7 +260,7 @@ describe('NetworkController', () => { /* @ts-expect-error We're intentionally passing bad input. */ { state: { - provider: invalidProviderConfig, + providerConfig: invalidProviderConfig, }, }, async ({ controller }) => { @@ -279,7 +279,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: networkType, // NOTE: This doesn't need to match the logical chain ID // of the network selected, it just needs to exist @@ -329,7 +329,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: networkType, // NOTE: This doesn't need to match the logical chain ID // of the network selected, it just needs to exist @@ -359,7 +359,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: networkType, // NOTE: This doesn't need to match the logical chain ID // of the network selected, it just needs to exist @@ -399,7 +399,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: networkType, // NOTE: This doesn't need to match the logical chain ID // of the network selected, it just needs to exist @@ -444,7 +444,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: 'rpc', chainId: '0x1337', rpcUrl: 'https://mock-rpc-url', @@ -502,7 +502,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: 'rpc', rpcUrl: 'https://mock-rpc-url', chainId: '0xtest', @@ -540,7 +540,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: 'rpc', rpcUrl: 'https://mock-rpc-url', chainId: '0xtest', @@ -579,7 +579,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: 'rpc', rpcUrl: 'https://mock-rpc-url', chainId: '0xtest', @@ -625,7 +625,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: 'rpc', rpcUrl: 'https://mock-rpc-url', chainId: '0xtest', @@ -705,7 +705,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: 'rpc', rpcUrl: 'https://mock-rpc-url', chainId: '0x1337', @@ -788,7 +788,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: 'goerli', // NOTE: This doesn't need to match the logical chain ID of // the network selected, it just needs to exist @@ -1088,7 +1088,7 @@ describe('NetworkController', () => { nickname: 'Test initial state', }; const initialState = { - provider: providerConfig, + providerConfig, networkDetails: { EIPS: { 1559: true, @@ -1160,7 +1160,7 @@ describe('NetworkController', () => { /* @ts-expect-error We are intentionally not including a chainId in the provider config. */ { state: { - provider: { + providerConfig: { type: 'rpc', rpcUrl: 'http://example-custom-rpc.metamask.io', }, @@ -1192,7 +1192,7 @@ describe('NetworkController', () => { /* @ts-expect-error We are intentionally not including a chainId in the provider config. */ { state: { - provider: { + providerConfig: { type: 'rpc', rpcUrl: 'http://example-custom-rpc.metamask.io', }, @@ -1223,7 +1223,7 @@ describe('NetworkController', () => { /* @ts-expect-error We are intentionally not including a chainId in the provider config. */ { state: { - provider: { + providerConfig: { type: 'rpc', rpcUrl: 'http://example-custom-rpc.metamask.io', }, @@ -1257,7 +1257,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: networkType, // NOTE: This doesn't need to match the logical chain ID of // the network selected, it just needs to exist @@ -1305,7 +1305,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: networkType, // NOTE: This doesn't need to match the logical chain ID of // the network selected, it just needs to exist @@ -1351,7 +1351,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: networkType, // NOTE: This doesn't need to match the logical chain ID of // the network selected, it just needs to exist @@ -1401,7 +1401,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: networkType, // NOTE: This doesn't need to match the logical chain ID of // the network selected, it just needs to exist @@ -1451,7 +1451,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: networkType, // NOTE: This doesn't need to match the logical chain ID // of the network selected, it just needs to exist @@ -1498,7 +1498,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: networkType, // NOTE: This doesn't need to match the logical chain ID // of the network selected, it just needs to exist @@ -1543,7 +1543,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: networkType, // NOTE: This doesn't need to match the logical chain ID of // the network selected, it just needs to exist @@ -1609,7 +1609,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: networkType, // NOTE: This doesn't need to match the logical chain ID of // the network selected, it just needs to exist @@ -1663,7 +1663,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: networkType, // NOTE: This doesn't need to match the logical chain ID // of the network selected, it just needs to exist @@ -1706,7 +1706,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: networkType, // NOTE: This doesn't need to match the logical chain ID // of the network selected, it just needs to exist @@ -1753,7 +1753,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: networkType, // NOTE: This doesn't need to match the logical chain ID of // the network selected, it just needs to exist @@ -1824,7 +1824,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: networkType, // NOTE: This doesn't need to match the logical chain ID of // the network selected, it just needs to exist @@ -1895,7 +1895,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: networkType, // NOTE: This doesn't need to match the logical chain ID of // the network selected, it just needs to exist @@ -1964,7 +1964,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: networkType, // NOTE: This doesn't need to match the logical chain ID of // the network selected, it just needs to exist @@ -2056,7 +2056,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: networkType, // NOTE: This doesn't need to match the logical chain ID of // the network selected, it just needs to exist @@ -2103,7 +2103,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: networkType, // NOTE: This doesn't need to match the logical chain ID of // the network selected, it just needs to exist @@ -2213,7 +2213,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: networkType, // NOTE: This doesn't need to match the logical chain ID of // the network selected, it just needs to exist @@ -2305,7 +2305,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: networkType, // NOTE: This doesn't need to match the logical chain ID of // the network selected, it just needs to exist @@ -2407,7 +2407,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: networkType, // NOTE: This doesn't need to match the logical chain ID // of the network selected, it just needs to exist @@ -2491,7 +2491,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: 'rpc', rpcUrl: 'https://mock-rpc-url', chainId: '0x1337', @@ -2542,7 +2542,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: 'rpc', rpcUrl: 'https://mock-rpc-url', chainId: '0x1337', @@ -2595,7 +2595,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: 'rpc', rpcUrl: 'https://mock-rpc-url', chainId: '0x1337', @@ -2647,7 +2647,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: 'rpc', rpcUrl: 'https://mock-rpc-url', chainId: '0x1337', @@ -2699,7 +2699,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: 'rpc', rpcUrl: 'https://mock-rpc-url', chainId: '0x1337', @@ -2751,7 +2751,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: 'rpc', rpcUrl: 'https://mock-rpc-url', chainId: '0x1337', @@ -2817,7 +2817,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: 'rpc', rpcUrl: 'https://mock-rpc-url', chainId: '0x1337', @@ -2881,7 +2881,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: 'rpc', rpcUrl: 'https://mock-rpc-url', chainId: '0x1337', @@ -2945,7 +2945,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: 'rpc', rpcUrl: 'https://mock-rpc-url', chainId: '0x1337', @@ -3026,7 +3026,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: 'rpc', rpcUrl: 'https://mock-rpc-url', chainId: '0x1337', @@ -3075,7 +3075,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: 'rpc', rpcUrl: 'https://mock-rpc-url', chainId: '0x1337', @@ -3125,7 +3125,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: 'rpc', rpcUrl: 'https://mock-rpc-url', chainId: '0x1337', @@ -3189,7 +3189,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: 'rpc', rpcUrl: 'https://mock-rpc-url', chainId: '0x1337', @@ -3255,7 +3255,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: 'rpc', rpcUrl: 'https://mock-rpc-url', chainId: '0x1337', @@ -3330,7 +3330,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: 'rpc', rpcUrl: 'https://mock-rpc-url', chainId: '0x1337', @@ -3379,7 +3379,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: 'rpc', rpcUrl: 'https://mock-rpc-url', chainId: '0x1337', @@ -3429,7 +3429,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: 'rpc', rpcUrl: 'https://mock-rpc-url', chainId: '0x1337', @@ -3521,7 +3521,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: 'rpc', rpcUrl: 'https://mock-rpc-url', chainId: '0x1337', @@ -3625,7 +3625,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: 'rpc', rpcUrl: 'https://mock-rpc-url', chainId: '0x1337', @@ -3745,7 +3745,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: 'rpc', rpcUrl: 'https://mock-rpc-url', chainId: '0x1337', @@ -3836,7 +3836,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: 'rpc', rpcUrl: 'https://mock-rpc-url', chainId: '0x1337', @@ -3932,7 +3932,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: 'rpc', rpcUrl: 'https://mock-rpc-url', chainId: '0x1337', @@ -4035,7 +4035,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: 'rpc', rpcUrl: 'https://mock-rpc-url', chainId: '0x1337', @@ -4155,7 +4155,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: 'rpc', rpcUrl: 'https://mock-rpc-url', chainId: '0x1337', @@ -4278,7 +4278,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: 'rpc', rpcUrl: 'https://mock-rpc-url-1', chainId: '0x111', @@ -4315,7 +4315,7 @@ describe('NetworkController', () => { await controller.setActiveNetwork('testNetworkConfiguration'); - expect(controller.store.getState().provider).toStrictEqual({ + expect(controller.store.getState().providerConfig).toStrictEqual({ id: 'testNetworkConfiguration', type: 'rpc', rpcUrl: 'https://mock-rpc-url-2', @@ -4334,7 +4334,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: 'rpc', rpcUrl: 'https://mock-rpc-url-1', chainId: '0x111', @@ -4419,7 +4419,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: 'rpc', rpcUrl: 'https://mock-rpc-url-1', chainId: '0x111', @@ -4497,7 +4497,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: 'rpc', rpcUrl: 'https://mock-rpc-url-1', chainId: '0x111', @@ -4643,7 +4643,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: 'rpc', rpcUrl: 'https://mock-rpc-url-1', chainId: '0x111', @@ -4874,7 +4874,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: 'rpc', rpcUrl: 'https://mock-rpc-url', chainId: '0x1337', @@ -4893,7 +4893,7 @@ describe('NetworkController', () => { controller.setProviderType(networkType); - expect(controller.store.getState().provider).toStrictEqual({ + expect(controller.store.getState().providerConfig).toStrictEqual({ type: networkType, rpcUrl: undefined, chainId, @@ -4929,7 +4929,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: 'rpc', rpcUrl: 'https://mock-rpc-url', chainId: '0x1337', @@ -4997,7 +4997,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: 'rpc', rpcUrl: 'https://mock-rpc-url', chainId: '0x1337', @@ -5127,7 +5127,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: 'rpc', rpcUrl: 'https://mock-rpc-url', chainId: '0x1337', @@ -5309,7 +5309,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: networkType, // NOTE: This doesn't need to match the logical chain ID of // the network selected, it just needs to exist @@ -5341,7 +5341,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: networkType, // NOTE: This doesn't need to match the logical chain ID of // the network selected, it just needs to exist @@ -5387,7 +5387,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: networkType, // NOTE: This doesn't need to match the logical chain ID of // the network selected, it just needs to exist @@ -5441,7 +5441,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: networkType, // NOTE: This doesn't need to match the logical chain ID of // the network selected, it just needs to exist @@ -5484,7 +5484,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: networkType, // NOTE: This doesn't need to match the logical chain ID of // the network selected, it just needs to exist @@ -5513,7 +5513,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: networkType, // NOTE: This doesn't need to match the logical chain ID of // the network selected, it just needs to exist @@ -5543,7 +5543,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: networkType, // NOTE: This doesn't need to match the logical chain ID of // the network selected, it just needs to exist @@ -5585,7 +5585,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: networkType, // NOTE: This doesn't need to match the logical chain ID of // the network selected, it just needs to exist @@ -5624,7 +5624,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: networkType, // NOTE: This doesn't need to match the logical chain ID of // the network selected, it just needs to exist @@ -5668,7 +5668,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: 'rpc', rpcUrl: 'https://mock-rpc-url', chainId: '0x1337', @@ -5699,7 +5699,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: 'rpc', rpcUrl: 'https://mock-rpc-url', chainId: '0x1337', @@ -5742,7 +5742,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: 'rpc', rpcUrl: 'https://mock-rpc-url', chainId: '0x1337', @@ -5799,7 +5799,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: 'rpc', rpcUrl: 'https://mock-rpc-url', chainId: '0x1337', @@ -5841,7 +5841,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: 'rpc', rpcUrl: 'https://mock-rpc-url', chainId: '0x1337', @@ -5869,7 +5869,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: 'rpc', rpcUrl: 'https://mock-rpc-url', chainId: '0x1337', @@ -5898,7 +5898,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: 'rpc', rpcUrl: 'https://mock-rpc-url', chainId: '0x1337', @@ -5927,7 +5927,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: 'rpc', rpcUrl: 'https://mock-rpc-url', chainId: '0x1337', @@ -5963,7 +5963,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: 'rpc', rpcUrl: 'https://mock-rpc-url', chainId: '0x1337', @@ -6008,7 +6008,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: networkType, // NOTE: This doesn't need to match the logical chain ID // of the network selected, it just needs to exist @@ -6057,7 +6057,7 @@ describe('NetworkController', () => { }) .mockReturnValue(fakeNetworkClients[1]); await controller.setActiveNetwork('testNetworkConfiguration'); - expect(controller.store.getState().provider).toStrictEqual({ + expect(controller.store.getState().providerConfig).toStrictEqual({ type: 'rpc', id: 'testNetworkConfiguration', rpcUrl: 'https://mock-rpc-url-2', @@ -6076,7 +6076,7 @@ describe('NetworkController', () => { }, }); - expect(controller.store.getState().provider).toStrictEqual({ + expect(controller.store.getState().providerConfig).toStrictEqual({ type: networkType, chainId: '0x111', rpcUrl: 'https://mock-rpc-url-1', @@ -6094,7 +6094,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: networkType, // NOTE: This doesn't need to match the logical chain ID of // the network selected, it just needs to exist @@ -6154,7 +6154,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: networkType, // NOTE: This doesn't need to match the logical chain ID of // the network selected, it just needs to exist @@ -6241,7 +6241,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: networkType, // NOTE: This doesn't need to match the logical chain ID of // the network selected, it just needs to exist @@ -6334,7 +6334,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: networkType, // NOTE: This doesn't need to match the logical chain ID of // the network selected, it just needs to exist @@ -6410,7 +6410,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: networkType, // NOTE: This doesn't need to match the logical chain ID of // the network selected, it just needs to exist @@ -6468,7 +6468,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: networkType, // NOTE: This doesn't need to match the logical chain ID of // the network selected, it just needs to exist @@ -6529,7 +6529,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: networkType, // NOTE: This doesn't need to match the logical chain ID of // the network selected, it just needs to exist @@ -6604,7 +6604,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: networkType, // NOTE: This doesn't need to match the logical chain ID of // the network selected, it just needs to exist @@ -6680,7 +6680,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: networkType, // NOTE: This doesn't need to match the logical chain ID of // the network selected, it just needs to exist @@ -6774,7 +6774,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: 'rpc', rpcUrl: 'https://mock-rpc-url', chainId: '0x1337', @@ -6807,7 +6807,7 @@ describe('NetworkController', () => { }) .mockReturnValue(fakeNetworkClients[1]); await controller.setProviderType('goerli'); - expect(controller.store.getState().provider).toStrictEqual({ + expect(controller.store.getState().providerConfig).toStrictEqual({ type: 'goerli', rpcUrl: undefined, chainId: '0x5', @@ -6824,7 +6824,7 @@ describe('NetworkController', () => { await controller.rollbackToPreviousProvider(); }, }); - expect(controller.store.getState().provider).toStrictEqual({ + expect(controller.store.getState().providerConfig).toStrictEqual({ type: 'rpc', rpcUrl: 'https://mock-rpc-url', chainId: '0x1337', @@ -6842,7 +6842,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: 'rpc', rpcUrl: 'https://mock-rpc-url', chainId: '0x1337', @@ -6893,7 +6893,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: 'rpc', rpcUrl: 'https://mock-rpc-url', chainId: '0x1337', @@ -6969,7 +6969,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: 'rpc', rpcUrl: 'https://mock-rpc-url', chainId: '0x1337', @@ -7049,7 +7049,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: 'rpc', rpcUrl: 'https://mock-rpc-url', chainId: '0x1337', @@ -7116,7 +7116,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: 'rpc', rpcUrl: 'https://mock-rpc-url', chainId: '0x1337', @@ -7165,7 +7165,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: 'rpc', rpcUrl: 'https://mock-rpc-url', chainId: '0x1337', @@ -7216,7 +7216,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: 'rpc', rpcUrl: 'https://mock-rpc-url', chainId: '0x1337', @@ -7267,7 +7267,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: 'rpc', rpcUrl: 'https://mock-rpc-url', chainId: '0x1337', @@ -7332,7 +7332,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: 'rpc', rpcUrl: 'https://mock-rpc-url', chainId: '0x1337', @@ -7781,7 +7781,7 @@ describe('NetworkController', () => { it('should add the given network and not set it to active if the setActive option is not passed (or a falsy value is passed)', async () => { uuidV4Mock.mockImplementationOnce(() => 'networkConfigurationId'); - const originalProvider = { + const originalProviderConfig = { type: NETWORK_TYPES.RPC, rpcUrl: 'https://mock-rpc-url', chainId: '0xtest' as const, @@ -7790,7 +7790,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: originalProvider, + providerConfig: originalProviderConfig, networkConfigurations: { testNetworkConfigurationId: { rpcUrl: 'https://mock-rpc-url', @@ -7813,8 +7813,8 @@ describe('NetworkController', () => { source: MetaMetricsNetworkEventSource.Dapp, }); - expect(controller.store.getState().provider).toStrictEqual( - originalProvider, + expect(controller.store.getState().providerConfig).toStrictEqual( + originalProviderConfig, ); }, ); @@ -7825,7 +7825,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: 'rpc', rpcUrl: 'https://mock-rpc-url', chainId: '0xtest', @@ -7857,7 +7857,7 @@ describe('NetworkController', () => { source: MetaMetricsNetworkEventSource.Dapp, }); - expect(controller.store.getState().provider).toStrictEqual({ + expect(controller.store.getState().providerConfig).toStrictEqual({ ...rpcUrlNetwork, nickname: undefined, rpcPrefs: undefined, @@ -7874,7 +7874,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: 'rpc', rpcUrl: 'https://mock-rpc-url', chainId: '0xtest', @@ -7941,7 +7941,7 @@ describe('NetworkController', () => { await withController( { state: { - provider: { + providerConfig: { type: 'rpc', rpcUrl: 'https://mock-rpc-url', chainId: '0xtest', diff --git a/app/scripts/controllers/network/network-controller.ts b/app/scripts/controllers/network/network-controller.ts index 51c6fad21..463565a54 100644 --- a/app/scripts/controllers/network/network-controller.ts +++ b/app/scripts/controllers/network/network-controller.ts @@ -266,7 +266,7 @@ type NetworkConfigurations = Record< * The state that NetworkController holds after combining its individual stores. */ export type NetworkControllerState = { - provider: ProviderConfiguration; + providerConfig: ProviderConfiguration; networkId: NetworkIdState; networkStatus: NetworkStatus; networkDetails: NetworkDetails; @@ -279,7 +279,7 @@ export type NetworkControllerState = { export type NetworkControllerOptions = { messenger: NetworkControllerMessenger; state?: { - provider?: ProviderConfiguration; + providerConfig?: ProviderConfiguration; networkDetails?: NetworkDetails; networkConfigurations?: NetworkConfigurations; }; @@ -386,7 +386,7 @@ function buildDefaultNetworkConfigurationsState(): NetworkConfigurations { */ function buildDefaultState() { return { - provider: buildDefaultProviderConfigState(), + providerConfig: buildDefaultProviderConfigState(), networkId: buildDefaultNetworkIdState(), networkStatus: buildDefaultNetworkStatusState(), networkDetails: buildDefaultNetworkDetailsState(), @@ -477,7 +477,7 @@ export class NetworkController extends EventEmitter { ...buildDefaultState(), ...state, }); - this.#previousProviderConfig = this.store.getState().provider; + this.#previousProviderConfig = this.store.getState().providerConfig; // provider and block tracker this.#provider = null; @@ -508,7 +508,7 @@ export class NetworkController extends EventEmitter { * using the provider to gather details about the network. */ async initializeProvider(): Promise { - const { type, rpcUrl, chainId } = this.store.getState().provider; + const { type, rpcUrl, chainId } = this.store.getState().providerConfig; this.#configureProvider({ type, rpcUrl, chainId }); await this.lookupNetwork(); } @@ -575,7 +575,7 @@ export class NetworkController extends EventEmitter { * blocking requests, or if the network is not Infura-supported. */ async lookupNetwork(): Promise { - const { chainId, type } = this.store.getState().provider; + const { chainId, type } = this.store.getState().providerConfig; const { provider } = this.getProviderAndBlockTracker(); let networkChanged = false; let networkId: NetworkIdState = null; @@ -754,7 +754,7 @@ export class NetworkController extends EventEmitter { * Re-initializes the provider and block tracker for the current network. */ async resetConnection() { - await this.#setProviderConfig(this.store.getState().provider); + await this.#setProviderConfig(this.store.getState().providerConfig); } /** @@ -765,7 +765,7 @@ export class NetworkController extends EventEmitter { async rollbackToPreviousProvider() { const config = this.#previousProviderConfig; this.store.updateState({ - provider: config, + providerConfig: config, }); await this.#switchNetwork(config); } @@ -850,8 +850,8 @@ export class NetworkController extends EventEmitter { * @param providerConfig - The provider configuration. */ async #setProviderConfig(providerConfig: ProviderConfiguration) { - this.#previousProviderConfig = this.store.getState().provider; - this.store.updateState({ provider: providerConfig }); + this.#previousProviderConfig = this.store.getState().providerConfig; + this.store.updateState({ providerConfig }); await this.#switchNetwork(providerConfig); } diff --git a/app/scripts/lib/setupSentry.js b/app/scripts/lib/setupSentry.js index 03241b288..a383f8221 100644 --- a/app/scripts/lib/setupSentry.js +++ b/app/scripts/lib/setupSentry.js @@ -56,7 +56,7 @@ export const SENTRY_STATE = { nextNonce: true, participateInMetaMetrics: true, preferences: true, - provider: { + providerConfig: { nickname: true, ticker: true, type: true, diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 2fee2e507..ffaa9bfe3 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -285,7 +285,7 @@ export default class MetamaskController extends EventEmitter { this.tokenListController = new TokenListController({ chainId: hexToDecimal( - this.networkController.store.getState().provider.chainId, + this.networkController.store.getState().providerConfig.chainId, ), preventPollingOnNetworkRestart: initState.TokenListController ? initState.TokenListController.preventPollingOnNetworkRestart @@ -295,8 +295,8 @@ export default class MetamaskController extends EventEmitter { const modifiedNetworkState = { ...networkState, providerConfig: { - ...networkState.provider, - chainId: hexToDecimal(networkState.provider.chainId), + ...networkState.providerConfig, + chainId: hexToDecimal(networkState.providerConfig.chainId), }, }; return cb(modifiedNetworkState); @@ -330,7 +330,7 @@ export default class MetamaskController extends EventEmitter { const modifiedNetworkState = { ...networkState, providerConfig: { - ...networkState.provider, + ...networkState.providerConfig, }, }; return cb(modifiedNetworkState); @@ -367,8 +367,8 @@ export default class MetamaskController extends EventEmitter { const modifiedNetworkState = { ...networkState, providerConfig: { - ...networkState.provider, - chainId: hexToDecimal(networkState.provider.chainId), + ...networkState.providerConfig, + chainId: hexToDecimal(networkState.providerConfig.chainId), }, }; return cb(modifiedNetworkState); @@ -392,8 +392,8 @@ export default class MetamaskController extends EventEmitter { const modifiedNetworkState = { ...networkState, providerConfig: { - ...networkState.provider, - chainId: hexToDecimal(networkState.provider.chainId), + ...networkState.providerConfig, + chainId: hexToDecimal(networkState.providerConfig.chainId), }, }; return cb(modifiedNetworkState); @@ -452,8 +452,8 @@ export default class MetamaskController extends EventEmitter { const modifiedNetworkState = { ...networkState, providerConfig: { - ...networkState.provider, - chainId: hexToDecimal(networkState.provider.chainId), + ...networkState.providerConfig, + chainId: hexToDecimal(networkState.providerConfig.chainId), }, }; return cb(modifiedNetworkState); @@ -476,11 +476,11 @@ export default class MetamaskController extends EventEmitter { ), getNetworkIdentifier: () => { const { type, rpcUrl } = - this.networkController.store.getState().provider; + this.networkController.store.getState().providerConfig; return type === NETWORK_TYPES.RPC ? rpcUrl : type; }, getCurrentChainId: () => - this.networkController.store.getState().provider.chainId, + this.networkController.store.getState().providerConfig.chainId, version: this.platform.getVersion(), environment: process.env.METAMASK_ENVIRONMENT, extension: this.extension, @@ -522,13 +522,14 @@ export default class MetamaskController extends EventEmitter { legacyAPIEndpoint: `${gasApiBaseUrl}/networks//gasPrices`, EIP1559APIEndpoint: `${gasApiBaseUrl}/networks//suggestedGasFees`, getCurrentNetworkLegacyGasAPICompatibility: () => { - const { chainId } = this.networkController.store.getState().provider; + const { chainId } = + this.networkController.store.getState().providerConfig; return process.env.IN_TEST || chainId === CHAIN_IDS.MAINNET; }, getChainId: () => { return process.env.IN_TEST ? CHAIN_IDS.MAINNET - : this.networkController.store.getState().provider.chainId; + : this.networkController.store.getState().providerConfig.chainId; }, }); @@ -558,7 +559,8 @@ export default class MetamaskController extends EventEmitter { messenger: currencyRateMessenger, state: { ...initState.CurrencyController, - nativeCurrency: this.networkController.store.getState().provider.ticker, + nativeCurrency: + this.networkController.store.getState().providerConfig.ticker, }, }); @@ -598,8 +600,8 @@ export default class MetamaskController extends EventEmitter { const modifiedNetworkState = { ...networkState, providerConfig: { - ...networkState.provider, - chainId: hexToDecimal(networkState.provider.chainId), + ...networkState.providerConfig, + chainId: hexToDecimal(networkState.providerConfig.chainId), }, }; return cb(modifiedNetworkState); @@ -632,7 +634,7 @@ export default class MetamaskController extends EventEmitter { this.ensController = new EnsController({ provider: this.provider, getCurrentChainId: () => - this.networkController.store.getState().provider.chainId, + this.networkController.store.getState().providerConfig.chainId, onNetworkDidChange: networkControllerMessenger.subscribe.bind( networkControllerMessenger, NetworkControllerEventType.NetworkDidChange, @@ -650,7 +652,7 @@ export default class MetamaskController extends EventEmitter { NetworkControllerEventType.NetworkDidChange, ), getCurrentChainId: () => - this.networkController.store.getState().provider.chainId, + this.networkController.store.getState().providerConfig.chainId, preferencesController: this.preferencesController, onboardingController: this.onboardingController, initState: initState.IncomingTransactionsController, @@ -661,10 +663,10 @@ export default class MetamaskController extends EventEmitter { provider: this.provider, blockTracker: this.blockTracker, getCurrentChainId: () => - this.networkController.store.getState().provider.chainId, + this.networkController.store.getState().providerConfig.chainId, getNetworkIdentifier: () => { const { type, rpcUrl } = - this.networkController.store.getState().provider; + this.networkController.store.getState().providerConfig; return type === NETWORK_TYPES.RPC ? rpcUrl : type; }, preferencesController: this.preferencesController, @@ -701,7 +703,7 @@ export default class MetamaskController extends EventEmitter { this.cachedBalancesController = new CachedBalancesController({ accountTracker: this.accountTracker, getCurrentChainId: () => - this.networkController.store.getState().provider.chainId, + this.networkController.store.getState().providerConfig.chainId, initState: initState.CachedBalancesController, }); @@ -987,7 +989,8 @@ export default class MetamaskController extends EventEmitter { initState: initState.TransactionController || initState.TransactionManager, getPermittedAccounts: this.getPermittedAccounts.bind(this), - getProviderConfig: () => this.networkController.store.getState().provider, + getProviderConfig: () => + this.networkController.store.getState().providerConfig, getCurrentNetworkEIP1559Compatibility: this.networkController.getEIP1559Compatibility.bind( this.networkController, @@ -1008,7 +1011,7 @@ export default class MetamaskController extends EventEmitter { }); }, getCurrentChainId: () => - this.networkController.store.getState().provider.chainId, + this.networkController.store.getState().providerConfig.chainId, preferencesStore: this.preferencesController.store, txHistoryLimit: 60, signTransaction: this.keyringController.signTransaction.bind( @@ -1144,7 +1147,8 @@ export default class MetamaskController extends EventEmitter { networkControllerMessenger.subscribe( NetworkControllerEventType.NetworkDidChange, async () => { - const { ticker } = this.networkController.store.getState().provider; + const { ticker } = + this.networkController.store.getState().providerConfig; try { await this.currencyRateController.setNativeCurrency(ticker); } catch (error) { @@ -1213,10 +1217,11 @@ export default class MetamaskController extends EventEmitter { onNetworkStateChange: (listener) => this.networkController.store.subscribe(listener), provider: this.provider, - getProviderConfig: () => this.networkController.store.getState().provider, + getProviderConfig: () => + this.networkController.store.getState().providerConfig, getTokenRatesState: () => this.tokenRatesController.state, getCurrentChainId: () => - this.networkController.store.getState().provider.chainId, + this.networkController.store.getState().providerConfig.chainId, getEIP1559GasFeeEstimates: this.gasFeeController.fetchGasFeeEstimates.bind(this.gasFeeController), }); @@ -1227,7 +1232,7 @@ export default class MetamaskController extends EventEmitter { const modifiedNetworkState = { ...networkState, providerConfig: { - ...networkState.provider, + ...networkState.providerConfig, }, }; return cb(modifiedNetworkState); @@ -1783,7 +1788,7 @@ export default class MetamaskController extends EventEmitter { updatePublicConfigStore(this.getState()); function updatePublicConfigStore(memState) { - const { chainId } = networkController.store.getState().provider; + const { chainId } = networkController.store.getState().providerConfig; if (memState.networkStatus === NetworkStatus.Available) { publicConfigStore.putState(selectPublicState(chainId, memState)); } @@ -1824,7 +1829,7 @@ export default class MetamaskController extends EventEmitter { getProviderNetworkState(memState) { const { networkId } = memState || this.getState(); return { - chainId: this.networkController.store.getState().provider.chainId, + chainId: this.networkController.store.getState().providerConfig.chainId, networkVersion: networkId ?? 'loading', }; } @@ -2796,7 +2801,8 @@ export default class MetamaskController extends EventEmitter { this.appStateController.setTrezorModel(model); } - keyring.network = this.networkController.store.getState().provider.type; + keyring.network = + this.networkController.store.getState().providerConfig.type; return keyring; } @@ -3668,9 +3674,9 @@ export default class MetamaskController extends EventEmitter { ), getCurrentChainId: () => - this.networkController.store.getState().provider.chainId, + this.networkController.store.getState().providerConfig.chainId, getCurrentRpcUrl: () => - this.networkController.store.getState().provider.rpcUrl, + this.networkController.store.getState().providerConfig.rpcUrl, // network configuration-related getNetworkConfigurations: () => this.networkController.store.getState().networkConfigurations, @@ -4262,7 +4268,9 @@ export default class MetamaskController extends EventEmitter { if (transactionSecurityCheckEnabled) { const chainId = Number( - hexToDecimal(this.networkController.store.getState().provider.chainId), + hexToDecimal( + this.networkController.store.getState().providerConfig.chainId, + ), ); try { diff --git a/app/scripts/metamask-controller.test.js b/app/scripts/metamask-controller.test.js index af2e5c62f..f5cf0ddaa 100644 --- a/app/scripts/metamask-controller.test.js +++ b/app/scripts/metamask-controller.test.js @@ -116,7 +116,7 @@ const MAINNET_CHAIN_ID = '0x1'; const firstTimeState = { config: {}, NetworkController: { - provider: { + providerConfig: { type: NETWORK_TYPES.RPC, rpcUrl: ALT_MAINNET_RPC_URL, chainId: MAINNET_CHAIN_ID, diff --git a/app/scripts/migrations/086.test.js b/app/scripts/migrations/086.test.js new file mode 100644 index 000000000..f38f0444d --- /dev/null +++ b/app/scripts/migrations/086.test.js @@ -0,0 +1,88 @@ +import { migrate, version } from './086'; + +jest.mock('uuid', () => { + const actual = jest.requireActual('uuid'); + + return { + ...actual, + v4: jest.fn(), + }; +}); + +describe('migration #86', () => { + it('should update the version metadata', async () => { + const oldStorage = { + meta: { + version: 85, + }, + data: {}, + }; + + const newStorage = await migrate(oldStorage); + expect(newStorage.meta).toStrictEqual({ + version, + }); + }); + + it('should return state unaltered if there is no network controller state', async () => { + const oldData = { + other: 'data', + }; + const oldStorage = { + meta: { + version: 85, + }, + data: oldData, + }; + + const newStorage = await migrate(oldStorage); + expect(newStorage.data).toStrictEqual(oldData); + }); + + it('should return state unaltered if there is no network controller provider state', async () => { + const oldData = { + other: 'data', + NetworkController: { + networkConfigurations: { + foo: 'bar', + }, + }, + }; + const oldStorage = { + meta: { + version: 85, + }, + data: oldData, + }; + + const newStorage = await migrate(oldStorage); + expect(newStorage.data).toStrictEqual(oldData); + }); + + it('should rename the provider config state', async () => { + const oldData = { + other: 'data', + NetworkController: { + provider: { + some: 'provider', + }, + }, + }; + const oldStorage = { + meta: { + version: 85, + }, + data: oldData, + }; + + const newStorage = await migrate(oldStorage); + expect(newStorage.data).toStrictEqual({ + other: 'data', + NetworkController: { + providerConfig: { + some: 'provider', + }, + }, + }); + }); +}); diff --git a/app/scripts/migrations/086.ts b/app/scripts/migrations/086.ts new file mode 100644 index 000000000..c4b60e270 --- /dev/null +++ b/app/scripts/migrations/086.ts @@ -0,0 +1,41 @@ +import { hasProperty, isObject } from '@metamask/utils'; +import { cloneDeep } from 'lodash'; + +export const version = 86; + +/** + * Rename network controller `provider` state to `providerConfig`. + * + * @param originalVersionedData - Versioned MetaMask extension state, exactly what we persist to dist. + * @param originalVersionedData.meta - State metadata. + * @param originalVersionedData.meta.version - The current state version. + * @param originalVersionedData.data - The persisted MetaMask state, keyed by controller. + * @returns Updated versioned MetaMask extension state. + */ +export async function migrate(originalVersionedData: { + meta: { version: number }; + data: Record; +}) { + const versionedData = cloneDeep(originalVersionedData); + versionedData.meta.version = version; + versionedData.data = transformState(versionedData.data); + return versionedData; +} + +function transformState(state: Record) { + if ( + hasProperty(state, 'NetworkController') && + isObject(state.NetworkController) && + hasProperty(state.NetworkController, 'provider') + ) { + const networkControllerState = state.NetworkController; + networkControllerState.providerConfig = networkControllerState.provider; + delete networkControllerState.provider; + + return { + ...state, + NetworkController: networkControllerState, + }; + } + return state; +} diff --git a/app/scripts/migrations/index.js b/app/scripts/migrations/index.js index 5cbe4ee04..acde4758b 100644 --- a/app/scripts/migrations/index.js +++ b/app/scripts/migrations/index.js @@ -89,6 +89,7 @@ import * as m082 from './082'; import * as m083 from './083'; import * as m084 from './084'; import * as m085 from './085'; +import * as m086 from './086'; const migrations = [ m002, @@ -175,6 +176,7 @@ const migrations = [ m083, m084, m085, + m086, ]; export default migrations; diff --git a/development/states/navigate-txs.json b/development/states/navigate-txs.json index 6a4605e9a..12fc75607 100644 --- a/development/states/navigate-txs.json +++ b/development/states/navigate-txs.json @@ -225,7 +225,7 @@ "preferences": { "useETHAsPrimaryCurrency": true }, - "provider": { + "providerConfig": { "type": "goerli" }, "network": "4", diff --git a/test/data/mock-send-state.json b/test/data/mock-send-state.json index a8d379dcd..0193c3ce5 100644 --- a/test/data/mock-send-state.json +++ b/test/data/mock-send-state.json @@ -115,7 +115,7 @@ "showIncomingTransactions": true }, "network": "5", - "provider": { + "providerConfig": { "type": "rpc", "chainId": "0x5" }, diff --git a/test/data/mock-state.json b/test/data/mock-state.json index 23f79951e..b2a446938 100644 --- a/test/data/mock-state.json +++ b/test/data/mock-state.json @@ -111,7 +111,7 @@ }, "networkId": "5", "networkStatus": "available", - "provider": { + "providerConfig": { "type": "rpc", "chainId": "0x5", "ticker": "ETH", diff --git a/test/e2e/fixture-builder.js b/test/e2e/fixture-builder.js index bb844ba4a..d82b2ef45 100644 --- a/test/e2e/fixture-builder.js +++ b/test/e2e/fixture-builder.js @@ -197,7 +197,7 @@ function defaultFixture() { NetworkController: { networkId: '1337', networkStatus: 'available', - provider: { + providerConfig: { chainId: CHAIN_IDS.LOCALHOST, nickname: 'Localhost 8545', rpcPrefs: {}, @@ -329,7 +329,7 @@ function onboardingFixture() { NetworkController: { networkId: '1337', networkStatus: 'available', - provider: { + providerConfig: { ticker: 'ETH', type: 'rpc', rpcUrl: 'http://localhost:8545', diff --git a/test/e2e/tests/ens.spec.js b/test/e2e/tests/ens.spec.js index 136f06df1..be48816c9 100644 --- a/test/e2e/tests/ens.spec.js +++ b/test/e2e/tests/ens.spec.js @@ -80,7 +80,7 @@ describe('ENS', function () { { fixtures: new FixtureBuilder() .withNetworkController({ - provider: { + providerConfig: { chainId: '0x1', nickname: '', rpcUrl: '', diff --git a/test/jest/mock-store.js b/test/jest/mock-store.js index 80c477a10..80934403b 100644 --- a/test/jest/mock-store.js +++ b/test/jest/mock-store.js @@ -137,7 +137,7 @@ export const createSwapsMockStore = () => { 1559: false, }, }, - provider: { + providerConfig: { chainId: CHAIN_IDS.MAINNET, }, cachedBalances: { diff --git a/ui/components/app/account-menu/account-menu.test.js b/ui/components/app/account-menu/account-menu.test.js index 504631350..90a3d6a42 100644 --- a/ui/components/app/account-menu/account-menu.test.js +++ b/ui/components/app/account-menu/account-menu.test.js @@ -43,7 +43,7 @@ const initialProps = { const mockStore = { metamask: { - provider: { + providerConfig: { type: 'test', }, preferences: { diff --git a/ui/components/app/advanced-gas-controls/advanced-gas-controls.test.js b/ui/components/app/advanced-gas-controls/advanced-gas-controls.test.js index bd6007774..6a15f9c6b 100644 --- a/ui/components/app/advanced-gas-controls/advanced-gas-controls.test.js +++ b/ui/components/app/advanced-gas-controls/advanced-gas-controls.test.js @@ -7,7 +7,7 @@ import AdvancedGasControls from './advanced-gas-controls.component'; const renderComponent = (props) => { const store = configureMockStore([])({ - metamask: { identities: [], provider: {} }, + metamask: { identities: [], providerConfig: {} }, }); return renderWithProvider(, store); }; diff --git a/ui/components/app/advanced-gas-inputs/advanced-gas-inputs.test.js b/ui/components/app/advanced-gas-inputs/advanced-gas-inputs.test.js index cff1c62d1..c1db0ef69 100644 --- a/ui/components/app/advanced-gas-inputs/advanced-gas-inputs.test.js +++ b/ui/components/app/advanced-gas-inputs/advanced-gas-inputs.test.js @@ -20,7 +20,7 @@ describe('AdvancedGasInputs', () => { minimumGasLimit: 21000, }; - const store = configureStore({ metamask: { provider: {} } }); + const store = configureStore({ metamask: { providerConfig: {} } }); beforeEach(() => { clock = sinon.useFakeTimers(); diff --git a/ui/components/app/alerts/unconnected-account-alert/unconnected-account-alert.test.js b/ui/components/app/alerts/unconnected-account-alert/unconnected-account-alert.test.js index c710da525..10c514743 100644 --- a/ui/components/app/alerts/unconnected-account-alert/unconnected-account-alert.test.js +++ b/ui/components/app/alerts/unconnected-account-alert/unconnected-account-alert.test.js @@ -64,7 +64,7 @@ describe('Unconnected Account Alert', () => { accounts, cachedBalances, keyrings, - provider: { + providerConfig: { chainId: CHAIN_IDS, }, permissionHistory: { diff --git a/ui/components/app/confirm-gas-display/confirm-legacy-gas-display/confirm-legacy-gas-display.test.js b/ui/components/app/confirm-gas-display/confirm-legacy-gas-display/confirm-legacy-gas-display.test.js index 2de3c0f54..1d975e19e 100644 --- a/ui/components/app/confirm-gas-display/confirm-legacy-gas-display/confirm-legacy-gas-display.test.js +++ b/ui/components/app/confirm-gas-display/confirm-legacy-gas-display/confirm-legacy-gas-display.test.js @@ -111,13 +111,13 @@ describe('ConfirmLegacyGasDisplay', () => { }); it('should contain L1 L2 fee details for optimism', async () => { - mmState.metamask.provider.chainId = CHAIN_IDS.OPTIMISM; + mmState.metamask.providerConfig.chainId = CHAIN_IDS.OPTIMISM; mmState.confirmTransaction.txData.chainId = CHAIN_IDS.OPTIMISM; const state = { metamask: { ...mmState.metamask, - provider: { - ...mmState.metamask.provider, + providerConfig: { + ...mmState.metamask.providerConfig, chainId: CHAIN_IDS.OPTIMISM, }, }, diff --git a/ui/components/app/confirm-page-container/confirm-detail-row/confirm-detail-row.component.test.js b/ui/components/app/confirm-page-container/confirm-detail-row/confirm-detail-row.component.test.js index 52c795265..9edd0c53b 100644 --- a/ui/components/app/confirm-page-container/confirm-detail-row/confirm-detail-row.component.test.js +++ b/ui/components/app/confirm-page-container/confirm-detail-row/confirm-detail-row.component.test.js @@ -7,7 +7,7 @@ import ConfirmDetailRow from '.'; describe('Confirm Detail Row Component', () => { const mockState = { metamask: { - provider: { + providerConfig: { type: 'rpc', chainId: '0x5', }, diff --git a/ui/components/app/confirm-page-container/confirm-page-container-content/confirm-page-container-content.component.test.js b/ui/components/app/confirm-page-container/confirm-page-container-content/confirm-page-container-content.component.test.js index 2918c167c..5d6e5dfdc 100644 --- a/ui/components/app/confirm-page-container/confirm-page-container-content/confirm-page-container-content.component.test.js +++ b/ui/components/app/confirm-page-container/confirm-page-container-content/confirm-page-container-content.component.test.js @@ -13,7 +13,7 @@ import ConfirmPageContainerContent from './confirm-page-container-content.compon describe('Confirm Page Container Content', () => { const mockStore = { metamask: { - provider: { + providerConfig: { type: 'test', chainId: '0x5', }, diff --git a/ui/components/app/confirm-page-container/confirm-page-container-header/confirm-page-container-header.component.test.js b/ui/components/app/confirm-page-container/confirm-page-container-header/confirm-page-container-header.component.test.js index e616f04a4..cca653ded 100644 --- a/ui/components/app/confirm-page-container/confirm-page-container-header/confirm-page-container-header.component.test.js +++ b/ui/components/app/confirm-page-container/confirm-page-container-header/confirm-page-container-header.component.test.js @@ -13,7 +13,7 @@ describe('Confirm Detail Row Component', () => { const mockState = { metamask: { networkStatus: 'available', - provider: { + providerConfig: { type: 'rpc', chainId: '0x5', }, diff --git a/ui/components/app/confirm-subtitle/confirm-subtitle.test.js b/ui/components/app/confirm-subtitle/confirm-subtitle.test.js index 41cdc3da4..b8218029a 100644 --- a/ui/components/app/confirm-subtitle/confirm-subtitle.test.js +++ b/ui/components/app/confirm-subtitle/confirm-subtitle.test.js @@ -46,7 +46,7 @@ describe('ConfirmSubTitle', () => { mockState.metamask.preferences.showFiatInTestnets = false; mockState.metamask.allNftContracts = { [mockState.metamask.selectedAddress]: { - [hexToDecimal(mockState.metamask.provider.chainId)]: [ + [hexToDecimal(mockState.metamask.providerConfig.chainId)]: [ { address: '0x9' }, ], }, diff --git a/ui/components/app/contact-list/contact-list.test.js b/ui/components/app/contact-list/contact-list.test.js index fd03336e8..fce0619ae 100644 --- a/ui/components/app/contact-list/contact-list.test.js +++ b/ui/components/app/contact-list/contact-list.test.js @@ -6,7 +6,7 @@ import ContactList from '.'; describe('Contact List', () => { const store = configureMockStore([])({ - metamask: { provider: { chainId: '0x0' } }, + metamask: { providerConfig: { chainId: '0x0' } }, }); describe('given searchForContacts', () => { diff --git a/ui/components/app/currency-input/currency-input.test.js b/ui/components/app/currency-input/currency-input.test.js index a870cfe99..91ab46b71 100644 --- a/ui/components/app/currency-input/currency-input.test.js +++ b/ui/components/app/currency-input/currency-input.test.js @@ -10,7 +10,7 @@ describe('CurrencyInput Component', () => { nativeCurrency: 'ETH', currentCurrency: 'usd', conversionRate: 231.06, - provider: { + providerConfig: { chainId: '0x5', }, preferences: { diff --git a/ui/components/app/dropdowns/network-dropdown.js b/ui/components/app/dropdowns/network-dropdown.js index 6ac6ef543..3c1ceb8e2 100644 --- a/ui/components/app/dropdowns/network-dropdown.js +++ b/ui/components/app/dropdowns/network-dropdown.js @@ -56,7 +56,7 @@ const DROP_DOWN_MENU_ITEM_STYLE = { function mapStateToProps(state) { return { - provider: getProviderConfig(state), + providerConfig: getProviderConfig(state), shouldShowTestNetworks: getShowTestNetworks(state), networkConfigurations: state.metamask.networkConfigurations, networkDropdownOpen: state.appState.networkDropdownOpen, @@ -98,7 +98,7 @@ class NetworkDropdown extends Component { }; static propTypes = { - provider: PropTypes.shape({ + providerConfig: PropTypes.shape({ nickname: PropTypes.string, rpcUrl: PropTypes.string, type: PropTypes.string, @@ -123,7 +123,7 @@ class NetworkDropdown extends Component { handleClick(newProviderType) { const { - provider: { type: providerType }, + providerConfig: { type: providerType }, setProviderType, } = this.props; const { trackEvent } = this.context; @@ -164,12 +164,13 @@ class NetworkDropdown extends Component { ); } - renderCustomRpcList(networkConfigurations, provider, opts = {}) { + renderCustomRpcList(networkConfigurations, providerConfig, opts = {}) { return Object.entries(networkConfigurations).map( ([networkConfigurationId, networkConfiguration]) => { const { rpcUrl, chainId, nickname = '', id } = networkConfiguration; const isCurrentRpcTarget = - provider.type === NETWORK_TYPES.RPC && rpcUrl === provider.rpcUrl; + providerConfig.type === NETWORK_TYPES.RPC && + rpcUrl === providerConfig.rpcUrl; return ( diff --git a/ui/components/app/dropdowns/network-dropdown.test.js b/ui/components/app/dropdowns/network-dropdown.test.js index a4a1f6398..a54807e41 100644 --- a/ui/components/app/dropdowns/network-dropdown.test.js +++ b/ui/components/app/dropdowns/network-dropdown.test.js @@ -23,7 +23,7 @@ describe('Network Dropdown', () => { metamask: { networkId: '1', networkStatus: 'available', - provider: { + providerConfig: { type: 'test', }, showTestnetMessageInDropdown: false, @@ -58,7 +58,7 @@ describe('Network Dropdown', () => { metamask: { networkId: '1', networkStatus: 'available', - provider: { + providerConfig: { type: 'test', }, showTestnetMessageInDropdown: false, @@ -137,7 +137,7 @@ describe('Network Dropdown', () => { metamask: { networkId: '1', networkStatus: 'available', - provider: { + providerConfig: { type: 'test', }, showTestnetMessageInDropdown: false, diff --git a/ui/components/app/edit-gas-fee-popover/edit-gas-fee-popover.test.js b/ui/components/app/edit-gas-fee-popover/edit-gas-fee-popover.test.js index 5fec41f57..3e371a05d 100644 --- a/ui/components/app/edit-gas-fee-popover/edit-gas-fee-popover.test.js +++ b/ui/components/app/edit-gas-fee-popover/edit-gas-fee-popover.test.js @@ -53,7 +53,7 @@ const render = ({ txProps, contextProps } = {}) => { const store = configureStore({ metamask: { nativeCurrency: ETH, - provider: {}, + providerConfig: {}, cachedBalances: {}, accounts: { '0xAddress': { diff --git a/ui/components/app/edit-gas-fee-popover/edit-gas-item/edit-gas-item.test.js b/ui/components/app/edit-gas-fee-popover/edit-gas-item/edit-gas-item.test.js index 653b23d8a..44ac34b87 100644 --- a/ui/components/app/edit-gas-fee-popover/edit-gas-item/edit-gas-item.test.js +++ b/ui/components/app/edit-gas-fee-popover/edit-gas-item/edit-gas-item.test.js @@ -59,7 +59,7 @@ const renderComponent = ({ const store = configureStore({ metamask: { nativeCurrency: ETH, - provider: {}, + providerConfig: {}, cachedBalances: {}, accounts: { '0xAddress': { diff --git a/ui/components/app/edit-gas-fee-popover/edit-gas-tooltip/edit-gas-tooltip.test.js b/ui/components/app/edit-gas-fee-popover/edit-gas-tooltip/edit-gas-tooltip.test.js index 6c9adbadb..dbeda43ac 100644 --- a/ui/components/app/edit-gas-fee-popover/edit-gas-tooltip/edit-gas-tooltip.test.js +++ b/ui/components/app/edit-gas-fee-popover/edit-gas-tooltip/edit-gas-tooltip.test.js @@ -33,7 +33,7 @@ const HIGH_GAS_OPTION = { const renderComponent = (componentProps) => { const mockStore = { metamask: { - provider: {}, + providerConfig: {}, cachedBalances: {}, accounts: { '0xAddress': { diff --git a/ui/components/app/gas-details-item/gas-details-item-title/gas-details-item-title.test.js b/ui/components/app/gas-details-item/gas-details-item-title/gas-details-item-title.test.js index 809932567..9d8f36c4e 100644 --- a/ui/components/app/gas-details-item/gas-details-item-title/gas-details-item-title.test.js +++ b/ui/components/app/gas-details-item/gas-details-item-title/gas-details-item-title.test.js @@ -20,7 +20,7 @@ jest.mock('../../../../store/actions', () => ({ const render = () => { const store = configureStore({ metamask: { - provider: { chainId: CHAIN_IDS.MAINNET }, + providerConfig: { chainId: CHAIN_IDS.MAINNET }, cachedBalances: {}, accounts: { '0xAddress': { diff --git a/ui/components/app/import-token-link/import-token-link.test.js b/ui/components/app/import-token-link/import-token-link.test.js index 551858532..504ab5ce3 100644 --- a/ui/components/app/import-token-link/import-token-link.test.js +++ b/ui/components/app/import-token-link/import-token-link.test.js @@ -26,7 +26,7 @@ describe('Import Token Link', () => { it('should match snapshot for goerli chainId', () => { const mockState = { metamask: { - provider: { + providerConfig: { chainId: '0x5', }, }, @@ -42,7 +42,7 @@ describe('Import Token Link', () => { it('should match snapshot for mainnet chainId', () => { const mockState = { metamask: { - provider: { + providerConfig: { chainId: '0x1', }, }, @@ -58,7 +58,7 @@ describe('Import Token Link', () => { it('should detectNewTokens when clicking refresh', () => { const mockState = { metamask: { - provider: { + providerConfig: { chainId: '0x5', }, }, @@ -77,7 +77,7 @@ describe('Import Token Link', () => { it('should push import token route', () => { const mockState = { metamask: { - provider: { + providerConfig: { chainId: '0x5', }, }, diff --git a/ui/components/app/loading-network-screen/loading-network-screen.component.js b/ui/components/app/loading-network-screen/loading-network-screen.component.js index 9a258557d..72c4ea31e 100644 --- a/ui/components/app/loading-network-screen/loading-network-screen.component.js +++ b/ui/components/app/loading-network-screen/loading-network-screen.component.js @@ -17,7 +17,7 @@ export default class LoadingNetworkScreen extends PureComponent { static propTypes = { loadingMessage: PropTypes.string, cancelTime: PropTypes.number, - provider: PropTypes.oneOfType([PropTypes.string, PropTypes.object]), + providerConfig: PropTypes.object, providerId: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), showNetworkDropdown: PropTypes.func, setProviderArgs: PropTypes.array, @@ -38,8 +38,8 @@ export default class LoadingNetworkScreen extends PureComponent { if (loadingMessage) { return loadingMessage; } - const { provider, providerId } = this.props; - const providerName = provider.type; + const { providerConfig, providerId } = this.props; + const providerName = providerConfig.type; const { t } = this.context; switch (providerName) { @@ -125,9 +125,9 @@ export default class LoadingNetworkScreen extends PureComponent { }; componentDidUpdate = (prevProps) => { - const { provider } = this.props; - const { provider: prevProvider } = prevProps; - if (provider.type !== prevProvider.type) { + const { providerConfig } = this.props; + const { providerConfig: prevProvider } = prevProps; + if (providerConfig.type !== prevProvider.type) { window.clearTimeout(this.cancelCallTimeout); this.setState({ showErrorScreen: false }); this.cancelCallTimeout = setTimeout( diff --git a/ui/components/app/loading-network-screen/loading-network-screen.container.js b/ui/components/app/loading-network-screen/loading-network-screen.container.js index c67db5119..badf2b723 100644 --- a/ui/components/app/loading-network-screen/loading-network-screen.container.js +++ b/ui/components/app/loading-network-screen/loading-network-screen.container.js @@ -9,8 +9,8 @@ const DEPRECATED_TEST_NET_CHAINIDS = ['0x3', '0x2a', '0x4']; const mapStateToProps = (state) => { const { loadingMessage } = state.appState; - const provider = getProviderConfig(state); - const { rpcUrl, chainId, ticker, nickname, type } = provider; + const providerConfig = getProviderConfig(state); + const { rpcUrl, chainId, ticker, nickname, type } = providerConfig; const setProviderArgs = type === NETWORK_TYPES.RPC ? [rpcUrl, chainId, ticker, nickname] : [type]; @@ -25,7 +25,7 @@ const mapStateToProps = (state) => { isNetworkLoading: isNetworkLoading(state), loadingMessage, setProviderArgs, - provider, + providerConfig, providerId: getNetworkIdentifier(state), showDeprecatedRpcUrlWarning, }; diff --git a/ui/components/app/menu-bar/menu-bar.test.js b/ui/components/app/menu-bar/menu-bar.test.js index 2a148a54a..03db1f1ef 100644 --- a/ui/components/app/menu-bar/menu-bar.test.js +++ b/ui/components/app/menu-bar/menu-bar.test.js @@ -9,7 +9,7 @@ import MenuBar from './menu-bar'; const initState = { activeTab: {}, metamask: { - provider: { + providerConfig: { chainId: CHAIN_IDS.GOERLI, }, selectedAddress: '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc', diff --git a/ui/components/app/modals/account-details-modal/account-details-modal.test.js b/ui/components/app/modals/account-details-modal/account-details-modal.test.js index a66c4fc12..72bf233c2 100644 --- a/ui/components/app/modals/account-details-modal/account-details-modal.test.js +++ b/ui/components/app/modals/account-details-modal/account-details-modal.test.js @@ -86,7 +86,7 @@ describe('Account Details Modal', () => { }, }, }, - provider: { + providerConfig: { chainId: '0x99', }, }, diff --git a/ui/components/app/modals/cancel-transaction/cancel-transaction-gas-fee/cancel-transaction-gas-fee.component.test.js b/ui/components/app/modals/cancel-transaction/cancel-transaction-gas-fee/cancel-transaction-gas-fee.component.test.js index bfbf7a61d..31b225e53 100644 --- a/ui/components/app/modals/cancel-transaction/cancel-transaction-gas-fee/cancel-transaction-gas-fee.component.test.js +++ b/ui/components/app/modals/cancel-transaction/cancel-transaction-gas-fee/cancel-transaction-gas-fee.component.test.js @@ -6,7 +6,7 @@ import CancelTransactionGasFee from './cancel-transaction-gas-fee.component'; describe('CancelTransactionGasFee Component', () => { const mockState = { metamask: { - provider: { + providerConfig: { chainId: '0x4', }, preferences: { diff --git a/ui/components/app/modals/confirm-remove-account/confirm-remove-account.test.js b/ui/components/app/modals/confirm-remove-account/confirm-remove-account.test.js index 444188919..39e353565 100644 --- a/ui/components/app/modals/confirm-remove-account/confirm-remove-account.test.js +++ b/ui/components/app/modals/confirm-remove-account/confirm-remove-account.test.js @@ -7,7 +7,7 @@ import ConfirmRemoveAccount from '.'; describe('Confirm Remove Account', () => { const state = { metamask: { - provider: { + providerConfig: { chainId: '0x99', }, }, diff --git a/ui/components/app/nft-details/nft-details.test.js b/ui/components/app/nft-details/nft-details.test.js index 57e99f25a..6985b31ec 100644 --- a/ui/components/app/nft-details/nft-details.test.js +++ b/ui/components/app/nft-details/nft-details.test.js @@ -170,7 +170,7 @@ describe('NFT Details', () => { ...mockState, metamask: { ...mockState.metamask, - provider: { + providerConfig: { chainId: '0x1', }, }, @@ -200,7 +200,7 @@ describe('NFT Details', () => { ...mockState, metamask: { ...mockState.metamask, - provider: { + providerConfig: { chainId: '0x89', }, }, @@ -230,7 +230,7 @@ describe('NFT Details', () => { ...mockState, metamask: { ...mockState.metamask, - provider: { + providerConfig: { chainId: '0xaa36a7', }, }, @@ -260,7 +260,7 @@ describe('NFT Details', () => { ...mockState, metamask: { ...mockState.metamask, - provider: { + providerConfig: { chainId: '0x99', }, }, diff --git a/ui/components/app/nfts-tab/nfts-tab.test.js b/ui/components/app/nfts-tab/nfts-tab.test.js index 39cf054fb..57d8f42a8 100644 --- a/ui/components/app/nfts-tab/nfts-tab.test.js +++ b/ui/components/app/nfts-tab/nfts-tab.test.js @@ -166,7 +166,7 @@ const render = ({ [chainIdAsDecimal]: nftContracts, }, }, - provider: { chainId }, + providerConfig: { chainId }, selectedAddress, useNftDetection, nftsDropdownState, diff --git a/ui/components/app/signature-request-original/signature-request-original.component.js b/ui/components/app/signature-request-original/signature-request-original.component.js index c422553bf..cfabd20bb 100644 --- a/ui/components/app/signature-request-original/signature-request-original.component.js +++ b/ui/components/app/signature-request-original/signature-request-original.component.js @@ -72,7 +72,7 @@ export default class SignatureRequestOriginal extends Component { messagesCount: PropTypes.number, showRejectTransactionsConfirmationModal: PropTypes.func.isRequired, cancelAll: PropTypes.func.isRequired, - provider: PropTypes.object, + providerConfig: PropTypes.object, ///: BEGIN:ONLY_INCLUDE_IN(build-mmi) selectedAccount: PropTypes.object, ///: END:ONLY_INCLUDE_IN @@ -83,8 +83,8 @@ export default class SignatureRequestOriginal extends Component { }; getNetworkName() { - const { provider } = this.props; - const providerName = provider.type; + const { providerConfig } = this.props; + const providerName = providerConfig.type; const { t } = this.context; switch (providerName) { @@ -99,7 +99,7 @@ export default class SignatureRequestOriginal extends Component { case NETWORK_TYPES.LOCALHOST: return t('localhost'); default: - return provider.nickname || t('unknownNetwork'); + return providerConfig.nickname || t('unknownNetwork'); } } diff --git a/ui/components/app/signature-request-original/signature-request-original.container.js b/ui/components/app/signature-request-original/signature-request-original.container.js index 4e1b238a6..7ab93113a 100644 --- a/ui/components/app/signature-request-original/signature-request-original.container.js +++ b/ui/components/app/signature-request-original/signature-request-original.container.js @@ -31,7 +31,7 @@ function mapStateToProps(state, ownProps) { const { msgParams: { from }, } = ownProps.txData; - const provider = getProviderConfig(state); + const providerConfig = getProviderConfig(state); const hardwareWalletRequiresConnection = doesAddressRequireLedgerHidConnection(state, from); @@ -56,7 +56,7 @@ function mapStateToProps(state, ownProps) { subjectMetadata: getSubjectMetadata(state), messagesList, messagesCount, - provider, + providerConfig, ///: BEGIN:ONLY_INCLUDE_IN(build-mmi) selectedAccount: getSelectedAccount(state), ///: END:ONLY_INCLUDE_IN diff --git a/ui/components/app/signature-request-original/signature-request-original.stories.js b/ui/components/app/signature-request-original/signature-request-original.stories.js index 806df6245..df8d450cc 100644 --- a/ui/components/app/signature-request-original/signature-request-original.stories.js +++ b/ui/components/app/signature-request-original/signature-request-original.stories.js @@ -73,7 +73,7 @@ export default { }, mostRecentOverviewPage: '/', nativeCurrency: 'ETH', - provider: { name: 'Goerli ETH' }, + providerConfig: { name: 'Goerli ETH' }, selectedAccount: MOCK_PRIMARY_IDENTITY, }, }; diff --git a/ui/components/app/signature-request/signature-request-data/signature-request-data.test.js b/ui/components/app/signature-request/signature-request-data/signature-request-data.test.js index c6fabe549..fd90d85db 100644 --- a/ui/components/app/signature-request/signature-request-data/signature-request-data.test.js +++ b/ui/components/app/signature-request/signature-request-data/signature-request-data.test.js @@ -34,7 +34,7 @@ describe('Signature Request Data', () => { unlisted: false, }, }, - provider: { + providerConfig: { type: 'test', chainId: '0x5', }, diff --git a/ui/components/app/signature-request/signature-request.component.js b/ui/components/app/signature-request/signature-request.component.js index 925d2ed6d..75d5708d6 100644 --- a/ui/components/app/signature-request/signature-request.component.js +++ b/ui/components/app/signature-request/signature-request.component.js @@ -85,7 +85,7 @@ export default class SignatureRequest extends PureComponent { nativeCurrency: PropTypes.string, currentCurrency: PropTypes.string.isRequired, conversionRate: PropTypes.number, - provider: PropTypes.object, + providerConfig: PropTypes.object, subjectMetadata: PropTypes.object, unapprovedMessagesCount: PropTypes.number, clearConfirmTransaction: PropTypes.func.isRequired, @@ -122,8 +122,8 @@ export default class SignatureRequest extends PureComponent { } getNetworkName() { - const { provider } = this.props; - const providerName = provider.type; + const { providerConfig } = this.props; + const providerName = providerConfig.type; const { t } = this.context; switch (providerName) { @@ -138,7 +138,7 @@ export default class SignatureRequest extends PureComponent { case NETWORK_TYPES.LOCALHOST: return t('localhost'); default: - return provider.nickname || t('unknownNetwork'); + return providerConfig.nickname || t('unknownNetwork'); } } diff --git a/ui/components/app/signature-request/signature-request.component.test.js b/ui/components/app/signature-request/signature-request.component.test.js index de30703d0..935485840 100644 --- a/ui/components/app/signature-request/signature-request.component.test.js +++ b/ui/components/app/signature-request/signature-request.component.test.js @@ -15,7 +15,7 @@ const baseProps = { showRejectTransactionsConfirmationModal: () => undefined, sign: () => undefined, history: { push: '/' }, - provider: { type: 'rpc' }, + providerConfig: { type: 'rpc' }, nativeCurrency: 'ABC', currentCurrency: 'def', fromAccount: { diff --git a/ui/components/app/signature-request/signature-request.container.js b/ui/components/app/signature-request/signature-request.container.js index 5d3be6ea1..0be3f4c42 100644 --- a/ui/components/app/signature-request/signature-request.container.js +++ b/ui/components/app/signature-request/signature-request.container.js @@ -31,7 +31,7 @@ function mapStateToProps(state, ownProps) { const { msgParams: { from }, } = txData; - const provider = getProviderConfig(state); + const providerConfig = getProviderConfig(state); const hardwareWalletRequiresConnection = doesAddressRequireLedgerHidConnection(state, from); @@ -43,7 +43,7 @@ function mapStateToProps(state, ownProps) { const { useNativeCurrencyAsPrimaryCurrency } = getPreferences(state); return { - provider, + providerConfig, isLedgerWallet, hardwareWalletRequiresConnection, chainId, @@ -96,7 +96,7 @@ function mergeProps(stateProps, dispatchProps, ownProps) { nativeCurrency, currentCurrency, conversionRate, - provider, + providerConfig, subjectMetadata, unconfirmedMessagesList, unapprovedMessagesCount, @@ -149,7 +149,7 @@ function mergeProps(stateProps, dispatchProps, ownProps) { nativeCurrency, currentCurrency, conversionRate, - provider, + providerConfig, subjectMetadata, unapprovedMessagesCount, mostRecentOverviewPage, diff --git a/ui/components/app/signature-request/signature-request.container.test.js b/ui/components/app/signature-request/signature-request.container.test.js index 54a60c889..440c9b5e5 100644 --- a/ui/components/app/signature-request/signature-request.container.test.js +++ b/ui/components/app/signature-request/signature-request.container.test.js @@ -46,7 +46,7 @@ const mockStoreWithEth = { }, }, }, - provider: { + providerConfig: { type: 'rpc', }, preferences: { @@ -92,7 +92,7 @@ describe('Signature Request', () => { cancel: sinon.stub().resolves(), showRejectTransactionsConfirmationModal: sinon.stub().resolves(), cancelAll: sinon.stub().resolves(), - provider: { + providerConfig: { type: 'rpc', }, unapprovedMessagesCount: 2, diff --git a/ui/components/app/signature-request/signature-request.stories.js b/ui/components/app/signature-request/signature-request.stories.js index cfd118c5b..fbae8f99c 100644 --- a/ui/components/app/signature-request/signature-request.stories.js +++ b/ui/components/app/signature-request/signature-request.stories.js @@ -77,7 +77,7 @@ DefaultStory.args = { }, }, fromAccount: MOCK_PRIMARY_IDENTITY, - provider: { name: 'Goerli ETH' }, + providerConfig: { name: 'Goerli ETH' }, selectedAccount: MOCK_PRIMARY_IDENTITY, }; diff --git a/ui/components/app/token-cell/token-cell.test.js b/ui/components/app/token-cell/token-cell.test.js index 8179047e8..05c0157b8 100644 --- a/ui/components/app/token-cell/token-cell.test.js +++ b/ui/components/app/token-cell/token-cell.test.js @@ -15,7 +15,7 @@ describe('Token Cell', () => { }, conversionRate: 7.0, preferences: {}, - provider: { + providerConfig: { chainId: '0x1', ticker: 'ETH', type: 'mainnet', diff --git a/ui/components/app/transaction-activity-log/transaction-activity-log.container.test.js b/ui/components/app/transaction-activity-log/transaction-activity-log.container.test.js index 1eb79d514..4f81bfd59 100644 --- a/ui/components/app/transaction-activity-log/transaction-activity-log.container.test.js +++ b/ui/components/app/transaction-activity-log/transaction-activity-log.container.test.js @@ -18,7 +18,7 @@ describe('TransactionActivityLog container', () => { conversionRate: 280.45, nativeCurrency: 'ETH', networkConfigurations: {}, - provider: { + providerConfig: { ticker: 'ETH', }, }, @@ -41,7 +41,7 @@ describe('TransactionActivityLog container', () => { rpcUrl: 'https://customnetwork.com/', }, }, - provider: { + providerConfig: { rpcUrl: 'https://customnetwork.com/', ticker: 'ETH', rpcPrefs: { diff --git a/ui/components/app/transaction-alerts/transaction-alerts.stories.js b/ui/components/app/transaction-alerts/transaction-alerts.stories.js index 7cb5886fe..701764f26 100644 --- a/ui/components/app/transaction-alerts/transaction-alerts.stories.js +++ b/ui/components/app/transaction-alerts/transaction-alerts.stories.js @@ -19,7 +19,7 @@ const customTransaction = ({ blockNumber: `${10902987 + i}`, id: 4678200543090545 + i, metamaskNetworkId: testData?.metamask?.networkId, - chainId: testData?.metamask?.provider?.chainId, + chainId: testData?.metamask?.providerConfig?.chainId, status: 'confirmed', time: 1600654021000, txParams: { diff --git a/ui/components/app/transaction-breakdown/transaction-breakdown.test.js b/ui/components/app/transaction-breakdown/transaction-breakdown.test.js index de382ab57..9f59107a0 100644 --- a/ui/components/app/transaction-breakdown/transaction-breakdown.test.js +++ b/ui/components/app/transaction-breakdown/transaction-breakdown.test.js @@ -21,7 +21,7 @@ describe('TransactionBreakdown', () => { metamask: { nativeCurrency: null, preferences: {}, - provider: { + providerConfig: { chainId: null, }, }, diff --git a/ui/components/app/user-preferenced-currency-display/user-preferenced-currency-display.test.js b/ui/components/app/user-preferenced-currency-display/user-preferenced-currency-display.test.js index 046964bb3..93ed738ee 100644 --- a/ui/components/app/user-preferenced-currency-display/user-preferenced-currency-display.test.js +++ b/ui/components/app/user-preferenced-currency-display/user-preferenced-currency-display.test.js @@ -7,7 +7,7 @@ describe('UserPreferencedCurrencyDisplay Component', () => { describe('rendering', () => { const mockState = { metamask: { - provider: { + providerConfig: { chainId: '0x99', }, preferences: { diff --git a/ui/components/app/wallet-overview/eth-overview.test.js b/ui/components/app/wallet-overview/eth-overview.test.js index a237e6879..79a183700 100644 --- a/ui/components/app/wallet-overview/eth-overview.test.js +++ b/ui/components/app/wallet-overview/eth-overview.test.js @@ -28,7 +28,7 @@ let openTabSpy; describe('EthOverview', () => { const mockStore = { metamask: { - provider: { + providerConfig: { type: 'test', chainId: CHAIN_IDS.MAINNET, }, @@ -150,7 +150,10 @@ describe('EthOverview', () => { ...mockStore, metamask: { ...mockStore.metamask, - provider: { ...mockStore.metamask.provider, chainId: '0xa86a' }, + providerConfig: { + ...mockStore.metamask.providerConfig, + chainId: '0xa86a', + }, }, }; const mockedStore = configureMockStore([thunk])(mockedAvalancheStore); @@ -193,7 +196,10 @@ describe('EthOverview', () => { ...mockStore, metamask: { ...mockStore.metamask, - provider: { ...mockStore.metamask.provider, chainId: '0xfa' }, + providerConfig: { + ...mockStore.metamask.providerConfig, + chainId: '0xfa', + }, }, }; const mockedStore = configureMockStore([thunk])(mockedFantomStore); @@ -245,7 +251,7 @@ describe('EthOverview', () => { const mockedStoreWithUnbuyableChainId = { metamask: { ...mockStore.metamask, - provider: { type: 'test', chainId: CHAIN_IDS.FANTOM }, + providerConfig: { type: 'test', chainId: CHAIN_IDS.FANTOM }, }, }; const mockedStore = configureMockStore([thunk])( @@ -265,7 +271,7 @@ describe('EthOverview', () => { const mockedStoreWithUnbuyableChainId = { metamask: { ...mockStore.metamask, - provider: { type: 'test', chainId: CHAIN_IDS.POLYGON }, + providerConfig: { type: 'test', chainId: CHAIN_IDS.POLYGON }, }, }; const mockedStore = configureMockStore([thunk])( @@ -285,7 +291,7 @@ describe('EthOverview', () => { const mockedStoreWithBuyableChainId = { metamask: { ...mockStore.metamask, - provider: { type: 'test', chainId: CHAIN_IDS.POLYGON }, + providerConfig: { type: 'test', chainId: CHAIN_IDS.POLYGON }, }, }; const mockedStore = configureMockStore([thunk])( diff --git a/ui/components/app/wallet-overview/token-overview.test.js b/ui/components/app/wallet-overview/token-overview.test.js index 0368e5f4c..8a5495858 100644 --- a/ui/components/app/wallet-overview/token-overview.test.js +++ b/ui/components/app/wallet-overview/token-overview.test.js @@ -28,7 +28,7 @@ let openTabSpy; describe('TokenOverview', () => { const mockStore = { metamask: { - provider: { + providerConfig: { type: 'test', chainId: CHAIN_IDS.MAINNET, }, @@ -110,7 +110,7 @@ describe('TokenOverview', () => { const mockedStoreWithUnbuyableChainId = { metamask: { ...mockStore.metamask, - provider: { type: 'test', chainId: CHAIN_IDS.PALM }, + providerConfig: { type: 'test', chainId: CHAIN_IDS.PALM }, }, }; const mockedStore = configureMockStore([thunk])( @@ -143,7 +143,7 @@ describe('TokenOverview', () => { const mockedStoreWithUnbuyableChainId = { metamask: { ...mockStore.metamask, - provider: { type: 'test', chainId: CHAIN_IDS.FANTOM }, + providerConfig: { type: 'test', chainId: CHAIN_IDS.FANTOM }, }, }; const mockedStore = configureMockStore([thunk])( @@ -163,7 +163,7 @@ describe('TokenOverview', () => { const mockedStoreWithBuyableChainId = { metamask: { ...mockStore.metamask, - provider: { type: 'test', chainId: CHAIN_IDS.POLYGON }, + providerConfig: { type: 'test', chainId: CHAIN_IDS.POLYGON }, }, }; const mockedStore = configureMockStore([thunk])( @@ -188,7 +188,7 @@ describe('TokenOverview', () => { const mockedStoreWithBuyableChainId = { metamask: { ...mockStore.metamask, - provider: { type: 'test', chainId: CHAIN_IDS.POLYGON }, + providerConfig: { type: 'test', chainId: CHAIN_IDS.POLYGON }, }, }; const mockedStore = configureMockStore([thunk])( @@ -208,7 +208,7 @@ describe('TokenOverview', () => { const mockedStoreWithBuyableChainId = { metamask: { ...mockStore.metamask, - provider: { type: 'test', chainId: CHAIN_IDS.POLYGON }, + providerConfig: { type: 'test', chainId: CHAIN_IDS.POLYGON }, }, }; const mockedStore = configureMockStore([thunk])( @@ -286,7 +286,7 @@ describe('TokenOverview', () => { const mockedStoreWithBridgeableChainId = { metamask: { ...mockStore.metamask, - provider: { type: 'test', chainId: CHAIN_IDS.POLYGON }, + providerConfig: { type: 'test', chainId: CHAIN_IDS.POLYGON }, }, }; const mockedStore = configureMockStore([thunk])( @@ -324,7 +324,7 @@ describe('TokenOverview', () => { const mockedStoreWithBridgeableChainId = { metamask: { ...mockStore.metamask, - provider: { type: 'test', chainId: CHAIN_IDS.FANTOM }, + providerConfig: { type: 'test', chainId: CHAIN_IDS.FANTOM }, }, }; const mockedStore = configureMockStore([thunk])( @@ -350,7 +350,7 @@ describe('TokenOverview', () => { const mockedStoreWithBridgeableChainId = { metamask: { ...mockStore.metamask, - provider: { type: 'test', chainId: CHAIN_IDS.POLYGON }, + providerConfig: { type: 'test', chainId: CHAIN_IDS.POLYGON }, }, }; const mockedStore = configureMockStore([thunk])( diff --git a/ui/components/institutional/compliance-settings/compliance-settings.test.js b/ui/components/institutional/compliance-settings/compliance-settings.test.js index b6d3e95b1..0478f7d75 100644 --- a/ui/components/institutional/compliance-settings/compliance-settings.test.js +++ b/ui/components/institutional/compliance-settings/compliance-settings.test.js @@ -14,7 +14,7 @@ jest.mock('../../../store/institutional/institution-background', () => ({ const mockStore = { metamask: { - provider: { + providerConfig: { type: 'test', }, institutionalFeatures: { diff --git a/ui/components/institutional/custody-confirm-link-modal/custody-confirm-link-modal.stories.js b/ui/components/institutional/custody-confirm-link-modal/custody-confirm-link-modal.stories.js index 642bd1d59..b735b9dd9 100644 --- a/ui/components/institutional/custody-confirm-link-modal/custody-confirm-link-modal.stories.js +++ b/ui/components/institutional/custody-confirm-link-modal/custody-confirm-link-modal.stories.js @@ -52,7 +52,7 @@ const customData = { custodianName: 'saturn-dev', }, }, - provider: { + providerConfig: { type: 'test', }, selectedAddress: '0xAddress', diff --git a/ui/components/institutional/custody-confirm-link-modal/custody-confirm-link-modal.test.js b/ui/components/institutional/custody-confirm-link-modal/custody-confirm-link-modal.test.js index c659623a9..a82ec7283 100644 --- a/ui/components/institutional/custody-confirm-link-modal/custody-confirm-link-modal.test.js +++ b/ui/components/institutional/custody-confirm-link-modal/custody-confirm-link-modal.test.js @@ -70,7 +70,7 @@ describe('Custody Confirm Link', () => { custodianName: mockedCustodianName, }, }, - provider: { + providerConfig: { type: 'test', }, selectedAddress: '0xAddress', diff --git a/ui/components/institutional/interactive-replacement-token-modal/interactive-replacement-token-modal.stories.js b/ui/components/institutional/interactive-replacement-token-modal/interactive-replacement-token-modal.stories.js index 86c03504c..9ef1baac8 100644 --- a/ui/components/institutional/interactive-replacement-token-modal/interactive-replacement-token-modal.stories.js +++ b/ui/components/institutional/interactive-replacement-token-modal/interactive-replacement-token-modal.stories.js @@ -42,7 +42,7 @@ const customData = { custodianName: 'saturn-dev', }, }, - provider: { + providerConfig: { type: 'test', }, selectedAddress: '0xAddress', diff --git a/ui/components/institutional/interactive-replacement-token-modal/interactive-replacement-token-modal.test.js b/ui/components/institutional/interactive-replacement-token-modal/interactive-replacement-token-modal.test.js index 4a78a2237..c6a1f8545 100644 --- a/ui/components/institutional/interactive-replacement-token-modal/interactive-replacement-token-modal.test.js +++ b/ui/components/institutional/interactive-replacement-token-modal/interactive-replacement-token-modal.test.js @@ -45,7 +45,7 @@ describe('Interactive Replacement Token Modal', function () { custodianName: 'saturn-dev', }, }, - provider: { + providerConfig: { type: 'test', }, selectedAddress: '0xAddress', diff --git a/ui/components/institutional/interactive-replacement-token-notification/interactive-replacement-token-notification.stories.js b/ui/components/institutional/interactive-replacement-token-notification/interactive-replacement-token-notification.stories.js index 60014af39..33e750a8c 100644 --- a/ui/components/institutional/interactive-replacement-token-notification/interactive-replacement-token-notification.stories.js +++ b/ui/components/institutional/interactive-replacement-token-notification/interactive-replacement-token-notification.stories.js @@ -8,7 +8,7 @@ const customData = { ...testData, metamask: { ...testData.metamask, - provider: { + providerConfig: { type: 'test', }, selectedAddress: '0xca8f1F0245530118D0cf14a06b01Daf8f76Cf281', diff --git a/ui/components/institutional/interactive-replacement-token-notification/interactive-replacement-token-notification.test.js b/ui/components/institutional/interactive-replacement-token-notification/interactive-replacement-token-notification.test.js index e201cf180..817600e2d 100644 --- a/ui/components/institutional/interactive-replacement-token-notification/interactive-replacement-token-notification.test.js +++ b/ui/components/institutional/interactive-replacement-token-notification/interactive-replacement-token-notification.test.js @@ -49,7 +49,7 @@ describe('Interactive Replacement Token Notification', () => { const mockStore = { metamask: { - provider: { + providerConfig: { type: 'test', }, selectedAddress, diff --git a/ui/components/institutional/jwt-url-form/jwt-url-form.test.js b/ui/components/institutional/jwt-url-form/jwt-url-form.test.js index 14a54ecbc..d134c5302 100644 --- a/ui/components/institutional/jwt-url-form/jwt-url-form.test.js +++ b/ui/components/institutional/jwt-url-form/jwt-url-form.test.js @@ -8,7 +8,7 @@ import JwtUrlForm from './jwt-url-form'; describe('JwtUrlForm', function () { const mockStore = { metamask: { - provider: { + providerConfig: { type: 'test', }, }, diff --git a/ui/components/multichain/account-picker/account-picker.test.js b/ui/components/multichain/account-picker/account-picker.test.js index b16bccd04..5c499929d 100644 --- a/ui/components/multichain/account-picker/account-picker.test.js +++ b/ui/components/multichain/account-picker/account-picker.test.js @@ -16,7 +16,7 @@ const render = (props = {}, state = {}) => { const store = configureStore({ metamask: { ...mockState.metamask, - provider: { + providerConfig: { chainId: '0x99', }, ...state, diff --git a/ui/components/multichain/app-header/app-header.test.js b/ui/components/multichain/app-header/app-header.test.js index 0e69cc03b..d2885587e 100644 --- a/ui/components/multichain/app-header/app-header.test.js +++ b/ui/components/multichain/app-header/app-header.test.js @@ -14,7 +14,7 @@ describe('App Header', () => { url: 'https://remix.ethereum.org/', }, metamask: { - provider: { + providerConfig: { chainId: CHAIN_IDS.GOERLI, }, accounts: { diff --git a/ui/components/multichain/multichain-import-token-link/multichain-import-token-link.test.js b/ui/components/multichain/multichain-import-token-link/multichain-import-token-link.test.js index dd376c52b..d738162af 100644 --- a/ui/components/multichain/multichain-import-token-link/multichain-import-token-link.test.js +++ b/ui/components/multichain/multichain-import-token-link/multichain-import-token-link.test.js @@ -26,7 +26,7 @@ describe('Import Token Link', () => { it('should match snapshot for goerli chainId', () => { const mockState = { metamask: { - provider: { + providerConfig: { chainId: '0x5', }, }, @@ -45,7 +45,7 @@ describe('Import Token Link', () => { it('should match snapshot for mainnet chainId', () => { const mockState = { metamask: { - provider: { + providerConfig: { chainId: '0x1', }, }, @@ -64,7 +64,7 @@ describe('Import Token Link', () => { it('should detectNewTokens when clicking refresh', () => { const mockState = { metamask: { - provider: { + providerConfig: { chainId: '0x5', }, }, @@ -83,7 +83,7 @@ describe('Import Token Link', () => { it('should push import token route', () => { const mockState = { metamask: { - provider: { + providerConfig: { chainId: '0x5', }, }, diff --git a/ui/components/multichain/multichain-token-list-item/multichain-token-list-item.test.js b/ui/components/multichain/multichain-token-list-item/multichain-token-list-item.test.js index 6f0498298..0e8f1746a 100644 --- a/ui/components/multichain/multichain-token-list-item/multichain-token-list-item.test.js +++ b/ui/components/multichain/multichain-token-list-item/multichain-token-list-item.test.js @@ -7,7 +7,7 @@ import { MultichainTokenListItem } from './multichain-token-list-item'; const state = { metamask: { - provider: { + providerConfig: { ticker: 'ETH', nickname: '', chainId: '0x1', diff --git a/ui/components/ui/identicon/identicon.component.test.js b/ui/components/ui/identicon/identicon.component.test.js index db60d8b18..cc2b8a9fd 100644 --- a/ui/components/ui/identicon/identicon.component.test.js +++ b/ui/components/ui/identicon/identicon.component.test.js @@ -6,7 +6,7 @@ import Identicon from '.'; describe('Identicon', () => { const mockState = { metamask: { - provider: { + providerConfig: { chainId: '0x99', }, useBlockie: false, diff --git a/ui/components/ui/new-network-info/new-network-info.test.js b/ui/components/ui/new-network-info/new-network-info.test.js index fdf90aa11..fc80c7573 100644 --- a/ui/components/ui/new-network-info/new-network-info.test.js +++ b/ui/components/ui/new-network-info/new-network-info.test.js @@ -9,7 +9,7 @@ const fetchWithCache = const state = { metamask: { - provider: { + providerConfig: { ticker: 'ETH', nickname: '', chainId: '0x1', @@ -139,7 +139,7 @@ describe('NewNetworkInfo', () => { 'https://token-api.metaswap.codefi.network/tokens/0x3', ); - state.metamask.provider.ticker = null; + state.metamask.providerConfig.ticker = null; const store = configureMockStore()( state, diff --git a/ui/ducks/confirm-transaction/confirm-transaction.duck.test.js b/ui/ducks/confirm-transaction/confirm-transaction.duck.test.js index 04286b4f8..30f4183ad 100644 --- a/ui/ducks/confirm-transaction/confirm-transaction.duck.test.js +++ b/ui/ducks/confirm-transaction/confirm-transaction.duck.test.js @@ -290,7 +290,7 @@ describe('Confirm Transaction Duck', () => { metamask: { conversionRate: 468.58, currentCurrency: 'usd', - provider: { + providerConfig: { ticker: 'ETH', }, }, @@ -345,7 +345,7 @@ describe('Confirm Transaction Duck', () => { currentCurrency: 'usd', networkId: '5', networkStatus: 'available', - provider: { + providerConfig: { chainId: '0x5', }, unapprovedTxs: { diff --git a/ui/ducks/metamask/metamask.js b/ui/ducks/metamask/metamask.js index d8b5836ac..21cec390f 100644 --- a/ui/ducks/metamask/metamask.js +++ b/ui/ducks/metamask/metamask.js @@ -234,10 +234,10 @@ export const getAlertEnabledness = (state) => state.metamask.alertEnabledness; * Get the provider configuration for the current selected network. * * @param {object} state - Redux state object. - * @returns {import('../../../app/scripts/controllers/network/network-controller').NetworkControllerState['provider']} The provider configuration for the current selected network. + * @returns {import('../../../app/scripts/controllers/network/network-controller').NetworkControllerState['providerConfig']} The provider configuration for the current selected network. */ export function getProviderConfig(state) { - return state.metamask.provider; + return state.metamask.providerConfig; } export const getUnconnectedAccountAlertEnabledness = (state) => diff --git a/ui/ducks/metamask/metamask.test.js b/ui/ducks/metamask/metamask.test.js index 92241d589..1370bf9a6 100644 --- a/ui/ducks/metamask/metamask.test.js +++ b/ui/ducks/metamask/metamask.test.js @@ -43,7 +43,7 @@ describe('MetaMask Reducers', () => { useCurrencyRateCheck: true, networkId: '5', networkStatus: 'available', - provider: { + providerConfig: { type: 'testnet', chainId: '0x5', ticker: 'TestETH', diff --git a/ui/ducks/send/send.test.js b/ui/ducks/send/send.test.js index 7a3a789a7..cb10c7a87 100644 --- a/ui/ducks/send/send.test.js +++ b/ui/ducks/send/send.test.js @@ -1293,7 +1293,7 @@ describe('Send Slice', () => { '0xAddress': '0x0', }, }, - provider: { + providerConfig: { chainId: '0x5', }, useTokenDetection: true, @@ -1425,7 +1425,7 @@ describe('Send Slice', () => { metamask: { blockGasLimit: '', selectedAddress: '', - provider: { + providerConfig: { chainId: '0x1', }, }, @@ -1478,7 +1478,7 @@ describe('Send Slice', () => { metamask: { blockGasLimit: '', selectedAddress: '', - provider: { + providerConfig: { chainId: '0x1', }, }, @@ -1530,7 +1530,7 @@ describe('Send Slice', () => { metamask: { blockGasLimit: '', selectedAddress: '', - provider: { + providerConfig: { chainId: '0x1', }, }, @@ -1575,7 +1575,7 @@ describe('Send Slice', () => { metamask: { blockGasLimit: '', selectedAddress: '', - provider: { + providerConfig: { chainId: CHAIN_IDS.GOERLI, }, cachedBalances: { @@ -1745,7 +1745,7 @@ describe('Send Slice', () => { describe('updateRecipientUserInput', () => { const updateRecipientUserInputState = { metamask: { - provider: { + providerConfig: { chainId: '', }, tokens: [], @@ -1882,7 +1882,7 @@ describe('Send Slice', () => { metamask: { addressBook: {}, identities: {}, - provider: { + providerConfig: { chainId: '0x1', }, }, @@ -1941,7 +1941,7 @@ describe('Send Slice', () => { }, ], }, - provider: { + providerConfig: { chainId: '0x1', }, }, @@ -1992,7 +1992,7 @@ describe('Send Slice', () => { identities: {}, blockGasLimit: '', selectedAddress: '', - provider: { + providerConfig: { chainId: '0x1', }, }, @@ -2040,7 +2040,7 @@ describe('Send Slice', () => { metamask: { addressBook: {}, identities: {}, - provider: { + providerConfig: { chainId: '', }, tokens: [], @@ -2165,7 +2165,7 @@ describe('Send Slice', () => { userInputHexData: '', }, metamask: { - provider: { + providerConfig: { chainId: CHAIN_IDS.GOERLI, }, }, @@ -2214,7 +2214,7 @@ describe('Send Slice', () => { amountMode: AMOUNT_MODES.MAX, }, metamask: { - provider: { + providerConfig: { chainId: CHAIN_IDS.GOERLI, }, }, @@ -2372,7 +2372,7 @@ describe('Send Slice', () => { metamask: { gasEstimateType: GasEstimateTypes.none, gasFeeEstimates: {}, - provider: { + providerConfig: { chainId: CHAIN_IDS.GOERLI, }, tokens: [], @@ -2507,7 +2507,7 @@ describe('Send Slice', () => { metamask: { blockGasLimit: '0x3a98', selectedAddress: '', - provider: { + providerConfig: { chainId: CHAIN_IDS.GOERLI, }, tokens: [], @@ -2679,7 +2679,7 @@ describe('Send Slice', () => { metamask: { blockGasLimit: '0x3a98', selectedAddress: '', - provider: { + providerConfig: { chainId: CHAIN_IDS.GOERLI, }, tokens: [ @@ -2910,7 +2910,7 @@ describe('Send Slice', () => { expect( getGasInputMode({ metamask: { - provider: { chainId: CHAIN_IDS.MAINNET }, + providerConfig: { chainId: CHAIN_IDS.MAINNET }, featureFlags: { advancedInlineGas: false }, }, send: initialState, @@ -2923,7 +2923,7 @@ describe('Send Slice', () => { expect( getGasInputMode({ metamask: { - provider: { chainId: '0x539' }, + providerConfig: { chainId: '0x539' }, featureFlags: { advancedInlineGas: false }, }, send: initialState, @@ -2936,7 +2936,7 @@ describe('Send Slice', () => { expect( getGasInputMode({ metamask: { - provider: { chainId: CHAIN_IDS.MAINNET }, + providerConfig: { chainId: CHAIN_IDS.MAINNET }, featureFlags: { advancedInlineGas: true }, }, send: initialState, @@ -2948,7 +2948,7 @@ describe('Send Slice', () => { expect( getGasInputMode({ metamask: { - provider: { chainId: CHAIN_IDS.MAINNET }, + providerConfig: { chainId: CHAIN_IDS.MAINNET }, featureFlags: { advancedInlineGas: false }, gasEstimateType: GasEstimateTypes.ethGasPrice, }, @@ -2962,7 +2962,7 @@ describe('Send Slice', () => { expect( getGasInputMode({ metamask: { - provider: { chainId: CHAIN_IDS.MAINNET }, + providerConfig: { chainId: CHAIN_IDS.MAINNET }, featureFlags: { advancedInlineGas: false }, gasEstimateType: GasEstimateTypes.ethGasPrice, }, @@ -2976,7 +2976,7 @@ describe('Send Slice', () => { expect( getGasInputMode({ metamask: { - provider: { chainId: CHAIN_IDS.MAINNET }, + providerConfig: { chainId: CHAIN_IDS.MAINNET }, featureFlags: { advancedInlineGas: true }, }, send: { @@ -3116,7 +3116,7 @@ describe('Send Slice', () => { ensResolutionsByAddress: {}, identities: {}, addressBook: {}, - provider: { + providerConfig: { chainId: '0x5', }, }, @@ -3131,7 +3131,7 @@ describe('Send Slice', () => { ensResolutionsByAddress: {}, addressBook: {}, identities: {}, - provider: { + providerConfig: { chainId: '0x5', }, }, @@ -3179,7 +3179,7 @@ describe('Send Slice', () => { ensResolutionsByAddress: {}, identities: {}, addressBook: {}, - provider: { + providerConfig: { chainId: '0x5', }, }, diff --git a/ui/ducks/swaps/swaps.test.js b/ui/ducks/swaps/swaps.test.js index f425ed460..a537223d4 100644 --- a/ui/ducks/swaps/swaps.test.js +++ b/ui/ducks/swaps/swaps.test.js @@ -19,7 +19,7 @@ jest.mock('../../store/actions.ts', () => ({ }), })); -const providerState = { +const providerConfigState = { chainId: '0x1', nickname: '', rpcPrefs: {}, @@ -64,7 +64,7 @@ describe('Ducks - Swaps', () => { const createGetState = () => { return () => ({ metamask: { - provider: { ...providerState }, + providerConfig: { ...providerConfigState }, from: '0x64a845a5b02460acf8a3d84503b0d68d028b4bb4', }, }); @@ -427,19 +427,19 @@ describe('Ducks - Swaps', () => { it('returns false if feature flag is enabled, not a HW and is Polygon network', () => { const state = createSwapsMockStore(); - state.metamask.provider.chainId = CHAIN_IDS.POLYGON; + state.metamask.providerConfig.chainId = CHAIN_IDS.POLYGON; expect(swaps.getSmartTransactionsEnabled(state)).toBe(false); }); it('returns false if feature flag is enabled, not a HW and is BSC network', () => { const state = createSwapsMockStore(); - state.metamask.provider.chainId = CHAIN_IDS.BSC; + state.metamask.providerConfig.chainId = CHAIN_IDS.BSC; expect(swaps.getSmartTransactionsEnabled(state)).toBe(false); }); it('returns true if feature flag is enabled, not a HW and is Goerli network', () => { const state = createSwapsMockStore(); - state.metamask.provider.chainId = CHAIN_IDS.GOERLI; + state.metamask.providerConfig.chainId = CHAIN_IDS.GOERLI; expect(swaps.getSmartTransactionsEnabled(state)).toBe(true); }); diff --git a/ui/hooks/useAddressDetails.test.js b/ui/hooks/useAddressDetails.test.js index b255c6c71..cf09f1b9d 100644 --- a/ui/hooks/useAddressDetails.test.js +++ b/ui/hooks/useAddressDetails.test.js @@ -8,7 +8,7 @@ import useAddressDetails from './useAddressDetails'; const renderUseAddressDetails = (toAddress, stateVariables = {}) => { const mockState = { metamask: { - provider: { + providerConfig: { type: 'test', chainId: '0x5', }, diff --git a/ui/hooks/useAssetDetails.test.js b/ui/hooks/useAssetDetails.test.js index f057a3f3e..074a3aec6 100644 --- a/ui/hooks/useAssetDetails.test.js +++ b/ui/hooks/useAssetDetails.test.js @@ -14,7 +14,7 @@ const renderUseAssetDetails = ({ }) => { const mockState = { metamask: { - provider: { + providerConfig: { type: 'test', chainId: '0x5', }, diff --git a/ui/hooks/useTransactionInfo.test.js b/ui/hooks/useTransactionInfo.test.js index 9858185ed..680c99e1d 100644 --- a/ui/hooks/useTransactionInfo.test.js +++ b/ui/hooks/useTransactionInfo.test.js @@ -18,7 +18,7 @@ describe('useTransactionInfo', () => { it('should return true if transaction is NFT transfer', () => { mockState.metamask.allNftContracts = { [mockState.metamask.selectedAddress]: { - [hexToDecimal(mockState.metamask.provider.chainId)]: [ + [hexToDecimal(mockState.metamask.providerConfig.chainId)]: [ { address: '0x9' }, ], }, diff --git a/ui/index.js b/ui/index.js index b2a1d936e..1f1aeb281 100644 --- a/ui/index.js +++ b/ui/index.js @@ -161,7 +161,7 @@ async function startApp(metamaskState, backgroundConnection, opts) { metamaskState.unapprovedEncryptionPublicKeyMsgs, metamaskState.unapprovedTypedMessages, metamaskState.networkId, - metamaskState.provider.chainId, + metamaskState.providerConfig.chainId, ); const numberOfUnapprovedTx = unapprovedTxsAll.length; if (numberOfUnapprovedTx > 0) { diff --git a/ui/pages/confirm-add-suggested-token/confirm-add-suggested-token.test.js b/ui/pages/confirm-add-suggested-token/confirm-add-suggested-token.test.js index 4ebb2fb02..e48e96086 100644 --- a/ui/pages/confirm-add-suggested-token/confirm-add-suggested-token.test.js +++ b/ui/pages/confirm-add-suggested-token/confirm-add-suggested-token.test.js @@ -44,7 +44,7 @@ const renderComponent = (tokens = []) => { metamask: { suggestedAssets: [...MOCK_SUGGESTED_ASSETS], tokens, - provider: { chainId: '0x1' }, + providerConfig: { chainId: '0x1' }, }, history: { mostRecentOverviewPage: '/', diff --git a/ui/pages/confirm-approve/confirm-approve-content/confirm-approve-content.component.test.js b/ui/pages/confirm-approve/confirm-approve-content/confirm-approve-content.component.test.js index c82da63b8..332d562a3 100644 --- a/ui/pages/confirm-approve/confirm-approve-content/confirm-approve-content.component.test.js +++ b/ui/pages/confirm-approve/confirm-approve-content/confirm-approve-content.component.test.js @@ -7,7 +7,7 @@ import ConfirmApproveContent from '.'; const renderComponent = (props) => { const store = configureMockStore([])({ - metamask: { provider: { chainId: '0x0' } }, + metamask: { providerConfig: { chainId: '0x0' } }, }); return renderWithProvider(, store); }; diff --git a/ui/pages/confirm-import-token/confirm-import-token.test.js b/ui/pages/confirm-import-token/confirm-import-token.test.js index 0e947de1c..a4c9d824a 100644 --- a/ui/pages/confirm-import-token/confirm-import-token.test.js +++ b/ui/pages/confirm-import-token/confirm-import-token.test.js @@ -36,7 +36,7 @@ const renderComponent = (mockPendingTokens = MOCK_PENDING_TOKENS) => { const store = configureStore({ metamask: { pendingTokens: { ...mockPendingTokens }, - provider: { chainId: '0x1' }, + providerConfig: { chainId: '0x1' }, }, history: { mostRecentOverviewPage: '/', diff --git a/ui/pages/confirm-signature-request/index.test.js b/ui/pages/confirm-signature-request/index.test.js index fa3a8b006..cec7fe8f4 100644 --- a/ui/pages/confirm-signature-request/index.test.js +++ b/ui/pages/confirm-signature-request/index.test.js @@ -31,7 +31,7 @@ const mockState = { }, }, unapprovedTypedMessagesCount: 1, - provider: { chainId: '0x5', type: 'goerli' }, + providerConfig: { chainId: '0x5', type: 'goerli' }, keyrings: [], networkConfigurations: {}, subjectMetadata: {}, diff --git a/ui/pages/confirm-transaction-base/confirm-transaction-base.test.js b/ui/pages/confirm-transaction-base/confirm-transaction-base.test.js index 30d699486..d1c736c95 100644 --- a/ui/pages/confirm-transaction-base/confirm-transaction-base.test.js +++ b/ui/pages/confirm-transaction-base/confirm-transaction-base.test.js @@ -72,7 +72,7 @@ const baseStore = { useNativeCurrencyAsPrimaryCurrency: false, }, currentCurrency: 'USD', - provider: { + providerConfig: { chainId: CHAIN_IDS.GOERLI, }, nativeCurrency: 'ETH', @@ -156,7 +156,7 @@ describe('Confirm Transaction Base', () => { }); it('should contain L1 L2 fee details for optimism', () => { - baseStore.metamask.provider.chainId = CHAIN_IDS.OPTIMISM; + baseStore.metamask.providerConfig.chainId = CHAIN_IDS.OPTIMISM; baseStore.confirmTransaction.txData.chainId = CHAIN_IDS.OPTIMISM; const store = configureMockStore(middleware)(baseStore); const { getByText } = renderWithProvider( diff --git a/ui/pages/create-account/connect-hardware/index.test.tsx b/ui/pages/create-account/connect-hardware/index.test.tsx index e6f0e6538..395fffaa1 100644 --- a/ui/pages/create-account/connect-hardware/index.test.tsx +++ b/ui/pages/create-account/connect-hardware/index.test.tsx @@ -48,7 +48,7 @@ const mockProps = { const mockState = { metamask: { - provider: { + providerConfig: { chainId: '0x1', }, }, diff --git a/ui/pages/import-token/import-token.test.js b/ui/pages/import-token/import-token.test.js index a7379a89f..b2fb6b5a2 100644 --- a/ui/pages/import-token/import-token.test.js +++ b/ui/pages/import-token/import-token.test.js @@ -35,7 +35,7 @@ describe('Import Token', () => { const baseStore = { metamask: { tokens: [], - provider: { chainId: '0x1' }, + providerConfig: { chainId: '0x1' }, networkConfigurations: {}, identities: {}, selectedAddress: '0x1231231', diff --git a/ui/pages/institutional/compliance-feature-page/compliance-feature-page.test.js b/ui/pages/institutional/compliance-feature-page/compliance-feature-page.test.js index 9b75b9107..281e4ec7b 100644 --- a/ui/pages/institutional/compliance-feature-page/compliance-feature-page.test.js +++ b/ui/pages/institutional/compliance-feature-page/compliance-feature-page.test.js @@ -17,7 +17,7 @@ jest.mock('../../../store/institutional/institution-background', () => ({ describe('Compliance Feature, connect', function () { const mockStore = { metamask: { - provider: { + providerConfig: { type: 'test', }, institutionalFeatures: { diff --git a/ui/pages/institutional/confirm-add-custodian-token/confirm-add-custodian-token.test.js b/ui/pages/institutional/confirm-add-custodian-token/confirm-add-custodian-token.test.js index 37660c0da..4f4b75690 100644 --- a/ui/pages/institutional/confirm-add-custodian-token/confirm-add-custodian-token.test.js +++ b/ui/pages/institutional/confirm-add-custodian-token/confirm-add-custodian-token.test.js @@ -7,7 +7,7 @@ import ConfirmAddCustodianToken from './confirm-add-custodian-token'; describe('Confirm Add Custodian Token', () => { const mockStore = { metamask: { - provider: { + providerConfig: { type: 'test', }, preferences: { @@ -61,7 +61,7 @@ describe('Confirm Add Custodian Token', () => { it('tries to connect to custodian with empty token', async () => { const customMockedStore = { metamask: { - provider: { + providerConfig: { type: 'test', }, preferences: { diff --git a/ui/pages/institutional/confirm-add-institutional-feature/confirm-add-institutional-feature.stories.js b/ui/pages/institutional/confirm-add-institutional-feature/confirm-add-institutional-feature.stories.js index 07299393f..383013a44 100644 --- a/ui/pages/institutional/confirm-add-institutional-feature/confirm-add-institutional-feature.stories.js +++ b/ui/pages/institutional/confirm-add-institutional-feature/confirm-add-institutional-feature.stories.js @@ -7,7 +7,7 @@ import ConfirmAddInstitutionalFeature from '.'; const customData = { ...testData, metamask: { - provider: { + providerConfig: { type: 'test', }, institutionalFeatures: { diff --git a/ui/pages/institutional/confirm-add-institutional-feature/confirm-add-institutional-feature.test.js b/ui/pages/institutional/confirm-add-institutional-feature/confirm-add-institutional-feature.test.js index 141e27156..6815adafe 100644 --- a/ui/pages/institutional/confirm-add-institutional-feature/confirm-add-institutional-feature.test.js +++ b/ui/pages/institutional/confirm-add-institutional-feature/confirm-add-institutional-feature.test.js @@ -46,7 +46,7 @@ const render = ({ newState } = {}) => { const state = { ...mockState, metamask: { - provider: { + providerConfig: { type: 'test', }, institutionalFeatures: { diff --git a/ui/pages/institutional/connect-custody/account-list.stories.js b/ui/pages/institutional/connect-custody/account-list.stories.js index a7847b73c..7161c8d0e 100644 --- a/ui/pages/institutional/connect-custody/account-list.stories.js +++ b/ui/pages/institutional/connect-custody/account-list.stories.js @@ -24,7 +24,6 @@ export default { selectedAccounts: {}, onAddAccounts: () => undefined, onCancel: () => undefined, - provider: 'Test', rawList: false, }, }; diff --git a/ui/pages/institutional/custody/custody.js b/ui/pages/institutional/custody/custody.js index 7b0169685..828eb3020 100644 --- a/ui/pages/institutional/custody/custody.js +++ b/ui/pages/institutional/custody/custody.js @@ -41,7 +41,6 @@ import { DEFAULT_ROUTE, } from '../../../helpers/constants/routes'; import { getCurrentChainId } from '../../../selectors'; -import { getProviderConfig } from '../../../ducks/metamask/metamask'; import { getMMIConfiguration } from '../../../selectors/institutional/selectors'; import CustodyAccountList from '../connect-custody/account-list'; import JwtUrlForm from '../../../components/institutional/jwt-url-form'; @@ -54,7 +53,6 @@ const CustodyPage = () => { const mmiActions = mmiActionsFactory(); const currentChainId = useSelector(getCurrentChainId); - const providerConfig = useSelector(getProviderConfig); const { custodians } = useSelector(getMMIConfiguration); const [selectedAccounts, setSelectedAccounts] = useState({}); @@ -494,7 +492,6 @@ const CustodyPage = () => { setSelectedAccounts(selectedAccounts); }} - provider={providerConfig} selectedAccounts={selectedAccounts} onAddAccounts={async () => { try { diff --git a/ui/pages/institutional/custody/custody.test.js b/ui/pages/institutional/custody/custody.test.js index b9381e309..f944d33aa 100644 --- a/ui/pages/institutional/custody/custody.test.js +++ b/ui/pages/institutional/custody/custody.test.js @@ -34,7 +34,7 @@ jest.mock('../../../store/institutional/institution-background', () => ({ describe('CustodyPage', function () { const mockStore = { metamask: { - provider: { chainId: 0x1, type: 'test' }, + providerConfig: { chainId: 0x1, type: 'test' }, mmiConfiguration: { portfolio: { enabled: true, diff --git a/ui/pages/institutional/institutional-entity-done-page/institutional-entity-done-page.test.js b/ui/pages/institutional/institutional-entity-done-page/institutional-entity-done-page.test.js index 0b9d77dd6..47eb95d9e 100644 --- a/ui/pages/institutional/institutional-entity-done-page/institutional-entity-done-page.test.js +++ b/ui/pages/institutional/institutional-entity-done-page/institutional-entity-done-page.test.js @@ -19,7 +19,7 @@ const render = () => { const store = configureStore({ ...mockState, metamask: { - provider: { + providerConfig: { type: 'test', }, }, diff --git a/ui/pages/onboarding-flow/creation-successful/creation-successful.test.js b/ui/pages/onboarding-flow/creation-successful/creation-successful.test.js index 126d90dad..dd7e5b455 100644 --- a/ui/pages/onboarding-flow/creation-successful/creation-successful.test.js +++ b/ui/pages/onboarding-flow/creation-successful/creation-successful.test.js @@ -28,7 +28,7 @@ jest.mock('react-router-dom', () => ({ describe('Creation Successful Onboarding View', () => { const mockStore = { metamask: { - provider: { + providerConfig: { type: 'test', }, }, diff --git a/ui/pages/onboarding-flow/pin-extension/pin-extension.test.js b/ui/pages/onboarding-flow/pin-extension/pin-extension.test.js index c3a4d70d9..7a6988c5b 100644 --- a/ui/pages/onboarding-flow/pin-extension/pin-extension.test.js +++ b/ui/pages/onboarding-flow/pin-extension/pin-extension.test.js @@ -16,7 +16,7 @@ const completeOnboardingStub = jest describe('Creation Successful Onboarding View', () => { const mockStore = { metamask: { - provider: { + providerConfig: { type: 'test', }, }, diff --git a/ui/pages/onboarding-flow/privacy-settings/privacy-settings.test.js b/ui/pages/onboarding-flow/privacy-settings/privacy-settings.test.js index 1c8d8e29c..3eb2493cf 100644 --- a/ui/pages/onboarding-flow/privacy-settings/privacy-settings.test.js +++ b/ui/pages/onboarding-flow/privacy-settings/privacy-settings.test.js @@ -12,7 +12,7 @@ describe('Privacy Settings Onboarding View', () => { const mockStore = { metamask: { networkConfigurations: {}, - provider: { + providerConfig: { type: 'test', }, }, diff --git a/ui/pages/onboarding-flow/secure-your-wallet/secure-your-wallet.test.js b/ui/pages/onboarding-flow/secure-your-wallet/secure-your-wallet.test.js index 75e979f9c..204392d66 100644 --- a/ui/pages/onboarding-flow/secure-your-wallet/secure-your-wallet.test.js +++ b/ui/pages/onboarding-flow/secure-your-wallet/secure-your-wallet.test.js @@ -24,7 +24,7 @@ describe('Secure Your Wallet Onboarding View', () => { const mockStore = { metamask: { - provider: { + providerConfig: { type: 'test', }, }, diff --git a/ui/pages/send/send.test.js b/ui/pages/send/send.test.js index ffe97670f..5f73a700b 100644 --- a/ui/pages/send/send.test.js +++ b/ui/pages/send/send.test.js @@ -93,7 +93,7 @@ const baseStore = { useNativeCurrencyAsPrimaryCurrency: false, }, currentCurrency: 'USD', - provider: { + providerConfig: { chainId: CHAIN_IDS.GOERLI, }, nativeCurrency: 'ETH', diff --git a/ui/pages/settings/contact-list-tab/add-contact/add-contact.test.js b/ui/pages/settings/contact-list-tab/add-contact/add-contact.test.js index 2cc5234de..29f9fc772 100644 --- a/ui/pages/settings/contact-list-tab/add-contact/add-contact.test.js +++ b/ui/pages/settings/contact-list-tab/add-contact/add-contact.test.js @@ -10,7 +10,7 @@ describe('AddContact component', () => { const middleware = [thunk]; const state = { metamask: { - provider: { + providerConfig: { type: 'mainnet', nickname: '', }, diff --git a/ui/pages/settings/contact-list-tab/edit-contact/edit-contact.test.js b/ui/pages/settings/contact-list-tab/edit-contact/edit-contact.test.js index 1853a4de1..dcb13d871 100644 --- a/ui/pages/settings/contact-list-tab/edit-contact/edit-contact.test.js +++ b/ui/pages/settings/contact-list-tab/edit-contact/edit-contact.test.js @@ -10,7 +10,7 @@ describe('AddContact component', () => { const middleware = [thunk]; const state = { metamask: { - provider: { + providerConfig: { type: 'mainnet', nickname: '', }, diff --git a/ui/pages/settings/networks-tab/networks-list-item/networks-list-item.test.js b/ui/pages/settings/networks-tab/networks-list-item/networks-list-item.test.js index f4d4f3832..4cfbc852d 100644 --- a/ui/pages/settings/networks-tab/networks-list-item/networks-list-item.test.js +++ b/ui/pages/settings/networks-tab/networks-list-item/networks-list-item.test.js @@ -6,7 +6,7 @@ import NetworksListItem from '.'; const mockState = { metamask: { - provider: { + providerConfig: { chainId: '0x5', nickname: '', rpcPrefs: {}, diff --git a/ui/pages/settings/networks-tab/networks-list/networks-list.test.js b/ui/pages/settings/networks-tab/networks-list/networks-list.test.js index c9633ba06..21432d3a5 100644 --- a/ui/pages/settings/networks-tab/networks-list/networks-list.test.js +++ b/ui/pages/settings/networks-tab/networks-list/networks-list.test.js @@ -6,7 +6,7 @@ import NetworksList from '.'; const mockState = { metamask: { - provider: { + providerConfig: { chainId: '0x5', nickname: '', rpcPrefs: {}, diff --git a/ui/pages/settings/networks-tab/networks-tab-content/networks-tab-content.test.js b/ui/pages/settings/networks-tab/networks-tab-content/networks-tab-content.test.js index 1277975a6..4dac21afd 100644 --- a/ui/pages/settings/networks-tab/networks-tab-content/networks-tab-content.test.js +++ b/ui/pages/settings/networks-tab/networks-tab-content/networks-tab-content.test.js @@ -7,7 +7,7 @@ import NetworksTabContent from '.'; const mockState = { metamask: { - provider: { + providerConfig: { chainId: '0x539', nickname: '', rpcPrefs: {}, diff --git a/ui/pages/settings/networks-tab/networks-tab-subheader/networks-tab-subheader.test.js b/ui/pages/settings/networks-tab/networks-tab-subheader/networks-tab-subheader.test.js index 62117af54..1ca8d0d8d 100644 --- a/ui/pages/settings/networks-tab/networks-tab-subheader/networks-tab-subheader.test.js +++ b/ui/pages/settings/networks-tab/networks-tab-subheader/networks-tab-subheader.test.js @@ -6,7 +6,7 @@ import NetworksTabSubheader from '.'; const mockState = { metamask: { - provider: { + providerConfig: { chainId: '0x539', nickname: '', rpcPrefs: {}, diff --git a/ui/pages/settings/networks-tab/networks-tab.test.js b/ui/pages/settings/networks-tab/networks-tab.test.js index 687bb82f6..87cafb9fd 100644 --- a/ui/pages/settings/networks-tab/networks-tab.test.js +++ b/ui/pages/settings/networks-tab/networks-tab.test.js @@ -5,7 +5,7 @@ import NetworksTab from '.'; const mockState = { metamask: { - provider: { + providerConfig: { chainId: '0x539', nickname: '', rpcPrefs: {}, diff --git a/ui/pages/swaps/view-quote/view-quote-price-difference.test.js b/ui/pages/swaps/view-quote/view-quote-price-difference.test.js index cec109c28..b98979b17 100644 --- a/ui/pages/swaps/view-quote/view-quote-price-difference.test.js +++ b/ui/pages/swaps/view-quote/view-quote-price-difference.test.js @@ -9,7 +9,7 @@ describe('View Price Quote Difference', () => { const mockState = { metamask: { tokens: [], - provider: { type: NETWORK_TYPES.RPC, nickname: '', rpcUrl: '' }, + providerConfig: { type: NETWORK_TYPES.RPC, nickname: '', rpcUrl: '' }, preferences: { showFiatInTestnets: true }, currentCurrency: 'usd', conversionRate: 600.0, diff --git a/ui/pages/token-allowance/token-allowance.test.js b/ui/pages/token-allowance/token-allowance.test.js index 48c38826b..a9be836ec 100644 --- a/ui/pages/token-allowance/token-allowance.test.js +++ b/ui/pages/token-allowance/token-allowance.test.js @@ -39,7 +39,7 @@ const state = { name: 'Address Book Account 1', }, ], - provider: { + providerConfig: { type: 'mainnet', nickname: '', }, diff --git a/ui/pages/token-details/token-details-page.test.js b/ui/pages/token-details/token-details-page.test.js index 766a0607b..1e7cf7107 100644 --- a/ui/pages/token-details/token-details-page.test.js +++ b/ui/pages/token-details/token-details-page.test.js @@ -209,7 +209,7 @@ const state = { symbol: 'UMA', }, }, - provider: { + providerConfig: { type: 'mainnet', nickname: '', }, diff --git a/ui/selectors/confirm-transaction.test.js b/ui/selectors/confirm-transaction.test.js index 86a551aae..e0f7c9c6f 100644 --- a/ui/selectors/confirm-transaction.test.js +++ b/ui/selectors/confirm-transaction.test.js @@ -32,7 +32,7 @@ describe('Confirm Transaction Selector', () => { unapprovedPersonalMsgCount: 1, unapprovedTypedMessagesCount: 1, networkId: '5', - provider: { + providerConfig: { chainId: '0x5', }, }, diff --git a/ui/selectors/institutional/selectors.test.js b/ui/selectors/institutional/selectors.test.js index 1cbf02213..71fe44eb9 100644 --- a/ui/selectors/institutional/selectors.test.js +++ b/ui/selectors/institutional/selectors.test.js @@ -14,7 +14,7 @@ import { describe('Institutional selectors', () => { const state = { metamask: { - provider: { + providerConfig: { type: 'test', chainId: '1', }, diff --git a/ui/selectors/nonce-sorted-transactions-selector.test.js b/ui/selectors/nonce-sorted-transactions-selector.test.js index 4cd6840df..89a2599af 100644 --- a/ui/selectors/nonce-sorted-transactions-selector.test.js +++ b/ui/selectors/nonce-sorted-transactions-selector.test.js @@ -74,7 +74,7 @@ const getStateTree = ({ unapprovedMsgs = [], } = {}) => ({ metamask: { - provider: { + providerConfig: { nickname: 'mainnet', chainId: CHAIN_IDS.MAINNET, }, diff --git a/ui/selectors/permissions.test.js b/ui/selectors/permissions.test.js index 6611454ba..d531bce2f 100644 --- a/ui/selectors/permissions.test.js +++ b/ui/selectors/permissions.test.js @@ -149,7 +149,7 @@ describe('selectors', () => { url: 'https://remix.ethereum.org/', }, metamask: { - provider: { + providerConfig: { chainId: CHAIN_IDS.GOERLI, }, accounts: { diff --git a/ui/selectors/selectors.test.js b/ui/selectors/selectors.test.js index 81f31340d..e5964a73c 100644 --- a/ui/selectors/selectors.test.js +++ b/ui/selectors/selectors.test.js @@ -35,16 +35,18 @@ describe('Selectors', () => { }); describe('#getRpcPrefsForCurrentProvider', () => { - it('returns an empty object if state.metamask.provider is empty', () => { + it('returns an empty object if state.metamask.providerConfig is empty', () => { expect( - selectors.getRpcPrefsForCurrentProvider({ metamask: { provider: {} } }), + selectors.getRpcPrefsForCurrentProvider({ + metamask: { providerConfig: {} }, + }), ).toStrictEqual({}); }); - it('returns rpcPrefs from the provider', () => { + it('returns rpcPrefs from the providerConfig', () => { expect( selectors.getRpcPrefsForCurrentProvider({ metamask: { - provider: { + providerConfig: { rpcPrefs: { blockExplorerUrl: 'https://test-block-explorer' }, }, }, @@ -440,17 +442,17 @@ describe('Selectors', () => { }); it('#getIsBridgeChain', () => { - mockState.metamask.provider.chainId = '0xa'; + mockState.metamask.providerConfig.chainId = '0xa'; const isOptimismSupported = selectors.getIsBridgeChain(mockState); expect(isOptimismSupported).toBeTruthy(); - mockState.metamask.provider.chainId = '0xfa'; + mockState.metamask.providerConfig.chainId = '0xfa'; const isFantomSupported = selectors.getIsBridgeChain(mockState); expect(isFantomSupported).toBeFalsy(); }); it('#getIsBridgeToken', () => { - mockState.metamask.provider.chainId = '0xa'; + mockState.metamask.providerConfig.chainId = '0xa'; const isOptimismTokenSupported = selectors.getIsBridgeToken( '0x94B008aa00579c1307b0ef2c499ad98a8ce58e58', )(mockState); @@ -461,7 +463,7 @@ describe('Selectors', () => { )(mockState); expect(isOptimismUnknownTokenSupported).toBeFalsy(); - mockState.metamask.provider.chainId = '0xfa'; + mockState.metamask.providerConfig.chainId = '0xfa'; const isFantomTokenSupported = selectors.getIsBridgeToken( '0x94B008aa00579c1307b0ef2c499ad98a8ce58e58', )(mockState); diff --git a/ui/selectors/transactions.test.js b/ui/selectors/transactions.test.js index b8eab61eb..02227c410 100644 --- a/ui/selectors/transactions.test.js +++ b/ui/selectors/transactions.test.js @@ -29,7 +29,7 @@ describe('Transaction Selectors', () => { unapprovedMsgs: { 1: msg, }, - provider: { + providerConfig: { chainId: '0x5', }, }, @@ -59,7 +59,7 @@ describe('Transaction Selectors', () => { unapprovedPersonalMsgs: { 1: msg, }, - provider: { + providerConfig: { chainId: '0x5', }, }, @@ -90,7 +90,7 @@ describe('Transaction Selectors', () => { unapprovedTypedMessages: { 1: msg, }, - provider: { + providerConfig: { chainId: '0x5', }, }, @@ -107,7 +107,7 @@ describe('Transaction Selectors', () => { it('selects the currentNetworkTxList', () => { const state = { metamask: { - provider: { + providerConfig: { nickname: 'mainnet', chainId: CHAIN_IDS.MAINNET, }, @@ -171,7 +171,7 @@ describe('Transaction Selectors', () => { const state = { metamask: { - provider: { + providerConfig: { nickname: 'mainnet', chainId: CHAIN_IDS.MAINNET, }, @@ -255,7 +255,7 @@ describe('Transaction Selectors', () => { const state = { metamask: { - provider: { + providerConfig: { nickname: 'mainnet', chainId: CHAIN_IDS.MAINNET, }, diff --git a/ui/store/actions.test.js b/ui/store/actions.test.js index b0b008add..9f336f8d9 100644 --- a/ui/store/actions.test.js +++ b/ui/store/actions.test.js @@ -16,7 +16,7 @@ const defaultState = { metamask: { currentLocale: 'test', selectedAddress: '0xFirstAddress', - provider: { chainId: '0x1' }, + providerConfig: { chainId: '0x1' }, accounts: { '0xFirstAddress': { balance: '0x0', @@ -231,7 +231,7 @@ describe('Actions', () => { cb(null, { currentLocale: 'test', selectedAddress: '0xAnotherAddress', - provider: { + providerConfig: { chainId: '0x1', }, accounts: { @@ -2038,7 +2038,7 @@ describe('Actions', () => { cb(null, { currentLocale: 'test', selectedAddress: '0xFirstAddress', - provider: { + providerConfig: { chainId: '0x1', }, accounts: { @@ -2084,7 +2084,7 @@ describe('Actions', () => { cb(null, { currentLocale: 'test', selectedAddress: '0xFirstAddress', - provider: { + providerConfig: { chainId: '0x1', }, accounts: { diff --git a/ui/store/actions.ts b/ui/store/actions.ts index 6501b9ee6..5f33fecd8 100644 --- a/ui/store/actions.ts +++ b/ui/store/actions.ts @@ -1776,7 +1776,7 @@ export function updateMetamaskState( const { currentLocale: newLocale, selectedAddress: newSelectedAddress, - provider: newProviderConfig, + providerConfig: newProviderConfig, } = newState; if (currentLocale && newLocale && currentLocale !== newLocale) { diff --git a/ui/store/institutional/institution-actions.test.js b/ui/store/institutional/institution-actions.test.js index 2c9a7dca0..2c9ac1a15 100644 --- a/ui/store/institutional/institution-actions.test.js +++ b/ui/store/institutional/institution-actions.test.js @@ -15,7 +15,7 @@ const defaultState = { metamask: { currentLocale: 'test', selectedAddress: '0xFirstAddress', - provider: { chainId: '0x1' }, + providerConfig: { chainId: '0x1' }, accounts: { '0xFirstAddress': { balance: '0x0', @@ -199,7 +199,7 @@ describe('#updateCustodyState', () => { _setBackgroundConnection(background.getApi()); const newState = { - provider: { + providerConfig: { nickname: 'mainnet', chainId: '0x1', }, @@ -225,7 +225,7 @@ describe('#updateCustodyState', () => { _setBackgroundConnection(background.getApi()); const newState = { - provider: { + providerConfig: { nickname: 'mainnet', chainId: '0x1', }, @@ -280,7 +280,7 @@ describe('#updateCustodyState', () => { _setBackgroundConnection(background.getApi()); const newState = { - provider: { + providerConfig: { nickname: 'mainnet', chainId: '0x1', }, diff --git a/ui/store/store.ts b/ui/store/store.ts index ad3f3e714..1f0903ae2 100644 --- a/ui/store/store.ts +++ b/ui/store/store.ts @@ -48,7 +48,7 @@ interface TemporaryBackgroundState { name: string; }[]; }; - provider: { + providerConfig: { chainId: string; }; currentNetworkTxList: TransactionMeta[];