11import { ref , computed , Ref } from 'vue' ;
22import snapshot from '@snapshot-labs/snapshot.js' ;
33
4- const SUPPORTED_ABIS = [ 'erc721 ' , 'erc1155 ' ] ;
4+ const SUPPORTED_ABIS = [ 'ERC721 ' , 'ERC1155 ' ] ;
55
66const nfts : Ref < any [ ] > = ref ( [ ] ) ;
77const loading = ref ( true ) ;
@@ -10,42 +10,32 @@ const loaded = ref(false);
1010export function useNfts ( ) {
1111 async function loadNfts ( address ) {
1212 loading . value = true ;
13- const key = 'ckey_2d082caf47f04a46947f4f212a8' ;
14- const url = `https://api.covalenthq.com/v1/1/address/${ address } /balances_v2/?quote-currency=USD&format=JSON&nft=true&key=${ key } ` ;
15- const results = await snapshot . utils . getJSON ( url ) ;
16- nfts . value = results . data . items
17- . filter (
18- item =>
19- item . type === 'nft' &&
20- item . nft_data &&
21- item . supports_erc ?. some ( itemErc => SUPPORTED_ABIS . includes ( itemErc ) )
13+
14+ const url =
15+ 'https://testnets-api.opensea.io/api/v1/assets?owner=0x0000000000000000000000000000000000000000&order_direction=desc&offset=0&limit=20&include_orders=false' ;
16+ const { assets } = await snapshot . utils . getJSON ( url ) ;
17+
18+ nfts . value = assets
19+ . filter ( asset =>
20+ SUPPORTED_ABIS . includes ( asset . asset_contract ?. schema_name )
2221 )
23- . map ( item => {
24- const type = item . supports_erc ?. find ( itemErc =>
25- SUPPORTED_ABIS . includes ( itemErc )
26- ) ;
27- const tokenId = item . nft_data [ 0 ] ?. token_id ;
28- const title =
29- item . nft_data [ 0 ] ?. external_data ?. name ??
30- item . contract_name ??
31- 'Untitled' ;
22+ . map ( asset => {
23+ const tokenId = asset . token_id ;
24+ const title = asset . name ?? 'Untitled' ;
3225 const displayTitle =
3326 title . match ( / ( # [ 0 - 9 ] + ) $ / ) || ! tokenId
3427 ? title
3528 : `${ title } #${ tokenId } ` ;
3629
37- const image =
38- item ?. nft_data [ 0 ] ?. external_data . image ??
39- `https://cdn.stamp.fyi/token/${ item . contract_address } ?s=256` ;
40-
4130 return {
42- ...item ,
43- id : `${ item . contract_address } :${ tokenId || 0 } ` ,
44- type,
31+ ...asset ,
32+ type : asset . asset_contract . schema_name . toLowerCase ( ) ,
4533 tokenId,
4634 title,
4735 displayTitle,
48- image
36+ image : asset . image_url ,
37+ collectionName : asset . collection . name ,
38+ contractAddress : asset . asset_contract . address
4939 } ;
5040 } ) ;
5141 loading . value = false ;
0 commit comments