Skip to content

Commit

Permalink
chore: sort (#82)
Browse files Browse the repository at this point in the history
* chore: sort

* chore: sort

* chore: sort

* chore: done
  • Loading branch information
zhouhanseng authored Apr 14, 2023
1 parent 265aef5 commit 0dc6284
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mask-token-lists",
"version": "0.0.61",
"version": "0.0.62",
"repository": "https://github.com/DimensionDev/Mask-Token-Lists.git",
"license": "MIT",
"author": "guanbinrui <[email protected]>",
Expand Down
14 changes: 10 additions & 4 deletions scripts/commands/rankByMarketCap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,16 @@ export async function rankByMarketCap(chainId: ChainId, toAddList?: FungibleToke

const tokenListWithRank = await fetch(fetchPage)

const results = tokenList.map((x) => {
const tokenWithRank = tokenListWithRank.find((y) => isSameAddress(x.address, y.address))
return tokenWithRank?.rank ? { ...x, rank: tokenWithRank.rank } : x
})
const results = tokenList
.map((x) => {
const tokenWithRank = tokenListWithRank.find((y) => isSameAddress(x.address, y.address))
return tokenWithRank?.rank ? { ...x, rank: tokenWithRank.rank } : x
})
.sort((a, z) => {
if (z.rank && (!a.rank || a.rank - z.rank > 0)) return 1
if (a.rank && (!z.rank || z.rank - a.rank > 0)) return -1
return 0
})

if (results.length && !toAddList) {
await writeTokensToFile(chainId, results)
Expand Down
14 changes: 4 additions & 10 deletions scripts/utils/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,10 @@ export async function writeTokensToFile(chain: ChainId, tokens: FungibleToken[])

function generate(tokens: FungibleToken[]) {
const tokenList = generateTokenList(
tokens
.map((x) => ({
...x,
address: x.chainId !== ChainId.Solana ? EthereumAddress.checksumAddress(x.address) : x.address,
}))
.sort((a, z) => {
if (a.name > z.name) return 1
if (a.name < z.name) return -1
return 0
}),
tokens.map((x) => ({
...x,
address: x.chainId !== ChainId.Solana ? EthereumAddress.checksumAddress(x.address) : x.address,
})),
{
name: 'Mask Network',
logoURI:
Expand Down

0 comments on commit 0dc6284

Please sign in to comment.