Skip to content

Commit

Permalink
chore: add more params
Browse files Browse the repository at this point in the history
  • Loading branch information
zhouhanseng committed Apr 21, 2023
1 parent e06a213 commit 247fd30
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 61 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
name: Generate and Deploy

on:
schedule:
- cron: '0 0 * * *'
push:
on:
- 'dao-space-2'
workflow_dispatch:

jobs:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mask-dsearch",
"version": "0.0.3",
"version": "0.0.4",
"repository": "https://github.com/DimensionDev/Mask-DSearch.git",
"license": "MIT",
"author": "guanbinrui <guanbinrui@mask.io>",
Expand Down
114 changes: 57 additions & 57 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,63 +19,63 @@ const nonFungibleCollectionProviders = [nftScanCollectionAPI]
async function main() {
await initFolder()

for (const p of fungibleProviders) {
let fungibleTokens: FungibleToken[] = []
console.log(`Fetch the data from ${p.getProviderName()}`)
try {
const tokens = await p.getTopTokens()
fungibleTokens = [...fungibleTokens, ...tokens]
} catch (e) {
console.log(`Fetching the chain failed by ${p.getProviderName()}`)
console.log(e)
}

console.log(`The current chain get ${fungibleTokens.length} tokens`)

if (fungibleTokens.length) {
await writeTokensToFile(
p.getProviderName(),
'fungible-tokens',
fungibleTokens.filter((x) => x.source === p.getProviderName()),
)
}
}

for (const p of nonFungibleTokenProviders) {
let nonFungibleTokens: NonFungibleToken[] = []
console.log(`Fetch the data from ${p.getProviderName()}`)
try {
const tokens = await p.getTopTokens()
nonFungibleTokens = [...nonFungibleTokens, ...tokens]
} catch (e) {
console.log(`Fetch the chain failed by ${p.getProviderName()}`)
console.log(e)
}

console.log(`The current chain get ${nonFungibleTokens.length} tokens`)

if (nonFungibleTokens.length) {
await writeTokensToFile(p.getProviderName(), 'non-fungible-tokens', nonFungibleTokens)
}
}

for (const p of nonFungibleCollectionProviders) {
let nonFungibleCollections: NonFungibleCollection[] = []
console.log(`Fetch the data from ${p.getProviderName()}`)
try {
const collections = await p.getCollections()
nonFungibleCollections = [...nonFungibleCollections, ...collections]
} catch (e) {
console.log(`Fetch the chain failed by ${p.getProviderName()}`)
console.log(e)
}

console.log(`The current chain get ${nonFungibleCollections.length} collections`)

if (nonFungibleCollections.length) {
await writeCollectionsToFile(p.getProviderName(), nonFungibleCollections)
}
}
// for (const p of fungibleProviders) {
// let fungibleTokens: FungibleToken[] = []
// console.log(`Fetch the data from ${p.getProviderName()}`)
// try {
// const tokens = await p.getTopTokens()
// fungibleTokens = [...fungibleTokens, ...tokens]
// } catch (e) {
// console.log(`Fetching the chain failed by ${p.getProviderName()}`)
// console.log(e)
// }

// console.log(`The current chain get ${fungibleTokens.length} tokens`)

// if (fungibleTokens.length) {
// await writeTokensToFile(
// p.getProviderName(),
// 'fungible-tokens',
// fungibleTokens.filter((x) => x.source === p.getProviderName()),
// )
// }
// }

// for (const p of nonFungibleTokenProviders) {
// let nonFungibleTokens: NonFungibleToken[] = []
// console.log(`Fetch the data from ${p.getProviderName()}`)
// try {
// const tokens = await p.getTopTokens()
// nonFungibleTokens = [...nonFungibleTokens, ...tokens]
// } catch (e) {
// console.log(`Fetch the chain failed by ${p.getProviderName()}`)
// console.log(e)
// }

// console.log(`The current chain get ${nonFungibleTokens.length} tokens`)

// if (nonFungibleTokens.length) {
// await writeTokensToFile(p.getProviderName(), 'non-fungible-tokens', nonFungibleTokens)
// }
// }

// for (const p of nonFungibleCollectionProviders) {
// let nonFungibleCollections: NonFungibleCollection[] = []
// console.log(`Fetch the data from ${p.getProviderName()}`)
// try {
// const collections = await p.getCollections()
// nonFungibleCollections = [...nonFungibleCollections, ...collections]
// } catch (e) {
// console.log(`Fetch the chain failed by ${p.getProviderName()}`)
// console.log(e)
// }

// console.log(`The current chain get ${nonFungibleCollections.length} collections`)

// if (nonFungibleCollections.length) {
// await writeCollectionsToFile(p.getProviderName(), nonFungibleCollections)
// }
// }

const spaces = await daoAPI.getSpaces()
await writeDAOToFile(spaces)
Expand Down
4 changes: 3 additions & 1 deletion src/providers/dao.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ export class DAO implements DaoProvider {
return uniqBy(rawSpaces.filter(x => x.avatar && x.followersCount > 499 && x.validation.name !== 'any' && x.twitter).map(x => ({
spaceId: x.id,
spaceName: x.name,
twitterHandler: x.twitter
twitterHandler: x.twitter,
avatar: x.avatar,
followersCount: x.followersCount
}) as Space), x => x.spaceId)
}
}
2 changes: 2 additions & 0 deletions src/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ export interface Space {
spaceId: string
spaceName: string
twitterHandler: string
followersCount: number
avatar: string
}

export interface FungibleTokenProvider {
Expand Down

0 comments on commit 247fd30

Please sign in to comment.