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 24, 2025
2 parents f3d6193 + adee4fd commit 918565a
Show file tree
Hide file tree
Showing 13 changed files with 640 additions and 1,543 deletions.
2,024 changes: 530 additions & 1,494 deletions package-lock.json

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions public/networkLogos/sophon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions public/networkLogos/zero.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { consts } from "@guildxyz/types"
import { useAddRewardDiscardAlert } from "components/[guild]/AddRewardButton/hooks/useAddRewardDiscardAlert"
import { useAddRewardContext } from "components/[guild]/AddRewardContext"
import Button from "components/common/Button"
Expand All @@ -7,7 +8,6 @@ import { useAccount } from "wagmi"
import { Chains } from "wagmiConfig/chains"
import NftDataForm, { CreateNftFormType } from "./components/NftDataForm"
import useCreateNft, {
CONTRACT_CALL_SUPPORTED_CHAINS,
ContractCallSupportedChain,
CreateNFTResponse,
} from "./hooks/useCreateNft"
Expand All @@ -17,11 +17,11 @@ type Props = {
}

const getDefaultChain = (chainId: number) =>
(CONTRACT_CALL_SUPPORTED_CHAINS.includes(
(consts.NFTRewardSupportedChains.includes(
Chains[chainId] as ContractCallSupportedChain
)
? Chains[chainId]
: CONTRACT_CALL_SUPPORTED_CHAINS[0]) as ContractCallSupportedChain
: consts.NFTRewardSupportedChains[0]) as ContractCallSupportedChain

const CreateNftForm = ({ onSuccess }: Props) => {
const { isConnected: isEvmConnected, address, chainId } = useAccount()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
Tooltip,
useColorModeValue,
} from "@chakra-ui/react"
import { consts } from "@guildxyz/types"
import {
ArrowSquareOut,
Clock,
Expand All @@ -51,10 +52,7 @@ import { ADDRESS_REGEX } from "utils/guildCheckout/constants"
import { formatUnits } from "viem"
import { useAccount } from "wagmi"
import { CHAIN_CONFIG, Chains } from "wagmiConfig/chains"
import {
CONTRACT_CALL_SUPPORTED_CHAINS,
ContractCallSupportedChain,
} from "../hooks/useCreateNft"
import { ContractCallSupportedChain } from "../hooks/useCreateNft"
import ImagePicker from "./ImagePicker"
import MintPerAddressInput from "./MintPerAddressInput"
import NftTypeInput from "./NftTypeInput"
Expand Down Expand Up @@ -309,7 +307,11 @@ const NftDataForm = ({ isEditMode, submitButton }: Props) => {

<ChainPicker
controlName="chain"
supportedChains={CONTRACT_CALL_SUPPORTED_CHAINS}
supportedChains={
Object.keys(
consts.NFTRewardFactoryAddresses
) as (keyof typeof consts.NFTRewardFactoryAddresses)[]
}
showDivider={false}
isDisabled={isEditMode}
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { usePostHogContext } from "@/components/Providers/PostHogProvider"
import { consts } from "@guildxyz/types"
import { datetimeLocalToIsoString } from "components/[guild]/RolePlatforms/components/EditRewardAvailabilityModal/components/StartEndTimeForm"
import { guildNftRewardMetadataSchema } from "components/[guild]/collect/hooks/useNftDetails"
import useGuild from "components/[guild]/hooks/useGuild"
Expand All @@ -16,45 +17,11 @@ import getEventsFromViemTxReceipt from "utils/getEventsFromViemTxReceipt"
import processViemContractError from "utils/processViemContractError"
import { TransactionReceipt, WriteContractParameters, parseUnits } from "viem"
import { useAccount, usePublicClient, useWalletClient } from "wagmi"
import { CHAIN_CONFIG, Chain, Chains } from "wagmiConfig/chains"
import { CHAIN_CONFIG, Chains } from "wagmiConfig/chains"
import { CreateNftFormType } from "../components/NftDataForm"

export const GUILD_REWARD_NFT_FACTORY_ADDRESSES = {
ETHEREUM: "0x6ee2dd02fbfb71f518827042b6adca242f1ba0b2",
BASE_MAINNET: "0x4205e56a69a0130a9e0828d45d0c84e45340a196",
OPTIMISM: "0xe6e6b676f94a6207882ac92b6014a391766fa96e",
BSC: "0xa445e7d3af54867d14467b44d5487352403d1e59",
CRONOS: "0x6c2c223b84724c4b8fd41ae0142c2369dfa7e319",
POLYGON: "0xc1c23618110277ffe6d529816eb23de42b24cc33",
MANTLE: "0x326f14942f8899406e3224bd63E9f250D275a52e",
ZKSYNC_ERA: "0x2a1eaf11a9753a871b15e2865d8a47cf17dd9450",
LINEA: "0x326f14942f8899406e3224bd63E9f250D275a52e",
CYBER: "0x097E05f7a194a30A482CC9616460498980bE79d3",
ARBITRUM: "0x13ec6B98362E43Add08f7CC4f6befd02fa52eE01",
SCROLL: "0x13ec6B98362E43Add08f7CC4f6befd02fa52eE01",
TAIKO: "0x13ec6B98362E43Add08f7CC4f6befd02fa52eE01",
BLAST_MAINNET: "0x13ec6B98362E43Add08f7CC4f6befd02fa52eE01",
X1: "0x13ec6B98362E43Add08f7CC4f6befd02fa52eE01",
CORE_DAO: "0x13ec6B98362E43Add08f7CC4f6befd02fa52eE01",
METIS: "0x13ec6B98362E43Add08f7CC4f6befd02fa52eE01",
NEON_EVM: "0x13ec6B98362E43Add08f7CC4f6befd02fa52eE01",
POLYGON_ZKEVM: "0x13ec6B98362E43Add08f7CC4f6befd02fa52eE01",
ZETACHAIN: "0x13ec6B98362E43Add08f7CC4f6befd02fa52eE01",
MINT: "0x097E05f7a194a30A482CC9616460498980bE79d3",
MODE: "0x097E05f7a194a30A482CC9616460498980bE79d3",
AVALANCHE: "0x13ec6b98362e43add08f7cc4f6befd02fa52ee01",
LISK: "0x13ec6b98362e43add08f7cc4f6befd02fa52ee01",
INK: "0x13ec6b98362e43add08f7cc4f6befd02fa52ee01",
SEPOLIA: "0xa9e8e62266d449b766d305075248790bdd46facb",
IOTA: "0x097E05f7a194a30A482CC9616460498980bE79d3",
SONIC: "0x070cD1FD4de1ed0259871B7d0b85C0e237702691",
} as const satisfies Partial<Record<Chain, `0x${string}`>>

export const CONTRACT_CALL_SUPPORTED_CHAINS = Object.keys(
GUILD_REWARD_NFT_FACTORY_ADDRESSES
) as (keyof typeof GUILD_REWARD_NFT_FACTORY_ADDRESSES)[]
export type ContractCallSupportedChain =
(typeof CONTRACT_CALL_SUPPORTED_CHAINS)[number]
(typeof consts.NFTRewardSupportedChains)[number]

export enum ContractCallFunction {
// Kept the old one too, we can use it to determine if we need to show the old or the new UI for the availability-related features
Expand Down Expand Up @@ -150,7 +117,7 @@ const useCreateNft = (

const { request } = await publicClient.simulateContract({
abi: guildRewardNFTFacotryAbi,
address: GUILD_REWARD_NFT_FACTORY_ADDRESSES[Chains[chainId]],
address: consts.NFTRewardFactoryAddresses[Chains[chainId]],
functionName: "deployConfigurableNFT",
args: contractCallParams,
})
Expand Down
4 changes: 2 additions & 2 deletions src/components/[guild]/collect/hooks/useGuildFee.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GUILD_REWARD_NFT_FACTORY_ADDRESSES } from "components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddContractCallPanel/components/CreateNftForm/hooks/useCreateNft"
import { consts } from "@guildxyz/types"
import guildRewardNFTFactoryAbi from "static/abis/guildRewardNFTFactory"
import { useReadContract } from "wagmi"
import { Chain, Chains } from "wagmiConfig/chains"
Expand All @@ -23,7 +23,7 @@ const useGuildFee = (
} = useReadContract({
abi: guildRewardNFTFactoryAbi,
chainId: Chains[chain],
address: GUILD_REWARD_NFT_FACTORY_ADDRESSES[chain],
address: consts.NFTRewardFactoryAddresses[chain],
functionName:
contractAddress && chainsWithOverrides.includes(chain)
? "getFeeWithOverrides"
Expand Down
2 changes: 2 additions & 0 deletions src/hooks/useTokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ const TokenApiURLs: Record<Chain, string[]> = {
"https://raw.githubusercontent.com/MagicSea-Finance/tokenlist/main/token.default.json",
],
SONIC: ["https://tokens.coingecko.com/sonic/all.json"],
SOPHON: [],
ZERO: [],
}

const fetchTokens = async ([_, chain]) =>
Expand Down
4 changes: 2 additions & 2 deletions src/pages/api/nft/collectors/[chain]/[address].ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CONTRACT_CALL_SUPPORTED_CHAINS } from "components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddContractCallPanel/components/CreateNftForm/hooks/useCreateNft"
import { consts } from "@guildxyz/types"
import { env } from "env"
import { NextApiHandler } from "next"
import { topCollectorsSupportedChains } from "pages/[guild]/collect/[chain]/[address]"
Expand Down Expand Up @@ -38,7 +38,7 @@ export const alchemyApiUrl: Record<
// TODO: just use Zod.
export const validateNftChain = (value: string | string[]): Chain => {
const valueAsString = value?.toString()?.toUpperCase()
if (!value || !CONTRACT_CALL_SUPPORTED_CHAINS.includes(valueAsString as any))
if (!value || !consts.NFTRewardSupportedChains.includes(valueAsString as any))
return null
return valueAsString as Chain
}
Expand Down
4 changes: 4 additions & 0 deletions src/requirements/WalletActivity/WalletActivityForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ const COVALENT_CHAINS = new Set<Chain>([
"INK",
"IOTA",
"SONIC",
"SOPHON",
"ZERO",
])

const walletActivityRequirementTypes: SelectOption[] = [
Expand Down Expand Up @@ -140,6 +142,8 @@ const WalletActivityForm = ({
"INK",
"IOTA",
"SONIC",
"SOPHON",
"ZERO",
]

for (const covalentChain of COVALENT_CHAINS.values()) {
Expand Down
26 changes: 26 additions & 0 deletions src/static/customChains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -454,3 +454,29 @@ export const ink = {
},
testnet: false,
} as const satisfies Chain

export const zero = {
id: 543210,
name: "Zero",
nativeCurrency: {
decimals: 18,
name: "Ether",
symbol: "ETH",
},
rpcUrls: {
default: { http: ["https://rpc.zerion.io/v1/zero"] },
},
blockExplorers: {
default: {
name: "Blockscout",
url: "https://explorer.zero.network",
},
},
contracts: {
multicall3: {
address: "0x0307F341a18f1FC1f63a7Ceeac970245A08C5a80",
blockCreated: 11517,
},
},
testnet: false,
} as const satisfies Chain
20 changes: 20 additions & 0 deletions src/wagmiConfig/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
scrollAlpha,
taikoKatlaTestnet,
x1,
zero,
} from "static/customChains"
import {
type Chain as ViemChain,
Expand Down Expand Up @@ -67,6 +68,7 @@ import {
sepolia,
shimmer,
sonic,
sophon,
taiko,
worldchain,
x1Testnet,
Expand Down Expand Up @@ -760,6 +762,22 @@ const CHAIN_CONFIG: Record<Chain, GuildChain> = {
dark: "/networkLogos/sonic.svg",
},
},
SOPHON: {
...generateChainConfig(sophon, "/networkLogos/sophon.svg"),
iconUrl: "/networkLogos/sophon.svg",
blockExplorerIconUrl: {
light: "/networkLogos/sophon.svg",
dark: "/networkLogos/sophon.svg",
},
},
ZERO: {
...generateChainConfig(zero, ETH_ICON),
iconUrl: "/networkLogos/zero.svg",
blockExplorerIconUrl: {
light: "/networkLogos/zero.svg",
dark: "/networkLogos/zero.svg",
},
},
}

enum Chains {
Expand Down Expand Up @@ -835,6 +853,8 @@ enum Chains {
INK = ink.id,
IOTA = iota.id,
SONIC = sonic.id,
SOPHON = sophon.id,
ZERO = zero.id,
}

export type Chain = keyof typeof Chains
Expand Down
6 changes: 6 additions & 0 deletions src/wagmiConfig/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
palm,
taikoKatlaTestnet,
x1,
zero,
} from "static/customChains"
import {
http,
Expand Down Expand Up @@ -73,6 +74,7 @@ import {
sepolia,
shimmer,
sonic,
sophon,
taiko,
worldchain,
x1Testnet,
Expand Down Expand Up @@ -200,6 +202,8 @@ export const wagmiConfig = IS_TEST
ink,
iota,
sonic,
sophon,
zero,
],
transports: {
[mainnet.id]: http(),
Expand Down Expand Up @@ -270,6 +274,8 @@ export const wagmiConfig = IS_TEST
[ink.id]: http(),
[iota.id]: http(),
[sonic.id]: http(),
[sophon.id]: http(),
[zero.id]: http(),
},
ssr: true,
connectors: [
Expand Down

0 comments on commit 918565a

Please sign in to comment.