-
Notifications
You must be signed in to change notification settings - Fork 5
feat: Metis token list #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
094f313
8f315b4
6384550
7efaa97
41ce669
118df20
a25e29f
d71fc63
4e1ff28
4efcc44
0d0d98c
eb6145d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| { | ||
| "name": "mask-token-lists", | ||
| "version": "0.0.38", | ||
| "version": "0.0.39", | ||
| "repository": "https://github.com/DimensionDev/Mask-Token-Lists.git", | ||
| "license": "MIT", | ||
| "author": "guanbinrui <[email protected]>", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| # read versionn | ||
| VERSION=$(node -p -e "require('./package.json').version") | ||
|
|
||
| CHAIN[0]=dist/v$VERSION | ||
|
|
||
|
|
||
| for i in {1,3,4,10,56,97,100,122,128,137,250,288,588,1030,1088,42161,42220,43114,80001,1313161554}; do | ||
| CHAIN[$i]=dist/v$VERSION/$i | ||
| done | ||
|
|
||
| mkdir -p dist | ||
| mkdir -p latest | ||
|
|
||
| # build the latest version | ||
| for i in "${!CHAIN[@]}"; do | ||
| printf "Generate for chain id %s to folder: %s\n" "$i" "${CHAIN[$i]}" | ||
| mkdir -p "${CHAIN[$i]}" | ||
| touch "${CHAIN[$i]}/tokens.json" | ||
| node scripts/generate-erc20.js $i > "${CHAIN[$i]}/tokens.json" | ||
|
|
||
| if [ $? -ne 0 ]; then | ||
| exit 1; | ||
| fi | ||
|
|
||
| node scripts/risk-check.js $i > "${CHAIN[$i]}/riskInfo.json" | ||
| done | ||
|
|
||
| node scripts/generate-erc721.js > "dist/mask_nft.json" | ||
|
|
||
| # build the current version | ||
| #cp dist/v${VERSION}/tokens.json "dist/mask.json" | ||
| cp -r dist/v"${VERSION}/" "dist/latest" | ||
| cp dist/mask_nft.json "dist/mask_nft_v_$(echo $VERSION | sed "s/\./_/g").json" | ||
|
|
||
| echo "v${VERSION} is built." | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,168 @@ | ||
| const Ajv = require("ajv"); | ||
developerfred marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| const { EthereumAddress } = require("wallet.ts"); | ||
| const { schema } = require("@uniswap/token-lists"); | ||
| const metadata = require("../src/erc20/contract-metadata.json"); | ||
| const Mainnet = require("../src/erc20/mainnet.json"); | ||
| const Ropsten = require("../src/erc20/ropsten.json"); | ||
| const Rinkeby = require("../src/erc20/rinkeby.json"); | ||
| const Optimistic = require("../src/erc20/optimistic.json"); | ||
| const Fuse = require("../src/erc20/fuse.json"); | ||
| const Bsc = require("../src/erc20/bsc.json"); | ||
| const Chapel = require("../src/erc20/chapel.json"); | ||
| const xDai = require("../src/erc20/xdai.json"); | ||
| const Fantom = require("../src/erc20/fantom.json"); | ||
| const Celo = require("../src/erc20/celo.json"); | ||
| const Matic = require("../src/erc20/matic.json"); | ||
| const Arbiturm = require("../src/erc20/arbiturm.json"); | ||
| const Mumbai = require("../src/erc20/mumbai.json"); | ||
| const Aurora = require("../src/erc20/aurora.json"); | ||
| const Avalanche = require("../src/erc20/avalanche.json"); | ||
| const Boba = require("../src/erc20/boba.json"); | ||
| const Heco = require("../src/erc20/heco.json"); | ||
| const Pancake = require("../src/erc20/pancake.json"); | ||
| const Metis = require("../src/erc20/metis.json"); | ||
| const Stardust = require("../src/erc20/stardust.json"); | ||
| const QucikSwapTokens = require("../src/erc20/quickswap.json"); | ||
| const ConfluxTokens = require("../src/erc20/conflux.json"); | ||
| const { fetchDebankLogoURI } = require("./fetch-debank-logo-uri"); | ||
| const { addChainId, generateTokenList } = require("./shared"); | ||
|
|
||
| const getMetaMaskLogoURL = (url) => | ||
| `https://raw.githubusercontent.com/MetaMask/contract-metadata/master/images/${url}`; | ||
|
|
||
| const chainId = Number.parseInt(process.argv.slice(2)[0]); | ||
|
|
||
| const MetaMask = Object.keys(metadata) | ||
| .filter((key) => { | ||
| const record = metadata[key]; | ||
| return ( | ||
| typeof record.symbol === "string" && | ||
| typeof record.decimals === "number" && | ||
| typeof record.name === "string" && | ||
| new RegExp("^[ \\w.'+\\-%/À-ÖØ-öø-ÿ]+$").test(record.name) && | ||
| EthereumAddress.isValid(key) | ||
| ); | ||
| }) | ||
| .map((key) => ({ | ||
| chainId: 1, | ||
| address: key, | ||
| symbol: metadata[key].symbol, | ||
| decimals: metadata[key].decimals, | ||
| name: metadata[key].name, | ||
| logo: metadata[key].logo, | ||
| })); | ||
|
|
||
| const QuickSwap = QucikSwapTokens.tokens.map( | ||
| ({ name, address, symbol, decimals, logoURI }) => ({ | ||
| name, | ||
| address, | ||
| symbol, | ||
| decimals, | ||
| logoURI, | ||
| }) | ||
| ); | ||
|
|
||
| const chainIdToTokensMapping = { | ||
| 1: [MetaMask, Mainnet], | ||
| 3: [Ropsten], | ||
| 4: [Rinkeby], | ||
| 10: [Optimistic], | ||
| 56: [Bsc, Pancake], | ||
| 97: [Chapel], | ||
| 100: [xDai], | ||
| 122: [Fuse], | ||
| 128: [Heco], | ||
| 250: [Fantom], | ||
| 288: [Boba], | ||
| 137: [Matic, QuickSwap], | ||
| 588: [Stardust], | ||
| 1030: [ConfluxTokens], | ||
| 1088: [Metis], | ||
| 42161: [Arbiturm], | ||
| 42220: [Celo], | ||
| 43114: [Avalanche], | ||
| 80001: [Mumbai], | ||
| 1313161554: [Aurora], | ||
| }; | ||
|
|
||
| const getUntreatedTokens = async () => { | ||
| const baseTokens = | ||
| chainId === 0 | ||
| ? Object.entries(chainIdToTokensMapping) | ||
| .map(([key, value]) => { | ||
| return value.map((x) => addChainId(x, Number.parseInt(key))); | ||
| }) | ||
| .flat() | ||
| .flat() | ||
| : chainIdToTokensMapping[chainId] | ||
| .map((x) => addChainId(x, chainId)) | ||
| .flat(); | ||
|
|
||
| const debankTokens = await fetchDebankLogoURI( | ||
| chainId, | ||
| baseTokens.map((x) => x.address) | ||
| ); | ||
|
|
||
| return baseTokens.map((token) => { | ||
| const { logo, ...rest } = token; | ||
| const tokenWithLogoURI = debankTokens.find( | ||
| (x) => x.address.toLowerCase() === token.address.toLowerCase() | ||
| ); | ||
| const logoURI = | ||
| tokenWithLogoURI?.logoURI || | ||
| (logo && getMetaMaskLogoURL(logo)) || | ||
| token.logoURI; | ||
|
|
||
| return logoURI ? { ...rest, logoURI } : { ...rest }; | ||
| }); | ||
| }; | ||
|
|
||
| const start = async () => { | ||
| const tokens = await getUntreatedTokens(); | ||
| const MaskTokenList = generateTokenList( | ||
| tokens | ||
| .map((x) => ({ | ||
| ...x, | ||
| address: EthereumAddress.checksumAddress(x.address), | ||
| })) | ||
| .sort((a, z) => { | ||
| if (a.name > z.name) return 1; | ||
| if (a.name < z.name) return -1; | ||
| return 0; | ||
| }), | ||
| { | ||
| name: "Mask Network", | ||
| logoURI: | ||
| "https://raw.githubusercontent.com/DimensionDev/Maskbook-Website/master/img/MB--CircleCanvas--WhiteOverBlue.svg", | ||
| keywords: [ | ||
| "browser extension", | ||
| "web3", | ||
| "peer to peer", | ||
| "encryption", | ||
| "cryptography", | ||
| "gundb", | ||
| "privacy protection", | ||
| "ownyourdata", | ||
| "social network", | ||
| "blockchain", | ||
| "crypto", | ||
| "dweb", | ||
| ], | ||
| timestamp: new Date().toISOString(), | ||
| } | ||
| ); | ||
|
|
||
| const ajv = new Ajv(); | ||
| schema.definitions.TokenInfo.properties.symbol.pattern = | ||
| "^[a-zA-Z0-9+\\-%/\\$\\.]+$"; | ||
| const validate = ajv.compile(schema); | ||
| if (validate(MaskTokenList)) { | ||
| process.stdout.write(JSON.stringify(MaskTokenList)); | ||
| } else { | ||
| console.error("Failed to build ERC20 token list."); | ||
| console.error(validate.errors); | ||
| process.exit(1); | ||
| } | ||
| }; | ||
|
|
||
| start(); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| [ | ||
| { | ||
| "chainId": 1088, | ||
| "address": "0xea32a96608495e54156ae48931a7c20f0dcc1a21", | ||
| "decimals": 6, | ||
| "name": "USDC Token", | ||
| "symbol": "m.USDC", | ||
| "logoURI": "https://raw.githubusercontent.com/MetisProtocol/metis-bridge-resources/master/tokens/USDC/logo.png" | ||
| }, | ||
| { | ||
| "chainId": 1088, | ||
| "address": "0xbb06dca3ae6887fabf931640f67cab3e3a16f4dc", | ||
| "decimals": 6, | ||
| "name": "USDT Token", | ||
| "symbol": "m.USDT", | ||
| "logoURI": "https://raw.githubusercontent.com/MetisProtocol/metis-bridge-resources/master/tokens/USDT/logo.png" | ||
| }, | ||
| { | ||
| "chainId": 1088, | ||
| "address": "0x5ce34d9abe4bf239cbc08b89287c87f4cd6d80b7", | ||
| "decimals": 18, | ||
| "name": "WOW Token", | ||
| "symbol": "m.WOW", | ||
| "logoURI": "https://raw.githubusercontent.com/MetisProtocol/metis-bridge-resources/master/tokens/WOW/logo.png" | ||
| }, | ||
| { | ||
| "chainId": 1088, | ||
| "address": "0xf5f66d5daa89c090a7afa10e6c1553b2887a9a33", | ||
| "decimals": 18, | ||
| "name": "LINK Token", | ||
| "symbol": "m.LINK", | ||
| "logoURI": "https://raw.githubusercontent.com/MetisProtocol/metis-bridge-resources/master/tokens/LINK/logo.png" | ||
| }, | ||
| { | ||
| "chainId": 1088, | ||
| "address": "0x420000000000000000000000000000000000000a", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A strange address. Isn't it an unreachable address?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, it's very affordable, take a look.: https://andromeda-explorer.metis.io/address/0x420000000000000000000000000000000000000A/transactions |
||
| "decimals": 18, | ||
| "name": "Ether", | ||
| "symbol": "WETH", | ||
| "logoURI": "https://raw.githubusercontent.com/MetisProtocol/metis-bridge-resources/master/tokens/ETH/logo.png" | ||
| }, | ||
| { | ||
| "chainId": 1088, | ||
| "address": "0x68D97B7A961a5239B9F911DA8dEb57F6eF6e5e28", | ||
| "decimals": 18, | ||
| "name": "AAVE Token", | ||
| "symbol": "AAVE", | ||
| "logoURI": "https://raw.githubusercontent.com/MetisProtocol/metis-bridge-resources/master/tokens/AAVE/logo.png" | ||
| }, | ||
| { | ||
| "chainId": 1088, | ||
| "address": "0x87DD4a7Ad23B95cD9fF9C26B5cF325905CaF8663", | ||
| "decimals": 18, | ||
| "name": "Curve DAO Token", | ||
| "symbol": "CRV", | ||
| "logoURI": "https://raw.githubusercontent.com/MetisProtocol/metis-bridge-resources/master/tokens/CRV/logo.png" | ||
| }, | ||
| { | ||
| "chainId": 1088, | ||
| "address": "0x90fE084F877C65e1b577c7b2eA64B8D8dd1AB278", | ||
| "decimals": 18, | ||
| "name": "Netswap Token", | ||
| "symbol": "NETT", | ||
| "logoURI": "https://raw.githubusercontent.com/Netswap/tokens/master/assets/0x90fe084f877c65e1b577c7b2ea64b8d8dd1ab278/logo.png" | ||
| } | ||
| ] | ||
Uh oh!
There was an error while loading. Please reload this page.