thirdweb 5.95.0-nightly-e7b01108037ebef07fba95f888be1905c8fab5df-20250417000348 → 5.95.0-nightly-4cf15a2475fce1c5b55d19f7cf51ab080e80e33f-20250418000341
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/extensions/erc1155/read/getNFT.js +38 -0
- package/dist/cjs/extensions/erc1155/read/getNFT.js.map +1 -1
- package/dist/cjs/extensions/erc1155/read/getNFTs.js +26 -0
- package/dist/cjs/extensions/erc1155/read/getNFTs.js.map +1 -1
- package/dist/cjs/extensions/erc1155/read/getOwnedNFTs.js +46 -0
- package/dist/cjs/extensions/erc1155/read/getOwnedNFTs.js.map +1 -1
- package/dist/cjs/insight/get-nfts.js +67 -12
- package/dist/cjs/insight/get-nfts.js.map +1 -1
- package/dist/cjs/rpc/fetch-rpc.js +2 -22
- package/dist/cjs/rpc/fetch-rpc.js.map +1 -1
- package/dist/cjs/rpc/rpc.js +1 -1
- package/dist/cjs/rpc/rpc.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/wallets/in-app/core/users/getUser.js +2 -1
- package/dist/cjs/wallets/in-app/core/users/getUser.js.map +1 -1
- package/dist/esm/extensions/erc1155/read/getNFT.js +38 -0
- package/dist/esm/extensions/erc1155/read/getNFT.js.map +1 -1
- package/dist/esm/extensions/erc1155/read/getNFTs.js +26 -0
- package/dist/esm/extensions/erc1155/read/getNFTs.js.map +1 -1
- package/dist/esm/extensions/erc1155/read/getOwnedNFTs.js +46 -0
- package/dist/esm/extensions/erc1155/read/getOwnedNFTs.js.map +1 -1
- package/dist/esm/insight/get-nfts.js +67 -12
- package/dist/esm/insight/get-nfts.js.map +1 -1
- package/dist/esm/rpc/fetch-rpc.js +2 -22
- package/dist/esm/rpc/fetch-rpc.js.map +1 -1
- package/dist/esm/rpc/rpc.js +1 -1
- package/dist/esm/rpc/rpc.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/wallets/in-app/core/users/getUser.js +2 -1
- package/dist/esm/wallets/in-app/core/users/getUser.js.map +1 -1
- package/dist/types/extensions/erc1155/read/getNFT.d.ts +5 -0
- package/dist/types/extensions/erc1155/read/getNFT.d.ts.map +1 -1
- package/dist/types/extensions/erc1155/read/getNFTs.d.ts +5 -0
- package/dist/types/extensions/erc1155/read/getNFTs.d.ts.map +1 -1
- package/dist/types/extensions/erc1155/read/getOwnedNFTs.d.ts +7 -1
- package/dist/types/extensions/erc1155/read/getOwnedNFTs.d.ts.map +1 -1
- package/dist/types/insight/get-nfts.d.ts.map +1 -1
- package/dist/types/rpc/fetch-rpc.d.ts.map +1 -1
- package/dist/types/rpc/rpc.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/dist/types/wallets/in-app/core/users/getUser.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/extensions/erc1155/read/getNFT.test.ts +11 -0
- package/src/extensions/erc1155/read/getNFT.ts +51 -1
- package/src/extensions/erc1155/read/getNFTs.ts +38 -0
- package/src/extensions/erc1155/read/getOwnedNFTs.ts +65 -2
- package/src/extensions/erc721/read/getNFT.test.ts +81 -83
- package/src/extensions/erc721/read/getNFTs.test.ts +189 -189
- package/src/insight/get-nfts.ts +112 -48
- package/src/rpc/fetch-rpc.ts +2 -20
- package/src/rpc/rpc.ts +5 -1
- package/src/version.ts +1 -1
- package/src/wallets/in-app/core/users/getUser.test.ts +4 -1
- package/src/wallets/in-app/core/users/getUser.ts +4 -1
@@ -14,195 +14,195 @@ describe.runIf(process.env.TW_SECRET_KEY)("erc721.getNFTs", () => {
|
|
14
14
|
|
15
15
|
expect(nfts.length).toBe(5);
|
16
16
|
// TODO (insight): re-enable once insight fixes the client id caching issue
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
17
|
+
expect(nfts).toMatchInlineSnapshot(`
|
18
|
+
[
|
19
|
+
{
|
20
|
+
"chainId": 1,
|
21
|
+
"id": 0n,
|
22
|
+
"metadata": {
|
23
|
+
"attributes": [
|
24
|
+
{
|
25
|
+
"trait_type": "face",
|
26
|
+
"value": "mustache",
|
27
|
+
},
|
28
|
+
{
|
29
|
+
"trait_type": "hair",
|
30
|
+
"value": "purple long",
|
31
|
+
},
|
32
|
+
{
|
33
|
+
"trait_type": "body",
|
34
|
+
"value": "blue and yellow jacket",
|
35
|
+
},
|
36
|
+
{
|
37
|
+
"trait_type": "background",
|
38
|
+
"value": "green",
|
39
|
+
},
|
40
|
+
{
|
41
|
+
"trait_type": "head",
|
42
|
+
"value": "tan",
|
43
|
+
},
|
44
|
+
],
|
45
|
+
"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.",
|
46
|
+
"image": "ipfs://QmUEfFfwAh4wyB5UfHCVPUxis4j4Q4kJXtm5x5p3g1fVUn",
|
47
|
+
"image_url": "ipfs://QmUEfFfwAh4wyB5UfHCVPUxis4j4Q4kJXtm5x5p3g1fVUn",
|
48
|
+
"name": "Doodle #0",
|
49
|
+
"uri": "ipfs://QmPMc4tcBsMqLRuCQtPmPe84bpSjrC3Ky7t3JWuHXYB4aS/0",
|
50
|
+
},
|
51
|
+
"owner": null,
|
52
|
+
"tokenAddress": "0x8a90cab2b38dba80c64b7734e58ee1db38b8992e",
|
53
|
+
"tokenURI": "ipfs://QmPMc4tcBsMqLRuCQtPmPe84bpSjrC3Ky7t3JWuHXYB4aS/0",
|
54
|
+
"type": "ERC721",
|
55
|
+
},
|
56
|
+
{
|
57
|
+
"chainId": 1,
|
58
|
+
"id": 1n,
|
59
|
+
"metadata": {
|
60
|
+
"attributes": [
|
61
|
+
{
|
62
|
+
"trait_type": "face",
|
63
|
+
"value": "holographic beard",
|
64
|
+
},
|
65
|
+
{
|
66
|
+
"trait_type": "hair",
|
67
|
+
"value": "white bucket cap",
|
68
|
+
},
|
69
|
+
{
|
70
|
+
"trait_type": "body",
|
71
|
+
"value": "purple sweater with satchel",
|
72
|
+
},
|
73
|
+
{
|
74
|
+
"trait_type": "background",
|
75
|
+
"value": "grey",
|
76
|
+
},
|
77
|
+
{
|
78
|
+
"trait_type": "head",
|
79
|
+
"value": "gradient 2",
|
80
|
+
},
|
81
|
+
],
|
82
|
+
"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.",
|
83
|
+
"image": "ipfs://QmTDxnzcvj2p3xBrKcGv1wxoyhAn2yzCQnZZ9LmFjReuH9",
|
84
|
+
"image_url": "ipfs://QmTDxnzcvj2p3xBrKcGv1wxoyhAn2yzCQnZZ9LmFjReuH9",
|
85
|
+
"name": "Doodle #1",
|
86
|
+
"uri": "ipfs://QmPMc4tcBsMqLRuCQtPmPe84bpSjrC3Ky7t3JWuHXYB4aS/1",
|
87
|
+
},
|
88
|
+
"owner": null,
|
89
|
+
"tokenAddress": "0x8a90cab2b38dba80c64b7734e58ee1db38b8992e",
|
90
|
+
"tokenURI": "ipfs://QmPMc4tcBsMqLRuCQtPmPe84bpSjrC3Ky7t3JWuHXYB4aS/1",
|
91
|
+
"type": "ERC721",
|
92
|
+
},
|
93
|
+
{
|
94
|
+
"chainId": 1,
|
95
|
+
"id": 2n,
|
96
|
+
"metadata": {
|
97
|
+
"attributes": [
|
98
|
+
{
|
99
|
+
"trait_type": "face",
|
100
|
+
"value": "designer glasses",
|
101
|
+
},
|
102
|
+
{
|
103
|
+
"trait_type": "hair",
|
104
|
+
"value": "poopie",
|
105
|
+
},
|
106
|
+
{
|
107
|
+
"trait_type": "body",
|
108
|
+
"value": "blue fleece",
|
109
|
+
},
|
110
|
+
{
|
111
|
+
"trait_type": "background",
|
112
|
+
"value": "yellow",
|
113
|
+
},
|
114
|
+
{
|
115
|
+
"trait_type": "head",
|
116
|
+
"value": "purple",
|
117
|
+
},
|
118
|
+
],
|
119
|
+
"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.",
|
120
|
+
"image": "ipfs://QmbvZ2hbF3nEq5r3ijMEiSGssAmJvtyFwiejTAGHv74LR5",
|
121
|
+
"image_url": "ipfs://QmbvZ2hbF3nEq5r3ijMEiSGssAmJvtyFwiejTAGHv74LR5",
|
122
|
+
"name": "Doodle #2",
|
123
|
+
"uri": "ipfs://QmPMc4tcBsMqLRuCQtPmPe84bpSjrC3Ky7t3JWuHXYB4aS/2",
|
124
|
+
},
|
125
|
+
"owner": null,
|
126
|
+
"tokenAddress": "0x8a90cab2b38dba80c64b7734e58ee1db38b8992e",
|
127
|
+
"tokenURI": "ipfs://QmPMc4tcBsMqLRuCQtPmPe84bpSjrC3Ky7t3JWuHXYB4aS/2",
|
128
|
+
"type": "ERC721",
|
129
|
+
},
|
130
|
+
{
|
131
|
+
"chainId": 1,
|
132
|
+
"id": 3n,
|
133
|
+
"metadata": {
|
134
|
+
"attributes": [
|
135
|
+
{
|
136
|
+
"trait_type": "face",
|
137
|
+
"value": "designer glasses",
|
138
|
+
},
|
139
|
+
{
|
140
|
+
"trait_type": "hair",
|
141
|
+
"value": "holographic mohawk",
|
142
|
+
},
|
143
|
+
{
|
144
|
+
"trait_type": "body",
|
145
|
+
"value": "pink fleece",
|
146
|
+
},
|
147
|
+
{
|
148
|
+
"trait_type": "background",
|
149
|
+
"value": "gradient 1",
|
150
|
+
},
|
151
|
+
{
|
152
|
+
"trait_type": "head",
|
153
|
+
"value": "pale",
|
154
|
+
},
|
155
|
+
],
|
156
|
+
"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.",
|
157
|
+
"image": "ipfs://QmVpwaCqLut3wqwB5KSQr2fGnbLuJt5e3LhNvzvcisewZB",
|
158
|
+
"image_url": "ipfs://QmVpwaCqLut3wqwB5KSQr2fGnbLuJt5e3LhNvzvcisewZB",
|
159
|
+
"name": "Doodle #3",
|
160
|
+
"uri": "ipfs://QmPMc4tcBsMqLRuCQtPmPe84bpSjrC3Ky7t3JWuHXYB4aS/3",
|
161
|
+
},
|
162
|
+
"owner": null,
|
163
|
+
"tokenAddress": "0x8a90cab2b38dba80c64b7734e58ee1db38b8992e",
|
164
|
+
"tokenURI": "ipfs://QmPMc4tcBsMqLRuCQtPmPe84bpSjrC3Ky7t3JWuHXYB4aS/3",
|
165
|
+
"type": "ERC721",
|
166
|
+
},
|
167
|
+
{
|
168
|
+
"chainId": 1,
|
169
|
+
"id": 4n,
|
170
|
+
"metadata": {
|
171
|
+
"attributes": [
|
172
|
+
{
|
173
|
+
"trait_type": "face",
|
174
|
+
"value": "happy",
|
175
|
+
},
|
176
|
+
{
|
177
|
+
"trait_type": "hair",
|
178
|
+
"value": "purple long",
|
179
|
+
},
|
180
|
+
{
|
181
|
+
"trait_type": "body",
|
182
|
+
"value": "spotted hoodie",
|
183
|
+
},
|
184
|
+
{
|
185
|
+
"trait_type": "background",
|
186
|
+
"value": "gradient 2",
|
187
|
+
},
|
188
|
+
{
|
189
|
+
"trait_type": "head",
|
190
|
+
"value": "purple",
|
191
|
+
},
|
192
|
+
],
|
193
|
+
"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.",
|
194
|
+
"image": "ipfs://QmcyuFVLbfBmSeQ9ynu4dk67r97nB1abEekotuVuRGWedm",
|
195
|
+
"image_url": "ipfs://QmcyuFVLbfBmSeQ9ynu4dk67r97nB1abEekotuVuRGWedm",
|
196
|
+
"name": "Doodle #4",
|
197
|
+
"uri": "ipfs://QmPMc4tcBsMqLRuCQtPmPe84bpSjrC3Ky7t3JWuHXYB4aS/4",
|
198
|
+
},
|
199
|
+
"owner": null,
|
200
|
+
"tokenAddress": "0x8a90cab2b38dba80c64b7734e58ee1db38b8992e",
|
201
|
+
"tokenURI": "ipfs://QmPMc4tcBsMqLRuCQtPmPe84bpSjrC3Ky7t3JWuHXYB4aS/4",
|
202
|
+
"type": "ERC721",
|
203
|
+
},
|
204
|
+
]
|
205
|
+
`);
|
206
206
|
});
|
207
207
|
|
208
208
|
it("should throw error if totalSupply and nextTokenIdToMint are not supported", async () => {
|
package/src/insight/get-nfts.ts
CHANGED
@@ -9,6 +9,8 @@ import type { Chain } from "../chains/types.js";
|
|
9
9
|
import type { ThirdwebClient } from "../client/client.js";
|
10
10
|
import type { NFT } from "../utils/nft/parseNft.js";
|
11
11
|
|
12
|
+
import { getCachedChain } from "../chains/utils.js";
|
13
|
+
import { getContract } from "../contract/contract.js";
|
12
14
|
type OwnedNFT = GetV1NftsResponse["data"][number];
|
13
15
|
type ContractNFT = GetV1NftsByContractAddressResponse["data"][number];
|
14
16
|
|
@@ -76,6 +78,7 @@ export async function getOwnedNFTs(args: {
|
|
76
78
|
|
77
79
|
const transformedNfts = await transformNFTModel(
|
78
80
|
result.data?.data ?? [],
|
81
|
+
client,
|
79
82
|
ownerAddress,
|
80
83
|
);
|
81
84
|
return transformedNfts.map((nft) => ({
|
@@ -156,7 +159,7 @@ export async function getContractNFTs(args: {
|
|
156
159
|
);
|
157
160
|
}
|
158
161
|
|
159
|
-
return transformNFTModel(result.data?.data ?? []);
|
162
|
+
return transformNFTModel(result.data?.data ?? [], client);
|
160
163
|
}
|
161
164
|
|
162
165
|
/**
|
@@ -233,64 +236,125 @@ export async function getNFT(args: {
|
|
233
236
|
);
|
234
237
|
}
|
235
238
|
|
236
|
-
const transformedNfts = await transformNFTModel(
|
239
|
+
const transformedNfts = await transformNFTModel(
|
240
|
+
result.data?.data ?? [],
|
241
|
+
client,
|
242
|
+
);
|
237
243
|
return transformedNfts?.[0];
|
238
244
|
}
|
239
245
|
|
240
246
|
async function transformNFTModel(
|
241
247
|
nfts: (ContractNFT | OwnedNFT)[],
|
248
|
+
client: ThirdwebClient,
|
242
249
|
ownerAddress?: string,
|
243
250
|
): Promise<(NFT & { quantityOwned?: bigint })[]> {
|
244
|
-
const { parseNFT } = await
|
251
|
+
const [{ parseNFT }, { totalSupply }] = await Promise.all([
|
252
|
+
import("../utils/nft/parseNft.js"),
|
253
|
+
import("../extensions/erc1155/__generated__/IERC1155/read/totalSupply.js"),
|
254
|
+
]);
|
245
255
|
|
246
|
-
return
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
256
|
+
return await Promise.all(
|
257
|
+
nfts.map(async (nft) => {
|
258
|
+
let parsedNft: NFT;
|
259
|
+
const {
|
260
|
+
contract,
|
261
|
+
extra_metadata,
|
262
|
+
collection,
|
263
|
+
metadata_url,
|
264
|
+
chain_id,
|
265
|
+
token_id,
|
266
|
+
status,
|
267
|
+
balance,
|
268
|
+
token_type,
|
269
|
+
...rest
|
270
|
+
} = nft;
|
271
|
+
const metadata = replaceIPFSGatewayRecursively({
|
272
|
+
uri: nft.metadata_url ?? "",
|
273
|
+
image: nft.image_url,
|
274
|
+
attributes: nft.extra_metadata?.attributes ?? undefined,
|
275
|
+
...rest,
|
276
|
+
});
|
266
277
|
|
267
|
-
|
268
|
-
? [ownerAddress]
|
269
|
-
: "owner_addresses" in nft
|
270
|
-
? nft.owner_addresses
|
271
|
-
: undefined;
|
278
|
+
// replace the ipfs gateway with the ipfs gateway from the client recusively for each key in the metadata object
|
272
279
|
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
supply
|
282
|
-
|
280
|
+
const owner_addresses = ownerAddress
|
281
|
+
? [ownerAddress]
|
282
|
+
: "owner_addresses" in nft
|
283
|
+
? nft.owner_addresses
|
284
|
+
: undefined;
|
285
|
+
|
286
|
+
if (contract?.type === "erc1155") {
|
287
|
+
// TODO (insight): this needs to be added in the API
|
288
|
+
const supply = await totalSupply({
|
289
|
+
contract: getContract({
|
290
|
+
address: contract.address,
|
291
|
+
chain: getCachedChain(contract.chain_id),
|
292
|
+
client: client,
|
293
|
+
}),
|
294
|
+
id: BigInt(token_id),
|
295
|
+
});
|
296
|
+
|
297
|
+
parsedNft = parseNFT(metadata, {
|
298
|
+
tokenId: BigInt(token_id),
|
299
|
+
tokenUri: replaceIPFSGateway(metadata_url) ?? "",
|
300
|
+
type: "ERC1155",
|
301
|
+
owner: owner_addresses?.[0],
|
302
|
+
tokenAddress: contract?.address ?? "",
|
303
|
+
chainId: contract?.chain_id ?? 0,
|
304
|
+
supply: supply,
|
305
|
+
});
|
306
|
+
} else {
|
307
|
+
parsedNft = parseNFT(metadata, {
|
308
|
+
tokenId: BigInt(token_id),
|
309
|
+
type: "ERC721",
|
310
|
+
owner: owner_addresses?.[0],
|
311
|
+
tokenUri: replaceIPFSGateway(metadata_url) ?? "",
|
312
|
+
tokenAddress: contract?.address ?? "",
|
313
|
+
chainId: contract?.chain_id ?? 0,
|
314
|
+
});
|
315
|
+
}
|
316
|
+
|
317
|
+
return parsedNft;
|
318
|
+
}),
|
319
|
+
);
|
320
|
+
}
|
321
|
+
|
322
|
+
// biome-ignore lint/suspicious/noExplicitAny: this should be fixed in the API
|
323
|
+
function replaceIPFSGatewayRecursively(obj: any) {
|
324
|
+
if (typeof obj !== "object" || obj === null) {
|
325
|
+
return obj;
|
326
|
+
}
|
327
|
+
for (const key in obj) {
|
328
|
+
if (typeof obj[key] === "string") {
|
329
|
+
obj[key] = replaceIPFSGateway(obj[key]);
|
283
330
|
} else {
|
284
|
-
|
285
|
-
tokenId: BigInt(token_id),
|
286
|
-
type: "ERC721",
|
287
|
-
owner: owner_addresses?.[0],
|
288
|
-
tokenUri: metadata_url ?? "",
|
289
|
-
tokenAddress: contract?.address ?? "",
|
290
|
-
chainId: contract?.chain_id ?? 0,
|
291
|
-
});
|
331
|
+
replaceIPFSGatewayRecursively(obj[key]);
|
292
332
|
}
|
333
|
+
}
|
334
|
+
return obj;
|
335
|
+
}
|
293
336
|
|
294
|
-
|
295
|
-
|
337
|
+
function replaceIPFSGateway(url?: string) {
|
338
|
+
if (!url || typeof url !== "string") {
|
339
|
+
return url;
|
340
|
+
}
|
341
|
+
try {
|
342
|
+
const parsedUrl = new URL(url);
|
343
|
+
if (parsedUrl.host.endsWith(".ipfscdn.io")) {
|
344
|
+
const paths = parsedUrl.pathname.split("/");
|
345
|
+
const index = paths.findIndex((path) => path === "ipfs");
|
346
|
+
if (index === -1) {
|
347
|
+
return url;
|
348
|
+
}
|
349
|
+
const ipfsHash = paths.slice(index + 1).join("/");
|
350
|
+
if (ipfsHash) {
|
351
|
+
return `ipfs://${ipfsHash}`;
|
352
|
+
}
|
353
|
+
return url;
|
354
|
+
}
|
355
|
+
} catch {
|
356
|
+
// If the URL is invalid, return it as is
|
357
|
+
return url;
|
358
|
+
}
|
359
|
+
return url;
|
296
360
|
}
|
package/src/rpc/fetch-rpc.ts
CHANGED
@@ -78,16 +78,7 @@ export async function fetchRpc(
|
|
78
78
|
);
|
79
79
|
}
|
80
80
|
|
81
|
-
|
82
|
-
return await response.json();
|
83
|
-
}
|
84
|
-
const text = await response.text();
|
85
|
-
try {
|
86
|
-
return JSON.parse(text);
|
87
|
-
} catch (err) {
|
88
|
-
console.error("Error parsing response", err, text);
|
89
|
-
throw err;
|
90
|
-
}
|
81
|
+
return await response.json();
|
91
82
|
}
|
92
83
|
|
93
84
|
type FetchSingleRpcOptions = {
|
@@ -121,14 +112,5 @@ export async function fetchSingleRpc(
|
|
121
112
|
`RPC request failed with status ${response.status} - ${response.statusText}: ${error || "unknown error"}`,
|
122
113
|
);
|
123
114
|
}
|
124
|
-
|
125
|
-
return await response.json();
|
126
|
-
}
|
127
|
-
const text = await response.text();
|
128
|
-
try {
|
129
|
-
return JSON.parse(text);
|
130
|
-
} catch (err) {
|
131
|
-
console.error("Error parsing response", err, text);
|
132
|
-
throw err;
|
133
|
-
}
|
115
|
+
return await response.json();
|
134
116
|
}
|
package/src/rpc/rpc.ts
CHANGED
@@ -144,7 +144,11 @@ export function getRpcClient(
|
|
144
144
|
|
145
145
|
// No response.
|
146
146
|
if (!response) {
|
147
|
-
inflight.reject(
|
147
|
+
inflight.reject(
|
148
|
+
new Error(
|
149
|
+
`No response for index ${index} - all responses: ${stringify(responses)}`,
|
150
|
+
),
|
151
|
+
);
|
148
152
|
}
|
149
153
|
// Response is an error or error string.
|
150
154
|
else if (response instanceof Error) {
|
package/src/version.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const version = "5.95.0-nightly-
|
1
|
+
export const version = "5.95.0-nightly-4cf15a2475fce1c5b55d19f7cf51ab080e80e33f-20250418000341";
|