Skip to content

Commit

Permalink
clean up, tscompile
Browse files Browse the repository at this point in the history
  • Loading branch information
aeolianeth committed Dec 8, 2024
1 parent fe9dee7 commit db8901a
Show file tree
Hide file tree
Showing 11 changed files with 146 additions and 145 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { Form, FormInstance } from 'antd'
import ExternalLink from 'components/ExternalLink'
import TooltipLabel from 'components/TooltipLabel'
import { JuiceInput } from 'components/inputs/JuiceTextInput'
import { NftPostPayModalConfig, NftRewardTier } from 'models/nftRewards'
import { NftPostPayModalConfig } from 'models/nftPostPayModal'
import { NftRewardTier } from 'models/nftRewards'
import { CreateCollapse } from 'packages/v2v3/components/Create/components/CreateCollapse/CreateCollapse'
import { OptionalHeader } from 'packages/v2v3/components/Create/components/OptionalHeader'
import { useLockPageRulesWrapper } from 'packages/v2v3/components/Create/hooks/useLockPageRulesWrapper'
Expand Down
49 changes: 22 additions & 27 deletions src/components/NftRewards/RewardsList/AddEditRewardModal.tsx
Original file line number Diff line number Diff line change
@@ -1,35 +1,34 @@
import { Form, Modal, Tooltip } from 'antd'
import { NftFileType, UploadNoStyle } from 'components/inputs/UploadNoStyle'
import { QuestionCircleOutlined } from '@ant-design/icons'
import { Trans, t } from '@lingui/macro'
import {
inputIsIntegerRule,
inputIsValidUrlRule,
inputMustBeEthAddressRule,
inputMustExistRule,
inputNonZeroRule,
} from 'utils/antdRules'
import { useCallback, useEffect, useLayoutEffect, useState } from 'react'

import { CreateCollapse } from 'packages/v2v3/components/Create/components/CreateCollapse/CreateCollapse'
import { DEFAULT_NFT_MAX_SUPPLY } from 'packages/v2v3/constants/nftRewards'
import { Form, Modal, Tooltip } from 'antd'
import InputAccessoryButton from 'components/buttons/InputAccessoryButton'
import { WarningCallout } from 'components/Callout/WarningCallout'
import { EthAddressInput } from 'components/inputs/EthAddressInput'
import FormattedNumberInput from 'components/inputs/FormattedNumberInput'
import InputAccessoryButton from 'components/buttons/InputAccessoryButton'
import { JuiceInput } from 'components/inputs/JuiceTextInput'
import { JuiceSwitch } from 'components/inputs/JuiceSwitch'
import { JuiceTextArea } from 'components/inputs/JuiceTextArea'
import { NftRewardTier } from 'models/nftRewards'
import { NftRewardsData } from 'redux/slices/shared/v2ProjectTypes'
import { OptionalHeader } from 'packages/v2v3/components/Create/components/OptionalHeader'
import { JuiceInput } from 'components/inputs/JuiceTextInput'
import PrefixedInput from 'components/inputs/PrefixedInput'
import { QuestionCircleOutlined } from '@ant-design/icons'
import { UploadRequestOption } from 'rc-upload/lib/interface'
import { NftFileType, UploadNoStyle } from 'components/inputs/UploadNoStyle'
import { VIDEO_FILE_TYPES } from 'constants/fileTypes'
import { WarningCallout } from 'components/Callout/WarningCallout'
import { ipfsGatewayUrl } from 'utils/ipfs'
import { pinFile } from 'lib/api/ipfs'
import random from 'lodash/random'
import { NftRewardTier } from 'models/nftRewards'
import { CreateCollapse } from 'packages/v2v3/components/Create/components/CreateCollapse/CreateCollapse'
import { OptionalHeader } from 'packages/v2v3/components/Create/components/OptionalHeader'
import { DEFAULT_NFT_MAX_SUPPLY } from 'packages/v2v3/constants/nftRewards'
import { UploadRequestOption } from 'rc-upload/lib/interface'
import { useCallback, useEffect, useLayoutEffect, useState } from 'react'
import { NftRewardsData } from 'redux/slices/shared/v2ProjectTypes'
import {
inputIsIntegerRule,
inputIsValidUrlRule,
inputMustBeEthAddressRule,
inputMustExistRule,
inputNonZeroRule,
} from 'utils/antdRules'
import { withHttps } from 'utils/externalLink'
import { ipfsGatewayUrl } from 'utils/ipfs'

