Skip to content

Commit

Permalink
Merge branch 'main' into jumper-requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
BrickheadJohnny committed Jan 28, 2025
2 parents a4ed945 + 14c1e0c commit dad851b
Show file tree
Hide file tree
Showing 15 changed files with 1,804 additions and 959 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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=""
10 changes: 0 additions & 10 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// @ts-check

const { BugsnagSourceMapUploaderPlugin } = require("webpack-bugsnag-plugins")
const CircularDependencyPlugin = require("circular-dependency-plugin")

/** @type {import("next").NextConfig} */
const nextConfig = {
Expand Down Expand Up @@ -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
Expand Down
2,605 changes: 1,695 additions & 910 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@emotion/styled": "^11.11.0",
"@fuels/connectors": "^0.36.0",
"@fuels/react": "^0.36.0",
"@guildxyz/types": "^1.10.39",
"@guildxyz/types": "^1.10.40",
"@hcaptcha/react-hcaptcha": "^1.4.4",
"@hookform/resolvers": "^3.3.4",
"@lexical/code": "^0.12.0",
Expand Down Expand Up @@ -101,7 +101,7 @@
"next-themes": "^0.3.0",
"nextjs-toploader": "^1.6.12",
"papaparse": "^5.4.1",
"posthog-js": "^1.139.3",
"posthog-js": "1.205.0",
"qrcode.react": "^3.1.0",
"randombytes": "^2.1.0",
"react": "^18.2.0",
Expand Down
2 changes: 2 additions & 0 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -54,6 +55,7 @@ export default function RootLayout({ children }: RootLayoutProps) {
<AnnouncementDialog />
<Suspense>
<PostHogPageViews />
<OAuthResultToast />
</Suspense>
</Providers>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 10 additions & 2 deletions src/components/[guild]/collect/components/Details/Details.tsx
Original file line number Diff line number Diff line change
@@ -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"

export const NFT_BLOCK_EXPLORER_ADDRESS_PATHS = ["IOTA"] as Chain[]

const Details = () => {
const { chain, nftAddress } = useCollectNftContext()
const { maxSupply, soulbound, isLoading } = useNftDetails(chain, nftAddress)
Expand All @@ -16,7 +18,13 @@ const Details = () => {
<InfoBlock label="Network">{CHAIN_CONFIG[chain].name}</InfoBlock>

<InfoBlock label="Contract">
<BlockExplorerLink chain={chain} address={nftAddress} path="token" />
<BlockExplorerLink
chain={chain}
address={nftAddress}
path={
NFT_BLOCK_EXPLORER_ADDRESS_PATHS.includes(chain) ? "address" : "token"
}
/>
</InfoBlock>

<InfoBlock label="Transferable">{soulbound ? "No" : "Yes"}</InfoBlock>
Expand Down
7 changes: 6 additions & 1 deletion src/components/[guild]/collect/components/Links.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,18 @@ 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()
const { chain, nftAddress } = useCollectNftContext()
const { totalSupply } = useNftDetails(chain, nftAddress)
const { socialLinks } = useGuild()

const blockExplorerPath = NFT_BLOCK_EXPLORER_ADDRESS_PATHS.includes(chain)
? "address"
: "token"

return (
<Section title="Links" spacing={3}>
<Wrap spacingX={6} spacingY={3}>
Expand Down Expand Up @@ -46,7 +51,7 @@ const Links = () => {
)}

<Link
href={`${CHAIN_CONFIG[chain].blockExplorerUrl}/token/${nftAddress}`}
href={`${CHAIN_CONFIG[chain].blockExplorerUrl}/${blockExplorerPath}/${nftAddress}`}
isExternal
colorScheme="gray"
fontWeight="medium"
Expand Down
5 changes: 5 additions & 0 deletions src/components/[guild]/collect/hooks/useGuildFee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ const chainsWithOverrides = [
"ARBITRUM",
"OPTIMISM",
"POLYGON",
"INK",
"IOTA",
"SONIC",
"ZERO",
"MANTLE",
]

const useGuildFee = (
Expand Down
2 changes: 2 additions & 0 deletions src/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -84,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,
Expand Down
33 changes: 0 additions & 33 deletions src/middleware.ts

This file was deleted.

5 changes: 5 additions & 0 deletions src/pages/[guild]/collect/[chain]/[address].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ export const topCollectorsSupportedChains = [
"OPTIMISM",
"ARBITRUM",
"SEPOLIA",
"ZKSYNC_ERA",
"LINEA",
"SCROLL",
"BLAST_MAINNET",
"AVALANCHE",
] as const satisfies ContractCallSupportedChain[]

const CollectNftPageContent = ({
Expand Down
6 changes: 6 additions & 0 deletions src/pages/api/nft/collectors/[chain]/[address].ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -33,6 +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/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.
Expand Down
2 changes: 2 additions & 0 deletions src/requirements/WalletActivity/WalletActivityForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const COVALENT_CHAINS = new Set<Chain>([
"SONIC",
"SOPHON",
"ZERO",
"FORM",
])

const walletActivityRequirementTypes: SelectOption[] = [
Expand Down Expand Up @@ -144,6 +145,7 @@ const WalletActivityForm = ({
"SONIC",
"SOPHON",
"ZERO",
"FORM",
]

for (const covalentChain of COVALENT_CHAINS.values()) {
Expand Down
66 changes: 66 additions & 0 deletions src/v2/components/Providers/OAuthResultToast.tsx
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit dad851b

Please sign in to comment.