@manifoldxyz/marketplace-sdk 3.0.10 → 3.0.12

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.
@@ -56,6 +56,7 @@ var APIEndpoints;
56
56
  APIEndpoints["MAINNET"] = "https://marketplace.api.manifoldxyz.dev";
57
57
  APIEndpoints["OPTIMISM"] = "https://optimism.marketplace.api.manifoldxyz.dev";
58
58
  APIEndpoints["BASE"] = "https://base.marketplace.api.manifoldxyz.dev";
59
+ APIEndpoints["SEPOLIA"] = "https://sepolia.marketplace.api.manifoldxyz.dev";
59
60
  APIEndpoints["CAMPAIGN"] = "https://redeem.api.manifoldxyz.dev";
60
61
  })(APIEndpoints || (APIEndpoints = {}));
61
62
  const NULL_ADDRESS = '0x0000000000000000000000000000000000000000';
@@ -1279,24 +1280,23 @@ class MarketplaceListing {
1279
1280
  let response;
1280
1281
  const isArweave = tokenURI.match(/^https:\/\/arweave.net/);
1281
1282
  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();
1283
+ const isOpenSea = tokenURI.match(/^https:\/\/api.opensea.io/);
1284
+ // Attempt a direct fetch of metadata from source server if not OpenSea
1285
+ // OpenSea API now requires an API key, so we need to defer to our server.
1286
+ if (!isOpenSea) {
1287
+ try {
1288
+ response = yield MarketplaceListing._fetchWithTimeout(tokenURI, {}, isArweave || isIPFS ? 2000 : 60000);
1289
+ }
1290
+ catch (error) {
1291
+ console.log(`Error fetching metadata: from ${tokenURI}`, error);
1292
+ // Do nothing
1293
+ }
1294
+ if (response && response.status === 200) {
1295
+ return response.json();
1296
+ }
1297
1297
  }
1298
- // No response, so fallback to server only if Arweave endpoints
1299
- if (isArweave || isIPFS) {
1298
+ // No response, so fallback to server only if Arweave, IPFS or OpenSea endpoints
1299
+ if (isArweave || isIPFS || isOpenSea) {
1300
1300
  response = yield fetch(`${this._getEndpoint()}/token/${tokenAddress}/${tokenId}/metadata`);
1301
1301
  if (response.status === 200) {
1302
1302
  return response.json();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@manifoldxyz/marketplace-sdk",
3
- "version": "3.0.10",
3
+ "version": "3.0.12",
4
4
  "typings": "dist/index.d.ts",
5
5
  "description": "",
6
6
  "main": "dist/index.js",
@@ -50,6 +50,7 @@ enum APIEndpoints {
50
50
  MAINNET = 'https://marketplace.api.manifoldxyz.dev',
51
51
  OPTIMISM = 'https://optimism.marketplace.api.manifoldxyz.dev',
52
52
  BASE = 'https://base.marketplace.api.manifoldxyz.dev',
53
+ SEPOLIA = 'https://sepolia.marketplace.api.manifoldxyz.dev',
53
54
  CAMPAIGN = 'https://redeem.api.manifoldxyz.dev',
54
55
  }
55
56
 
@@ -1592,24 +1593,27 @@ class MarketplaceListing {
1592
1593
  let response;
1593
1594
  const isArweave = tokenURI.match(/^https:\/\/arweave.net/);
1594
1595
  const isIPFS = tokenURI.match(/^https:\/\/ipfs.io/);
1596
+ const isOpenSea = tokenURI.match(/^https:\/\/api.opensea.io/);
1595
1597
 
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();
1598
+ // Attempt a direct fetch of metadata from source server if not OpenSea
1599
+ // OpenSea API now requires an API key, so we need to defer to our server.
1600
+ if (!isOpenSea) {
1601
+ try {
1602
+ response = await MarketplaceListing._fetchWithTimeout(
1603
+ tokenURI,
1604
+ {},
1605
+ isArweave || isIPFS ? 2000 : 60000
1606
+ );
1607
+ } catch (error) {
1608
+ console.log(`Error fetching metadata: from ${tokenURI}`, error);
1609
+ // Do nothing
1610
+ }
1611
+ if (response && response.status === 200) {
1612
+ return response.json();
1613
+ }
1610
1614
  }
1611
- // No response, so fallback to server only if Arweave endpoints
1612
- if (isArweave || isIPFS) {
1615
+ // No response, so fallback to server only if Arweave, IPFS or OpenSea endpoints
1616
+ if (isArweave || isIPFS || isOpenSea) {
1613
1617
  response = await fetch(`${this._getEndpoint()}/token/${tokenAddress}/${tokenId}/metadata`);
1614
1618
  if (response.status === 200) {
1615
1619
  return response.json();