Skip to content

chore: prettier code #68

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
dist/
dist/
pnpm-lock.yaml
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
18 changes: 9 additions & 9 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 12 additions & 13 deletions src/providers/NFTScan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
Expand Down
32 changes: 17 additions & 15 deletions src/providers/coingecko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export type CoinDetail = {
}

const tokenRelatedTwitters: Record<string, string[]> = {
'binancecoin': ['binance', 'bnbchain']
binancecoin: ['binance', 'bnbchain'],
}

export class CoinGecko implements FungibleTokenProvider {
Expand Down Expand Up @@ -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}`)

Expand Down
31 changes: 15 additions & 16 deletions src/providers/coinmarketcap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
75 changes: 41 additions & 34 deletions src/providers/dao.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Space[]> {
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,
Expand All @@ -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,
)
}
}
10 changes: 3 additions & 7 deletions src/utils/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down