From 42e7c888eb50ef246f14d326160714bffb16d2db Mon Sep 17 00:00:00 2001 From: Adam R <13562139+catenocrypt@users.noreply.github.com> Date: Thu, 22 Oct 2020 16:41:12 +0200 Subject: [PATCH] [internal] Refine explorerUrl check, fix existing warnings. (#4566) * Refine explorerUrl check, fix existing warnings. * Lint fix Co-authored-by: Catenocrypt --- .../info.json | 2 +- .../info.json | 2 +- .../info.json | 2 +- .../info.json | 2 +- .../info.json | 2 +- .../info.json | 8 ++--- .../info.json | 2 +- .../info.json | 2 +- script/generic/asset-infos.ts | 29 +++++++++++++++++-- 9 files changed, 37 insertions(+), 14 deletions(-) diff --git a/blockchains/ethereum/assets/0x03042482d64577A7bdb282260e2eA4c8a89C064B/info.json b/blockchains/ethereum/assets/0x03042482d64577A7bdb282260e2eA4c8a89C064B/info.json index 5a88fdfab..3812c7df8 100644 --- a/blockchains/ethereum/assets/0x03042482d64577A7bdb282260e2eA4c8a89C064B/info.json +++ b/blockchains/ethereum/assets/0x03042482d64577A7bdb282260e2eA4c8a89C064B/info.json @@ -3,5 +3,5 @@ "website": "https://cntr.finance", "white_paper": "https://cntr.finance/docs/whitepaper.pdf", "short_description": "The bridge between decentralized and traditional finance.", - "explorer": "https://explorer.cntr.finance" + "explorer": "https://etherscan.io/token/0x03042482d64577A7bdb282260e2eA4c8a89C064B" } \ No newline at end of file diff --git a/blockchains/ethereum/assets/0xB63B606Ac810a52cCa15e44bB630fd42D8d1d83d/info.json b/blockchains/ethereum/assets/0xB63B606Ac810a52cCa15e44bB630fd42D8d1d83d/info.json index b0565c858..6494e8e10 100644 --- a/blockchains/ethereum/assets/0xB63B606Ac810a52cCa15e44bB630fd42D8d1d83d/info.json +++ b/blockchains/ethereum/assets/0xB63B606Ac810a52cCa15e44bB630fd42D8d1d83d/info.json @@ -1,5 +1,5 @@ { - "name": "MCO", + "name": "Monaco", "website": "https://crypto.com", "short_description": "Crypto.com provides a powerful alternative to traditional financial services, turning its vision of ”cryptocurrency in every wallet” into reality, one customer at a time.", "explorer": "https://etherscan.io/token/Monaco" diff --git a/blockchains/ethereum/assets/0xD9Ec3ff1f8be459Bb9369b4E79e9Ebcf7141C093/info.json b/blockchains/ethereum/assets/0xD9Ec3ff1f8be459Bb9369b4E79e9Ebcf7141C093/info.json index 678aadc7b..af64ebc55 100644 --- a/blockchains/ethereum/assets/0xD9Ec3ff1f8be459Bb9369b4E79e9Ebcf7141C093/info.json +++ b/blockchains/ethereum/assets/0xD9Ec3ff1f8be459Bb9369b4E79e9Ebcf7141C093/info.json @@ -17,5 +17,5 @@ "handle": "KardiaChain" } ], - "explorer": "https://explorer.kardiachain.io/" + "explorer": "https://explorer.kardiachain.io" } \ No newline at end of file diff --git a/blockchains/ethereum/assets/0xE41d2489571d322189246DaFA5ebDe1F4699F498/info.json b/blockchains/ethereum/assets/0xE41d2489571d322189246DaFA5ebDe1F4699F498/info.json index db2dda477..78fc620a2 100644 --- a/blockchains/ethereum/assets/0xE41d2489571d322189246DaFA5ebDe1F4699F498/info.json +++ b/blockchains/ethereum/assets/0xE41d2489571d322189246DaFA5ebDe1F4699F498/info.json @@ -1,5 +1,5 @@ { - "name": "0x", + "name": "ZRX", "website": "https://0x.org", "short_description": "0x (ZRX) is an open-source protocol that provides smart contract infrastructure and liquidity to enable the peer-to-peer exchange of tokens on the Ethereum blockchain.", "explorer": "https://etherscan.io/token/ZRX", diff --git a/blockchains/ethereum/assets/0xbbFF862d906E348E9946Bfb2132ecB157Da3D4b4/info.json b/blockchains/ethereum/assets/0xbbFF862d906E348E9946Bfb2132ecB157Da3D4b4/info.json index 9404e58de..98ea22129 100644 --- a/blockchains/ethereum/assets/0xbbFF862d906E348E9946Bfb2132ecB157Da3D4b4/info.json +++ b/blockchains/ethereum/assets/0xbbFF862d906E348E9946Bfb2132ecB157Da3D4b4/info.json @@ -3,5 +3,5 @@ "website": "https://sharder.org", "short_description": "Sharder is a multi-chain storage & validation network.", "socials": [], - "explorer": "http://scan.sharder.io/" + "explorer": "https://etherscan.io/token/0xbbFF862d906E348E9946Bfb2132ecB157Da3D4b4" } \ No newline at end of file diff --git a/blockchains/ethereum/assets/0xbe038A2FDfec62Cf1beD852f141A43005035edcC/info.json b/blockchains/ethereum/assets/0xbe038A2FDfec62Cf1beD852f141A43005035edcC/info.json index ea740f543..c09b80e00 100644 --- a/blockchains/ethereum/assets/0xbe038A2FDfec62Cf1beD852f141A43005035edcC/info.json +++ b/blockchains/ethereum/assets/0xbe038A2FDfec62Cf1beD852f141A43005035edcC/info.json @@ -1,9 +1,9 @@ { - "name": "INT", + "name": "Intchain", "website": "https://intchain.io/", "source_code": "https://github.com/intfoundation/int", "white_paper": "https://intchain.io/whitepaper/INT-whitepaper-release-EN.pdf", "short_description": "INT is an INT Chain cross-chain asset based on Ethereum network, and INT Chain is a blockchain application platform and interactive standard based on the economic driving mode.", - "explorer": "https://explorer.intchain.io/", - "explorer-ETH": "https://etherscan.io/address/0xbe038a2fdfec62cf1bed852f141a43005035edcc" -} \ No newline at end of file + "explorer": "https://explorer.intchain.io", + "explorer-ETH": "https://etherscan.io/token/0xbe038A2FDfec62Cf1beD852f141A43005035edcC" +} diff --git a/blockchains/neo/assets/2efdb22c152896964665d0a8214dc7bd59232162/info.json b/blockchains/neo/assets/2efdb22c152896964665d0a8214dc7bd59232162/info.json index bf6cdcc99..49310e309 100644 --- a/blockchains/neo/assets/2efdb22c152896964665d0a8214dc7bd59232162/info.json +++ b/blockchains/neo/assets/2efdb22c152896964665d0a8214dc7bd59232162/info.json @@ -2,5 +2,5 @@ "name": "aleph.im NEP-5", "website": "https://aleph.im", "short_description": "Aleph.im is a cross-blockchain layer-2 networkspecifically focused on decentralized applications and their related infrastructure (storage, computing servers, security).", - "explorer": "https://neo.tokenview.com/fr/token/0x2efdb22c152896964665d0a8214dc7bd59232162" + "explorer": "https://neo.tokenview.com/en/token/0x2efdb22c152896964665d0a8214dc7bd59232162" } diff --git a/blockchains/neo/assets/bac0d143a547dc66a1d6a2b7d66b06de42614971/info.json b/blockchains/neo/assets/bac0d143a547dc66a1d6a2b7d66b06de42614971/info.json index 97284eff8..dcff1539b 100644 --- a/blockchains/neo/assets/bac0d143a547dc66a1d6a2b7d66b06de42614971/info.json +++ b/blockchains/neo/assets/bac0d143a547dc66a1d6a2b7d66b06de42614971/info.json @@ -2,5 +2,5 @@ "name": "Bridge Protocol Token (NEP5)", "website": "https://bridgeprotocol.io/", "short_description": "Bridge Protocol NEP-5 utility token (BRDG) on the NEO Smart Economy", - "explorer": "https://explorer.o3.network/contracts/bac0d143a547dc66a1d6a2b7d66b06de42614971" + "explorer": "https://neo.tokenview.com/en/token/0xbac0d143a547dc66a1d6a2b7d66b06de42614971" } diff --git a/script/generic/asset-infos.ts b/script/generic/asset-infos.ts index f38dbc1c5..e24ebfad9 100644 --- a/script/generic/asset-infos.ts +++ b/script/generic/asset-infos.ts @@ -54,7 +54,7 @@ function explorerUrl(chain: string, contract: string): string { return `https://bscscan.com/token/${contract}`; case "neo": - return `https://neo.tokenview.com/fr/token/0x${contract}`; + return `https://neo.tokenview.com/en/token/0x${contract}`; case "nuls": return `https://nulscan.io/token/info?contractAddress=${contract}`; @@ -66,6 +66,19 @@ function explorerUrl(chain: string, contract: string): string { return ""; } +function explorerUrlAlternatives(chain: string, contract: string, name: string): string[] { + const altUrls: string[] = []; + if (name) { + const nameNorm = name.toLowerCase().replace(' ', '').replace(')', '').replace('(', ''); + if (chain.toLowerCase() == "ethereum") { + altUrls.push(`https://etherscan.io/token/${nameNorm}`); + } + altUrls.push(`https://explorer.${nameNorm}.io`); + altUrls.push(`https://scan.${nameNorm}.io`); + } + return altUrls; +} + function isAssetInfoOK(chain: string, address: string, errors: string[], warnings: string[]): void { const assetInfoPath = getChainAssetInfoPath(chain, address); if (!isPathExistsSync(assetInfoPath)) { @@ -91,9 +104,19 @@ function isAssetInfoOK(chain: string, address: string, errors: string[], warning errors.push(`Missing explorer key`); } else { const explorerActual = info['explorer']; + const explorerActualLower = explorerActual.toLowerCase(); const explorerExpected = explorerUrl(chain, address); - if (explorerActual != explorerExpected) { - warnings.push(`Unexpected explorer, ${explorerActual} instead of ${explorerExpected}`); + if (explorerActualLower != explorerExpected.toLowerCase() && explorerExpected) { + // doesn't match, check for alternatives + const explorersAlt = explorerUrlAlternatives(chain, address, info['name']); + if (explorersAlt && explorersAlt.length > 0) { + let matchCount = 0; + explorersAlt.forEach(exp => { if (exp.toLowerCase() == explorerActualLower) { ++matchCount; }}); + if (matchCount == 0) { + // none matchs + warnings.push(`Unexpected explorer, ${explorerActual} instead of ${explorerExpected} (${explorersAlt.join(', ')})`); + } + } } } }