Skip to content

Commit

Permalink
feat: add getTopCollectorsByContract api to SimpleHashEVM (#11611)
Browse files Browse the repository at this point in the history
  • Loading branch information
LeifXu authored May 10, 2024
1 parent 7b2c864 commit e09739b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
22 changes: 22 additions & 0 deletions packages/web3-providers/src/SimpleHash/apis/EVM.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,28 @@ class SimpleHashAPI_EVM implements NonFungibleTokenAPI.Provider<ChainId, SchemaT
)
}

async getTopCollectorsByContract(
address: string,
{ chainId = ChainId.Mainnet, indicator, size = 20 }: BaseHubOptions<ChainId> = {},
) {
const chain = resolveChain(NetworkPluginID.PLUGIN_EVM, chainId)
const path = urlcat('/api/v0/nfts/top_collectors/:chain/:contract_address', {
chain,
contract_address: address,
cursor: indicator?.id || undefined,
limit: size,
include_owner_image: '1',
})
const response = await fetchFromSimpleHash<{ next_cursor: string; top_collectors: SimpleHash.TopCollector[] }>(
path,
)
return createPageable(
response.top_collectors,
indicator,
response.next_cursor ? createNextIndicator(indicator, response.next_cursor) : undefined,
)
}

async getCollectionOverview(chainId: ChainId, id: string): Promise<NonFungibleCollectionOverview | undefined> {
// SimpleHash collection id is not address
if (isValidAddress(id)) return
Expand Down
8 changes: 8 additions & 0 deletions packages/web3-providers/src/types/SimpleHash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,12 @@ export namespace SimpleHash {
first_acquired_date: string
last_acquired_date: string
}

export interface TopCollector {
owner_address: string
owner_ens_name: string | null
owner_image: string
distinct_nfts_owned: number
total_copies_owned: number
}
}

0 comments on commit e09739b

Please sign in to comment.