mirror of
https://github.com/Instadapp/trustwallet-assets.git
synced 2024-07-29 22:37:31 +00:00
[internal] Refine explorerUrl check, fix existing warnings. (#4566)
* Refine explorerUrl check, fix existing warnings. * Lint fix Co-authored-by: Catenocrypt <catenocrypt@users.noreply.github.com>
This commit is contained in:
parent
49eae44cd8
commit
42e7c888eb
|
@ -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"
|
||||
}
|
|
@ -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"
|
||||
|
|
|
@ -17,5 +17,5 @@
|
|||
"handle": "KardiaChain"
|
||||
}
|
||||
],
|
||||
"explorer": "https://explorer.kardiachain.io/"
|
||||
"explorer": "https://explorer.kardiachain.io"
|
||||
}
|
|
@ -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",
|
||||
|
|
|
@ -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"
|
||||
}
|
|
@ -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"
|
||||
"explorer": "https://explorer.intchain.io",
|
||||
"explorer-ETH": "https://etherscan.io/token/0xbe038A2FDfec62Cf1beD852f141A43005035edcC"
|
||||
}
|
|
@ -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"
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
|
|
|
@ -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(', ')})`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user