Skip to content
Merged
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
36 changes: 32 additions & 4 deletions packages/web3-providers/src/rss3/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import urlcat from 'urlcat'
import RSS3 from 'rss3-next'
import { RSS3_ENDPOINT } from './constants'
import { RSS3BaseAPI } from '../types'
import { NonFungibleTokenAPI, RSS3BaseAPI } from '../types'
import { fetchJSON } from '../helpers'

export class RSS3API implements RSS3BaseAPI.Provider {
export class RSS3API implements RSS3BaseAPI.Provider, NonFungibleTokenAPI.Provider {
createRSS3(
address: string,
sign: (message: string) => Promise<string> = () => {
Expand Down Expand Up @@ -62,11 +62,39 @@ export class RSS3API implements RSS3BaseAPI.Provider {
}>(url)
return rsp?.profile
}
async getNFTs(address: string) {
async getAssets(address: string) {
const url = urlcat(RSS3_ENDPOINT, '/assets/list', {
personaID: address,
type: RSS3BaseAPI.AssetType.NFT,
})
return fetchJSON<RSS3BaseAPI.GeneralAssetResponse>(url)

const { status, assets = [] } = await fetchJSON<RSS3BaseAPI.GeneralAssetResponse>(url)
if (!status) return []
return assets.map((asset) => {
return {
is_verified: false,
is_auction: false,
image_url: asset.info.image_preview_url ?? '',
asset_contract: null,
current_price: null,
current_symbol: '',
owner: null,
creator: null,
token_id: asset.id.substr(asset.id.lastIndexOf('-') + 1),
token_address: asset.id.substr(0, asset.id.indexOf('-')),
traits: [],
safelist_request_status: '',
description: '',
name: asset.info.title ?? '',
collection_name: asset.info.collection ?? '',
animation_url: asset.info.animation_url ?? '',
end_time: asset.info.end_date ? new Date(asset.info.end_date) : null,
order_payment_tokens: [],
offer_payment_tokens: [],
slug: null,
top_ownerships: [],
response_: asset,
}
})
}
}
2 changes: 1 addition & 1 deletion packages/web3-providers/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ export namespace RSS3BaseAPI {
getFootprints(address: string): Promise<GeneralAssetResponse | undefined>
getNameInfo(id: string): Promise<NameInfo | undefined>
getProfileInfo(address: string): Promise<ProfileInfo | undefined>
getNFTs(address: string): Promise<GeneralAssetResponse | undefined>
}
}

Expand Down Expand Up @@ -287,6 +286,7 @@ export namespace NonFungibleTokenAPI {
opts?: Options,
) => Promise<AssetOrder[]>
getCollections?: (address: string, opts?: Options) => Promise<ProviderPageable<Collection>>
getAssets?: (address: string) => Promise<Asset[] | undefined>
}
}

Expand Down