@manifoldxyz/marketplace-sdk 3.0.9 → 3.0.11
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/lib/MarketplaceListing.js +17 -18
- package/package.json +2 -2
- package/src/lib/MarketplaceListing.ts +20 -17
|
@@ -1218,7 +1218,7 @@ class MarketplaceListing {
|
|
|
1218
1218
|
tokenData = JSON.parse(decodeURIComponent(tokenURI.slice(22)));
|
|
1219
1219
|
}
|
|
1220
1220
|
}
|
|
1221
|
-
else if (tokenURI.startsWith(
|
|
1221
|
+
else if (tokenURI.startsWith('data:application/json;,')) {
|
|
1222
1222
|
try {
|
|
1223
1223
|
tokenData = JSON.parse(tokenURI.slice(23));
|
|
1224
1224
|
}
|
|
@@ -1279,24 +1279,23 @@ class MarketplaceListing {
|
|
|
1279
1279
|
let response;
|
|
1280
1280
|
const isArweave = tokenURI.match(/^https:\/\/arweave.net/);
|
|
1281
1281
|
const isIPFS = tokenURI.match(/^https:\/\/ipfs.io/);
|
|
1282
|
-
|
|
1283
|
-
//
|
|
1284
|
-
//
|
|
1285
|
-
if (
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
return response.json();
|
|
1282
|
+
const isOpenSea = tokenURI.match(/^https:\/\/api.opensea.io/);
|
|
1283
|
+
// Attempt a direct fetch of metadata from source server if not OpenSea
|
|
1284
|
+
// OpenSea API now requires an API key, so we need to defer to our server.
|
|
1285
|
+
if (!isOpenSea) {
|
|
1286
|
+
try {
|
|
1287
|
+
response = yield MarketplaceListing._fetchWithTimeout(tokenURI, {}, isArweave || isIPFS ? 2000 : 60000);
|
|
1288
|
+
}
|
|
1289
|
+
catch (error) {
|
|
1290
|
+
console.log(`Error fetching metadata: from ${tokenURI}`, error);
|
|
1291
|
+
// Do nothing
|
|
1292
|
+
}
|
|
1293
|
+
if (response && response.status === 200) {
|
|
1294
|
+
return response.json();
|
|
1295
|
+
}
|
|
1297
1296
|
}
|
|
1298
|
-
// No response, so fallback to server only if Arweave endpoints
|
|
1299
|
-
if (isArweave || isIPFS) {
|
|
1297
|
+
// No response, so fallback to server only if Arweave, IPFS or OpenSea endpoints
|
|
1298
|
+
if (isArweave || isIPFS || isOpenSea) {
|
|
1300
1299
|
response = yield fetch(`${this._getEndpoint()}/token/${tokenAddress}/${tokenId}/metadata`);
|
|
1301
1300
|
if (response.status === 200) {
|
|
1302
1301
|
return response.json();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@manifoldxyz/marketplace-sdk",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.11",
|
|
4
4
|
"typings": "dist/index.d.ts",
|
|
5
5
|
"description": "",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@manifoldxyz/contract-abis": "^1.0.0",
|
|
46
46
|
"@manifoldxyz/ens-batch-lookup-ethers": "^0.0.2",
|
|
47
47
|
"@manifoldxyz/frontend-provider-types": "^1.0.0",
|
|
48
|
-
"@manifoldxyz/manifold-provider-client": "^0.0.
|
|
48
|
+
"@manifoldxyz/manifold-provider-client": "^0.0.5",
|
|
49
49
|
"keccak256": "^1.0.6",
|
|
50
50
|
"merkletreejs": "^0.2.32"
|
|
51
51
|
}
|
|
@@ -1514,7 +1514,7 @@ class MarketplaceListing {
|
|
|
1514
1514
|
} catch (error) {
|
|
1515
1515
|
tokenData = JSON.parse(decodeURIComponent(tokenURI.slice(22)));
|
|
1516
1516
|
}
|
|
1517
|
-
} else if (tokenURI.startsWith(
|
|
1517
|
+
} else if (tokenURI.startsWith('data:application/json;,')) {
|
|
1518
1518
|
try {
|
|
1519
1519
|
tokenData = JSON.parse(tokenURI.slice(23));
|
|
1520
1520
|
} catch (error) {
|
|
@@ -1592,24 +1592,27 @@ class MarketplaceListing {
|
|
|
1592
1592
|
let response;
|
|
1593
1593
|
const isArweave = tokenURI.match(/^https:\/\/arweave.net/);
|
|
1594
1594
|
const isIPFS = tokenURI.match(/^https:\/\/ipfs.io/);
|
|
1595
|
+
const isOpenSea = tokenURI.match(/^https:\/\/api.opensea.io/);
|
|
1595
1596
|
|
|
1596
|
-
//
|
|
1597
|
-
//
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1597
|
+
// Attempt a direct fetch of metadata from source server if not OpenSea
|
|
1598
|
+
// OpenSea API now requires an API key, so we need to defer to our server.
|
|
1599
|
+
if (!isOpenSea) {
|
|
1600
|
+
try {
|
|
1601
|
+
response = await MarketplaceListing._fetchWithTimeout(
|
|
1602
|
+
tokenURI,
|
|
1603
|
+
{},
|
|
1604
|
+
isArweave || isIPFS ? 2000 : 60000
|
|
1605
|
+
);
|
|
1606
|
+
} catch (error) {
|
|
1607
|
+
console.log(`Error fetching metadata: from ${tokenURI}`, error);
|
|
1608
|
+
// Do nothing
|
|
1609
|
+
}
|
|
1610
|
+
if (response && response.status === 200) {
|
|
1611
|
+
return response.json();
|
|
1612
|
+
}
|
|
1610
1613
|
}
|
|
1611
|
-
// No response, so fallback to server only if Arweave endpoints
|
|
1612
|
-
if (isArweave || isIPFS) {
|
|
1614
|
+
// No response, so fallback to server only if Arweave, IPFS or OpenSea endpoints
|
|
1615
|
+
if (isArweave || isIPFS || isOpenSea) {
|
|
1613
1616
|
response = await fetch(`${this._getEndpoint()}/token/${tokenAddress}/${tokenId}/metadata`);
|
|
1614
1617
|
if (response.status === 200) {
|
|
1615
1618
|
return response.json();
|