Skip to content

Commit

Permalink
Merge pull request #5 from Jeff-CCH/feat/support_Base_Metis_Optimism_…
Browse files Browse the repository at this point in the history
…Avalanche

Add Optimism, Base, Metis and Avalanche Info in Common Package
  • Loading branch information
Jeff-CCH authored Oct 11, 2023
2 parents 29710e4 + 2ed89a6 commit 141462f
Show file tree
Hide file tree
Showing 6 changed files with 232 additions and 28 deletions.
5 changes: 5 additions & 0 deletions .changeset/brave-dolls-try.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@protocolink/common': patch
---

add Optimism, Base, Metis, Avalanche information
5 changes: 5 additions & 0 deletions .changeset/strange-wolves-sleep.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@protocolink/core': patch
---

add Router address for Optimism, Base, Metis and Avalanche network
125 changes: 109 additions & 16 deletions packages/common/src/networks/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,29 @@
"multicall2Address": "0x5BA1e12693Dc8F9c48aAD8770482f4739bEeD696",
"multicall3Address": "0xcA11bde05977b3631167028862bE2a173976CA11"
},
{
"id": "optimism",
"chainId": 10,
"name": "Optimism",
"explorerUrl": "https://optimistic.etherscan.io/",
"rpcUrl": "https://rpc.ankr.com/optimism",
"nativeToken": {
"chainId": 10,
"address": "0x0000000000000000000000000000000000000000",
"decimals": 18,
"symbol": "ETH",
"name": "Ethereum"
},
"wrappedNativeToken": {
"chainId": 10,
"address": "0x4200000000000000000000000000000000000006",
"decimals": 18,
"symbol": "WETH",
"name": "Wrapped Ether"
},
"multicall2Address": "0x5BA1e12693Dc8F9c48aAD8770482f4739bEeD696",
"multicall3Address": "0xcA11bde05977b3631167028862bE2a173976CA11"
},
{
"id": "polygon",
"chainId": 137,
Expand All @@ -45,6 +68,76 @@
"multicall2Address": "0x275617327c958bD06b5D6b871E7f491D76113dd8",
"multicall3Address": "0xcA11bde05977b3631167028862bE2a173976CA11"
},
{
"id": "zksync",
"chainId": 324,
"name": "zkSync",
"explorerUrl": "https://explorer.zksync.io/",
"rpcUrl": "https://mainnet.era.zksync.io/",
"nativeToken": {
"chainId": 324,
"address": "0x0000000000000000000000000000000000000000",
"decimals": 18,
"symbol": "ETH",
"name": "Ethereum"
},
"wrappedNativeToken": {
"chainId": 324,
"address": "0x5AEa5775959fBC2557Cc8789bC1bf90A239D9a91",
"decimals": 18,
"symbol": "WETH",
"name": "Wrapped Ether"
},
"multicall2Address": "0x1fCD733705ec1CF534dD19ecF627F013352e776F",
"multicall3Address": "0xF9cda624FBC7e059355ce98a31693d299FACd963"
},
{
"id": "metis",
"chainId": 1088,
"name": "Metis",
"explorerUrl": "https://andromeda-explorer.metis.io/",
"rpcUrl": "https://metis-mainnet.public.blastapi.io",
"nativeToken": {
"chainId": 1088,
"address": "0xDeadDeAddeAddEAddeadDEaDDEAdDeaDDeAD0000",
"decimals": 18,
"symbol": "METIS",
"name": "Metis"
},
"wrappedNativeToken": {
"chainId": 1088,
"address": "0x71802e8F394BB9d05a1b8E9d0562917609FD7325",
"decimals": 18,
"symbol": "WMETIS",
"name": "Wrapped METIS"
},

"multicall2Address": "0xc39aBB6c4451089dE48Cffb013c39d3110530e5C",
"multicall3Address": "0xcA11bde05977b3631167028862bE2a173976CA11"
},
{
"id": "base",
"chainId": 8453,
"name": "Base",
"explorerUrl": "https://basescan.org/",
"rpcUrl": "https://rpc.ankr.com/base",
"nativeToken": {
"chainId": 8453,
"address": "0x0000000000000000000000000000000000000000",
"decimals": 18,
"symbol": "ETH",
"name": "Ethereum"
},
"wrappedNativeToken": {
"chainId": 8453,
"address": "0x4200000000000000000000000000000000000006",
"decimals": 18,
"symbol": "WETH",
"name": "Wrapped Ether"
},
"multicall2Address": "0xcA11bde05977b3631167028862bE2a173976CA11",
"multicall3Address": "0xcA11bde05977b3631167028862bE2a173976CA11"
},
{
"id": "arbitrum",
"chainId": 42161,
Expand All @@ -69,26 +162,26 @@
"multicall3Address": "0xcA11bde05977b3631167028862bE2a173976CA11"
},
{
"id": "zksync",
"chainId": 324,
"name": "zkSync",
"explorerUrl": "https://explorer.zksync.io/",
"rpcUrl": "https://mainnet.era.zksync.io/",
"id": "avalanche",
"chainId": 43114,
"name": "Avalanche",
"explorerUrl": "https://snowtrace.io/",
"rpcUrl": "https://rpc.ankr.com/avalanche",
"nativeToken": {
"chainId": 324,
"symbol": "ETH",
"name": "Ethereum",
"chainId": 43114,
"address": "0x0000000000000000000000000000000000000000",
"decimals": 18
"decimals": 18,
"symbol": "AVAX",
"name": "Avalanche"
},
"wrappedNativeToken": {
"chainId": 324,
"symbol": "WETH",
"name": "Wrapped Ether",
"address": "0x5AEa5775959fBC2557Cc8789bC1bf90A239D9a91",
"decimals": 18
"chainId": 43114,
"address": "0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7",
"decimals": 18,
"symbol": "WAVAX",
"name": "Wrapped AVAX"
},
"multicall2Address": "0x1fCD733705ec1CF534dD19ecF627F013352e776F",
"multicall3Address": "0xF9cda624FBC7e059355ce98a31693d299FACd963"
"multicall2Address": "0xF2FD8219609E28C61A998cc534681f95D2740f61",
"multicall3Address": "0xcA11bde05977b3631167028862bE2a173976CA11"
}
]
97 changes: 89 additions & 8 deletions packages/common/src/networks/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@ import { expect } from 'chai';
describe('Test isSupportedChainId', function () {
const testCases = [
{ chainId: ChainId.mainnet, expected: true },
{ chainId: ChainId.optimism, expected: true },
{ chainId: ChainId.polygon, expected: true },
{ chainId: ChainId.arbitrum, expected: true },
{ chainId: ChainId.zksync, expected: true },
{ chainId: ChainId.metis, expected: true },
{ chainId: ChainId.base, expected: true },
{ chainId: ChainId.arbitrum, expected: true },
{ chainId: ChainId.avalanche, expected: true },
{ chainId: 1337, expected: false },
];

Expand All @@ -30,9 +34,13 @@ describe('Test isSupportedChainId', function () {
describe('Test isSupportedNetworkId', function () {
const testCases = [
{ networkId: NetworkId.mainnet, expected: true },
{ networkId: NetworkId.optimism, expected: true },
{ networkId: NetworkId.polygon, expected: true },
{ networkId: NetworkId.arbitrum, expected: true },
{ networkId: NetworkId.zksync, expected: true },
{ networkId: NetworkId.metis, expected: true },
{ networkId: NetworkId.base, expected: true },
{ networkId: NetworkId.arbitrum, expected: true },
{ networkId: NetworkId.avalanche, expected: true },
{ networkId: 'hardhat', expected: false },
];

Expand Down Expand Up @@ -63,6 +71,24 @@ describe('Test newExplorerUrl', function () {
data: '0xdAC17F958D2ee523a2206206994597C13D831ec7',
expected: 'https://etherscan.io/token/0xdAC17F958D2ee523a2206206994597C13D831ec7',
},
{
chainId: ChainId.optimism,
type: ExplorerType.tx,
data: '0x7b00ad829b19ebd4df94f8b5cd0120d300d67482d41755dd5d259defb0164743',
expected: 'https://optimistic.etherscan.io/tx/0x7b00ad829b19ebd4df94f8b5cd0120d300d67482d41755dd5d259defb0164743',
},
{
chainId: ChainId.optimism,
type: ExplorerType.address,
data: '0xd8c1cecca51d5d97a70a35e194bb6670b85d8576',
expected: 'https://optimistic.etherscan.io/address/0xd8c1cecca51d5d97a70a35e194bb6670b85d8576',
},
{
chainId: ChainId.optimism,
type: ExplorerType.token,
data: '0xdAC17F958D2ee523a2206206994597C13D831ec7',
expected: 'https://optimistic.etherscan.io/token/0xdAC17F958D2ee523a2206206994597C13D831ec7',
},
{
chainId: ChainId.polygon,
type: ExplorerType.tx,
Expand All @@ -81,6 +107,55 @@ describe('Test newExplorerUrl', function () {
data: '0xdAC17F958D2ee523a2206206994597C13D831ec7',
expected: 'https://polygonscan.com/token/0xdAC17F958D2ee523a2206206994597C13D831ec7',
},
{
chainId: ChainId.zksync,
type: ExplorerType.tx,
data: '0xf2796c0c8814a8fb37e30fef66a43b872803921d7d674b87916959ae57efcc71',
expected: 'https://explorer.zksync.io/tx/0xf2796c0c8814a8fb37e30fef66a43b872803921d7d674b87916959ae57efcc71',
},
{
chainId: ChainId.zksync,
type: ExplorerType.address,
data: '0x460f500EFfDC9d9ddD120f2812ff409bFdff47fA',
expected: 'https://explorer.zksync.io/address/0x460f500EFfDC9d9ddD120f2812ff409bFdff47fA',
},
{
chainId: ChainId.metis,
type: ExplorerType.tx,
data: '0x7b00ad829b19ebd4df94f8b5cd0120d300d67482d41755dd5d259defb0164743',
expected:
'https://andromeda-explorer.metis.io/tx/0x7b00ad829b19ebd4df94f8b5cd0120d300d67482d41755dd5d259defb0164743',
},
{
chainId: ChainId.metis,
type: ExplorerType.address,
data: '0xd8c1cecca51d5d97a70a35e194bb6670b85d8576',
expected: 'https://andromeda-explorer.metis.io/address/0xd8c1cecca51d5d97a70a35e194bb6670b85d8576',
},
{
chainId: ChainId.metis,
type: ExplorerType.token,
data: '0xdAC17F958D2ee523a2206206994597C13D831ec7',
expected: 'https://andromeda-explorer.metis.io/token/0xdAC17F958D2ee523a2206206994597C13D831ec7',
},
{
chainId: ChainId.base,
type: ExplorerType.tx,
data: '0x7b00ad829b19ebd4df94f8b5cd0120d300d67482d41755dd5d259defb0164743',
expected: 'https://basescan.org/tx/0x7b00ad829b19ebd4df94f8b5cd0120d300d67482d41755dd5d259defb0164743',
},
{
chainId: ChainId.base,
type: ExplorerType.address,
data: '0xd8c1cecca51d5d97a70a35e194bb6670b85d8576',
expected: 'https://basescan.org/address/0xd8c1cecca51d5d97a70a35e194bb6670b85d8576',
},
{
chainId: ChainId.base,
type: ExplorerType.token,
data: '0xdAC17F958D2ee523a2206206994597C13D831ec7',
expected: 'https://basescan.org/token/0xdAC17F958D2ee523a2206206994597C13D831ec7',
},
{
chainId: ChainId.arbitrum,
type: ExplorerType.tx,
Expand All @@ -100,16 +175,22 @@ describe('Test newExplorerUrl', function () {
expected: 'https://arbiscan.io/token/0xdAC17F958D2ee523a2206206994597C13D831ec7',
},
{
chainId: ChainId.zksync,
chainId: ChainId.avalanche,
type: ExplorerType.tx,
data: '0xf2796c0c8814a8fb37e30fef66a43b872803921d7d674b87916959ae57efcc71',
expected: 'https://explorer.zksync.io/tx/0xf2796c0c8814a8fb37e30fef66a43b872803921d7d674b87916959ae57efcc71',
data: '0x7b00ad829b19ebd4df94f8b5cd0120d300d67482d41755dd5d259defb0164743',
expected: 'https://snowtrace.io/tx/0x7b00ad829b19ebd4df94f8b5cd0120d300d67482d41755dd5d259defb0164743',
},
{
chainId: ChainId.zksync,
chainId: ChainId.avalanche,
type: ExplorerType.address,
data: '0x460f500EFfDC9d9ddD120f2812ff409bFdff47fA',
expected: 'https://explorer.zksync.io/address/0x460f500EFfDC9d9ddD120f2812ff409bFdff47fA',
data: '0xd8c1cecca51d5d97a70a35e194bb6670b85d8576',
expected: 'https://snowtrace.io/address/0xd8c1cecca51d5d97a70a35e194bb6670b85d8576',
},
{
chainId: ChainId.avalanche,
type: ExplorerType.token,
data: '0xdAC17F958D2ee523a2206206994597C13D831ec7',
expected: 'https://snowtrace.io/token/0xdAC17F958D2ee523a2206206994597C13D831ec7',
},
];

Expand Down
12 changes: 10 additions & 2 deletions packages/common/src/networks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,24 @@ export function toChainId(networkId: string) {

export enum ChainId {
mainnet = 1,
optimism = 10,
polygon = 137,
arbitrum = 42161,
zksync = 324,
metis = 1088,
base = 8453,
arbitrum = 42161,
avalanche = 43114,
}

export enum NetworkId {
mainnet = 'mainnet',
optimism = 'optimism',
polygon = 'polygon',
arbitrum = 'arbitrum',
zksync = 'zksync',
metis = 'metis',
base = 'base',
arbitrum = 'arbitrum',
avalanche = 'avalanche',
}

export function isSupportedChainId(chainId: number) {
Expand Down
16 changes: 14 additions & 2 deletions packages/core/src/configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,27 @@ export const contractAddressMap: Record<number, Record<ContractNames, string>> =
[common.ChainId.mainnet]: {
Router: '0x3fa3B62F0c9c13733245A778DE4157E47Cf5bA21',
},
[common.ChainId.polygon]: {
[common.ChainId.optimism]: {
Router: '0x3fa3B62F0c9c13733245A778DE4157E47Cf5bA21',
},
[common.ChainId.arbitrum]: {
[common.ChainId.polygon]: {
Router: '0x3fa3B62F0c9c13733245A778DE4157E47Cf5bA21',
},
[common.ChainId.zksync]: {
Router: '0xa8350893B36e0425B50917125d9603F81F2D3C87',
},
[common.ChainId.metis]: {
Router: '0x3fa3B62F0c9c13733245A778DE4157E47Cf5bA21',
},
[common.ChainId.base]: {
Router: '0x3fa3B62F0c9c13733245A778DE4157E47Cf5bA21',
},
[common.ChainId.arbitrum]: {
Router: '0x3fa3B62F0c9c13733245A778DE4157E47Cf5bA21',
},
[common.ChainId.avalanche]: {
Router: '0x3fa3B62F0c9c13733245A778DE4157E47Cf5bA21',
},
};

export function getContractAddress(chainId: number, name: ContractNames) {
Expand Down

0 comments on commit 141462f

Please sign in to comment.