From 9d75bec759e8a6f26e3e367f37406a55e386b7c5 Mon Sep 17 00:00:00 2001 From: ZD Hu Date: Mon, 20 Nov 2023 11:31:04 +0800 Subject: [PATCH 1/2] feat: core package update router addresses for production use --- .changeset/weak-cups-sing.md | 5 + packages/core/src/configs.ts | 19 +-- packages/core/src/router-kit.test.ts | 186 +++++++++++++++++++++++---- 3 files changed, 174 insertions(+), 36 deletions(-) create mode 100644 .changeset/weak-cups-sing.md diff --git a/.changeset/weak-cups-sing.md b/.changeset/weak-cups-sing.md new file mode 100644 index 00000000..d5b5ca42 --- /dev/null +++ b/.changeset/weak-cups-sing.md @@ -0,0 +1,5 @@ +--- +'@protocolink/core': patch +--- + +feat: update router addresses for production use diff --git a/packages/core/src/configs.ts b/packages/core/src/configs.ts index badc6038..d4b4d8f3 100644 --- a/packages/core/src/configs.ts +++ b/packages/core/src/configs.ts @@ -4,28 +4,31 @@ type ContractNames = 'Router'; export const contractAddressMap: Record> = { [common.ChainId.mainnet]: { - Router: '0x3fa3B62F0c9c13733245A778DE4157E47Cf5bA21', + Router: '0xDec80E988F4baF43be69c13711453013c212feA8', }, [common.ChainId.optimism]: { - Router: '0x3fa3B62F0c9c13733245A778DE4157E47Cf5bA21', + Router: '0xDec80E988F4baF43be69c13711453013c212feA8', + }, + [common.ChainId.gnosis]: { + Router: '0xDec80E988F4baF43be69c13711453013c212feA8', }, [common.ChainId.polygon]: { - Router: '0x3fa3B62F0c9c13733245A778DE4157E47Cf5bA21', + Router: '0xDec80E988F4baF43be69c13711453013c212feA8', }, [common.ChainId.zksync]: { - Router: '0xa8350893B36e0425B50917125d9603F81F2D3C87', + Router: '0xF0eD7De3cCc91682550cD178f1628830CDBcA237', }, [common.ChainId.metis]: { - Router: '0x3fa3B62F0c9c13733245A778DE4157E47Cf5bA21', + Router: '0xDec80E988F4baF43be69c13711453013c212feA8', }, [common.ChainId.base]: { - Router: '0x3fa3B62F0c9c13733245A778DE4157E47Cf5bA21', + Router: '0xDec80E988F4baF43be69c13711453013c212feA8', }, [common.ChainId.arbitrum]: { - Router: '0x3fa3B62F0c9c13733245A778DE4157E47Cf5bA21', + Router: '0xDec80E988F4baF43be69c13711453013c212feA8', }, [common.ChainId.avalanche]: { - Router: '0x3fa3B62F0c9c13733245A778DE4157E47Cf5bA21', + Router: '0xDec80E988F4baF43be69c13711453013c212feA8', }, }; diff --git a/packages/core/src/router-kit.test.ts b/packages/core/src/router-kit.test.ts index 2ce5a375..2f2f25f4 100644 --- a/packages/core/src/router-kit.test.ts +++ b/packages/core/src/router-kit.test.ts @@ -9,19 +9,39 @@ describe('RouterKit', function () { const testCases = [ { chainId: common.ChainId.mainnet, - expected: '0x903847853d5fE12BaC24dD85903190528CF6070b', + expected: '0x4D4c961De7140E642b7217f221b73e859E3A6482', + }, + { + chainId: common.ChainId.optimism, + expected: '0x4D4c961De7140E642b7217f221b73e859E3A6482', + }, + { + chainId: common.ChainId.gnosis, + expected: '0x4D4c961De7140E642b7217f221b73e859E3A6482', }, { chainId: common.ChainId.polygon, - expected: '0x903847853d5fE12BaC24dD85903190528CF6070b', + expected: '0x4D4c961De7140E642b7217f221b73e859E3A6482', + }, + { + chainId: common.ChainId.zksync, + expected: '0xB643d9A266DB03e038670058685Af10c13238EC6', + }, + { + chainId: common.ChainId.metis, + expected: '0x4D4c961De7140E642b7217f221b73e859E3A6482', + }, + { + chainId: common.ChainId.base, + expected: '0x4D4c961De7140E642b7217f221b73e859E3A6482', }, { chainId: common.ChainId.arbitrum, - expected: '0x903847853d5fE12BaC24dD85903190528CF6070b', + expected: '0x4D4c961De7140E642b7217f221b73e859E3A6482', }, { - chainId: common.ChainId.zksync, - expected: '0x1f4f87CDf642bAfD106fa42Ae327f5bAE7ab8F02', + chainId: common.ChainId.avalanche, + expected: '0x4D4c961De7140E642b7217f221b73e859E3A6482', }, ]; @@ -38,19 +58,39 @@ describe('RouterKit', function () { const testCases = [ { chainId: common.ChainId.mainnet, - expected: '0xDdbe07CB6D77e81802C55bB381546c0DA51163dd', + expected: '0x6304EB1B1eC2135a64a90bA901B12Cf769657579', + }, + { + chainId: common.ChainId.optimism, + expected: '0x168608B226ef4E59Db5E61359509656a51BAe090', + }, + { + chainId: common.ChainId.gnosis, + expected: '0x4207b828b673EDC01d7f0020E8e8A99D8b454136', }, { chainId: common.ChainId.polygon, - expected: '0xDdbe07CB6D77e81802C55bB381546c0DA51163dd', + expected: '0x3EBe4dfaF95cd320BF34633B3BDf773FbE732E63', + }, + { + chainId: common.ChainId.zksync, + expected: '0x33dcA7EF16B6a0893542A1033cB70a24b2208b8F', + }, + { + chainId: common.ChainId.metis, + expected: '0x75Ce960F2FD5f06C83EE034992362e593dcf7722', + }, + { + chainId: common.ChainId.base, + expected: '0x50Df7c73bA1B4bb74934E50298de73F265260Ea4', }, { chainId: common.ChainId.arbitrum, - expected: '0xDdbe07CB6D77e81802C55bB381546c0DA51163dd', + expected: '0x3EBe4dfaF95cd320BF34633B3BDf773FbE732E63', }, { - chainId: common.ChainId.zksync, - expected: '0xDdbe07CB6D77e81802C55bB381546c0DA51163dd', + chainId: common.ChainId.avalanche, + expected: '0x168608B226ef4E59Db5E61359509656a51BAe090', }, ]; @@ -67,19 +107,39 @@ describe('RouterKit', function () { const testCases = [ { chainId: common.ChainId.mainnet, - expected: '0xddbe07cb6d77e81802c55bb381546c0da51163dd000000000000000000002710', + expected: '0x6304eb1b1ec2135a64a90ba901b12cf769657579000000000000000000002710', + }, + { + chainId: common.ChainId.optimism, + expected: '0x168608b226ef4e59db5e61359509656a51bae090000000000000000000002710', + }, + { + chainId: common.ChainId.gnosis, + expected: '0x4207b828b673edc01d7f0020e8e8a99d8b454136000000000000000000002710', }, { chainId: common.ChainId.polygon, - expected: '0xddbe07cb6d77e81802c55bb381546c0da51163dd000000000000000000002710', + expected: '0x3ebe4dfaf95cd320bf34633b3bdf773fbe732e63000000000000000000002710', + }, + { + chainId: common.ChainId.zksync, + expected: '0x33dca7ef16b6a0893542a1033cb70a24b2208b8f000000000000000000002710', + }, + { + chainId: common.ChainId.metis, + expected: '0x75ce960f2fd5f06c83ee034992362e593dcf7722000000000000000000002710', + }, + { + chainId: common.ChainId.base, + expected: '0x50df7c73ba1b4bb74934e50298de73f265260ea4000000000000000000002710', }, { chainId: common.ChainId.arbitrum, - expected: '0xddbe07cb6d77e81802c55bb381546c0da51163dd000000000000000000002710', + expected: '0x3ebe4dfaf95cd320bf34633b3bdf773fbe732e63000000000000000000002710', }, { - chainId: common.ChainId.zksync, - expected: '0xddbe07cb6d77e81802c55bb381546c0da51163dd000000000000000000002710', + chainId: common.ChainId.avalanche, + expected: '0x168608b226ef4e59db5e61359509656a51bae090000000000000000000002710', }, ]; @@ -99,17 +159,37 @@ describe('RouterKit', function () { expected: '0x000000000022D473030F116dDEE9F6B43aC78BA3', }, { - chainId: common.ChainId.polygon, + chainId: common.ChainId.optimism, expected: '0x000000000022D473030F116dDEE9F6B43aC78BA3', }, { - chainId: common.ChainId.arbitrum, + chainId: common.ChainId.gnosis, + expected: '0x000000000022D473030F116dDEE9F6B43aC78BA3', + }, + { + chainId: common.ChainId.polygon, expected: '0x000000000022D473030F116dDEE9F6B43aC78BA3', }, { chainId: common.ChainId.zksync, expected: '0x87C0878B54c174199f438470FD74B3F7e1Def295', }, + { + chainId: common.ChainId.metis, + expected: '0x2EE5407017B878774b58c34A8c09CAcC94aDd69B', + }, + { + chainId: common.ChainId.base, + expected: '0x000000000022D473030F116dDEE9F6B43aC78BA3', + }, + { + chainId: common.ChainId.arbitrum, + expected: '0x000000000022D473030F116dDEE9F6B43aC78BA3', + }, + { + chainId: common.ChainId.avalanche, + expected: '0x000000000022D473030F116dDEE9F6B43aC78BA3', + }, ]; testCases.forEach(({ chainId, expected }, i) => { @@ -126,42 +206,92 @@ describe('RouterKit', function () { { chainId: common.ChainId.mainnet, account: '0x5cb738DAe833Ec21fe65ae1719fAd8ab8cE7f23D', - expected: '0xefc25B94FFeB90d5045cDAA936a52489bfBeA9D8', + expected: '0x8f6325f5E452B8Aa8137722A9f584C41c32d53A1', }, { chainId: common.ChainId.mainnet, account: '0xa3C1C91403F0026b9dd086882aDbC8Cdbc3b3cfB', - expected: '0x236E002fb1ba4043463aa89E1ccF845d2e3661a6', + expected: '0x22CF139619f4B8Afc863beCa670615C6310aC7c6', + }, + { + chainId: common.ChainId.optimism, + account: '0x5cb738DAe833Ec21fe65ae1719fAd8ab8cE7f23D', + expected: '0x8f6325f5E452B8Aa8137722A9f584C41c32d53A1', + }, + { + chainId: common.ChainId.optimism, + account: '0xa3C1C91403F0026b9dd086882aDbC8Cdbc3b3cfB', + expected: '0x22CF139619f4B8Afc863beCa670615C6310aC7c6', + }, + { + chainId: common.ChainId.gnosis, + account: '0x5cb738DAe833Ec21fe65ae1719fAd8ab8cE7f23D', + expected: '0x8f6325f5E452B8Aa8137722A9f584C41c32d53A1', + }, + { + chainId: common.ChainId.gnosis, + account: '0xa3C1C91403F0026b9dd086882aDbC8Cdbc3b3cfB', + expected: '0x22CF139619f4B8Afc863beCa670615C6310aC7c6', }, { chainId: common.ChainId.polygon, account: '0x5cb738DAe833Ec21fe65ae1719fAd8ab8cE7f23D', - expected: '0xefc25B94FFeB90d5045cDAA936a52489bfBeA9D8', + expected: '0x8f6325f5E452B8Aa8137722A9f584C41c32d53A1', }, { chainId: common.ChainId.polygon, account: '0xa3C1C91403F0026b9dd086882aDbC8Cdbc3b3cfB', - expected: '0x236E002fb1ba4043463aa89E1ccF845d2e3661a6', + expected: '0x22CF139619f4B8Afc863beCa670615C6310aC7c6', + }, + { + chainId: common.ChainId.zksync, + account: '0x5cb738DAe833Ec21fe65ae1719fAd8ab8cE7f23D', + expected: '0xE65a6d15C0EA2f47B80db8482C8d2dC5Ff69844c', + }, + { + chainId: common.ChainId.zksync, + account: '0xa3C1C91403F0026b9dd086882aDbC8Cdbc3b3cfB', + expected: '0x70B901C6013f5542b4039C9c96402cfAE9Ae6306', + }, + { + chainId: common.ChainId.metis, + account: '0x5cb738DAe833Ec21fe65ae1719fAd8ab8cE7f23D', + expected: '0x8f6325f5E452B8Aa8137722A9f584C41c32d53A1', + }, + { + chainId: common.ChainId.metis, + account: '0xa3C1C91403F0026b9dd086882aDbC8Cdbc3b3cfB', + expected: '0x22CF139619f4B8Afc863beCa670615C6310aC7c6', + }, + { + chainId: common.ChainId.base, + account: '0x5cb738DAe833Ec21fe65ae1719fAd8ab8cE7f23D', + expected: '0x8f6325f5E452B8Aa8137722A9f584C41c32d53A1', + }, + { + chainId: common.ChainId.base, + account: '0xa3C1C91403F0026b9dd086882aDbC8Cdbc3b3cfB', + expected: '0x22CF139619f4B8Afc863beCa670615C6310aC7c6', }, { chainId: common.ChainId.arbitrum, account: '0x5cb738DAe833Ec21fe65ae1719fAd8ab8cE7f23D', - expected: '0xefc25B94FFeB90d5045cDAA936a52489bfBeA9D8', + expected: '0x8f6325f5E452B8Aa8137722A9f584C41c32d53A1', }, { chainId: common.ChainId.arbitrum, account: '0xa3C1C91403F0026b9dd086882aDbC8Cdbc3b3cfB', - expected: '0x236E002fb1ba4043463aa89E1ccF845d2e3661a6', + expected: '0x22CF139619f4B8Afc863beCa670615C6310aC7c6', }, { - chainId: common.ChainId.zksync, + chainId: common.ChainId.avalanche, account: '0x5cb738DAe833Ec21fe65ae1719fAd8ab8cE7f23D', - expected: '0xE25c878fd40FF3aD79FaC9462563Ff41CE059e96', + expected: '0x8f6325f5E452B8Aa8137722A9f584C41c32d53A1', }, { - chainId: common.ChainId.zksync, + chainId: common.ChainId.avalanche, account: '0xa3C1C91403F0026b9dd086882aDbC8Cdbc3b3cfB', - expected: '0x7A4908e637ae38D565Ea88010F75EB5dBdf39fFc', + expected: '0x22CF139619f4B8Afc863beCa670615C6310aC7c6', }, ]; @@ -198,7 +328,7 @@ describe('RouterKit', function () { name: 'Protocolink', version: '1', chainId: 1, - verifyingContract: '0x3fa3B62F0c9c13733245A778DE4157E47Cf5bA21', + verifyingContract: '0xDec80E988F4baF43be69c13711453013c212feA8', }, types: { LogicBatch: [ From b3eec5b589dd450312e14527fe4e1c914170f240 Mon Sep 17 00:00:00 2001 From: Jeff Huang Date: Wed, 22 Nov 2023 11:38:13 +0800 Subject: [PATCH 2/2] feat: common package add Gnosis Chain information --- .changeset/smart-tools-provide.md | 5 +++++ packages/common/src/networks/data.json | 23 ++++++++++++++++++++++ packages/common/src/networks/index.test.ts | 20 +++++++++++++++++++ packages/common/src/networks/index.ts | 2 ++ 4 files changed, 50 insertions(+) create mode 100644 .changeset/smart-tools-provide.md diff --git a/.changeset/smart-tools-provide.md b/.changeset/smart-tools-provide.md new file mode 100644 index 00000000..36949d69 --- /dev/null +++ b/.changeset/smart-tools-provide.md @@ -0,0 +1,5 @@ +--- +'@protocolink/common': patch +--- + +add Gnosis Chain information diff --git a/packages/common/src/networks/data.json b/packages/common/src/networks/data.json index 1aefb71f..bd516e84 100644 --- a/packages/common/src/networks/data.json +++ b/packages/common/src/networks/data.json @@ -45,6 +45,29 @@ "multicall2Address": "0x5BA1e12693Dc8F9c48aAD8770482f4739bEeD696", "multicall3Address": "0xcA11bde05977b3631167028862bE2a173976CA11" }, + { + "id": "gnosis", + "chainId": 100, + "name": "Gnosis Chain", + "explorerUrl": "https://gnosisscan.io/", + "rpcUrl": "https://rpc.ankr.com/gnosis", + "nativeToken": { + "chainId": 100, + "address": "0x0000000000000000000000000000000000000000", + "decimals": 18, + "symbol": "xDAI", + "name": "xDai" + }, + "wrappedNativeToken": { + "chainId": 100, + "address": "0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d", + "decimals": 18, + "symbol": "WXDAI", + "name": "Wrapped XDAI" + }, + "multicall2Address": "0xecC4d9410c1a5276733cEF29d1C9015571f56BDC", + "multicall3Address": "0xcA11bde05977b3631167028862bE2a173976CA11" + }, { "id": "polygon", "chainId": 137, diff --git a/packages/common/src/networks/index.test.ts b/packages/common/src/networks/index.test.ts index 3ff20437..970ea7c7 100644 --- a/packages/common/src/networks/index.test.ts +++ b/packages/common/src/networks/index.test.ts @@ -15,6 +15,7 @@ describe('Test isSupportedChainId', function () { const testCases = [ { chainId: ChainId.mainnet, expected: true }, { chainId: ChainId.optimism, expected: true }, + { chainId: ChainId.gnosis, expected: true }, { chainId: ChainId.polygon, expected: true }, { chainId: ChainId.zksync, expected: true }, { chainId: ChainId.metis, expected: true }, @@ -35,6 +36,7 @@ describe('Test isSupportedNetworkId', function () { const testCases = [ { networkId: NetworkId.mainnet, expected: true }, { networkId: NetworkId.optimism, expected: true }, + { networkId: NetworkId.gnosis, expected: true }, { networkId: NetworkId.polygon, expected: true }, { networkId: NetworkId.zksync, expected: true }, { networkId: NetworkId.metis, expected: true }, @@ -89,6 +91,24 @@ describe('Test newExplorerUrl', function () { data: '0xdAC17F958D2ee523a2206206994597C13D831ec7', expected: 'https://optimistic.etherscan.io/token/0xdAC17F958D2ee523a2206206994597C13D831ec7', }, + { + chainId: ChainId.gnosis, + type: ExplorerType.tx, + data: '0xc371ef1ef7f36da374c9d1dbbf124bc0fc137245377d6acbf0d392addb6620dc', + expected: 'https://gnosisscan.io/tx/0xc371ef1ef7f36da374c9d1dbbf124bc0fc137245377d6acbf0d392addb6620dc', + }, + { + chainId: ChainId.gnosis, + type: ExplorerType.address, + data: '0x157253E7012bf08b24dDA7Fc16229d14d9f9833D', + expected: 'https://gnosisscan.io/address/0x157253E7012bf08b24dDA7Fc16229d14d9f9833D', + }, + { + chainId: ChainId.gnosis, + type: ExplorerType.token, + data: '0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d', + expected: 'https://gnosisscan.io/token/0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d', + }, { chainId: ChainId.polygon, type: ExplorerType.tx, diff --git a/packages/common/src/networks/index.ts b/packages/common/src/networks/index.ts index 5acdce7a..e2afb672 100644 --- a/packages/common/src/networks/index.ts +++ b/packages/common/src/networks/index.ts @@ -65,6 +65,7 @@ export function toChainId(networkId: string) { export enum ChainId { mainnet = 1, optimism = 10, + gnosis = 100, polygon = 137, zksync = 324, metis = 1088, @@ -76,6 +77,7 @@ export enum ChainId { export enum NetworkId { mainnet = 'mainnet', optimism = 'optimism', + gnosis = 'gnosis', polygon = 'polygon', zksync = 'zksync', metis = 'metis',