mirror of
https://github.com/Instadapp/trustwallet-assets.git
synced 2024-07-29 22:37:31 +00:00
[internal] Add Solana token infrastructure, Serum token. (#5000)
* Add Solana token infrastructure, Serum token. * Use CoinType constants for chains Co-authored-by: Catenocrypt <catenocrypt@users.noreply.github.com>
This commit is contained in:
parent
45efa792bc
commit
3876862de4
3
blockchains/solana/allowlist.json
Normal file
3
blockchains/solana/allowlist.json
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
[
|
||||||
|
"SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt"
|
||||||
|
]
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"name": "Serum",
|
||||||
|
"website": "https://projectserum.com/",
|
||||||
|
"short_description": "Serum is a decentralized exchange (DEX) and ecosystem that brings unprecedented speed and low transaction costs to decentralized finance. It is built on Solana and is completely permissionless.",
|
||||||
|
"explorer": "https://explorer.solana.com/address/SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt"
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 22 KiB |
2
blockchains/solana/denylist.json
Normal file
2
blockchains/solana/denylist.json
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
[
|
||||||
|
]
|
|
@ -11,6 +11,7 @@ import {
|
||||||
import { arrayDiff } from "./types";
|
import { arrayDiff } from "./types";
|
||||||
import { isValidJSON } from "../generic/json";
|
import { isValidJSON } from "../generic/json";
|
||||||
import { ActionInterface, CheckStepInterface } from "../generic/interface";
|
import { ActionInterface, CheckStepInterface } from "../generic/interface";
|
||||||
|
import { CoinType } from "@trustwallet/wallet-core";
|
||||||
import * as bluebird from "bluebird";
|
import * as bluebird from "bluebird";
|
||||||
|
|
||||||
const requiredKeys = ["explorer", "name", "website", "short_description"];
|
const requiredKeys = ["explorer", "name", "website", "short_description"];
|
||||||
|
@ -36,10 +37,10 @@ function isAssetInfoHasAllKeys(info: unknown, path: string): [boolean, string] {
|
||||||
function explorerUrl(chain: string, contract: string): string {
|
function explorerUrl(chain: string, contract: string): string {
|
||||||
if (contract) {
|
if (contract) {
|
||||||
switch (chain.toLowerCase()) {
|
switch (chain.toLowerCase()) {
|
||||||
case "ethereum":
|
case CoinType.name(CoinType.ethereum):
|
||||||
return `https://etherscan.io/token/${contract}`;
|
return `https://etherscan.io/token/${contract}`;
|
||||||
|
|
||||||
case "tron":
|
case CoinType.name(CoinType.tron):
|
||||||
if (contract.startsWith("10")) {
|
if (contract.startsWith("10")) {
|
||||||
// trc10
|
// trc10
|
||||||
return `https://tronscan.io/#/token/${contract}`;
|
return `https://tronscan.io/#/token/${contract}`;
|
||||||
|
@ -47,20 +48,23 @@ function explorerUrl(chain: string, contract: string): string {
|
||||||
// trc20
|
// trc20
|
||||||
return `https://tronscan.io/#/token20/${contract}`;
|
return `https://tronscan.io/#/token20/${contract}`;
|
||||||
|
|
||||||
case "binance":
|
case CoinType.name(CoinType.binance):
|
||||||
return `https://explorer.binance.org/asset/${contract}`;
|
return `https://explorer.binance.org/asset/${contract}`;
|
||||||
|
|
||||||
case "smartchain":
|
case CoinType.name(CoinType.smartchain):
|
||||||
return `https://bscscan.com/token/${contract}`;
|
return `https://bscscan.com/token/${contract}`;
|
||||||
|
|
||||||
case "neo":
|
case CoinType.name(CoinType.neo):
|
||||||
return `https://neo.tokenview.com/en/token/0x${contract}`;
|
return `https://neo.tokenview.com/en/token/0x${contract}`;
|
||||||
|
|
||||||
case "nuls":
|
case CoinType.name(CoinType.nuls):
|
||||||
return `https://nulscan.io/token/info?contractAddress=${contract}`;
|
return `https://nulscan.io/token/info?contractAddress=${contract}`;
|
||||||
|
|
||||||
case "wanchain":
|
case CoinType.name(CoinType.wanchain):
|
||||||
return `https://www.wanscan.org/token/${contract}`;
|
return `https://www.wanscan.org/token/${contract}`;
|
||||||
|
|
||||||
|
case CoinType.name(CoinType.solana):
|
||||||
|
return `https://explorer.solana.com/address/${contract}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
|
@ -70,7 +74,7 @@ function explorerUrlAlternatives(chain: string, contract: string, name: string):
|
||||||
const altUrls: string[] = [];
|
const altUrls: string[] = [];
|
||||||
if (name) {
|
if (name) {
|
||||||
const nameNorm = name.toLowerCase().replace(' ', '').replace(')', '').replace('(', '');
|
const nameNorm = name.toLowerCase().replace(' ', '').replace(')', '').replace('(', '');
|
||||||
if (chain.toLowerCase() == "ethereum") {
|
if (chain.toLowerCase() == CoinType.name(CoinType.ethereum)) {
|
||||||
altUrls.push(`https://etherscan.io/token/${nameNorm}`);
|
altUrls.push(`https://etherscan.io/token/${nameNorm}`);
|
||||||
}
|
}
|
||||||
altUrls.push(`https://explorer.${nameNorm}.io`);
|
altUrls.push(`https://explorer.${nameNorm}.io`);
|
||||||
|
@ -114,7 +118,7 @@ function isAssetInfoOK(chain: string, address: string, errors: string[], warning
|
||||||
explorersAlt.forEach(exp => { if (exp.toLowerCase() == explorerActualLower) { ++matchCount; }});
|
explorersAlt.forEach(exp => { if (exp.toLowerCase() == explorerActualLower) { ++matchCount; }});
|
||||||
if (matchCount == 0) {
|
if (matchCount == 0) {
|
||||||
// none matches, this is warning/error
|
// none matches, this is warning/error
|
||||||
if (chain.toLowerCase() == "ethereum" || chain.toLowerCase() == "smartchain") {
|
if (chain.toLowerCase() == CoinType.name(CoinType.ethereum) || chain.toLowerCase() == CoinType.name(CoinType.smartchain)) {
|
||||||
errors.push(`Incorrect explorer, ${explorerActual} instead of ${explorerExpected} (${explorersAlt.join(', ')})`);
|
errors.push(`Incorrect explorer, ${explorerActual} instead of ${explorerExpected} (${explorersAlt.join(', ')})`);
|
||||||
} else {
|
} else {
|
||||||
warnings.push(`Unexpected explorer, ${explorerActual} instead of ${explorerExpected} (${explorersAlt.join(', ')})`);
|
warnings.push(`Unexpected explorer, ${explorerActual} instead of ${explorerExpected} (${explorersAlt.join(', ')})`);
|
||||||
|
|
|
@ -55,5 +55,6 @@ export const chainsWithDenylist = ethForkChains.concat(
|
||||||
Vechain,
|
Vechain,
|
||||||
Ontology,
|
Ontology,
|
||||||
Theta,
|
Theta,
|
||||||
EOS
|
EOS,
|
||||||
|
Solana,
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user