diff --git a/packages/optimism-networks/__tests__/switch-to-l1.test.ts b/packages/optimism-networks/__tests__/switch-to-l1.test.ts index a2255a674..2baee6553 100644 --- a/packages/optimism-networks/__tests__/switch-to-l1.test.ts +++ b/packages/optimism-networks/__tests__/switch-to-l1.test.ts @@ -36,6 +36,23 @@ describe('switchToL1', () => { params: [{ chainId: '0x2a' }], }); }); + test('Switch to gorli when optimism gorli is selected', async () => { + const requestMock = jest.fn().mockResolvedValue(undefined); + const arg = { + ethereum: { + isMetaMask: true, + request: requestMock, + chainId: '0x45', + }, + } as any; + + await switchToL1(arg); + expect(requestMock).toBeCalledTimes(1); + expect(requestMock).toHaveBeenCalledWith({ + method: 'wallet_switchEthereumChain', + params: [{ chainId: '0x2a' }], + }); + }); test('Switch to mainnet when unsupported network selected', async () => { const requestMock = jest.fn().mockResolvedValue(undefined); const arg = { diff --git a/packages/optimism-networks/__tests__/switch-to-l2.test.ts b/packages/optimism-networks/__tests__/switch-to-l2.test.ts index f77c88735..8dbfc275f 100644 --- a/packages/optimism-networks/__tests__/switch-to-l2.test.ts +++ b/packages/optimism-networks/__tests__/switch-to-l2.test.ts @@ -37,6 +37,23 @@ describe('switchToL2', () => { params: [{ chainId: '0x45' }], }); }); + test('Switch to Optimism Goerli when Goerli selected ', async () => { + const requestMock = jest.fn().mockResolvedValue(undefined); + const deps = { + ethereum: { + isMetaMask: true, + request: requestMock, + chainId: '0x5', + }, + } as any; + + await switchToL2(deps); + expect(requestMock).toBeCalledTimes(1); + expect(requestMock).toHaveBeenCalledWith({ + method: 'wallet_switchEthereumChain', + params: [{ chainId: '0x1A4' }], + }); + }); test('Switch to Optimism mainnet when unsupported network selected ', async () => { const requestMock = jest.fn().mockResolvedValue(undefined); const deps = { diff --git a/packages/optimism-networks/src/constants.ts b/packages/optimism-networks/src/constants.ts index c9f34924c..25ec21dae 100644 --- a/packages/optimism-networks/src/constants.ts +++ b/packages/optimism-networks/src/constants.ts @@ -7,13 +7,13 @@ export const DEFAULT_LAYER2_NETWORK = 10; export const L1_TO_L2_NETWORK_MAPPER: NetworkMapper = { 1: 10, 42: 69, - 31337: 420, + 5: 420, }; export const L2_TO_L1_NETWORK_MAPPER: NetworkMapper = { 10: 1, 69: 42, - 420: 31337, + 420: 5, }; export const OPTIMISM_NETWORKS: Record = { @@ -27,11 +27,12 @@ export const OPTIMISM_NETWORKS: Record = { 'https://optimism.io/images/metamask_icon.png', ], }, - 69: { - chainId: '0x45', + + 420: { + chainId: '0x1A4', chainName: 'Optimism Kovan', - rpcUrls: ['https://kovan.optimism.io'], - blockExplorerUrls: ['https://kovan-optimistic.etherscan.io'], + rpcUrls: ['https://goerli.optimism.io/'], + blockExplorerUrls: [''], // TODO should add when it becomes avaiable iconUrls: [ 'https://optimism.io/images/metamask_icon.svg', 'https://optimism.io/images/metamask_icon.png', diff --git a/packages/optimism-networks/src/types.ts b/packages/optimism-networks/src/types.ts index 73f77c204..327e00768 100644 --- a/packages/optimism-networks/src/types.ts +++ b/packages/optimism-networks/src/types.ts @@ -10,6 +10,7 @@ export type OptimismNetwork = { export enum NetworkId { Mainnet = 10, Kovan = 69, + Goerli = 420, } export type OptimismWatcher = {