From b553a6fcd86b49f5984beb97c0d22b1da8902adf Mon Sep 17 00:00:00 2001 From: eddie <66155195+just-toby@users.noreply.github.com> Date: Fri, 13 Oct 2023 09:17:57 -0700 Subject: [PATCH] feat: nfts sitemap (#7456) * feat: add nft collections to sitemap * feat: size check on sitemap * fix: update generate-sitemap script --- public/sitemap.xml | 550 ++++++++++++++++++++++++++++++++++++ scripts/generate-sitemap.js | 53 +++- 2 files changed, 598 insertions(+), 5 deletions(-) diff --git a/public/sitemap.xml b/public/sitemap.xml index b632b7693f..f07cb711f7 100644 --- a/public/sitemap.xml +++ b/public/sitemap.xml @@ -1422,4 +1422,554 @@ 2023-10-11T19:57:27.976Z 0.8 + + https://app.uniswap.org/tokens/ethereum/0x5de8ab7e27f6e7a1fff3e5b337584aa43961beef + 2023-10-11T23:21:06.433Z + 0.8 + + + https://app.uniswap.org/tokens/ethereum/0x940a2db1b7008b6c776d4faaca729d6d4a4aa551 + 2023-10-11T23:21:06.433Z + 0.8 + + + https://app.uniswap.org/tokens/ethereum/0x80f0c1c49891dcfdd40b6e0f960f84e6042bcb6f + 2023-10-11T23:21:06.433Z + 0.8 + + + https://app.uniswap.org/tokens/arbitrum/0x1622bf67e6e5747b81866fe0b85178a93c7f86e3 + 2023-10-11T23:21:06.433Z + 0.8 + + + https://app.uniswap.org/tokens/arbitrum/0x031d35296154279dc1984dcd93e392b1f946737b + 2023-10-11T23:21:06.433Z + 0.8 + + + https://app.uniswap.org/tokens/optimism/0xdfa46478f9e5ea86d57387849598dbfb2e964b02 + 2023-10-11T23:21:06.433Z + 0.8 + + + https://app.uniswap.org/tokens/polygon/0x104592a158490a9228070e0a8e5343b499e125d0 + 2023-10-11T23:21:06.433Z + 0.8 + + + https://app.uniswap.org/tokens/polygon/0x4e3decbb3645551b8a19f0ea1678079fcb33fb4c + 2023-10-11T23:21:06.433Z + 0.8 + + + https://app.uniswap.org/tokens/bnb/0xb0b195aefa3650a6908f15cdac7d92f8a5791b0b + 2023-10-11T23:21:06.433Z + 0.8 + + + https://app.uniswap.org/tokens/celo/0x02de4766c272abc10bc88c220d214a26960a7e92 + 2023-10-11T23:21:06.433Z + 0.8 + + + https://app.uniswap.org/nfts/collection/0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x60e4d786628fea6478f785a6d7e704777c86a7c6 + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0xed5af388653567af2f388e6224dc7c4b3241c544 + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x34d85c9cdeb23fa97cb08333b511ac86e1c4e258 + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x99a9b7c1116f9ceeb1652de04d5969cce509b069 + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x49cf6f5d44e70224e2e23fdcdd2c053f30ada28b + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0xb7f7f6c52f2e2fdb1963eab30438024864c313f6 + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x23581767a106ae21c074b2276d25e5c3e136a68b + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x8a90cab2b38dba80c64b7734e58ee1db38b8992e + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0xba30e5f9bb24caa003e9f2f0497ad287fdf95623 + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0xbd3531da5cf5857e7cfaa92426877b022e612cf8 + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x7bd29408f11d2bfc23c34f18275bbf23bb716bc7 + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x306b1ea3ecdf94ab739f1910bbda052ed4a9f949 + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x1a92f7381b9f03921564a437210bb9396471050c + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x5cc5b05a8a13e3fbdb0bb9fccd98d38e50f90c38 + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x5af0d9827e0c53e4799bb226655a1de152a425a5 + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x3bf2922f4520a8ba0c2efc3d2a1539678dad5e9d + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0xe785e82358879f061bc3dcac6f0444462d4b5330 + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x76be3b62873462d2142405439777e971754e8e77 + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0xfd43af6d3fe1b916c026f6ac35b3ede068d1ca01 + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x1cb1a5e65610aeff2551a50f76a87a7d3fb649c6 + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0xff9c1b15b16263c61d017ee9f65c50e4ae0113d7 + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x6339e5e072086621540d0362c4e3cea0d643e114 + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0xb932a70a57673d89f4acffbe830e8ed7f75fb9e0 + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x79fcdef22feed20eddacbb2587640e45491b757f + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0xa3aee8bce55beea1951ef834b99f3ac60d1abeeb + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x769272677fab02575e84945f03eca517acc544cc + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x4db1f25d3d98600140dfc18deb7515be5bd293af + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x34eebee6942d8def3c125458d1a86e0a897fd6f9 + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x59468516a8259058bad1ca5f8f4bff190d30e066 + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x394e3d3044fc89fcdd966d3cb35ac0b32b0cda91 + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x60bb1e2aa1c9acafb4d34f71585d7e959f387769 + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x28472a58a490c5e09a238847f66a68a47cc76f0f + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x341a1c534248966c4b6afad165b98daed4b964ef + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x82c7a8f707110f5fbb16184a5933e9f78a34c6ab + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0xccc441ac31f02cd96c153db6fd5fe0a2f4e6a68d + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x764aeebcf425d56800ef2c84f2578689415a2daa + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x160c404b2b49cbc3240055ceaee026df1e8497a0 + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0xd2f668a8461d6761115daf8aeb3cdf5f40c532c6 + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x39ee2c7b3cb80254225884ca001f57118c8f21b6 + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0xd774557b647330c91bf44cfeab205095f7e6c367 + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x1792a96e5668ad7c167ab804a100ce42395ce54d + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0xf87e31492faf9a91b02ee0deaad50d51d56d5d4d + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x04afa589e2b933f9463c5639f412b183ec062505 + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0xe75512aa3bec8f00434bbd6ad8b0a3fbff100ad6 + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x348fc118bcc65a92dc033a951af153d14d945312 + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x892848074ddea461a15f337250da3ce55580ca85 + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x5946aeaab44e65eb370ffaa6a7ef2218cff9b47d + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x282bdd42f4eb70e7a9d9f40c8fea0825b7f68c5d + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x4b15a9c28034dc83db40cd810001427d3bd7163d + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x7ea3cca10668b8346aec0bf1844a49e995527c8b + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0xb852c6b5892256c264cc2c888ea462189154d8d7 + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x9378368ba6b85c1fba5b131b530f5f5bedf21a18 + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x2acab3dea77832c09420663b0e1cb386031ba17b + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x0c2e57efddba8c768147d1fdf9176a0a6ebd5d83 + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x08d7c0242953446436f34b4c78fe9da38c73668d + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x8943c7bac1914c9a7aba750bf2b6b09fd21037e0 + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x364c828ee171616a39897688a831c2499ad972ec + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x7f36182dee28c45de6072a34d29855bae76dbe2f + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0xf61f24c2d93bf2de187546b14425bf631f28d6dc + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x797a48c46be32aafcedcfd3d8992493d8a1f256b + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x123b30e25973fecd8354dd5f41cc45a3065ef88c + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x6632a9d63e142f17a668064d41a21193b49b41a0 + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0xf4ee95274741437636e748ddac70818b4ed7d043 + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x57a204aa1042f6e66dd7730813f4024114d74f37 + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0xd1258db6ac08eb0e625b75b371c023da478e94a9 + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x75e95ba5997eb235f40ecf8347cdb11f18ff640b + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0xd532b88607b1877fe20c181cba2550e3bbd6b31c + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0xa1d4657e0e6507d5a94d06da93e94dc7c8c44b51 + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0xedb61f74b0d09b2558f1eeb79b247c1f363ae452 + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x7d8820fa92eb1584636f4f5b8515b5476b75171a + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x231d3559aa848bf10366fb9868590f01d34bf240 + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0xad9fd7cb4fc7a0fbce08d64068f60cbde22ed34c + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x0e9d6552b85be180d941f1ca73ae3e318d2d4f1f + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0xb716600ed99b4710152582a124c697a7fe78adbf + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0xaadc2d4261199ce24a4b0a57370c4fcf43bb60aa + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x4e1f41613c9084fdb9e34e11fae9412427480e56 + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x79986af15539de2db9a5086382daeda917a9cf0c + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0xc99c679c50033bbc5321eb88752e89a93e9e83c5 + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0xc36cf0cfcb5d905b8b513860db0cfe63f6cf9f5c + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x9c8ff314c9bc7f6e59a9d9225fb22946427edc03 + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x3110ef5f612208724ca51f5761a69081809f03b7 + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x036721e5a769cc48b3189efbb9cce4471e8a48b1 + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x524cab2ec69124574082676e6f654a18df49a048 + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x7ab2352b1d2e185560494d5e577f9d3c238b78c5 + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x32973908faee0bf825a343000fe412ebe56f802a + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x7daec605e9e2a1717326eedfd660601e2753a057 + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0xc1caf0c19a8ac28c41fe59ba6c754e4b9bd54de9 + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x33fd426905f149f8376e227d0c9d3340aad17af1 + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x466cfcd0525189b573e794f554b8a751279213ac + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x6be69b2a9b153737887cfcdca7781ed1511c7e36 + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x80336ad7a747236ef41f47ed2c7641828a480baa + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x9401518f4ebba857baa879d9f76e1cc8b31ed197 + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x4b61413d4392c806e6d0ff5ee91e6073c21d6430 + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0xc3f733ca98e0dad0386979eb96fb1722a1a05e69 + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x09233d553058c2f42ba751c87816a8e9fae7ef10 + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x960b7a6bcd451c9968473f7bbfd9be826efd549a + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x36d30b3b85255473d27dd0f7fd8f35e36a9d6f06 + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x698fbaaca64944376e2cdc4cad86eaa91362cf54 + 2023-10-11T23:24:32.127Z + 0.7 + + + https://app.uniswap.org/nfts/collection/0x497a9a79e82e6fc0ff10a16f6f75e6fcd5ae65a8 + 2023-10-11T23:24:32.127Z + 0.7 + \ No newline at end of file diff --git a/scripts/generate-sitemap.js b/scripts/generate-sitemap.js index 94b0f3cde5..db6cbad8cd 100644 --- a/scripts/generate-sitemap.js +++ b/scripts/generate-sitemap.js @@ -6,7 +6,7 @@ const { parseStringPromise, Builder } = require('xml2js') const weekMs = 7 * 24 * 60 * 60 * 1000 const nowISO = new Date().toISOString() -const getQuery = (chain) => ` +const getTopTokensQuery = (chain) => ` query { topTokens(pageSize: 100, page: 1, chain: ${chain}, orderBy: VOLUME) { address @@ -15,6 +15,20 @@ const getQuery = (chain) => ` ` const chains = ['ETHEREUM', 'ARBITRUM', 'OPTIMISM', 'POLYGON', 'BASE', 'BNB', 'CELO'] +const nftTopCollectionsQuery = ` + query { + topCollections(first: 100, duration: MAX) { + edges { + node { + nftContracts { + address + } + } + } + } + } +` + fs.readFile('./public/sitemap.xml', 'utf8', async (err, data) => { const sitemapURLs = {} try { @@ -30,15 +44,15 @@ fs.readFile('./public/sitemap.xml', 'utf8', async (err, data) => { } for (const chainName of chains) { - const response = await fetch('https://api.uniswap.org/v1/graphql', { + const tokensResponse = await fetch('https://api.uniswap.org/v1/graphql', { method: 'POST', headers: { 'Content-Type': 'application/json', Origin: 'https://app.uniswap.org', }, - body: JSON.stringify({ query: getQuery(chainName) }), + body: JSON.stringify({ query: getTopTokensQuery(chainName) }), }) - const tokensJSON = await response.json() + const tokensJSON = await tokensResponse.json() const tokenAddresses = tokensJSON.data.topTokens.map((token) => token.address.toLowerCase()) tokenAddresses.forEach((address) => { @@ -53,10 +67,39 @@ fs.readFile('./public/sitemap.xml', 'utf8', async (err, data) => { }) } + const nftResponse = await fetch('https://api.uniswap.org/v1/graphql', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + Origin: 'https://app.uniswap.org', + }, + body: JSON.stringify({ query: nftTopCollectionsQuery }), + }) + const nftJSON = await nftResponse.json() + const collectionAddresses = nftJSON.data.topCollections.edges.map((edge) => edge.node.nftContracts[0].address) + collectionAddresses.forEach((address) => { + const collectionURL = `https://app.uniswap.org/nfts/collection/${address}` + if (!(collectionURL in sitemapURLs)) { + sitemap.urlset.url.push({ + loc: [collectionURL], + lastmod: [nowISO], + priority: [0.7], + }) + } + }) + const builder = new Builder() const xml = builder.buildObject(sitemap) - fs.writeFile('./public/sitemap.xml', xml, (error) => { + const path = './public/sitemap.xml' + fs.writeFile(path, xml, (error) => { if (error) throw error + const stats = fs.statSync(path) + const fileSizeBytes = stats.size + const fileSizeMegabytes = fileSizeBytes / (1024 * 1024) + + if (fileSizeMegabytes > 50) { + throw new Error('Generated sitemap file size exceeds 50MB') + } console.log('Sitemap updated') }) } catch (e) {