diff --git a/lists/images/polygon-zkevm/0x1E4a5963aBFD975d8c9021ce480b42188849D41d.png b/lists/images/polygon-zkevm/0x1E4a5963aBFD975d8c9021ce480b42188849D41d.png new file mode 100644 index 00000000..b053ca26 Binary files /dev/null and b/lists/images/polygon-zkevm/0x1E4a5963aBFD975d8c9021ce480b42188849D41d.png differ diff --git a/lists/images/polygon-zkevm/0x4F9A0e7FD2Bf6067db6994CF12E4495Df938E6e9.png b/lists/images/polygon-zkevm/0x4F9A0e7FD2Bf6067db6994CF12E4495Df938E6e9.png new file mode 100644 index 00000000..b028b56e Binary files /dev/null and b/lists/images/polygon-zkevm/0x4F9A0e7FD2Bf6067db6994CF12E4495Df938E6e9.png differ diff --git a/lists/images/polygon-zkevm/0xA8CE8aee21bC2A48a5EF670afCc9274C7bbbC035.png b/lists/images/polygon-zkevm/0xA8CE8aee21bC2A48a5EF670afCc9274C7bbbC035.png new file mode 100644 index 00000000..ddff786c Binary files /dev/null and b/lists/images/polygon-zkevm/0xA8CE8aee21bC2A48a5EF670afCc9274C7bbbC035.png differ diff --git a/lists/images/polygon-zkevm/0xa2036f0538221a77A3937F1379699f44945018d0.png b/lists/images/polygon-zkevm/0xa2036f0538221a77A3937F1379699f44945018d0.png new file mode 100644 index 00000000..680969b0 Binary files /dev/null and b/lists/images/polygon-zkevm/0xa2036f0538221a77A3937F1379699f44945018d0.png differ diff --git a/lists/pancakeswap-polygon-zkevm-default.json b/lists/pancakeswap-polygon-zkevm-default.json new file mode 100644 index 00000000..ae756014 --- /dev/null +++ b/lists/pancakeswap-polygon-zkevm-default.json @@ -0,0 +1,50 @@ +{ + "name": "PancakeSwap Zkevm Default", + "timestamp": "2023-07-25T11:30:46.083Z", + "version": { + "major": 0, + "minor": 0, + "patch": 1 + }, + "logoURI": "https://pancakeswap.finance/logo.png", + "keywords": [ + "pancakeswap", + "default", + "polygon", + "zkevm" + ], + "tokens": [ + { + "name": "Wrapped Ether", + "symbol": "WETH", + "address": "0x4F9A0e7FD2Bf6067db6994CF12E4495Df938E6e9", + "chainId": 1101, + "decimals": 18, + "logoURI": "https://tokens.pancakeswap.finance/images/polygon-zkevm/0x4F9A0e7FD2Bf6067db6994CF12E4495Df938E6e9.png" + }, + { + "name": "USD Coin", + "symbol": "USDC", + "address": "0xA8CE8aee21bC2A48a5EF670afCc9274C7bbbC035", + "chainId": 1101, + "decimals": 6, + "logoURI": "https://tokens.pancakeswap.finance/images/polygon-zkevm/0xA8CE8aee21bC2A48a5EF670afCc9274C7bbbC035.png" + }, + { + "name": "Tether USD", + "symbol": "USDT", + "address": "0x1E4a5963aBFD975d8c9021ce480b42188849D41d", + "chainId": 1101, + "decimals": 6, + "logoURI": "https://tokens.pancakeswap.finance/images/polygon-zkevm/0x1E4a5963aBFD975d8c9021ce480b42188849D41d.png" + }, + { + "name": "Matic Token", + "symbol": "MATIC", + "address": "0xa2036f0538221a77A3937F1379699f44945018d0", + "chainId": 1101, + "decimals": 18, + "logoURI": "https://tokens.pancakeswap.finance/images/polygon-zkevm/0xa2036f0538221a77A3937F1379699f44945018d0.png" + } + ] +} \ No newline at end of file diff --git a/package.json b/package.json index 639f2d10..c2dca596 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,9 @@ "checksum:pcs-eth-default": "yarn build && node ./dist checksum pancakeswap-eth-default", "generate:pcs-eth-default": "yarn test --list=pancakeswap-eth-default && yarn build && node ./dist generate pancakeswap-eth-default", "makelist:pcs-eth-default": "yarn checksum:pcs-eth-default && yarn generate:pcs-eth-default", + "checksum:pcs-polygon-zkevm-default": "yarn build && node ./dist checksum pancakeswap-polygon-zkevm-default", + "generate:pcs-polygon-zkevm-default": "yarn test --list=pancakeswap-polygon-zkevm-default && yarn build && node ./dist generate pancakeswap-polygon-zkevm-default", + "makelist:pcs-polygon-zkevm-default": "yarn checksum:pcs-polygon-zkevm-default && yarn generate:pcs-polygon-zkevm-default", "checksum:pcs-eth-mm": "yarn build && node ./dist checksum pancakeswap-eth-mm", "generate:pcs-eth-mm": "yarn test --list=pancakeswap-eth-mm && yarn build && node ./dist generate pancakeswap-eth-mm", "makelist:pcs-eth-mm": "yarn checksum:pcs-eth-mm && yarn generate:pcs-eth-mm", diff --git a/src/buildList.ts b/src/buildList.ts index 9bb916ac..a652f759 100644 --- a/src/buildList.ts +++ b/src/buildList.ts @@ -3,6 +3,7 @@ import path from "path"; import { TokenList } from "@pancakeswap/token-lists"; import { version as pancakeswapDefaultVersion } from "../lists/pancakeswap-default.json"; import { version as pancakeswapEthDefaultVersion } from "../lists/pancakeswap-eth-default.json"; +import { version as pancakeswapPolygonZkevmDefaultVersion } from "../lists/pancakeswap-polygon-zkevm-default.json"; import { version as pancakeswapEthMMVersion } from "../lists/pancakeswap-eth-mm.json"; import { version as pancakeswapBnbMMVersion } from "../lists/pancakeswap-bnb-mm.json"; import { version as pancakeswapExtendedVersion } from "../lists/pancakeswap-extended.json"; @@ -15,6 +16,7 @@ import { version as pancakeswapMiniVersion } from "../lists/pancakeswap-mini.jso import { version as pancakeswapMiniExtendedVersion } from "../lists/pancakeswap-mini-extended.json"; import pancakeswapAptos from "./tokens/pancakeswap-aptos.json"; import pancakeswapDefault from "./tokens/pancakeswap-default.json"; +import pancakeswapPolygonZkevmDefault from "./tokens/pancakeswap-polygon-zkevm-default.json"; import pancakeswapEthDefault from "./tokens/pancakeswap-eth-default.json"; import pancakeswapEthMM from "./tokens/pancakeswap-eth-mm.json"; import pancakeswapExtended from "./tokens/pancakeswap-extended.json"; @@ -48,6 +50,14 @@ const lists = { currentVersion: pancakeswapAptosVersion, schema: "aptos", }, + "pancakeswap-polygon-zkevm-default": { + list: pancakeswapPolygonZkevmDefault, + name: "PancakeSwap Zkevm Default", + keywords: ["pancakeswap", "default", "polygon", "zkevm"], + logoURI: "https://pancakeswap.finance/logo.png", + sort: false, + currentVersion: pancakeswapPolygonZkevmDefaultVersion, + }, "pancakeswap-eth-default": { list: pancakeswapEthDefault, name: "PancakeSwap Ethereum Default", diff --git a/src/checksum.ts b/src/checksum.ts index 624ee1b5..49ac89c4 100644 --- a/src/checksum.ts +++ b/src/checksum.ts @@ -3,6 +3,7 @@ import path from "path"; import { getAddress } from "@ethersproject/address"; import pancakeswapDefault from "./tokens/pancakeswap-default.json"; import pancakeswapEthDefault from "./tokens/pancakeswap-eth-default.json"; +import pancakeswapPolygonZkevmDefault from "./tokens/pancakeswap-polygon-zkevm-default.json"; import pancakeswapEthMM from "./tokens/pancakeswap-eth-mm.json"; import pancakeswapBnbMM from "./tokens/pancakeswap-bnb-mm.json"; import pancakeswapExtended from "./tokens/pancakeswap-extended.json"; @@ -16,6 +17,7 @@ import pancakeswapMiniExtended from "./tokens/pancakeswap-mini-extended.json"; const lists = { "pancakeswap-default": pancakeswapDefault, "pancakeswap-eth-default": pancakeswapEthDefault, + "pancakeswap-polygon-zkevm-default": pancakeswapPolygonZkevmDefault, "pancakeswap-eth-mm": pancakeswapEthMM, "pancakeswap-bnb-mm": pancakeswapBnbMM, "pancakeswap-extended": pancakeswapExtended, diff --git a/src/ci-check.ts b/src/ci-check.ts index 6c26bd2d..b0829a32 100644 --- a/src/ci-check.ts +++ b/src/ci-check.ts @@ -1,5 +1,6 @@ import srcDefault from "./tokens/pancakeswap-default.json"; import srcEthDefault from "./tokens/pancakeswap-eth-default.json"; +import srcPolygonZkevmDefault from "./tokens/pancakeswap-polygon-zkevm-default.json"; import srcExtended from "./tokens/pancakeswap-extended.json"; import srcTop100 from "./tokens/pancakeswap-top-100.json"; import srcTop15 from "./tokens/pancakeswap-top-15.json"; @@ -9,6 +10,7 @@ import srcMini from "./tokens/pancakeswap-mini.json"; import srcMiniExtended from "./tokens/pancakeswap-mini-extended.json"; import defaultList from "../lists/pancakeswap-default.json"; import defaultEthList from "../lists/pancakeswap-eth-default.json"; +import defaultPolygonZkevmList from "../lists/pancakeswap-polygon-zkevm-default.json"; import extendedtList from "../lists/pancakeswap-extended.json"; import top15List from "../lists/pancakeswap-top-15.json"; import top100tList from "../lists/pancakeswap-top-100.json"; @@ -28,6 +30,11 @@ const lists = [ src: srcEthDefault, actual: defaultEthList, }, + { + name: "pancakeswap-polygon-zkevm-default", + src: srcPolygonZkevmDefault, + actual: defaultPolygonZkevmList, + }, { name: "pancakeswap-extended", src: srcExtended, diff --git a/src/tokens/pancakeswap-polygon-zkevm-default.json b/src/tokens/pancakeswap-polygon-zkevm-default.json new file mode 100644 index 00000000..9cda5352 --- /dev/null +++ b/src/tokens/pancakeswap-polygon-zkevm-default.json @@ -0,0 +1,35 @@ +[ + { + "name": "Wrapped Ether", + "symbol": "WETH", + "address": "0x4F9A0e7FD2Bf6067db6994CF12E4495Df938E6e9", + "chainId": 1101, + "decimals": 18, + "logoURI": "https://tokens.pancakeswap.finance/images/polygon-zkevm/0x4F9A0e7FD2Bf6067db6994CF12E4495Df938E6e9.png" + }, + { + "name": "USD Coin", + "symbol": "USDC", + "address": "0xA8CE8aee21bC2A48a5EF670afCc9274C7bbbC035", + "chainId": 1101, + "decimals": 6, + "logoURI": "https://tokens.pancakeswap.finance/images/polygon-zkevm/0xA8CE8aee21bC2A48a5EF670afCc9274C7bbbC035.png" + }, + { + "name": "Tether USD", + "symbol": "USDT", + "address": "0x1E4a5963aBFD975d8c9021ce480b42188849D41d", + "chainId": 1101, + "decimals": 6, + "logoURI": "https://tokens.pancakeswap.finance/images/polygon-zkevm/0x1E4a5963aBFD975d8c9021ce480b42188849D41d.png" + }, + + { + "name": "Matic Token", + "symbol": "MATIC", + "address": "0xa2036f0538221a77A3937F1379699f44945018d0", + "chainId": 1101, + "decimals": 18, + "logoURI": "https://tokens.pancakeswap.finance/images/polygon-zkevm/0xa2036f0538221a77A3937F1379699f44945018d0.png" + } +] diff --git a/src/utils/multicall.ts b/src/utils/multicall.ts index c69bcc34..07b958d3 100644 --- a/src/utils/multicall.ts +++ b/src/utils/multicall.ts @@ -6,6 +6,7 @@ import simpleRpcProvider from "./simpleRpcProvider"; const multicall = { [1]: "0xcA11bde05977b3631167028862bE2a173976CA11", [56]: "0xcA11bde05977b3631167028862bE2a173976CA11", + [1101]: "0xcA11bde05977b3631167028862bE2a173976CA11", }; interface MultiCall { diff --git a/src/utils/simpleRpcProvider.ts b/src/utils/simpleRpcProvider.ts index 9c0be313..d392347b 100644 --- a/src/utils/simpleRpcProvider.ts +++ b/src/utils/simpleRpcProvider.ts @@ -2,13 +2,16 @@ import { ethers } from "ethers"; const RPC_URL = "https://nodes.pancakeswap.info"; const ETH_RPC_URL = "https://cloudflare-eth.com"; +const POLYGON_ZKEVM_RPC_URL = "https://f2562de09abc5efbd21eefa083ff5326.zkevm-rpc.com/"; const bscRpcProvider = new ethers.providers.StaticJsonRpcProvider(RPC_URL, 56); const ethRpcProvider = new ethers.providers.StaticJsonRpcProvider(ETH_RPC_URL, 1); +const polygonZkevmRpcProvider = new ethers.providers.StaticJsonRpcProvider(POLYGON_ZKEVM_RPC_URL, 1101); const simpleRpcProvider = { [1]: ethRpcProvider, [56]: bscRpcProvider, + [1101]: polygonZkevmRpcProvider, }; export default simpleRpcProvider; diff --git a/test/default.test.ts b/test/default.test.ts index 61def79b..e0257895 100644 --- a/test/default.test.ts +++ b/test/default.test.ts @@ -6,6 +6,7 @@ import { getAddress } from "@ethersproject/address"; import pancakeswapSchema from "@pancakeswap/token-lists/schema/pancakeswap.json"; import currentPancakeswapDefaultList from "../lists/pancakeswap-default.json"; import currentPancakeswapEthDefaultList from "../lists/pancakeswap-eth-default.json"; +import currentPancakeswapPolygonZkevmDefaultList from "../lists/pancakeswap-polygon-zkevm-default.json"; import currentPancakeswapEthMMList from "../lists/pancakeswap-eth-mm.json"; import currentPancakeswapBnbMMList from "../lists/pancakeswap-bnb-mm.json"; import currentPancakeswapExtendedtList from "../lists/pancakeswap-extended.json"; @@ -28,6 +29,7 @@ const listArgs = process.argv const CASES = [ ["pancakeswap-default"], ["pancakeswap-eth-default"], + ["pancakeswap-polygon-zkevm-default"], ["pancakeswap-eth-mm"], ["pancakeswap-extended"], ["pancakeswap-top-100"], @@ -47,6 +49,7 @@ const currentLists = { "pancakeswap-eth-mm": currentPancakeswapEthMMList, "pancakeswap-bnb-mm": currentPancakeswapBnbMMList, "pancakeswap-eth-default": currentPancakeswapEthDefaultList, + "pancakeswap-polygon-zkevm-default": currentPancakeswapPolygonZkevmDefaultList, "pancakeswap-extended": currentPancakeswapExtendedtList, "pancakeswap-top-100": currentPancakeswapTop100tList, "pancakeswap-top-15": currentPancakeswapTop15List, @@ -80,6 +83,7 @@ const validate = ajv.compile(pancakeswapSchema); const pathToImages = path.join(path.resolve(), "lists", "images"); const pathToEthImages = path.join(path.resolve(), "lists", "images", "eth"); +const pathToPolygonZkevmImages = path.join(path.resolve(), "lists", "images", "polygon-zkevm"); const logoFiles = fs .readdirSync(pathToImages, { withFileTypes: true }) @@ -91,6 +95,23 @@ const ethLogoFiles = fs .filter((f) => f.isFile()) .filter((f) => !/(^|\/)\.[^\/\.]/g.test(f.name)); +const polygonZkevmLogoFiles = fs + .readdirSync(pathToPolygonZkevmImages, { withFileTypes: true }) + .filter((f) => f.isFile()) + .filter((f) => !/(^|\/)\.[^\/\.]/g.test(f.name)); + +const multiChainLogoPath = { + [56]: "", + [1]: "/eth", + [1101]: "/polygon-zkevm", +}; + +const multiChainLogoFiles = { + [56]: logoFiles, + [1]: ethLogoFiles, + [1101]: polygonZkevmLogoFiles, +}; + // Modified https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_get const getByAjvPath = (obj, propertyPath: string, defaultValue = undefined) => { const travel = (regexp) => @@ -152,13 +173,12 @@ expect.extend({ token.logoURI === `https://assets-cdn.trustwallet.com/blockchains/smartchain/assets/${token.address}/logo.png`; let hasLocalLogo = false; const refersToLocalLogo = - token.logoURI === `https://tokens.pancakeswap.finance/images/${token.address}.png` || - token.logoURI === `https://tokens.pancakeswap.finance/images/eth/${token.address}.png`; + token.logoURI === + `https://tokens.pancakeswap.finance/images${multiChainLogoPath?.[token.chainId] || ""}/${token.address}.png`; if (refersToLocalLogo) { const fileName = token.logoURI.split("/").pop(); // Note: fs.existsSync can't be used here because its not case sensetive - hasLocalLogo = - logoFiles.map((f) => f.name).includes(fileName) || ethLogoFiles.map((f) => f.name).includes(fileName); + hasLocalLogo = multiChainLogoFiles[token.chainId]?.map((f) => f.name).includes(fileName); } if (hasTWLogo || hasLocalLogo) { return {