From cbb8a8803d2f50e21fa16195814576ad9414a741 Mon Sep 17 00:00:00 2001 From: BrickheadJohnny Date: Mon, 27 Jan 2025 14:33:54 +0100 Subject: [PATCH 01/15] fix(GithubRequirement): add missing whitespaces --- src/requirements/Github/GithubRequirement.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/requirements/Github/GithubRequirement.tsx b/src/requirements/Github/GithubRequirement.tsx index ac099e3ec9..b314a922d5 100644 --- a/src/requirements/Github/GithubRequirement.tsx +++ b/src/requirements/Github/GithubRequirement.tsx @@ -81,14 +81,14 @@ const GithubRequirement = (props: RequirementProps) => { ) : requirement.data.minAmount ? ( <> - {"older than "} + {" older than "} ) : requirement.data.maxAmount ? ( <> - {"no older than "} + {" no older than "} From e9b2337dcfee554ae6075f15eb4ba40243e33f88 Mon Sep 17 00:00:00 2001 From: Tomi_Ohl Date: Mon, 27 Jan 2025 14:55:04 +0100 Subject: [PATCH 02/15] feat(NFTReward): more override-supporting chains --- src/components/[guild]/collect/hooks/useGuildFee.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/components/[guild]/collect/hooks/useGuildFee.ts b/src/components/[guild]/collect/hooks/useGuildFee.ts index f5fc6135e9..6db9ec2cc8 100644 --- a/src/components/[guild]/collect/hooks/useGuildFee.ts +++ b/src/components/[guild]/collect/hooks/useGuildFee.ts @@ -10,6 +10,11 @@ const chainsWithOverrides = [ "ARBITRUM", "OPTIMISM", "POLYGON", + "INK", + "IOTA", + "SONIC", + "ZERO", + "MANTLE", ] const useGuildFee = ( From 2774eef5a1962c9ae933880d52ed3a2ab2ca7c87 Mon Sep 17 00:00:00 2001 From: BrickheadJohnny Date: Mon, 27 Jan 2025 15:56:09 +0100 Subject: [PATCH 03/15] temp(useOAuthResultToast): remove router.replace for debugging --- src/hooks/useOAuthResultToast.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/hooks/useOAuthResultToast.ts b/src/hooks/useOAuthResultToast.ts index 3490e02b29..0810768fad 100644 --- a/src/hooks/useOAuthResultToast.ts +++ b/src/hooks/useOAuthResultToast.ts @@ -12,7 +12,9 @@ export default function useOAuthResultToast() { const showPlatformMergeAlert = useSetAtom(platformMergeAlertAtom) useEffect(() => { + console.log("useEffect: query, showPlatformMergeAlert, pathname") if (query["oauth-status"]) { + console.log("oauth-status:") const { "oauth-platform": oauthPlatform, "oauth-status": oauthStatus, @@ -50,7 +52,7 @@ export default function useOAuthResultToast() { }) } - replace({ pathname, query: newQuery }) + // replace({ pathname, query: newQuery }) } // replace is intentionally left out // toast is intentionally left out, as it causes the toast to fire twice From cb2d3e98665b39bbd014d2b5cc18fabf7bec66d6 Mon Sep 17 00:00:00 2001 From: BrickheadJohnny Date: Tue, 28 Jan 2025 08:11:53 +0100 Subject: [PATCH 04/15] fix(useOAuthResultToast): remove console.log --- src/hooks/useOAuthResultToast.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/hooks/useOAuthResultToast.ts b/src/hooks/useOAuthResultToast.ts index 0810768fad..0fe8a39028 100644 --- a/src/hooks/useOAuthResultToast.ts +++ b/src/hooks/useOAuthResultToast.ts @@ -12,7 +12,6 @@ export default function useOAuthResultToast() { const showPlatformMergeAlert = useSetAtom(platformMergeAlertAtom) useEffect(() => { - console.log("useEffect: query, showPlatformMergeAlert, pathname") if (query["oauth-status"]) { console.log("oauth-status:") const { @@ -52,7 +51,7 @@ export default function useOAuthResultToast() { }) } - // replace({ pathname, query: newQuery }) + replace({ pathname, query: newQuery }) } // replace is intentionally left out // toast is intentionally left out, as it causes the toast to fire twice From 0949f977bfd2663f9c83d1619328dfd1557b873d Mon Sep 17 00:00:00 2001 From: BrickheadJohnny Date: Tue, 28 Jan 2025 08:12:53 +0100 Subject: [PATCH 05/15] feat(alchemyApiUrl): add more supported chains --- .env.example | 1 + src/env.js | 1 + src/pages/[guild]/collect/[chain]/[address].tsx | 11 +++++++++++ src/pages/api/nft/collectors/[chain]/[address].ts | 11 +++++++++++ 4 files changed, 24 insertions(+) diff --git a/.env.example b/.env.example index 1e1a6fd153..3a1533350d 100644 --- a/.env.example +++ b/.env.example @@ -19,5 +19,6 @@ POLYGON_ALCHEMY_KEY="" POLYGON_MUMBAI_ALCHEMY_KEY="" SECRET_WORDS="" SEPOLIA_ALCHEMY_KEY="" +FRONTEND_ALCHEMY_KEY="" SOUND_API_KEY="" ZEROX_API_KEY="" diff --git a/src/env.js b/src/env.js index e0528b73c8..5363c89042 100644 --- a/src/env.js +++ b/src/env.js @@ -14,6 +14,7 @@ export const env = createEnv({ OPTIMISM_ALCHEMY_KEY: z.string(), BASE_ALCHEMY_KEY: z.string(), ARBITRUM_ALCHEMY_KEY: z.string(), + FRONTEND_ALCHEMY_KEY: z.string(), // IPFS PINATA_ADMIN_JWT: z.string(), diff --git a/src/pages/[guild]/collect/[chain]/[address].tsx b/src/pages/[guild]/collect/[chain]/[address].tsx index 5389d080b6..a45e7e79ad 100644 --- a/src/pages/[guild]/collect/[chain]/[address].tsx +++ b/src/pages/[guild]/collect/[chain]/[address].tsx @@ -73,6 +73,17 @@ export const topCollectorsSupportedChains = [ "OPTIMISM", "ARBITRUM", "SEPOLIA", + "MANTLE", + "ZKSYNC_ERA", + "LINEA", + "SCROLL", + "BLAST_MAINNET", + "METIS", + "POLYGON_ZKEVM", + "ZETACHAIN", + "AVALANCHE", + "INK", + "SONIC", ] as const satisfies ContractCallSupportedChain[] const CollectNftPageContent = ({ diff --git a/src/pages/api/nft/collectors/[chain]/[address].ts b/src/pages/api/nft/collectors/[chain]/[address].ts index b1354a4c20..6a073e397f 100644 --- a/src/pages/api/nft/collectors/[chain]/[address].ts +++ b/src/pages/api/nft/collectors/[chain]/[address].ts @@ -33,6 +33,17 @@ export const alchemyApiUrl: Record< OPTIMISM: `https://opt-mainnet.g.alchemy.com/nft/v3/${env.OPTIMISM_ALCHEMY_KEY}/getOwnersForContract`, ARBITRUM: `https://arb-mainnet.g.alchemy.com/nft/v3/${env.ARBITRUM_ALCHEMY_KEY}/getOwnersForContract`, SEPOLIA: `https://eth-sepolia.g.alchemy.com/nft/v3/${env.SEPOLIA_ALCHEMY_KEY}/getOwnersForContract`, + MANTLE: `https://mantle-mainnet.g.alchemy.com/v2/${env.FRONTEND_ALCHEMY_KEY}`, + ZKSYNC_ERA: `https://zksync-mainnet.g.alchemy.com/v2/${env.FRONTEND_ALCHEMY_KEY}`, + LINEA: `https://linea-mainnet.g.alchemy.com/v2/${env.FRONTEND_ALCHEMY_KEY}`, + SCROLL: `https://scroll-mainnet.g.alchemy.com/v2/${env.FRONTEND_ALCHEMY_KEY}`, + BLAST_MAINNET: `https://blast-mainnet.g.alchemy.com/v2/${env.FRONTEND_ALCHEMY_KEY}`, + METIS: `https://metis-mainnet.g.alchemy.com/v2/${env.FRONTEND_ALCHEMY_KEY}`, + POLYGON_ZKEVM: `https://polygonzkevm-mainnet.g.alchemy.com/v2/${env.FRONTEND_ALCHEMY_KEY}`, + ZETACHAIN: `https://zetachain-mainnet.g.alchemy.com/v2/${env.FRONTEND_ALCHEMY_KEY}`, + AVALANCHE: `https://avax-mainnet.g.alchemy.com/v2/${env.FRONTEND_ALCHEMY_KEY}`, + INK: `https://ink-mainnet.g.alchemy.com/v2/${env.FRONTEND_ALCHEMY_KEY}`, + SONIC: `https://sonic-mainnet.g.alchemy.com/v2/${env.FRONTEND_ALCHEMY_KEY}`, } // TODO: just use Zod. From a3601fde8d475c00d9235128540e1a1fb3fddc94 Mon Sep 17 00:00:00 2001 From: BrickheadJohnny Date: Tue, 28 Jan 2025 08:23:47 +0100 Subject: [PATCH 06/15] fix(env): load the new env var properly --- src/env.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/env.js b/src/env.js index 5363c89042..1a06347fb5 100644 --- a/src/env.js +++ b/src/env.js @@ -85,6 +85,7 @@ export const env = createEnv({ OPTIMISM_ALCHEMY_KEY: process.env.OPTIMISM_ALCHEMY_KEY, BASE_ALCHEMY_KEY: process.env.BASE_ALCHEMY_KEY, ARBITRUM_ALCHEMY_KEY: process.env.ARBITRUM_ALCHEMY_KEY, + FRONTEND_ALCHEMY_KEY: process.env.FRONTEND_ALCHEMY_KEY, PINATA_ADMIN_JWT: process.env.PINATA_ADMIN_JWT, PINATA_ADMIN_KEY: process.env.PINATA_ADMIN_KEY, From c552a3ef04e424211074e8de09e534c705b6b3de Mon Sep 17 00:00:00 2001 From: BrickheadJohnny Date: Tue, 28 Jan 2025 08:39:37 +0100 Subject: [PATCH 07/15] fix(config): remove CircularDependencyPlugin --- next.config.js | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/next.config.js b/next.config.js index e806a1549b..a72cc7bc5e 100644 --- a/next.config.js +++ b/next.config.js @@ -1,7 +1,6 @@ // @ts-check const { BugsnagSourceMapUploaderPlugin } = require("webpack-bugsnag-plugins") -const CircularDependencyPlugin = require("circular-dependency-plugin") /** @type {import("next").NextConfig} */ const nextConfig = { @@ -35,15 +34,6 @@ const nextConfig = { publicPath: `https://${process.env.VERCEL_URL ?? "guild.xyz"}/_next/`, }) ) - config.plugins.push( - new CircularDependencyPlugin({ - exclude: /.next|node_modules/, - include: /src/, - // TODO: if all circular dependencies are resolved, set this argument to true - failOnError: false, - allowAsyncCycles: false, - }) - ) } return config From fe0b2c4230a69f21f2c8ce230bdefd0daaddde90 Mon Sep 17 00:00:00 2001 From: BrickheadJohnny Date: Tue, 28 Jan 2025 08:40:00 +0100 Subject: [PATCH 08/15] fix(alchemyApiUrl): fix URLs and remove unsupported chains --- src/pages/[guild]/collect/[chain]/[address].tsx | 6 ------ .../api/nft/collectors/[chain]/[address].ts | 17 ++++++----------- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/src/pages/[guild]/collect/[chain]/[address].tsx b/src/pages/[guild]/collect/[chain]/[address].tsx index a45e7e79ad..d92e1d271a 100644 --- a/src/pages/[guild]/collect/[chain]/[address].tsx +++ b/src/pages/[guild]/collect/[chain]/[address].tsx @@ -73,17 +73,11 @@ export const topCollectorsSupportedChains = [ "OPTIMISM", "ARBITRUM", "SEPOLIA", - "MANTLE", "ZKSYNC_ERA", "LINEA", "SCROLL", "BLAST_MAINNET", - "METIS", - "POLYGON_ZKEVM", - "ZETACHAIN", "AVALANCHE", - "INK", - "SONIC", ] as const satisfies ContractCallSupportedChain[] const CollectNftPageContent = ({ diff --git a/src/pages/api/nft/collectors/[chain]/[address].ts b/src/pages/api/nft/collectors/[chain]/[address].ts index 6a073e397f..42658801fa 100644 --- a/src/pages/api/nft/collectors/[chain]/[address].ts +++ b/src/pages/api/nft/collectors/[chain]/[address].ts @@ -23,6 +23,7 @@ export type TopCollectorsResponse = OneOf< { error: string } > +// https://docs.alchemy.com/reference/getownersforcontract-v3 export const alchemyApiUrl: Record< (typeof topCollectorsSupportedChains)[number], string @@ -33,17 +34,11 @@ export const alchemyApiUrl: Record< OPTIMISM: `https://opt-mainnet.g.alchemy.com/nft/v3/${env.OPTIMISM_ALCHEMY_KEY}/getOwnersForContract`, ARBITRUM: `https://arb-mainnet.g.alchemy.com/nft/v3/${env.ARBITRUM_ALCHEMY_KEY}/getOwnersForContract`, SEPOLIA: `https://eth-sepolia.g.alchemy.com/nft/v3/${env.SEPOLIA_ALCHEMY_KEY}/getOwnersForContract`, - MANTLE: `https://mantle-mainnet.g.alchemy.com/v2/${env.FRONTEND_ALCHEMY_KEY}`, - ZKSYNC_ERA: `https://zksync-mainnet.g.alchemy.com/v2/${env.FRONTEND_ALCHEMY_KEY}`, - LINEA: `https://linea-mainnet.g.alchemy.com/v2/${env.FRONTEND_ALCHEMY_KEY}`, - SCROLL: `https://scroll-mainnet.g.alchemy.com/v2/${env.FRONTEND_ALCHEMY_KEY}`, - BLAST_MAINNET: `https://blast-mainnet.g.alchemy.com/v2/${env.FRONTEND_ALCHEMY_KEY}`, - METIS: `https://metis-mainnet.g.alchemy.com/v2/${env.FRONTEND_ALCHEMY_KEY}`, - POLYGON_ZKEVM: `https://polygonzkevm-mainnet.g.alchemy.com/v2/${env.FRONTEND_ALCHEMY_KEY}`, - ZETACHAIN: `https://zetachain-mainnet.g.alchemy.com/v2/${env.FRONTEND_ALCHEMY_KEY}`, - AVALANCHE: `https://avax-mainnet.g.alchemy.com/v2/${env.FRONTEND_ALCHEMY_KEY}`, - INK: `https://ink-mainnet.g.alchemy.com/v2/${env.FRONTEND_ALCHEMY_KEY}`, - SONIC: `https://sonic-mainnet.g.alchemy.com/v2/${env.FRONTEND_ALCHEMY_KEY}`, + ZKSYNC_ERA: `https://zksync-mainnet.g.alchemy.com/v2/${env.FRONTEND_ALCHEMY_KEY}/getOwnersForContract`, + LINEA: `https://linea-mainnet.g.alchemy.com/v2/${env.FRONTEND_ALCHEMY_KEY}/getOwnersForContract`, + SCROLL: `https://scroll-mainnet.g.alchemy.com/v2/${env.FRONTEND_ALCHEMY_KEY}/getOwnersForContract`, + BLAST_MAINNET: `https://blast-mainnet.g.alchemy.com/v2/${env.FRONTEND_ALCHEMY_KEY}/getOwnersForContract`, + AVALANCHE: `https://avax-mainnet.g.alchemy.com/v2/${env.FRONTEND_ALCHEMY_KEY}/getOwnersForContract`, } // TODO: just use Zod. From 7eaf209578f0d6b01c972aace7325e412edb119b Mon Sep 17 00:00:00 2001 From: BrickheadJohnny Date: Tue, 28 Jan 2025 09:04:50 +0100 Subject: [PATCH 09/15] fix(alchemyApiUrl): add `/nft` to the URL paths --- src/pages/api/nft/collectors/[chain]/[address].ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/pages/api/nft/collectors/[chain]/[address].ts b/src/pages/api/nft/collectors/[chain]/[address].ts index 42658801fa..26812628c6 100644 --- a/src/pages/api/nft/collectors/[chain]/[address].ts +++ b/src/pages/api/nft/collectors/[chain]/[address].ts @@ -34,11 +34,11 @@ export const alchemyApiUrl: Record< OPTIMISM: `https://opt-mainnet.g.alchemy.com/nft/v3/${env.OPTIMISM_ALCHEMY_KEY}/getOwnersForContract`, ARBITRUM: `https://arb-mainnet.g.alchemy.com/nft/v3/${env.ARBITRUM_ALCHEMY_KEY}/getOwnersForContract`, SEPOLIA: `https://eth-sepolia.g.alchemy.com/nft/v3/${env.SEPOLIA_ALCHEMY_KEY}/getOwnersForContract`, - ZKSYNC_ERA: `https://zksync-mainnet.g.alchemy.com/v2/${env.FRONTEND_ALCHEMY_KEY}/getOwnersForContract`, - LINEA: `https://linea-mainnet.g.alchemy.com/v2/${env.FRONTEND_ALCHEMY_KEY}/getOwnersForContract`, - SCROLL: `https://scroll-mainnet.g.alchemy.com/v2/${env.FRONTEND_ALCHEMY_KEY}/getOwnersForContract`, - BLAST_MAINNET: `https://blast-mainnet.g.alchemy.com/v2/${env.FRONTEND_ALCHEMY_KEY}/getOwnersForContract`, - AVALANCHE: `https://avax-mainnet.g.alchemy.com/v2/${env.FRONTEND_ALCHEMY_KEY}/getOwnersForContract`, + ZKSYNC_ERA: `https://zksync-mainnet.g.alchemy.com/nft/v3/${env.FRONTEND_ALCHEMY_KEY}/getOwnersForContract`, + LINEA: `https://linea-mainnet.g.alchemy.com/nft/v3/${env.FRONTEND_ALCHEMY_KEY}/getOwnersForContract`, + SCROLL: `https://scroll-mainnet.g.alchemy.com/nft/v3/${env.FRONTEND_ALCHEMY_KEY}/getOwnersForContract`, + BLAST_MAINNET: `https://blast-mainnet.g.alchemy.com/nft/v3/${env.FRONTEND_ALCHEMY_KEY}/getOwnersForContract`, + AVALANCHE: `https://avax-mainnet.g.alchemy.com/nft/v3/${env.FRONTEND_ALCHEMY_KEY}/getOwnersForContract`, } // TODO: just use Zod. From f407a0011c558dad762de3e4b653ea20ae787071 Mon Sep 17 00:00:00 2001 From: BrickheadJohnny Date: Tue, 28 Jan 2025 09:53:59 +0100 Subject: [PATCH 10/15] feat(WalletActivityForm): add `FORM` to supported chains --- package-lock.json | 8 ++++---- package.json | 2 +- src/requirements/WalletActivity/WalletActivityForm.tsx | 2 ++ src/requirements/types.ts | 5 ++++- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index a05af52b11..085a52e5e7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,7 +18,7 @@ "@emotion/styled": "^11.11.0", "@fuels/connectors": "^0.36.0", "@fuels/react": "^0.36.0", - "@guildxyz/types": "^1.10.38", + "@guildxyz/types": "^1.10.40", "@hcaptcha/react-hcaptcha": "^1.4.4", "@hookform/resolvers": "^3.3.4", "@lexical/code": "^0.12.0", @@ -5433,9 +5433,9 @@ } }, "node_modules/@guildxyz/types": { - "version": "1.10.38", - "resolved": "https://registry.npmjs.org/@guildxyz/types/-/types-1.10.38.tgz", - "integrity": "sha512-oPbRzmoOt3dkv2B0gdjX4fMhiwWxSG+n99loOI1AsvsGyDO9C2NdPDTa8HFULXZXctpPoUyf9VpY9BlsT8mKIQ==", + "version": "1.10.40", + "resolved": "https://registry.npmjs.org/@guildxyz/types/-/types-1.10.40.tgz", + "integrity": "sha512-Yem5kvgGAsMkNAknHcMAOjMe+WepC6PFOlT8NoKJ8AgBehXDikrRHr+XeXwbATWlIi3SYgOeMjUIKg+jROh3Vw==", "license": "ISC", "dependencies": { "zod": "^3.22.4" diff --git a/package.json b/package.json index aec143e2f7..3374579f64 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "@emotion/styled": "^11.11.0", "@fuels/connectors": "^0.36.0", "@fuels/react": "^0.36.0", - "@guildxyz/types": "^1.10.38", + "@guildxyz/types": "^1.10.40", "@hcaptcha/react-hcaptcha": "^1.4.4", "@hookform/resolvers": "^3.3.4", "@lexical/code": "^0.12.0", diff --git a/src/requirements/WalletActivity/WalletActivityForm.tsx b/src/requirements/WalletActivity/WalletActivityForm.tsx index d8c40c12b3..99d820fbc6 100644 --- a/src/requirements/WalletActivity/WalletActivityForm.tsx +++ b/src/requirements/WalletActivity/WalletActivityForm.tsx @@ -53,6 +53,7 @@ const COVALENT_CHAINS = new Set([ "SONIC", "SOPHON", "ZERO", + "FORM", ]) const walletActivityRequirementTypes: SelectOption[] = [ @@ -144,6 +145,7 @@ const WalletActivityForm = ({ "SONIC", "SOPHON", "ZERO", + "FORM", ] for (const covalentChain of COVALENT_CHAINS.values()) { diff --git a/src/requirements/types.ts b/src/requirements/types.ts index 18d1d07bfa..22e98f2b89 100644 --- a/src/requirements/types.ts +++ b/src/requirements/types.ts @@ -3,7 +3,10 @@ import { Icon } from "@phosphor-icons/react" import { UseControllerProps } from "react-hook-form" import { Requirement } from "types" -export type RequirementType = Schemas["Requirement"]["type"] +export type RequirementType = Exclude< + Schemas["Requirement"]["type"], + "JUMPER_LEVEL" | "JUMPER_TYPE" | "JUMPER_TRAITS" +> export type RequirementFormProps = { baseFieldPath: string From 3700963482a4e4a1228f4792d3dd2ac9f7836271 Mon Sep 17 00:00:00 2001 From: BrickheadJohnny Date: Tue, 28 Jan 2025 11:11:37 +0100 Subject: [PATCH 11/15] fix(BlockExplorerLink): conditional `/token` or `/address` path --- .../Requirements/components/BlockExplorerUrl.tsx | 3 ++- .../[guild]/collect/components/Details/Details.tsx | 10 ++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/components/[guild]/Requirements/components/BlockExplorerUrl.tsx b/src/components/[guild]/Requirements/components/BlockExplorerUrl.tsx index 5da358f4ee..e778cd86a7 100644 --- a/src/components/[guild]/Requirements/components/BlockExplorerUrl.tsx +++ b/src/components/[guild]/Requirements/components/BlockExplorerUrl.tsx @@ -29,7 +29,8 @@ const BlockExplorerUrl = ({ // Some explorers don't support the /token path const path = - pathProp ?? (["BERA_TESTNET"].includes(chainProp ?? chain) ? "address" : "token") + pathProp ?? + (["BERA_TESTNET", "IOTA"].includes(chainProp ?? chain) ? "address" : "token") const url = (type === "ERC1155" || type === "ERC721") && data?.id diff --git a/src/components/[guild]/collect/components/Details/Details.tsx b/src/components/[guild]/collect/components/Details/Details.tsx index 891e7d6b2c..06f9bc8769 100644 --- a/src/components/[guild]/collect/components/Details/Details.tsx +++ b/src/components/[guild]/collect/components/Details/Details.tsx @@ -1,11 +1,13 @@ import { SimpleGrid, Skeleton, Text } from "@chakra-ui/react" import { useCollectNftContext } from "components/[guild]/collect/components/CollectNftContext" import Section from "components/common/Section" -import { CHAIN_CONFIG } from "wagmiConfig/chains" +import { CHAIN_CONFIG, Chain } from "wagmiConfig/chains" import useNftDetails from "../../hooks/useNftDetails" import BlockExplorerLink from "./components/BlockExplorerLink" import InfoBlock from "./components/InfoBlock" +const ADDRESS_PATHS = ["IOTA"] as Chain[] + const Details = () => { const { chain, nftAddress } = useCollectNftContext() const { maxSupply, soulbound, isLoading } = useNftDetails(chain, nftAddress) @@ -16,7 +18,11 @@ const Details = () => { {CHAIN_CONFIG[chain].name} - + {soulbound ? "No" : "Yes"} From f54d8474e33778a12bd1559513396c4592fd734b Mon Sep 17 00:00:00 2001 From: BrickheadJohnny Date: Tue, 28 Jan 2025 11:20:50 +0100 Subject: [PATCH 12/15] fix(Links): conditional `/token` or `/address` path --- .../[guild]/collect/components/Details/Details.tsx | 6 ++++-- src/components/[guild]/collect/components/Links.tsx | 7 ++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/components/[guild]/collect/components/Details/Details.tsx b/src/components/[guild]/collect/components/Details/Details.tsx index 06f9bc8769..2162a6272f 100644 --- a/src/components/[guild]/collect/components/Details/Details.tsx +++ b/src/components/[guild]/collect/components/Details/Details.tsx @@ -6,7 +6,7 @@ import useNftDetails from "../../hooks/useNftDetails" import BlockExplorerLink from "./components/BlockExplorerLink" import InfoBlock from "./components/InfoBlock" -const ADDRESS_PATHS = ["IOTA"] as Chain[] +export const NFT_BLOCK_EXPLORER_ADDRESS_PATHS = ["IOTA"] as Chain[] const Details = () => { const { chain, nftAddress } = useCollectNftContext() @@ -21,7 +21,9 @@ const Details = () => { diff --git a/src/components/[guild]/collect/components/Links.tsx b/src/components/[guild]/collect/components/Links.tsx index 75f3f37f31..3953d66fc1 100644 --- a/src/components/[guild]/collect/components/Links.tsx +++ b/src/components/[guild]/collect/components/Links.tsx @@ -9,6 +9,7 @@ import capitalize from "utils/capitalize" import { openseaBaseUrl } from "utils/guildCheckout/constants" import { CHAIN_CONFIG } from "wagmiConfig/chains" import useNftDetails from "../hooks/useNftDetails" +import { NFT_BLOCK_EXPLORER_ADDRESS_PATHS } from "./Details/Details" const Links = () => { const { colorMode } = useColorMode() @@ -16,6 +17,10 @@ const Links = () => { const { totalSupply } = useNftDetails(chain, nftAddress) const { socialLinks } = useGuild() + const blockExplorerPath = NFT_BLOCK_EXPLORER_ADDRESS_PATHS.includes(chain) + ? "address" + : "token" + return (
@@ -46,7 +51,7 @@ const Links = () => { )} Date: Tue, 28 Jan 2025 13:41:03 +0100 Subject: [PATCH 13/15] fix: remove middleware.ts --- src/middleware.ts | 33 --------------------------------- 1 file changed, 33 deletions(-) delete mode 100644 src/middleware.ts diff --git a/src/middleware.ts b/src/middleware.ts deleted file mode 100644 index c5c68babff..0000000000 --- a/src/middleware.ts +++ /dev/null @@ -1,33 +0,0 @@ -import type { NextRequest } from "next/server" -import { NextResponse } from "next/server" - -export const config = { - /** - * The middleware won't run for: - * - * - `/api` paths - * - `_next/...` paths - * - Image/animation/video files - */ - matcher: [ - "/((?!api(?:/.*)?|_next(?:/.*)?|.*\\.(?:jpg|jpeg|webp|webm|png|svg|ico|lottie)$).*)", - ], -} - -export function middleware(request: NextRequest) { - if ( - request.nextUrl.pathname === request.nextUrl.pathname.toLowerCase() || - request.nextUrl.pathname.startsWith("/lego") || - request.nextUrl.pathname.startsWith("/profile") - ) { - return NextResponse.next() - } - - let transformedURL = request.url.split("?")[0].toLowerCase() - - if (request.nextUrl.search) { - transformedURL += request.nextUrl.search - } - - return NextResponse.redirect(transformedURL) -} From 92b488b020b440668ab08ccc08fe4c1d5bc2c26a Mon Sep 17 00:00:00 2001 From: BrickheadJohnny Date: Tue, 28 Jan 2025 14:12:22 +0100 Subject: [PATCH 14/15] fix(requirements): remove deprecated requirements --- src/requirements/Twitter/TwitterRequirement.tsx | 8 +++++--- .../WalletActivity/WalletActivityRequirement.tsx | 2 +- src/requirements/requirementDisplayComponents.ts | 15 --------------- src/requirements/requirementFormComponents.ts | 15 --------------- src/requirements/types.ts | 8 +++++++- 5 files changed, 13 insertions(+), 35 deletions(-) diff --git a/src/requirements/Twitter/TwitterRequirement.tsx b/src/requirements/Twitter/TwitterRequirement.tsx index 3b2de18e37..5dda2e9f16 100644 --- a/src/requirements/Twitter/TwitterRequirement.tsx +++ b/src/requirements/Twitter/TwitterRequirement.tsx @@ -37,7 +37,7 @@ const requirementIntentAction: Partial< export const TWITTER_HANDLE_REGEX = /^[a-z0-9_]+$/i const TwitterRequirement = (props: RequirementProps) => { - const requirement = useRequirementContext() + const requirement = useRequirementContext() const { id: userId, platformUsers } = useUser() const isTwitterConnected = platformUsers?.find( (pu) => pu.platformId === PlatformType.TWITTER_V1 @@ -53,7 +53,9 @@ const TwitterRequirement = (props: RequirementProps) => { ) : ( ) @@ -68,7 +70,7 @@ const TwitterRequirement = (props: RequirementProps) => { "minAmount" in requirement.data ? requirement.data.minAmount : 0 ) - switch (requirement.type) { + switch (requirement.type as TwitterRequirementType) { case "TWITTER_NAME": return ( <> diff --git a/src/requirements/WalletActivity/WalletActivityRequirement.tsx b/src/requirements/WalletActivity/WalletActivityRequirement.tsx index 0965762d03..bd0e24acaf 100644 --- a/src/requirements/WalletActivity/WalletActivityRequirement.tsx +++ b/src/requirements/WalletActivity/WalletActivityRequirement.tsx @@ -44,7 +44,7 @@ type CovalentRequirementType = | "COVALENT_TX_VALUE_RELATIVE" const WalletActivityRequirement = (props: RequirementProps): JSX.Element => { - const requirement = useRequirementContext() + const requirement = useRequirementContext() const reqData = requirement.data as any // Important note: we needed a hotfix for the requirement icon, but we should find a proper solution for this. const maxAmount = reqData?.timestamps?.maxAmount diff --git a/src/requirements/requirementDisplayComponents.ts b/src/requirements/requirementDisplayComponents.ts index 360d0f2067..be6f75044b 100644 --- a/src/requirements/requirementDisplayComponents.ts +++ b/src/requirements/requirementDisplayComponents.ts @@ -28,13 +28,6 @@ export const REQUIREMENT_DISPLAY_COMPONENTS = { CONTRACT: dynamic( () => import("requirements/ContractState/ContractStateRequirement") ), - // TODO: TX_VALUE requirements are deprecated - COVALENT_TX_VALUE: dynamic( - () => import("requirements/WalletActivity/WalletActivityRequirement") - ), - COVALENT_TX_VALUE_RELATIVE: dynamic( - () => import("requirements/WalletActivity/WalletActivityRequirement") - ), COVALENT_FIRST_TX: dynamic( () => import("requirements/WalletActivity/WalletActivityRequirement") ), @@ -119,10 +112,6 @@ export const REQUIREMENT_DISPLAY_COMPONENTS = { FORM_SUBMISSION: dynamic( () => import("requirements/Form/FormRequirement") ), - // TODO: this is a deprecated requirement - FORM_APPROVAL: dynamic( - () => import("requirements/Form/FormRequirement") - ), WORLD_ID_VERIFICATION: dynamic( () => import("requirements/WorldID/WorldIDRequirement") ), @@ -180,10 +169,6 @@ export const REQUIREMENT_DISPLAY_COMPONENTS = { TWITTER_TWEET_COUNT: dynamic( () => import("requirements/Twitter/TwitterRequirement") ), - // TODO: this is a deprecated requirement - TWITTER_LIST_FOLLOW: dynamic( - () => import("requirements/Twitter/TwitterRequirement") - ), GITHUB_STARRING: dynamic( () => import("requirements/Github/GithubRequirement") ), diff --git a/src/requirements/requirementFormComponents.ts b/src/requirements/requirementFormComponents.ts index 86bdca7926..84029e2328 100644 --- a/src/requirements/requirementFormComponents.ts +++ b/src/requirements/requirementFormComponents.ts @@ -18,13 +18,6 @@ export const REQUIREMENT_FORM_COMPONENTS = { CONTRACT: dynamic( () => import("requirements/ContractState/ContractStateForm") ), - // TODO: TX_VALUE requirements are deprecated - COVALENT_TX_VALUE: dynamic( - () => import("requirements/WalletActivity/WalletActivityForm") - ), - COVALENT_TX_VALUE_RELATIVE: dynamic( - () => import("requirements/WalletActivity/WalletActivityForm") - ), COVALENT_FIRST_TX: dynamic( () => import("requirements/WalletActivity/WalletActivityForm") ), @@ -109,10 +102,6 @@ export const REQUIREMENT_FORM_COMPONENTS = { FORM_SUBMISSION: dynamic( () => import("requirements/Form/FormForm") ), - // TODO: this is a deprecated requirement - FORM_APPROVAL: dynamic( - () => import("requirements/Form/FormForm") - ), WORLD_ID_VERIFICATION: dynamic( () => import("requirements/WorldID/WorldIDForm") ), @@ -170,10 +159,6 @@ export const REQUIREMENT_FORM_COMPONENTS = { TWITTER_TWEET_COUNT: dynamic( () => import("requirements/Twitter/TwitterForm") ), - // TODO: this is a deprecated requirement - TWITTER_LIST_FOLLOW: dynamic( - () => import("requirements/Twitter/TwitterForm") - ), GITHUB_STARRING: dynamic( () => import("requirements/Github/GithubForm") ), diff --git a/src/requirements/types.ts b/src/requirements/types.ts index 22e98f2b89..f3c381a20b 100644 --- a/src/requirements/types.ts +++ b/src/requirements/types.ts @@ -5,7 +5,13 @@ import { Requirement } from "types" export type RequirementType = Exclude< Schemas["Requirement"]["type"], - "JUMPER_LEVEL" | "JUMPER_TYPE" | "JUMPER_TRAITS" + | "JUMPER_LEVEL" + | "JUMPER_TYPE" + | "JUMPER_TRAITS" + | "COVALENT_TX_VALUE" + | "COVALENT_TX_VALUE_RELATIVE" + | "FORM_APPROVAL" + | "TWITTER_LIST_FOLLOW" > export type RequirementFormProps = { From 14c1e0cb276da5493c4e38e9d4e061904e0cb3a0 Mon Sep 17 00:00:00 2001 From: BrickheadJohnny Date: Tue, 28 Jan 2025 14:14:00 +0100 Subject: [PATCH 15/15] feat(app router): `OAuthResultToast` component --- src/app/layout.tsx | 2 + src/hooks/useOAuthResultToast.ts | 1 - .../components/Providers/OAuthResultToast.tsx | 66 +++++++++++++++++++ 3 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 src/v2/components/Providers/OAuthResultToast.tsx diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 0d638eba6c..7fd3340b78 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -4,6 +4,7 @@ import { dystopian, inter } from "fonts" import { type ReactNode, Suspense } from "react" import "./globals.css" import { AnnouncementDialog } from "@/components/AnnouncementDialog" +import { OAuthResultToast } from "@/components/Providers/OAuthResultToast" import { TermsOfUseUpdateDialog } from "@/components/TermsOfUseUpdateDialog" import { cn } from "@/lib/utils" import type { Metadata, Viewport } from "next" @@ -54,6 +55,7 @@ export default function RootLayout({ children }: RootLayoutProps) { + diff --git a/src/hooks/useOAuthResultToast.ts b/src/hooks/useOAuthResultToast.ts index 0fe8a39028..3490e02b29 100644 --- a/src/hooks/useOAuthResultToast.ts +++ b/src/hooks/useOAuthResultToast.ts @@ -13,7 +13,6 @@ export default function useOAuthResultToast() { useEffect(() => { if (query["oauth-status"]) { - console.log("oauth-status:") const { "oauth-platform": oauthPlatform, "oauth-status": oauthStatus, diff --git a/src/v2/components/Providers/OAuthResultToast.tsx b/src/v2/components/Providers/OAuthResultToast.tsx new file mode 100644 index 0000000000..73e0d48c71 --- /dev/null +++ b/src/v2/components/Providers/OAuthResultToast.tsx @@ -0,0 +1,66 @@ +"use client" + +import { platformMergeAlertAtom } from "@/components/Providers/atoms" +import { useToast } from "@/components/ui/hooks/useToast" +import { useSetAtom } from "jotai" +import { usePathname, useRouter, useSearchParams } from "next/navigation" +import { useEffect } from "react" +import rewards from "rewards" +import { PlatformName } from "types" + +export function OAuthResultToast() { + const { toast } = useToast() + + const { replace } = useRouter() + const pathname = usePathname() + const readonlyQuery = useSearchParams() + + const showPlatformMergeAlert = useSetAtom(platformMergeAlertAtom) + + useEffect(() => { + if (readonlyQuery?.get("oauth-status")) { + const newQuery = new URLSearchParams(readonlyQuery.toString()) + + const oauthPlatform = readonlyQuery.get("oauth-platform") + const oauthStatus = readonlyQuery.get("oauth-status") + const oauthMessage = readonlyQuery.get("oauth-message") + + const platformNameHumanReadable = + rewards[(oauthPlatform as PlatformName) ?? ""]?.name ?? "Social" + + const title = + oauthStatus === "success" + ? `${platformNameHumanReadable} successfully connected` + : `Failed to connect ${platformNameHumanReadable}` + + if ( + oauthStatus === "error" && + oauthMessage?.toString()?.startsWith("Before connecting your") + ) { + const [, addressOrDomain] = oauthMessage + .toString() + .match( + /^Before connecting your (?:.*?) account, please disconnect it from this address: (.*?)$/ + ) + + showPlatformMergeAlert({ + addressOrDomain, + platformName: oauthPlatform as PlatformName, + }) + } else { + toast({ + variant: oauthStatus as "success" | "error", + title, + description: oauthMessage, + }) + } + + replace(`${pathname}?${newQuery.toString()}`) + } + // replace is intentionally left out + // toast is intentionally left out, as it causes the toast to fire twice + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [readonlyQuery, showPlatformMergeAlert, pathname]) + + return null +}