Skip to content

feat: add base to default rpc networks #5902

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Jun 5, 2025
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions eslint-warning-thresholds.json
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@
"jsdoc/check-tag-names": 5
},
"packages/controller-utils/src/types.ts": {
"@typescript-eslint/no-duplicate-enum-values": 2,
"jsdoc/tag-lines": 1
},
"packages/controller-utils/src/util.test.ts": {
Expand Down Expand Up @@ -447,12 +446,12 @@
"packages/remote-feature-flag-controller/src/utils/user-segmentation-utils.ts": {
"jsdoc/tag-lines": 2
},
"packages/seedless-onboarding-controller/src/errors.ts": {
"@typescript-eslint/no-unsafe-enum-comparison": 1
},
"packages/seedless-onboarding-controller/jest.environment.js": {
"n/no-unsupported-features/node-builtins": 1
},
"packages/seedless-onboarding-controller/src/errors.ts": {
"@typescript-eslint/no-unsafe-enum-comparison": 1
},
"packages/selected-network-controller/src/SelectedNetworkController.ts": {
"@typescript-eslint/prefer-readonly": 1,
"prettier/prettier": 6
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1167,7 +1167,7 @@ describe('TokenDetectionController', () => {
await advanceTime({ clock, duration: 1 });

expect(mockTokens).toHaveBeenNthCalledWith(1, {
chainIds: ['0x1', '0xaa36a7', '0xe705', '0xe708'],
chainIds: ['0x1', '0xaa36a7', '0xe705', '0xe708', '0x2105'],
selectedAddress: secondSelectedAccount.address,
});
},
Expand Down
8 changes: 8 additions & 0 deletions packages/controller-utils/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

- Add `TransactionBatch` in approval types enum ([#5793](https://github.com/MetaMask/core/pull/5793))
- Add Base network to default networks ([#5902](https://github.com/MetaMask/core/pull/5902))
- Add `base-mainnet` to `BUILT_IN_NETWORKS`
- Add `base-mainnet` to `InfuraNetworkType`
- Add `BaseMainnet` to `BuiltInNetworkName` enum
- Add `base-mainnet` to `ChainId` type
- Add `BaseMainnet` to `NetworksTicker` enum
- Add `BaseMainnet` to `BlockExplorerUrl` quasi-enum
- Add `BaseMainnet` to `NetworkNickname` quasi-enum

## [11.9.0]

Expand Down
7 changes: 7 additions & 0 deletions packages/controller-utils/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@ export const BUILT_IN_NETWORKS = {
blockExplorerUrl: BlockExplorerUrl['monad-testnet'],
},
},
[NetworkType['base-mainnet']]: {
chainId: ChainId['base-mainnet'],
ticker: NetworksTicker['base-mainnet'],
rpcPrefs: {
blockExplorerUrl: BlockExplorerUrl['base-mainnet'],
},
},
[NetworkType.rpc]: {
chainId: undefined,
blockExplorerUrl: undefined,
Expand Down
17 changes: 9 additions & 8 deletions packages/controller-utils/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const InfuraNetworkType = {
'linea-goerli': 'linea-goerli',
'linea-sepolia': 'linea-sepolia',
'linea-mainnet': 'linea-mainnet',
'base-mainnet': 'base-mainnet',
} as const;

export type InfuraNetworkType =
Expand Down Expand Up @@ -78,6 +79,7 @@ export enum BuiltInNetworkName {
Aurora = 'aurora',
MegaETHTestnet = 'megaeth-testnet',
MonadTestnet = 'monad-testnet',
BaseMainnet = 'base-mainnet',
}

/**
Expand All @@ -95,26 +97,23 @@ export const ChainId = {
[BuiltInNetworkName.LineaMainnet]: '0xe708', // toHex(59144)
[BuiltInNetworkName.MegaETHTestnet]: '0x18c6', // toHex(6342)
[BuiltInNetworkName.MonadTestnet]: '0x279f', // toHex(10143)
[BuiltInNetworkName.BaseMainnet]: '0x2105', // toHex(8453)
} as const;
export type ChainId = (typeof ChainId)[keyof typeof ChainId];

export enum NetworksTicker {
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
// eslint-disable-next-line @typescript-eslint/naming-convention
mainnet = 'ETH',
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
// eslint-disable-next-line @typescript-eslint/naming-convention
goerli = 'GoerliETH',
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
// eslint-disable-next-line @typescript-eslint/naming-convention
sepolia = 'SepoliaETH',
'linea-goerli' = 'LineaETH',
// eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values
'linea-sepolia' = 'LineaETH',
// eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values
'linea-mainnet' = 'ETH',
'megaeth-testnet' = 'MegaETH',
'monad-testnet' = 'MON',
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
// eslint-disable-next-line @typescript-eslint/naming-convention
// eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values
'base-mainnet' = 'ETH',
rpc = '',
}

Expand All @@ -127,6 +126,7 @@ export const BlockExplorerUrl = {
[BuiltInNetworkName.LineaMainnet]: 'https://lineascan.build',
[BuiltInNetworkName.MegaETHTestnet]: 'https://megaexplorer.xyz',
[BuiltInNetworkName.MonadTestnet]: 'https://testnet.monadexplorer.com',
[BuiltInNetworkName.BaseMainnet]: 'https://basescan.org',
} as const satisfies Record<BuiltInNetworkType, string>;
export type BlockExplorerUrl =
(typeof BlockExplorerUrl)[keyof typeof BlockExplorerUrl];
Expand All @@ -140,6 +140,7 @@ export const NetworkNickname = {
[BuiltInNetworkName.LineaMainnet]: 'Linea',
[BuiltInNetworkName.MegaETHTestnet]: 'Mega Testnet',
[BuiltInNetworkName.MonadTestnet]: 'Monad Testnet',
[BuiltInNetworkName.BaseMainnet]: 'Base Mainnet',
} as const satisfies Record<BuiltInNetworkType, string>;
export type NetworkNickname =
(typeof NetworkNickname)[keyof typeof NetworkNickname];
Expand Down
5 changes: 5 additions & 0 deletions packages/network-controller/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Add Base network to default infura networks ([#5902](https://github.com/MetaMask/core/pull/5902))
- Network changes were added in `@metamask/controller-utils`

## [23.5.1]

### Changed
Expand Down
45 changes: 45 additions & 0 deletions packages/network-controller/tests/NetworkController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,21 @@ describe('NetworkController', () => {
},
],
},
"0x2105": Object {
"blockExplorerUrls": Array [],
"chainId": "0x2105",
"defaultRpcEndpointIndex": 0,
"name": "Base Mainnet",
"nativeCurrency": "ETH",
"rpcEndpoints": Array [
Object {
"failoverUrls": Array [],
"networkClientId": "base-mainnet",
"type": "infura",
"url": "https://base-mainnet.infura.io/v3/{infuraProjectId}",
},
],
},
"0xaa36a7": Object {
"blockExplorerUrls": Array [],
"chainId": "0xaa36a7",
Expand Down Expand Up @@ -571,6 +586,21 @@ describe('NetworkController', () => {
},
],
},
"0x2105": Object {
"blockExplorerUrls": Array [],
"chainId": "0x2105",
"defaultRpcEndpointIndex": 0,
"name": "Base Mainnet",
"nativeCurrency": "ETH",
"rpcEndpoints": Array [
Object {
"failoverUrls": Array [],
"networkClientId": "base-mainnet",
"type": "infura",
"url": "https://base-mainnet.infura.io/v3/{infuraProjectId}",
},
],
},
"0xaa36a7": Object {
"blockExplorerUrls": Array [],
"chainId": "0xaa36a7",
Expand Down Expand Up @@ -1626,6 +1656,21 @@ describe('NetworkController', () => {
enableRpcFailover: expect.any(Function),
disableRpcFailover: expect.any(Function),
},
'base-mainnet': {
blockTracker: expect.anything(),
configuration: {
type: NetworkClientType.Infura,
failoverRpcUrls: [],
infuraProjectId,
chainId: '0x2105',
ticker: 'ETH',
network: InfuraNetworkType['base-mainnet'],
},
provider: expect.anything(),
destroy: expect.any(Function),
enableRpcFailover: expect.any(Function),
disableRpcFailover: expect.any(Function),
},
});
},
);
Expand Down
Loading