Skip to content

Commit

Permalink
Merge pull request #28973 from MetaMask/Version-v12.8.1
Browse files Browse the repository at this point in the history
Version v12.8.1 RC
  • Loading branch information
danjm authored Dec 6, 2024
2 parents 7689c6e + 4fa2bd1 commit 884d810
Show file tree
Hide file tree
Showing 10 changed files with 1,013 additions and 422 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [12.8.1]
### Fixed
- Update default Base rpc to https://base-mainnet.infura.io/ ([#28974](https://github.com/MetaMask/metamask-extension/pull/28974))

## [12.8.0]
### Added
- Added multi-chain polling for token prices ([#28158](https://github.com/MetaMask/metamask-extension/pull/28158))
Expand Down Expand Up @@ -5417,7 +5421,8 @@ Update styles and spacing on the critical error page ([#20350](https://github.c
- Added the ability to restore accounts from seed words.


[Unreleased]: https://github.com/MetaMask/metamask-extension/compare/v12.8.0...HEAD
[Unreleased]: https://github.com/MetaMask/metamask-extension/compare/v12.8.1...HEAD
[12.8.1]: https://github.com/MetaMask/metamask-extension/compare/v12.8.0...v12.8.1
[12.8.0]: https://github.com/MetaMask/metamask-extension/compare/v12.7.2...v12.8.0
[12.7.2]: https://github.com/MetaMask/metamask-extension/compare/v12.7.1...v12.7.2
[12.7.1]: https://github.com/MetaMask/metamask-extension/compare/v12.7.0...v12.7.1
Expand Down
1 change: 1 addition & 0 deletions app/scripts/controllers/metametrics-controller.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ describe('MetaMetricsController', function () {
});

const expectedFragment = merge(
{},
SAMPLE_TX_SUBMITTED_PARTIAL_FRAGMENT,
SAMPLE_PERSISTED_EVENT_NO_ID,
{
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/controllers/metametrics-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ export default class MetaMetricsController extends BaseController<

this.update((state) => {
// @ts-expect-error this is caused by a bug in Immer, not being able to handle recursive types like Json
state.fragments[id] = merge(additionalFragmentProps, fragment);
state.fragments[id] = merge({}, additionalFragmentProps, fragment);
});

if (fragment.initialEvent) {
Expand Down
254 changes: 254 additions & 0 deletions app/scripts/migrations/131.1.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,254 @@
import { cloneDeep } from 'lodash';
import { NetworkState } from '@metamask/network-controller';
import { infuraProjectId } from '../../../shared/constants/network';
import { migrate, version } from './131.1';

const oldVersion = 131;
const BASE_CHAIN_ID = '0x2105';

describe('migration #131.1', () => {
it('updates the version metadata', async () => {
const oldStorage = {
meta: { version: oldVersion },
data: {},
};

const newStorage = await migrate(cloneDeep(oldStorage));

expect(newStorage.meta).toStrictEqual({ version });
});

describe('Base Network Migration', () => {
it('does nothing if networkConfigurationsByChainId is not in state', async () => {
const oldState = {
OtherController: {},
};

const transformedState = await migrate({
meta: { version: oldVersion },
data: cloneDeep(oldState),
});

expect(transformedState.data).toEqual(oldState);
});

it('does nothing if no Infura RPC endpoints are used', async () => {
const oldState = {
NetworkController: {
networkConfigurationsByChainId: {
'0x1': {
rpcEndpoints: [
{
url: 'https://custom.rpc',
type: 'custom',
},
],
defaultRpcEndpointIndex: 0,
},
},
},
};

const transformedState = await migrate({
meta: { version: oldVersion },
data: cloneDeep(oldState),
});

expect(transformedState.data).toEqual(oldState);
});

it('does nothing if Base network configuration is missing', async () => {
const oldState = {
NetworkController: {
networkConfigurationsByChainId: {
'0x1': {
rpcEndpoints: [
{
url: `https://mainnet.infura.io/v3/${infuraProjectId}`,
type: 'infura',
},
],
defaultRpcEndpointIndex: 0,
},
},
},
};

const transformedState = await migrate({
meta: { version: oldVersion },
data: cloneDeep(oldState),
});

expect(transformedState.data).toEqual(oldState);
});

it('replaces "https://mainnet.base.org" if the default RPC endpoint is Infura', async () => {
const oldState = {
NetworkController: {
networkConfigurationsByChainId: {
[BASE_CHAIN_ID]: {
rpcEndpoints: [
{
url: 'https://mainnet.base.org',
type: 'custom',
},
],
defaultRpcEndpointIndex: 0,
},
'0x1': {
rpcEndpoints: [
{
url: `https://mainnet.infura.io/v3/${infuraProjectId}`,
type: 'infura',
},
],
defaultRpcEndpointIndex: 0,
},
},
},
};

const transformedState = await migrate({
meta: { version: oldVersion },
data: cloneDeep(oldState),
});

const updatedNetworkController = transformedState.data
.NetworkController as NetworkState;

expect(
updatedNetworkController.networkConfigurationsByChainId[BASE_CHAIN_ID]
.rpcEndpoints[0].url,
).toEqual(`https://base-mainnet.infura.io/v3/${infuraProjectId}`);
});

it('does not modify RPC endpoints if the default RPC endpoint is not Infura', async () => {
const oldState = {
NetworkController: {
networkConfigurationsByChainId: {
[BASE_CHAIN_ID]: {
rpcEndpoints: [
{
url: 'https://other.rpc',
type: 'custom',
},
],
defaultRpcEndpointIndex: 0,
},
'0x1': {
rpcEndpoints: [
{
url: 'https://custom.rpc',
type: 'custom',
},
],
defaultRpcEndpointIndex: 0,
},
},
},
};

const transformedState = await migrate({
meta: { version: oldVersion },
data: cloneDeep(oldState),
});

const updatedNetworkController = transformedState.data
.NetworkController as NetworkState;

expect(
updatedNetworkController.networkConfigurationsByChainId[BASE_CHAIN_ID]
.rpcEndpoints[0].url,
).toEqual('https://other.rpc');
});

it('keeps defaultRpcEndpointIndex unchanged when replacing "https://mainnet.base.org"', async () => {
const oldState = {
NetworkController: {
networkConfigurationsByChainId: {
[BASE_CHAIN_ID]: {
rpcEndpoints: [
{
url: 'https://mainnet.base.org',
type: 'custom',
},
],
defaultRpcEndpointIndex: 0,
},
'0x1': {
rpcEndpoints: [
{
url: `https://mainnet.infura.io/v3/${infuraProjectId}`,
type: 'infura',
},
],
defaultRpcEndpointIndex: 0,
},
},
},
};

const transformedState = await migrate({
meta: { version: oldVersion },
data: cloneDeep(oldState),
});

const updatedNetworkController = transformedState.data
.NetworkController as NetworkState;

expect(
updatedNetworkController.networkConfigurationsByChainId[BASE_CHAIN_ID]
.defaultRpcEndpointIndex,
).toEqual(0);
});

it('does nothing if Linea mainnet is excluded', async () => {
const oldState = {
NetworkController: {
networkConfigurationsByChainId: {
[BASE_CHAIN_ID]: {
rpcEndpoints: [
{
url: 'https://mainnet.base.org',
type: 'custom',
},
],
defaultRpcEndpointIndex: 0,
},
'0x1': {
rpcEndpoints: [
{
url: `https://mainnet.infura.io/v3/${infuraProjectId}`,
type: 'infura',
},
],
defaultRpcEndpointIndex: 0,
},
'0x13881': {
rpcEndpoints: [
{
url: 'https://rpc.goerli.linea.io',
type: 'custom',
},
],
defaultRpcEndpointIndex: 0,
},
},
},
};

const transformedState = await migrate({
meta: { version: oldVersion },
data: cloneDeep(oldState),
});

const updatedNetworkController = transformedState.data
.NetworkController as NetworkState;

expect(
updatedNetworkController.networkConfigurationsByChainId['0x13881']
.rpcEndpoints[0].url,
).toEqual('https://rpc.goerli.linea.io');
});
});
});
Loading

0 comments on commit 884d810

Please sign in to comment.