Skip to content

Commit

Permalink
fix(dcd): resolve around **/AddTokenPanel
Browse files Browse the repository at this point in the history
  • Loading branch information
dominik-stumpf committed Jul 17, 2024
1 parent 333df48 commit 2e331ab
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,34 +26,6 @@ import PoolStep from "./components/PoolStep"
import SetTokenStep from "./components/SetTokenStep"
import TokenAmountStep from "./components/TokenAmountStep"

export enum TokenRewardType {
DYNAMIC_SNAPSHOT = "DYNAMIC_SNAPSHOT",
DYNAMIC_POINTS = "DYNAMIC_POINTS",
STATIC = "STATIC",
}

export type AddTokenFormType = {
poolId: number
multiplier: number
addition: number
chain: Chain
contractAddress: `0x${string}`
tokenAddress: `0x${string}`
name: string
description: string
imageUrl: string
data: {
guildPlatformId: number
}
snapshotId: number
type: TokenRewardType
staticValue?: number
snapshotRequirement?: Extract<
Schemas["RequirementCreationPayload"],
{ type: "GUILD_SNAPSHOT" }
>
}

const AddTokenPanel = ({ onAdd }: AddRewardPanelProps) => {
const methods = useForm<AddTokenFormType>({
mode: "all",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { useFormContext, useWatch } from "react-hook-form"
import ChainPicker from "requirements/common/ChainPicker"
import TokenPicker from "requirements/common/TokenPicker"
import { ERC20_SUPPORTED_CHAINS } from "utils/guildCheckout/constants"
import { AddTokenFormType } from "../AddTokenPanel"
import { AddTokenFormType } from "../types"

const SetTokenStep = ({ onContinue }: { onContinue: () => void }) => {
const chain = useWatch({ name: `chain` })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { useFormContext, useWatch } from "react-hook-form"
import ControlledNumberInput from "requirements/WalletActivity/components/ControlledNumberInput"
import Token from "static/icons/token.svg"
import { MIN_TOKEN_AMOUNT } from "utils/guildCheckout/constants"
import { AddTokenFormType } from "../AddTokenPanel"
import { AddTokenFormType } from "../types"

const StaticAmount = () => {
const { control } = useFormContext<AddTokenFormType>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { useEffect, useState } from "react"
import { useFormContext, useWatch } from "react-hook-form"
import useRolePlatformsOfReward from "rewards/Token/hooks/useRolePlatformsOfReward"
import { PlatformType } from "types"
import { AddTokenFormType, TokenRewardType } from "../AddTokenPanel"
import { AddTokenFormType, TokenRewardType } from "../types"
import DynamicAmount from "./DynamicAmount"

const TokenAmountStep = ({ onContinue }: { onContinue: () => void }) => {
Expand All @@ -34,10 +34,10 @@ const TokenAmountStep = ({ onContinue }: { onContinue: () => void }) => {
(gp) => gp.platformId === PlatformType.ERC20
)

const platformForToken = tokenPlatforms.find(
const platformForToken = tokenPlatforms?.find(
(guildPlatform) =>
guildPlatform.platformGuildData.chain === chain &&
guildPlatform.platformGuildData.tokenAddress.toLowerCase() ===
guildPlatform.platformGuildData?.chain === chain &&
guildPlatform.platformGuildData?.tokenAddress?.toLowerCase() ===
address?.toLowerCase()
)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { Schemas } from "@guildxyz/types"
import { Chain } from "wagmiConfig/chains"

export enum TokenRewardType {
DYNAMIC_SNAPSHOT = "DYNAMIC_SNAPSHOT",
DYNAMIC_POINTS = "DYNAMIC_POINTS",
STATIC = "STATIC",
}

export type AddTokenFormType = {
poolId: number
multiplier: number
addition: number
chain: Chain
contractAddress: `0x${string}`
tokenAddress: `0x${string}`
name: string
description: string
imageUrl: string
data: {
guildPlatformId: number
}
snapshotId: number
type: TokenRewardType
staticValue?: number
snapshotRequirement?: Extract<
Schemas["RequirementCreationPayload"],
{ type: "GUILD_SNAPSHOT" }
>
}

0 comments on commit 2e331ab

Please sign in to comment.