interface AddEditRewardModalFormProps {
fileUrl: string
Expand Down Expand Up @@ -247,11 +246,7 @@ export const AddEditRewardModal = ({
rules={[inputMustExistRule({ label: t`Minimum Contribution` })]}
>
<FormattedNumberInput
accessory={
<InputAccessoryButton
content={currencySymbol}
/>
}
accessory={<InputAccessoryButton content={currencySymbol} />}
/>
</Form.Item>
<Form.Item>
Expand Down
15 changes: 8 additions & 7 deletions src/components/NftRewards/RewardsList/RewardItem.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import { DeleteOutlined, EditOutlined, LinkOutlined } from '@ant-design/icons'
import { Trans, t } from '@lingui/macro'

import EthereumAddress from 'components/EthereumAddress'
import ExternalLink from 'components/ExternalLink'
import { JuiceVideoThumbnailOrImage } from 'components/JuiceVideo/JuiceVideoThumbnailOrImage'
import TooltipLabel from 'components/TooltipLabel'
import round from 'lodash/round'
import { NftRewardTier } from 'models/nftRewards'
import { NftRewardsData } from 'redux/slices/shared/v2ProjectTypes'
import { ReactNode } from 'react'
import { RewardItemButton } from './RewardItemButton'
import TooltipLabel from 'components/TooltipLabel'
import { hasLimitedSupply } from 'utils/nftRewards'
import { NftRewardsData } from 'redux/slices/shared/v2ProjectTypes'
import { isZeroAddress } from 'utils/address'
import { hasLimitedSupply } from 'utils/nftRewards'
import { prettyUrl } from 'utils/url'
import round from 'lodash/round'
import { RewardItemButton } from './RewardItemButton'

const SIGNIFICANT_FIGURE_LIMIT = 6

Expand Down Expand Up @@ -99,7 +98,9 @@ export const RewardItem = ({
<div className="grid grid-cols-2 gap-y-6 gap-x-16">
<RewardStatLine
title={t`Minimum contribution`}
stat={`${numberUpToPrecisionFormat(contributionFloor)} ${priceCurrencySymbol}`}
stat={`${numberUpToPrecisionFormat(
contributionFloor,
)} ${priceCurrencySymbol}`}
/>
{hasLimitedSupply(maxSupply) && (
<RewardStatLine
Expand Down
19 changes: 9 additions & 10 deletions src/components/NftRewards/RewardsList/RewardsList.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import { createContext, useCallback, useContext, useState } from 'react'

import { AddEditRewardModal } from './AddEditRewardModal'
import { CreateButton } from 'components/buttons/CreateButton/CreateButton'
import { PlusCircleOutlined } from '@ant-design/icons'
import { Trans } from '@lingui/macro'
import { Divider } from 'antd'
import { CreateButton } from 'components/buttons/CreateButton/CreateButton'
import { useModal } from 'hooks/useModal'
import { FormItemInput } from 'models/formItemInput'
import { MAX_NFT_REWARD_TIERS } from 'packages/v2v3/constants/nftRewards'
import { NftRewardTier } from 'models/nftRewards'
import { MAX_NFT_REWARD_TIERS } from 'packages/v2v3/constants/nftRewards'
import { createContext, useCallback, useContext, useState } from 'react'
import { NftRewardsData } from 'redux/slices/shared/v2ProjectTypes'
import { PlusCircleOutlined } from '@ant-design/icons'
import { RewardItem } from './RewardItem'
import { Trans } from '@lingui/macro'
import { sortNftsByContributionFloor } from 'utils/nftRewards'
import { useModal } from 'hooks/useModal'
import { AddEditRewardModal } from './AddEditRewardModal'
import { useRewards } from './hooks/useRewards'
import { RewardItem } from './RewardItem'

const RewardsListContext = createContext<ReturnType<typeof useRewards>>({
rewards: [],
Expand Down Expand Up @@ -116,7 +115,7 @@ export const RewardsList: React.FC<React.PropsWithChildren<RewardsListProps>> &
)}
</div>
<AddEditRewardModal
priceCurrencySymbol={priceCurrencySymbol}
currencySymbol={priceCurrencySymbol}
open={modal.visible}
editingData={selectedReward}
nftRewards={nftRewardsData}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { AddNftCollectionForm } from 'components/NftRewards/AddNftCollectionForm/AddNftCollectionForm'
import { CREATE_FLOW } from 'constants/fathomEvents'
import { PageContext } from '../../Wizard/contexts/PageContext'
import { V2V3_CURRENCY_USD } from 'packages/v2v3/utils/currency'
import { Wizard } from '../../Wizard/Wizard'
import { trackFathomGoal } from 'lib/fathom'
import { useAppSelector } from 'redux/hooks/useAppSelector'
import { V2V3_CURRENCY_USD } from 'packages/v2v3/utils/currency'
import { useContext } from 'react'
import { useCreateFlowNftRewardsForm } from './hooks/useCreateFlowNftRewardsForm'
import { useAppSelector } from 'redux/hooks/useAppSelector'
import { useSetCreateFurthestPageReached } from 'redux/hooks/useEditingCreateFurthestPageReached'
import { PageContext } from '../../Wizard/contexts/PageContext'
import { Wizard } from '../../Wizard/Wizard'
import { useCreateFlowNftRewardsForm } from './hooks/useCreateFlowNftRewardsForm'

export function NftRewardsPage() {
const { goToNextPage } = useContext(PageContext)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { useCallback, useMemo } from 'react'

import { NftRewardTier } from 'models/nftRewards'
import { ReviewDescription } from '../ReviewDescription'
import { t } from '@lingui/macro'
import { RewardsList } from 'components/NftRewards/RewardsList/RewardsList'
import { NftRewardTier } from 'models/nftRewards'
import { V2V3_CURRENCY_USD } from 'packages/v2v3/utils/currency'
import { creatingV2ProjectActions } from 'redux/slices/creatingV2Project'
import { formatEnabled } from 'utils/format/formatBoolean'
import { t } from '@lingui/macro'
import { useCallback, useMemo } from 'react'
import { useAppDispatch } from 'redux/hooks/useAppDispatch'
import { useAppSelector } from 'redux/hooks/useAppSelector'
import { creatingV2ProjectActions } from 'redux/slices/creatingV2Project'
import { formatEnabled } from 'utils/format/formatBoolean'
import { v4 } from 'uuid'
import { ReviewDescription } from '../ReviewDescription'

export const RewardsReview = () => {
const { nftRewards: nftRewardsData, fundingCycleMetadata } = useAppSelector(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { AddNftCollectionForm } from 'components/NftRewards/AddNftCollectionForm/AddNftCollectionForm'
import { CREATE_FLOW } from 'constants/fathomEvents'
import { NATIVE_TOKEN_SYMBOLS } from 'juice-sdk-core'
import { PageContext } from '../../Wizard/contexts/PageContext'
import { SUPPORTED_JB_MULTITERMINAL_ADDRESS } from 'packages/v4/hooks/useLaunchProjectTx'
import { Wizard } from '../../Wizard/Wizard'
import { JBChainId, NATIVE_TOKEN_SYMBOLS } from 'juice-sdk-core'
import { trackFathomGoal } from 'lib/fathom'
import { useContext } from 'react'
import { useAppSelector } from 'redux/hooks/useAppSelector'
import { useSetCreateFurthestPageReached } from 'redux/hooks/useEditingCreateFurthestPageReached'
import { useChainId } from 'wagmi'
import { useContext } from 'react'
import { PageContext } from '../../Wizard/contexts/PageContext'
import { Wizard } from '../../Wizard/Wizard'
import { useCreateFlowNftRewardsForm } from './hooks/useCreateFlowNftRewardsForm'
import { useSetCreateFurthestPageReached } from 'redux/hooks/useEditingCreateFurthestPageReached'

export function NftRewardsPage() {
const { goToNextPage } = useContext(PageContext)
Expand All @@ -26,8 +25,6 @@ export function NftRewardsPage() {
useSetCreateFurthestPageReached('nftRewards')

const chainId = useChainId()
const chainIdStr =
chainId?.toString() as keyof typeof SUPPORTED_JB_MULTITERMINAL_ADDRESS

return (
<AddNftCollectionForm
Expand All @@ -36,7 +33,7 @@ export function NftRewardsPage() {
postPayModalData={postPayModalData}
nftRewardsData={nftRewardsData}
okButton={<Wizard.Page.ButtonControl />}
priceCurrencySymbol={NATIVE_TOKEN_SYMBOLS[chainIdStr]}
priceCurrencySymbol={NATIVE_TOKEN_SYMBOLS[chainId as JBChainId]}
onFinish={() => {
goToNextPage?.()
trackFathomGoal(CREATE_FLOW.NFT_NEXT_CTA)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import { useCallback, useMemo } from 'react'

import { NATIVE_TOKEN_SYMBOLS } from 'juice-sdk-core'
import { NftRewardTier } from 'models/nftRewards'
import { ReviewDescription } from '../ReviewDescription'
import { RewardsList } from 'components/NftRewards/RewardsList/RewardsList'
import { SUPPORTED_JB_MULTITERMINAL_ADDRESS } from 'packages/v4/hooks/useLaunchProjectTx'
import { creatingV2ProjectActions } from 'redux/slices/creatingV2Project'
import { formatEnabled } from 'utils/format/formatBoolean'
import { t } from '@lingui/macro'
import { RewardsList } from 'components/NftRewards/RewardsList/RewardsList'
import { JBChainId, NATIVE_TOKEN_SYMBOLS } from 'juice-sdk-core'
import { NftRewardTier } from 'models/nftRewards'
import { useCallback, useMemo } from 'react'
import { useAppDispatch } from 'redux/hooks/useAppDispatch'
import { useAppSelector } from 'redux/hooks/useAppSelector'
import { useChainId } from 'wagmi'
import { creatingV2ProjectActions } from 'redux/slices/creatingV2Project'
import { formatEnabled } from 'utils/format/formatBoolean'
import { v4 } from 'uuid'
import { useChainId } from 'wagmi'
import { ReviewDescription } from '../ReviewDescription'

export const RewardsReview = () => {
const { nftRewards: nftRewardsData, fundingCycleMetadata } = useAppSelector(
Expand Down Expand Up @@ -70,13 +68,11 @@ export const RewardsReview = () => {
}, [nftRewardsData.flags.preventOverspending])

const chainId = useChainId()
const chainIdStr =
chainId?.toString() as keyof typeof SUPPORTED_JB_MULTITERMINAL_ADDRESS

return (
<div className="flex flex-col gap-12">
<RewardsList
priceCurrencySymbol={NATIVE_TOKEN_SYMBOLS[chainIdStr]}
priceCurrencySymbol={NATIVE_TOKEN_SYMBOLS[chainId as JBChainId]}
nftRewardsData={nftRewardsData}
value={rewards}
onChange={setRewards}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,35 @@
import { waitForTransactionReceipt } from '@wagmi/core'
import { JUICEBOX_MONEY_PROJECT_METADATA_DOMAIN } from 'constants/metadataDomain'
import { TxHistoryContext } from 'contexts/Transaction/TxHistoryContext'
import { useWallet } from 'hooks/Wallet'
import {
DEFAULT_MEMO,
NATIVE_TOKEN,
NATIVE_TOKEN_DECIMALS,
} from 'juice-sdk-core'
import {
JBChainId,
jbPricesAddress,
useJBContractContext,
useWriteJb721TiersHookProjectDeployerLaunchProjectFor
useWriteJb721TiersHookProjectDeployerLaunchProjectFor,
} from 'juice-sdk-react'
import { isValidMustStartAtOrAfter } from 'packages/v2v3/utils/fundingCycle'
import {
JBDeploy721TiersHookConfig,
LaunchProjectWithNftsTxArgs,
} from 'packages/v4/models/nfts'
import { wagmiConfig } from 'packages/v4/wagmiConfig'
import { useContext } from 'react'
import { DEFAULT_MUST_START_AT_OR_AFTER } from 'redux/slices/shared/v2ProjectDefaultState'
import { ipfsUri } from 'utils/ipfs'
import { Address, WaitForTransactionReceiptReturnType, zeroAddress } from 'viem'
import {
arbitrumSepolia,
baseSepolia,
optimismSepolia,
sepolia,
} from 'viem/chains'
import { useChainId } from 'wagmi'
import {
LaunchV2V3ProjectArgs,
transformV2V3CreateArgsToV4,
Expand All @@ -23,17 +40,6 @@ import {
SUPPORTED_JB_MULTITERMINAL_ADDRESS,
} from '../../useLaunchProjectTx'

import { waitForTransactionReceipt } from '@wagmi/core'
import { JUICEBOX_MONEY_PROJECT_METADATA_DOMAIN } from 'constants/metadataDomain'
import { TxHistoryContext } from 'contexts/Transaction/TxHistoryContext'
import { useWallet } from 'hooks/Wallet'
import { isValidMustStartAtOrAfter } from 'packages/v2v3/utils/fundingCycle'
import { wagmiConfig } from 'packages/v4/wagmiConfig'
import { useContext } from 'react'
import { DEFAULT_MUST_START_AT_OR_AFTER } from 'redux/slices/shared/v2ProjectDefaultState'
import { ipfsUri } from 'utils/ipfs'
import { useChainId } from 'wagmi'

/**
* Return the project ID created from a `launchProjectFor` transaction.
* @param txReceipt receipt of `launchProjectFor` transaction
Expand All @@ -53,10 +59,10 @@ export const getProjectIdFromNftLaunchReceipt = (
* @todo not ideal to hardcode these addresses
*/
export const SUPPORTED_JB_721_TIER_STORE = {
'84532': '0x4DeF0AA5B9CA095d11705284221b2878731ab4EF' as Address,
'421614': '0x4DeF0AA5B9CA095d11705284221b2878731ab4EF' as Address,
'11155111': '0x4DeF0AA5B9CA095d11705284221b2878731ab4EF' as Address,
'11155420': '0x4DeF0AA5B9CA095d11705284221b2878731ab4EF' as Address,
[sepolia.id]: '0x4DeF0AA5B9CA095d11705284221b2878731ab4EF' as Address,
[optimismSepolia.id]: '0x4DeF0AA5B9CA095d11705284221b2878731ab4EF' as Address,
[arbitrumSepolia.id]: '0x4DeF0AA5B9CA095d11705284221b2878731ab4EF' as Address,
[baseSepolia.id]: '0x4DeF0AA5B9CA095d11705284221b2878731ab4EF' as Address,
}

export function useLaunchProjectWithNftsTx() {
Expand All @@ -65,17 +71,15 @@ export function useLaunchProjectWithNftsTx() {

const { userAddress } = useWallet()
const chainId = useChainId()
const chainIdStr =
chainId?.toString() as keyof typeof SUPPORTED_JB_MULTITERMINAL_ADDRESS

const defaultJBController = chainId
? SUPPORTED_JB_CONTROLLER_ADDRESS[chainIdStr]
? SUPPORTED_JB_CONTROLLER_ADDRESS[chainId as JBChainId]
: undefined
const defaultJBETHPaymentTerminal = chainId
? SUPPORTED_JB_MULTITERMINAL_ADDRESS[chainIdStr]
? SUPPORTED_JB_MULTITERMINAL_ADDRESS[chainId as JBChainId]
: undefined
const JBTiered721DelegateStoreAddress = chainId
? SUPPORTED_JB_721_TIER_STORE[chainIdStr]
? SUPPORTED_JB_721_TIER_STORE[chainId as JBChainId]
: undefined

const { writeContractAsync: writeLaunchProject } =
Expand Down Expand Up @@ -146,7 +150,7 @@ export function useLaunchProjectWithNftsTx() {
tiersConfig: {
currency,
decimals: NATIVE_TOKEN_DECIMALS,
prices: jbPricesAddress[chainIdStr],
prices: jbPricesAddress[chainId as JBChainId],
tiers,
},
reserveBeneficiary: zeroAddress,
Expand Down
Loading

0 comments on commit db8901a

Please sign in to comment.