11import { describe , expect , it } from "vitest" ;
22import { DOODLES_CONTRACT } from "~test/test-contracts.js" ;
3+ import { TEST_CLIENT } from "../../../../test/src/test-clients.js" ;
34import { getNFT } from "./getNFT.js" ;
45
56describe . runIf ( process . env . TW_SECRET_KEY ) ( "erc721.getNFT" , ( ) => {
7+ it ( "without owner using indexer" , async ( ) => {
8+ const clientId = TEST_CLIENT . clientId ;
9+ const nft = await getNFT ( {
10+ contract : { ...DOODLES_CONTRACT } ,
11+ tokenId : 1n ,
12+ includeOwner : false ,
13+ } ) ;
14+ expect ( nft ) . toMatchInlineSnapshot ( `
15+ {
16+ "chainId": 1,
17+ "id": 1n,
18+ "metadata": {
19+ "attributes": [
20+ {
21+ "trait_type": "face",
22+ "value": "holographic beard",
23+ },
24+ {
25+ "trait_type": "hair",
26+ "value": "white bucket cap",
27+ },
28+ {
29+ "trait_type": "body",
30+ "value": "purple sweater with satchel",
31+ },
32+ {
33+ "trait_type": "background",
34+ "value": "grey",
35+ },
36+ {
37+ "trait_type": "head",
38+ "value": "gradient 2",
39+ },
40+ ],
41+ "description": "A community-driven collectibles project featuring art by Burnt Toast. Doodles come in a joyful range of colors, traits and sizes with a collection size of 10,000. Each Doodle allows its owner to vote for experiences and activations paid for by the Doodles Community Treasury. Burnt Toast is the working alias for Scott Martin, a Canadian–based illustrator, designer, animator and muralist.",
42+ "image": "https://${ clientId } .ipfscdn.io/ipfs/QmTDxnzcvj2p3xBrKcGv1wxoyhAn2yzCQnZZ9LmFjReuH9",
43+ "image_url": "https://${ clientId } .ipfscdn.io/ipfs/QmTDxnzcvj2p3xBrKcGv1wxoyhAn2yzCQnZZ9LmFjReuH9",
44+ "name": "Doodle #1",
45+ "uri": "https://${ clientId } .ipfscdn.io/ipfs/QmPMc4tcBsMqLRuCQtPmPe84bpSjrC3Ky7t3JWuHXYB4aS/1",
46+ },
47+ "owner": null,
48+ "tokenAddress": "0x8a90cab2b38dba80c64b7734e58ee1db38b8992e",
49+ "tokenURI": "https://${ clientId } .ipfscdn.io/ipfs/QmPMc4tcBsMqLRuCQtPmPe84bpSjrC3Ky7t3JWuHXYB4aS/1",
50+ "type": "ERC721",
51+ }
52+ ` ) ;
53+ } ) ;
54+
55+ it ( "with owner using indexer" , async ( ) => {
56+ const nft = await getNFT ( {
57+ contract : { ...DOODLES_CONTRACT } ,
58+ tokenId : 1n ,
59+ includeOwner : true ,
60+ } ) ;
61+ expect ( nft ) . toMatchInlineSnapshot ( `
62+ {
63+ "chainId": 1,
64+ "id": 1n,
65+ "metadata": {
66+ "attributes": [
67+ {
68+ "trait_type": "face",
69+ "value": "holographic beard",
70+ },
71+ {
72+ "trait_type": "hair",
73+ "value": "white bucket cap",
74+ },
75+ {
76+ "trait_type": "body",
77+ "value": "purple sweater with satchel",
78+ },
79+ {
80+ "trait_type": "background",
81+ "value": "grey",
82+ },
83+ {
84+ "trait_type": "head",
85+ "value": "gradient 2",
86+ },
87+ ],
88+ "description": "A community-driven collectibles project featuring art by Burnt Toast. Doodles come in a joyful range of colors, traits and sizes with a collection size of 10,000. Each Doodle allows its owner to vote for experiences and activations paid for by the Doodles Community Treasury. Burnt Toast is the working alias for Scott Martin, a Canadian–based illustrator, designer, animator and muralist.",
89+ "image": "https://${ clientId } .ipfscdn.io/ipfs/QmTDxnzcvj2p3xBrKcGv1wxoyhAn2yzCQnZZ9LmFjReuH9",
90+ "image_url": "https://${ clientId } .ipfscdn.io/ipfs/QmTDxnzcvj2p3xBrKcGv1wxoyhAn2yzCQnZZ9LmFjReuH9",
91+ "name": "Doodle #1",
92+ "owner_addresses": [
93+ "0xbe9936fcfc50666f5425fde4a9decc59cef73b24",
94+ ],
95+ "uri": "https://${ clientId } .ipfscdn.io/ipfs/QmPMc4tcBsMqLRuCQtPmPe84bpSjrC3Ky7t3JWuHXYB4aS/1",
96+ },
97+ "owner": "0xbe9936fcfc50666f5425fde4a9decc59cef73b24",
98+ "tokenAddress": "0x8a90cab2b38dba80c64b7734e58ee1db38b8992e",
99+ "tokenURI": "https://${ clientId } .ipfscdn.io/ipfs/QmPMc4tcBsMqLRuCQtPmPe84bpSjrC3Ky7t3JWuHXYB4aS/1",
100+ "type": "ERC721",
101+ }
102+ ` ) ;
103+ } ) ;
104+
6105 it ( "without owner" , async ( ) => {
7106 const nft = await getNFT ( {
8107 contract : { ...DOODLES_CONTRACT } ,
9108 tokenId : 1n ,
10109 includeOwner : false ,
110+ useIndexer : false ,
11111 } ) ;
12112 expect ( nft ) . toMatchInlineSnapshot ( `
13113 {
114+ "chainId": 1,
14115 "id": 1n,
15116 "metadata": {
16117 "attributes": [
@@ -40,6 +141,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("erc721.getNFT", () => {
40141 "name": "Doodle #1",
41142 },
42143 "owner": null,
144+ "tokenAddress": "0x8a90cab2b38dba80c64b7734e58ee1db38b8992e",
43145 "tokenURI": "ipfs://QmPMc4tcBsMqLRuCQtPmPe84bpSjrC3Ky7t3JWuHXYB4aS/1",
44146 "type": "ERC721",
45147 }
@@ -51,9 +153,11 @@ describe.runIf(process.env.TW_SECRET_KEY)("erc721.getNFT", () => {
51153 contract : { ...DOODLES_CONTRACT } ,
52154 tokenId : 1n ,
53155 includeOwner : true ,
156+ useIndexer : false ,
54157 } ) ;
55158 expect ( nft ) . toMatchInlineSnapshot ( `
56159 {
160+ "chainId": 1,
57161 "id": 1n,
58162 "metadata": {
59163 "attributes": [
@@ -83,6 +187,7 @@ describe.runIf(process.env.TW_SECRET_KEY)("erc721.getNFT", () => {
83187 "name": "Doodle #1",
84188 },
85189 "owner": "0xbE9936FCFC50666f5425FDE4A9decC59cEF73b24",
190+ "tokenAddress": "0x8a90cab2b38dba80c64b7734e58ee1db38b8992e",
86191 "tokenURI": "ipfs://QmPMc4tcBsMqLRuCQtPmPe84bpSjrC3Ky7t3JWuHXYB4aS/1",
87192 "type": "ERC721",
88193 }
0 commit comments