@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.
@@ -1218,7 +1218,7 @@ class MarketplaceListing {
1218
1218
  tokenData = JSON.parse(decodeURIComponent(tokenURI.slice(22)));
1219
1219
  }
1220
1220
  }
1221
- else if (tokenURI.startsWith("data:application/json;,")) {
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
- // Note from Campion - not really sure what is going on here, but for tokens that point to OS, there
1283
- // is a weird character in them. Maybe to prevent bots? Specifically, this is for a token I wrapped
1284
- // to sell on my own contract. The "new" token points to the "old" token's URI, which was on OS.
1285
- if (tokenURI.includes('')) {
1286
- tokenURI = tokenURI.replace('', '');
1287
- }
1288
- try {
1289
- response = yield MarketplaceListing._fetchWithTimeout(tokenURI, {}, isArweave ? 2000 : 60000);
1290
- }
1291
- catch (error) {
1292
- console.log(`Error fetching metadata: from ${tokenURI}`, error);
1293
- // Do nothing
1294
- }
1295
- if (response && response.status === 200) {
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.9",
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.4",
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("data:application/json;,")) {
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
- // Note from Campion - not really sure what is going on here, but for tokens that point to OS, there
1597
- // is a weird character in them. Maybe to prevent bots? Specifically, this is for a token I wrapped
1598
- // to sell on my own contract. The "new" token points to the "old" token's URI, which was on OS.
1599
- if (tokenURI.includes('')) {
1600
- tokenURI = tokenURI.replace('', '');
1601
- }
1602
- try {
1603
- response = await MarketplaceListing._fetchWithTimeout(tokenURI, {}, isArweave ? 2000 : 60000);
1604
- } catch (error) {
1605
- console.log(`Error fetching metadata: from ${tokenURI}`, error);
1606
- // Do nothing
1607
- }
1608
- if (response && response.status === 200) {
1609
- return response.json();
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();