diff --git a/.prettierignore b/.prettierignore index 7773828..9809a24 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1 +1,2 @@ -dist/ \ No newline at end of file +dist/ +pnpm-lock.yaml diff --git a/package.json b/package.json index df21a93..3afd1e1 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "husky": "^7.0.0", "install": "0.13.0", "msw": "^0.47.4", - "prettier": "2.7.1", + "prettier": "3.5.3", "pretty-quick": "^3.1.3", "ts-node": "^10.9.1", "tsc": "^2.0.4", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ebb58f3..452fae1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -67,11 +67,11 @@ importers: specifier: ^0.47.4 version: 0.47.4(typescript@4.9.5) prettier: - specifier: 2.7.1 - version: 2.7.1 + specifier: 3.5.3 + version: 3.5.3 pretty-quick: specifier: ^3.1.3 - version: 3.3.1(prettier@2.7.1) + version: 3.3.1(prettier@3.5.3) ts-node: specifier: ^10.9.1 version: 10.9.2(@types/node@18.19.44)(typescript@4.9.5) @@ -1249,9 +1249,9 @@ packages: resolution: {integrity: sha512-TesUflQ0WKZqAvg52PWL6kHgLKP6xB6heTOdoYM0Wt2UHyxNa4K25EZZMgKns3BH1RLVbZCREPpLY0rhnNoHVQ==} engines: {node: ^10 || ^12 || >=14} - prettier@2.7.1: - resolution: {integrity: sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g==} - engines: {node: '>=10.13.0'} + prettier@3.5.3: + resolution: {integrity: sha512-QQtaxnoDJeAkDvDKWCLiwIXkTgRhwYDEQCghU9Z6q03iyek/rxRh/2lC3HB7P8sWT2xC/y5JDctPLBIGzHKbhw==} + engines: {node: '>=14'} hasBin: true pretty-quick@3.3.1: @@ -2795,9 +2795,9 @@ snapshots: picocolors: 1.0.1 source-map-js: 1.2.0 - prettier@2.7.1: {} + prettier@3.5.3: {} - pretty-quick@3.3.1(prettier@2.7.1): + pretty-quick@3.3.1(prettier@3.5.3): dependencies: execa: 4.1.0 find-up: 4.1.0 @@ -2805,7 +2805,7 @@ snapshots: mri: 1.2.0 picocolors: 1.0.1 picomatch: 3.0.1 - prettier: 2.7.1 + prettier: 3.5.3 tslib: 2.6.3 progress@2.0.3: {} diff --git a/src/providers/NFTScan.ts b/src/providers/NFTScan.ts index fdc9683..c5a9e7c 100644 --- a/src/providers/NFTScan.ts +++ b/src/providers/NFTScan.ts @@ -176,19 +176,18 @@ export class NFTScanToken implements NonFungibleTokenProvider { }) const data = list.data.data - .map( - (x, index) => - ({ - pluginID: config.pluginID, - address: x.contract_address, - name: x.contract_name, - chainId: config.chainId, - type: SearchResultType.NonFungibleToken, - source: SourceType.NFTScan, - logoURL: x.logo_url, - rank: index + 1, - } as NonFungibleToken), - ) + .map((x, index) => { + return { + pluginID: config.pluginID, + address: x.contract_address, + name: x.contract_name, + chainId: config.chainId, + type: SearchResultType.NonFungibleToken, + source: SourceType.NFTScan, + logoURL: x.logo_url, + rank: index + 1, + } as NonFungibleToken + }) .slice(0, config.limit) return data }) diff --git a/src/providers/coingecko.ts b/src/providers/coingecko.ts index 39e00d8..04c66bf 100644 --- a/src/providers/coingecko.ts +++ b/src/providers/coingecko.ts @@ -73,7 +73,7 @@ export type CoinDetail = { } const tokenRelatedTwitters: Record = { - 'binancecoin': ['binance', 'bnbchain'] + binancecoin: ['binance', 'bnbchain'], } export class CoinGecko implements FungibleTokenProvider { @@ -131,20 +131,22 @@ export class CoinGecko implements FungibleTokenProvider { const links = await this.getMetadata(list.data.map((x) => x.id)) result.push( - ...list.data.map((x) => ({ - pluginID: NetworkPluginID.PLUGIN_EVM, - id: x.id, - symbol: x.symbol, - name: x.name, - name_underscore: joinName(x.name, '_').toLowerCase(), - name_connect: joinName(x.name, '').toLowerCase(), - source: SourceType.CoinGecko, - type: SearchResultType.FungibleToken, - logoURL: x.image, - rank: x.market_cap_rank, - socialLinks: links[x.id], - relatedTwitters: tokenRelatedTwitters[x.id], - } satisfies FungibleToken)), + ...list.data.map((x) => { + return { + pluginID: NetworkPluginID.PLUGIN_EVM, + id: x.id, + symbol: x.symbol, + name: x.name, + name_underscore: joinName(x.name, '_').toLowerCase(), + name_connect: joinName(x.name, '').toLowerCase(), + source: SourceType.CoinGecko, + type: SearchResultType.FungibleToken, + logoURL: x.image, + rank: x.market_cap_rank, + socialLinks: links[x.id], + relatedTwitters: tokenRelatedTwitters[x.id], + } satisfies FungibleToken + }), ) console.timeEnd(`CoinGecko: get top tokens of page ${page}`) diff --git a/src/providers/coinmarketcap.ts b/src/providers/coinmarketcap.ts index c6dc39c..71a3458 100644 --- a/src/providers/coinmarketcap.ts +++ b/src/providers/coinmarketcap.ts @@ -88,22 +88,21 @@ export class CoinMarketCap implements FungibleTokenProvider { const metadata = await this.getMetadata(res.data.data.map((x) => x.id)) - const result = res.data.data.map( - (x) => - ({ - pluginID: NetworkPluginID.PLUGIN_EVM, - id: x.id, - name: x.name, - name_underscore: joinName(x.name, '_').toLowerCase(), - name_connect: joinName(x.name, '').toLowerCase(), - symbol: x.symbol, - source: SourceType.CoinMarketCap, - type: SearchResultType.FungibleToken, - rank: x.rank, - logoURL: metadata[x.id.toString()]?.logo, - socialLinks: this.getSocialLinks(metadata[x.id.toString()]), - } satisfies FungibleToken), - ) + const result = res.data.data.map((x) => { + return { + pluginID: NetworkPluginID.PLUGIN_EVM, + id: x.id, + name: x.name, + name_underscore: joinName(x.name, '_').toLowerCase(), + name_connect: joinName(x.name, '').toLowerCase(), + symbol: x.symbol, + source: SourceType.CoinMarketCap, + type: SearchResultType.FungibleToken, + rank: x.rank, + logoURL: metadata[x.id.toString()]?.logo, + socialLinks: this.getSocialLinks(metadata[x.id.toString()]), + } satisfies FungibleToken + }) console.timeEnd('CoinMarketCap: get top tokens') return result } diff --git a/src/providers/dao.ts b/src/providers/dao.ts index 68261db..e8fa840 100644 --- a/src/providers/dao.ts +++ b/src/providers/dao.ts @@ -6,34 +6,35 @@ import * as verifyList_ from '../../public/dao/verify-list.json' const verifyList: { [key: string]: number } = verifyList_ interface RawSpace { - id: string, - name: string, - avatar: string, - twitter: string, - followersCount: number, + id: string + name: string + avatar: string + twitter: string + followersCount: number filters: { - minScore: number, + minScore: number onlyMembers: boolean - }, + } validation: { - name: string, + name: string params: { - minScore: number, + minScore: number } } - treasuries: { name: string, address: string }[] + treasuries: { name: string; address: string }[] } export class DAO implements DaoProvider { async getSpaces(): Promise { - const allSettled = await Promise.allSettled(Array.from(Array(14)).map(async (x, i) => { - return axios.post<{ - data: { - spaces: RawSpace[] - } - }>('https://hub.snapshot.org/graphql', { - operationName: "Spaces", - query: ` + const allSettled = await Promise.allSettled( + Array.from(Array(14)).map(async (x, i) => { + return axios.post<{ + data: { + spaces: RawSpace[] + } + }>('https://hub.snapshot.org/graphql', { + operationName: 'Spaces', + query: ` query Spaces { spaces( first: 1000, @@ -60,23 +61,29 @@ export class DAO implements DaoProvider { } } `, - variables: null - }) - })) + variables: null, + }) + }), + ) - const rawSpaces = allSettled.flatMap( - (x) => (x.status === 'fulfilled' ? x.value.data.data.spaces ?? undefined : undefined) - ).filter(x => x) as RawSpace[] + const rawSpaces = allSettled + .flatMap((x) => (x.status === 'fulfilled' ? (x.value.data.data.spaces ?? undefined) : undefined)) + .filter((x) => x) as RawSpace[] - return uniqBy(rawSpaces.filter( - x => verifyList[x.id] !== -1 && (x.followersCount > 999 || verifyList[x.id] === 1) - ).map(x => ({ - spaceId: x.id, - spaceName: x.name, - twitterHandler: x.twitter, - avatar: x.avatar, - followersCount: x.followersCount, - isVerified: verifyList[x.id] === 1 - }) as Space), x => x.spaceId) + return uniqBy( + rawSpaces + .filter((x) => verifyList[x.id] !== -1 && (x.followersCount > 999 || verifyList[x.id] === 1)) + .map((x) => { + return { + spaceId: x.id, + spaceName: x.name, + twitterHandler: x.twitter, + avatar: x.avatar, + followersCount: x.followersCount, + isVerified: verifyList[x.id] === 1, + } as Space + }), + (x) => x.spaceId, + ) } } diff --git a/src/utils/file.ts b/src/utils/file.ts index 0d517a6..ccf0321 100644 --- a/src/utils/file.ts +++ b/src/utils/file.ts @@ -46,13 +46,9 @@ export async function writeCollectionsToFile(provider: SourceType, tokens: Fungi export async function writeDAOToFile(spaces: Space[]) { if (!spaces.length) throw new Error(`Forbid writing the empty data of DAO to output`) - await fs.writeFile( - path.join(getOutputDir('dao'), `spaces.json`), - JSON.stringify(spaces, undefined, 2), - { - encoding: 'utf-8', - }, - ) + await fs.writeFile(path.join(getOutputDir('dao'), `spaces.json`), JSON.stringify(spaces, undefined, 2), { + encoding: 'utf-8', + }) } export async function mergePublicFileToOutput(