forked from mistswapdex/default-token-list
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f5b0d58
commit 7cfe7ad
Showing
31 changed files
with
442 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.idea/ | ||
node_modules | ||
build/ | ||
build/ | ||
generated/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
const { version } = require("../package.json"); | ||
|
||
const mainnet = require("../tokens/mainnet.json"); | ||
const ropsten = require("../tokens/ropsten.json"); | ||
const rinkeby = require("../tokens/rinkeby.json"); | ||
const goerli = require("../tokens/goerli.json"); | ||
const kovan = require("../tokens/kovan.json"); | ||
const fantom = require("../tokens/fantom.json"); | ||
const fantomTestnet = require("../tokens/fantom-testnet.json"); | ||
const matic = require("../tokens/matic.json"); | ||
const maticTestnet = require("../tokens/matic-testnet.json"); | ||
const xdai = require("../tokens/xdai.json"); | ||
const bsc = require("../tokens/bsc.json"); | ||
const bscTestnet = require("../tokens/bsc-testnet.json"); | ||
const moonbase = require("../tokens/moonbase.json"); | ||
const avalanche = require("../tokens/avalanche.json"); | ||
const fuji = require("../tokens/fuji.json"); | ||
const heco = require("../tokens/heco.json"); | ||
const hecoTestnet = require("../tokens/heco-testnet.json"); | ||
const harmony = require("../tokens/harmony.json"); | ||
const harmonyTestnet = require("../tokens/harmony-testnet.json"); | ||
const okex = require("../tokens/okex.json"); | ||
const okexTestnet = require("../tokens/okex-testnet.json"); | ||
//const arbitrum = require("../tokens/arbitrum.json"); | ||
//const celo = require("../tokens/celo.json"); | ||
|
||
module.exports = function buildList() { | ||
const parsed = version.split("."); | ||
return { | ||
name: "SushiSwap Menu", | ||
timestamp: new Date().toISOString(), | ||
version: { | ||
major: +parsed[0], | ||
minor: +parsed[1], | ||
patch: +parsed[2], | ||
}, | ||
tags: {}, | ||
logoURI: | ||
"https://raw.githubusercontent.com/sushiswap/art/master/sushi/logo-256x256.png", | ||
keywords: ["sushiswap", "default"], | ||
tokens: [ | ||
...mainnet, | ||
...ropsten, | ||
...goerli, | ||
...kovan, | ||
...rinkeby, | ||
...fantom, | ||
...fantomTestnet, | ||
...matic, | ||
...maticTestnet, | ||
...xdai, | ||
...bsc, | ||
...bscTestnet, | ||
...moonbase, | ||
...avalanche, | ||
...fuji, | ||
...heco, | ||
...hecoTestnet, | ||
...harmony, | ||
...harmonyTestnet, | ||
...okex, | ||
...okexTestnet, | ||
//...arbitrum, | ||
//...celo, | ||
] | ||
// sort them by symbol for easy readability | ||
.sort((t1, t2) => { | ||
if (t1.chainId === t2.chainId) { | ||
return t1.symbol.toLowerCase() < t2.symbol.toLowerCase() ? -1 : 1; | ||
} | ||
return t1.chainId < t2.chainId ? -1 : 1; | ||
}), | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
const XLSX = require("xlsx"); | ||
|
||
const { Octokit } = require("@octokit/rest"); | ||
|
||
const octokit = new Octokit(); | ||
|
||
const { ChainId } = require("@sushiswap/sdk"); | ||
|
||
const fs = require("fs"); | ||
|
||
const { resolve } = require("path"); | ||
|
||
const NAME = { | ||
[ChainId.MAINNET]: "mainnet", | ||
[ChainId.FANTOM]: "fantom", | ||
[ChainId.MATIC]: "matic", | ||
[ChainId.XDAI]: "xdai", | ||
[ChainId.BSC]: "bsc", | ||
[ChainId.AVALANCHE]: "avalanche", | ||
[ChainId.HECO]: "heco", | ||
[ChainId.HARMONY]: "harmony", | ||
[ChainId.OKEX]: "okex", | ||
[ChainId.CELO]: "celo", | ||
}; | ||
|
||
(async () => { | ||
try { | ||
const book = XLSX.utils.book_new(); | ||
|
||
for (const key of Object.keys(ChainId)) { | ||
const path = resolve(__dirname, `../tokens/${NAME[key]}.json`); | ||
|
||
if (!fs.existsSync(path)) { | ||
continue; | ||
} | ||
|
||
const tokens = require(path); | ||
|
||
// Grab file file names of the sushiswap/icons repo at the token path | ||
// we can use this to see if our default list is missing icons | ||
const { data } = await octokit.rest.repos.getContent({ | ||
owner: "sushiswap", | ||
repo: "icons", | ||
path: "token", | ||
}); | ||
|
||
const icons = data.map((data) => data.name.replace(".jpg", "")); | ||
|
||
const json = []; | ||
|
||
for (const token of tokens) { | ||
const listIcon = icons.find( | ||
(icon) => icon === token.symbol.toLowerCase() | ||
); | ||
|
||
// TODO: Check Figma and get icon if available | ||
const figmaIcon = undefined; | ||
|
||
const icon = listIcon || figmaIcon; | ||
|
||
if ((!token.logoURI && !icon) || !icon) { | ||
json.push({ | ||
network: NAME[key], | ||
address: token.address, | ||
name: token.name, | ||
symbol: token.symbol, | ||
logoURI: token?.logoURI || "", | ||
}); | ||
console.log("Add to list to send to chester"); | ||
continue; | ||
} | ||
|
||
// Check if logoURI has correct path | ||
if (!token.logoURI.includes("sushiswap/icons")) { | ||
// TODO: Automate this part... | ||
const logoURI = `https://raw.githubusercontent.com/sushiswap/icons/master/token/${icon}.jpg`; | ||
|
||
console.log(`Update Logo URI for ${token.symbol} with ${logoURI}`); | ||
} else { | ||
console.log(`Logo URI for ${token.symbol} is correct`); | ||
} | ||
} | ||
|
||
const sheet = XLSX.utils.json_to_sheet(json); | ||
|
||
XLSX.utils.book_append_sheet(book, sheet, NAME[key]); | ||
} | ||
|
||
XLSX.writeFile(book, resolve(__dirname, `../generated/missing-icons.xlsx`)); | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
const buildList = require("./buildList"); | ||
console.log(JSON.stringify(buildList(), null, 2)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,60 @@ | ||
const packageJson = require('../package.json'); | ||
const schema = require('@uniswap/token-lists/src/tokenlist.schema.json'); | ||
const { expect } = require('chai'); | ||
const { getAddress } = require('@ethersproject/address'); | ||
const Ajv = require('ajv'); | ||
const buildList = require('../src/buildList'); | ||
|
||
const ajv = new Ajv({ allErrors: true, format: 'full' }); | ||
const packageJson = require("../package.json"); | ||
const schema = require("@uniswap/token-lists/src/tokenlist.schema.json"); | ||
const { expect } = require("chai"); | ||
const { getAddress } = require("@ethersproject/address"); | ||
const Ajv = require("ajv"); | ||
const buildList = require("../internal/buildList"); | ||
|
||
const ajv = new Ajv({ allErrors: true, format: "full" }); | ||
const validator = ajv.compile(schema); | ||
|
||
describe('buildList', () => { | ||
describe("buildList", () => { | ||
const defaultTokenList = buildList(); | ||
|
||
it('validates', () => { | ||
it("validates", () => { | ||
expect(validator(defaultTokenList)).to.equal(true); | ||
}); | ||
|
||
it('contains no duplicate addresses', () => { | ||
it("contains no duplicate addresses", () => { | ||
const map = {}; | ||
for (let token of defaultTokenList.tokens) { | ||
const key = `${token.chainId}-${token.address}`; | ||
expect(typeof map[ key ]) | ||
.to.equal('undefined'); | ||
map[ key ] = true; | ||
expect(typeof map[key]).to.equal("undefined"); | ||
map[key] = true; | ||
} | ||
}); | ||
|
||
it('contains no duplicate symbols', () => { | ||
it("contains no duplicate symbols", () => { | ||
const map = {}; | ||
for (let token of defaultTokenList.tokens) { | ||
const key = `${token.chainId}-${token.symbol.toLowerCase()}`; | ||
expect(typeof map[ key ]) | ||
.to.equal('undefined'); | ||
map[ key ] = true; | ||
expect(typeof map[key]).to.equal("undefined"); | ||
map[key] = true; | ||
} | ||
}) | ||
}); | ||
|
||
it('contains no duplicate names', () => { | ||
it("contains no duplicate names", () => { | ||
const map = {}; | ||
for (let token of defaultTokenList.tokens) { | ||
const key = `${token.chainId}-${token.name.toLowerCase()}`; | ||
expect(typeof map[ key ]) | ||
.to.equal('undefined', `duplicate name: ${token.name}`); | ||
map[ key ] = true; | ||
expect(typeof map[key]).to.equal( | ||
"undefined", | ||
`duplicate name: ${token.name}` | ||
); | ||
map[key] = true; | ||
} | ||
}) | ||
}); | ||
|
||
it('all addresses are valid and checksummed', () => { | ||
it("all addresses are valid and checksummed", () => { | ||
for (let token of defaultTokenList.tokens) { | ||
expect(getAddress(token.address)).to.eq(token.address); | ||
} | ||
}); | ||
|
||
it('version matches package.json', () => { | ||
it("version matches package.json", () => { | ||
expect(packageJson.version).to.match(/^\d+\.\d+\.\d+$/); | ||
expect(packageJson.version).to.equal(`${defaultTokenList.version.major}.${defaultTokenList.version.minor}.${defaultTokenList.version.patch}`); | ||
expect(packageJson.version).to.equal( | ||
`${defaultTokenList.version.major}.${defaultTokenList.version.minor}.${defaultTokenList.version.patch}` | ||
); | ||
}); | ||
}); | ||
}); |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.