diff --git a/src/components/Create/components/pages/PayoutsPage/components/CreateFlowPayoutsTable.tsx b/src/components/Create/components/pages/PayoutsPage/components/CreateFlowPayoutsTable.tsx index 0dfad91314..637af68cbc 100644 --- a/src/components/Create/components/pages/PayoutsPage/components/CreateFlowPayoutsTable.tsx +++ b/src/components/Create/components/pages/PayoutsPage/components/CreateFlowPayoutsTable.tsx @@ -10,7 +10,7 @@ import { V2V3CurrencyName, getV2V3CurrencyOption } from 'utils/v2v3/currency' import { MAX_DISTRIBUTION_LIMIT } from 'utils/v2v3/math' import { usePayoutsForm } from '../hooks/usePayoutsForm' -export const DEFAULT_CURRENCY_NAME = CURRENCY_METADATA.ETH.name +const DEFAULT_CURRENCY_NAME = CURRENCY_METADATA.ETH.name export function CreateFlowPayoutsTable({ onFinish, diff --git a/src/components/Create/components/pages/PayoutsPage/components/PayoutsList.tsx b/src/components/Create/components/pages/PayoutsPage/components/PayoutsList.tsx deleted file mode 100644 index b07c2cf800..0000000000 --- a/src/components/Create/components/pages/PayoutsPage/components/PayoutsList.tsx +++ /dev/null @@ -1,136 +0,0 @@ -import { t } from '@lingui/macro' -import { - Allocation, - AllocationSplit, -} from 'components/v2v3/shared/Allocation/Allocation' -import { OwnerPayoutCard } from 'components/v2v3/shared/PayoutCard/OwnerPayoutCard' -import { PayoutCard } from 'components/v2v3/shared/PayoutCard/PayoutCard' -import { BigNumber } from 'ethers' -import { FormItemInput } from 'models/formItemInput' -import { PayoutsSelection } from 'models/payoutsSelection' -import { V2V3CurrencyOption } from 'models/v2v3/currencyOption' -import { useCallback, useMemo } from 'react' -import { useEditingDistributionLimit } from 'redux/hooks/useEditingDistributionLimit' -import { fromWad, parseWad } from 'utils/format/formatNumber' -import { ceilIfCloseToNextInteger } from 'utils/math' -import { totalSplitsPercent } from 'utils/splits' -import { V2V3_CURRENCY_ETH } from 'utils/v2v3/currency' -import { amountFromPercent } from 'utils/v2v3/distributions' -import { MAX_DISTRIBUTION_LIMIT } from 'utils/v2v3/math' - -export const PayoutsList = ( - props: FormItemInput & { - payoutsSelection: PayoutsSelection - isEditable?: boolean - }, -) => { - const [distributionLimit, setDistributionLimit] = - useEditingDistributionLimit() - - const totalPercent = useMemo( - () => (props.value ? totalSplitsPercent(props.value) : 0), - [props.value], - ) - - const availableModes: Set<'amount' | 'percentage'> = useMemo( - () => - new Set( - props.payoutsSelection === 'amounts' ? ['amount'] : ['percentage'], - ), - [props.payoutsSelection], - ) - - const setTotalAllocationAmount = useCallback( - (total: BigNumber) => { - setDistributionLimit({ - amount: total, - currency: distributionLimit?.currency ?? V2V3_CURRENCY_ETH, - }) - }, - [distributionLimit, setDistributionLimit], - ) - - const setCurrency = useCallback( - (currency: V2V3CurrencyOption) => { - setDistributionLimit({ - amount: distributionLimit?.amount ?? BigNumber.from(0), - currency, - }) - }, - [distributionLimit, setDistributionLimit], - ) - - const onOwnerPayoutDeleted = useCallback(() => { - if (!distributionLimit?.amount) return - const totalAmount = parseFloat(fromWad(distributionLimit.amount)) - const ownerPayoutAmount = totalAmount - (totalPercent / 100) * totalAmount - const totalAmountAfterRemoval = Math.max(0, totalAmount - ownerPayoutAmount) - - const adjustedAllocations = (props.value ?? []).map(alloc => { - const currentAmount = amountFromPercent({ - percent: alloc.percent, - amount: totalAmount.toString(), - }) - const newPercent = (currentAmount / totalAmountAfterRemoval) * 100 - return { ...alloc, percent: newPercent } - }) - props.onChange?.(adjustedAllocations) - setTotalAllocationAmount(parseWad(totalAmountAfterRemoval)) - }, [distributionLimit?.amount, props, setTotalAllocationAmount, totalPercent]) - - const hasAllocations = - !!props.value?.length || - (distributionLimit?.amount.gt(0) && - distributionLimit.amount.lt(MAX_DISTRIBUTION_LIMIT)) - - const addButtonSize = - !hasAllocations && props.payoutsSelection === 'amounts' ? 'large' : 'small' - - return ( - -
- {(props.payoutsSelection === 'percentages' || - (distributionLimit && !distributionLimit.amount.eq(0))) && - ceilIfCloseToNextInteger(totalPercent) < 100 ? ( - - ) : null} - - {( - modal, - { allocations, removeAllocation, setSelectedAllocation }, - ) => ( - <> - {allocations.map(allocation => ( - removeAllocation(allocation.id)} - onClick={() => { - setSelectedAllocation(allocation) - modal.open() - }} - /> - ))} - - )} - -
-
- ) -} diff --git a/src/components/Create/components/pages/PayoutsPage/hooks/useFundingTarget.ts b/src/components/Create/components/pages/PayoutsPage/hooks/useFundingTarget.ts deleted file mode 100644 index fc40aa23b6..0000000000 --- a/src/components/Create/components/pages/PayoutsPage/hooks/useFundingTarget.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { useEditingDistributionLimit } from 'redux/hooks/useEditingDistributionLimit' -import { formatFundingTarget } from 'utils/format/formatFundingTarget' - -export const useFundingTarget = () => { - const [distributionLimit] = useEditingDistributionLimit() - - if (!distributionLimit) return null - - return formatFundingTarget({ - distributionLimitWad: distributionLimit.amount, - distributionLimitCurrency: distributionLimit.currency, - }) -} diff --git a/src/components/DomainBadge.tsx b/src/components/DomainBadge.tsx index ebab4b24bb..ee2c18b5af 100644 --- a/src/components/DomainBadge.tsx +++ b/src/components/DomainBadge.tsx @@ -5,7 +5,7 @@ import { twMerge } from 'tailwind-merge' import { getJuicecrowdUrl } from 'utils/juicecrowd' import { Badge } from './Badge' -export type DomainBadgeProps = { +type DomainBadgeProps = { className?: string domain: string | undefined projectId?: number diff --git a/src/components/v2v3/V2V3Project/ProjectDashboard/components/Cart/components/CartItem/CartItem.tsx b/src/components/v2v3/V2V3Project/ProjectDashboard/components/Cart/components/CartItem/CartItem.tsx index 35a8c50e02..21cc4a2756 100644 --- a/src/components/v2v3/V2V3Project/ProjectDashboard/components/Cart/components/CartItem/CartItem.tsx +++ b/src/components/v2v3/V2V3Project/ProjectDashboard/components/Cart/components/CartItem/CartItem.tsx @@ -5,7 +5,7 @@ import { ReactNode, useMemo } from 'react' import { twMerge } from 'tailwind-merge' import { formatCurrencyAmount } from 'utils/formatCurrencyAmount' -export type CartItemProps = { +type CartItemProps = { className?: string title: ReactNode price: { amount: number; currency: V2V3CurrencyOption } | null diff --git a/src/components/v2v3/V2V3Project/ProjectDashboard/components/CyclesPayoutsPanel/CyclesPayoutsPanel.tsx b/src/components/v2v3/V2V3Project/ProjectDashboard/components/CyclesPayoutsPanel/CyclesPayoutsPanel.tsx index 4f9c842011..9b5b511c10 100644 --- a/src/components/v2v3/V2V3Project/ProjectDashboard/components/CyclesPayoutsPanel/CyclesPayoutsPanel.tsx +++ b/src/components/v2v3/V2V3Project/ProjectDashboard/components/CyclesPayoutsPanel/CyclesPayoutsPanel.tsx @@ -5,7 +5,7 @@ import { CurrentUpcomingSubPanel } from './components/CurrentUpcomingSubPanel' import { CyclesTab } from './components/CyclesTab' import { HistorySubPanel } from './components/HistorySubPanel' -export type CyclesSubPanel = { +type CyclesSubPanel = { id: 'current' | 'upcoming' | 'history' name: string } diff --git a/src/components/v2v3/V2V3Project/ProjectDashboard/components/TokensPanel/components/AddTokenToMetamaskButton.tsx b/src/components/v2v3/V2V3Project/ProjectDashboard/components/TokensPanel/components/AddTokenToMetamaskButton.tsx index d08f706184..632c3bfc78 100644 --- a/src/components/v2v3/V2V3Project/ProjectDashboard/components/TokensPanel/components/AddTokenToMetamaskButton.tsx +++ b/src/components/v2v3/V2V3Project/ProjectDashboard/components/TokensPanel/components/AddTokenToMetamaskButton.tsx @@ -3,8 +3,7 @@ import type { MetaMaskInpageProvider } from '@metamask/providers' import { Button } from 'antd' import { V2V3ProjectContext } from 'contexts/v2v3/Project/V2V3ProjectContext' import { providers } from 'ethers' -import { useWallet } from 'hooks/Wallet' -import { useContext, useMemo } from 'react' +import { useContext } from 'react' import { twMerge } from 'tailwind-merge' declare global { @@ -13,15 +12,15 @@ declare global { } } -export const useProviderIsMetamask = () => { - const { signer } = useWallet() - const isMetamask = useMemo(() => { - return signer?.provider.connection.url === 'metamask' - }, [signer]) - return isMetamask -} +// const useProviderIsMetamask = () => { +// const { signer } = useWallet() +// const isMetamask = useMemo(() => { +// return signer?.provider.connection.url === 'metamask' +// }, [signer]) +// return isMetamask +// } -export const useMetamask = () => { +const useMetamask = () => { const ethereum = global?.window?.ethereum if (!ethereum || !ethereum.isMetaMask) return return ethereum as unknown as MetaMaskInpageProvider diff --git a/src/components/v2v3/V2V3Project/ProjectDashboard/hooks/usePayProjectCard.ts b/src/components/v2v3/V2V3Project/ProjectDashboard/hooks/usePayProjectCard.ts index c334ef2a70..c9e1e908e6 100644 --- a/src/components/v2v3/V2V3Project/ProjectDashboard/hooks/usePayProjectCard.ts +++ b/src/components/v2v3/V2V3Project/ProjectDashboard/hooks/usePayProjectCard.ts @@ -6,7 +6,7 @@ import * as Yup from 'yup' import { useProjectCart } from './useProjectCart' import { useProjectContext } from './useProjectContext' -export const PayProjectCardSchema = Yup.object().shape({ +const PayProjectCardSchema = Yup.object().shape({ payAmount: Yup.object() .shape({ amount: Yup.number() diff --git a/src/components/v2v3/V2V3Project/V2V3FundingCycleSection/FundingCycleHistory/utils.ts b/src/components/v2v3/V2V3Project/V2V3FundingCycleSection/FundingCycleHistory/utils.ts deleted file mode 100644 index e09d5ae920..0000000000 --- a/src/components/v2v3/V2V3Project/V2V3FundingCycleSection/FundingCycleHistory/utils.ts +++ /dev/null @@ -1,143 +0,0 @@ -import { BigNumber, Contract, constants } from 'ethers' -import { - V2V3FundingCycle, - V2V3FundingCycleMetadata, -} from 'models/v2v3/fundingCycle' - -// Fill in gaps between first funding cycle of each configuration: -// - derives starts from duration and start time of the first FC of that configuration -// - derives weights from discount rate and weight of the first FC of the configuration -// - derives number by incrementing -// - everything else the same as the first FC of the configuration -const deriveFundingCyclesBetweenEachConfiguration = ({ - firstFCOfEachConfiguration, - currentFundingCycle, -}: { - firstFCOfEachConfiguration: [V2V3FundingCycle, V2V3FundingCycleMetadata][] - currentFundingCycle: V2V3FundingCycle -}) => { - const allFundingCycles: [V2V3FundingCycle, V2V3FundingCycleMetadata][] = [] - - firstFCOfEachConfiguration.forEach( - (firstFundingCycleOfConfiguration, configurationIndex) => { - allFundingCycles.push(firstFundingCycleOfConfiguration) - - const [fundingCycle, fundingCycleMetadata] = - firstFundingCycleOfConfiguration - - const currentReconfigurationStart = fundingCycle.start - const nextConfigurationStart = - configurationIndex < firstFCOfEachConfiguration.length - 1 - ? firstFCOfEachConfiguration[configurationIndex + 1][0].start - : currentFundingCycle.start - const currentDuration = fundingCycle.duration - const currentDiscountRate = fundingCycle.discountRate - - let numInterimFundingCycles: number - - if (currentDuration && !currentDuration.eq(0)) { - numInterimFundingCycles = nextConfigurationStart - .sub(currentReconfigurationStart) - .div(currentDuration) - .toNumber() - } else { - numInterimFundingCycles = 0 - } - - const isLastConfiguration = - configurationIndex === firstFCOfEachConfiguration.length - 1 - - let interimIndex = 0 - - // Initially set to first of the reconfiguration - let interimWeight: BigNumber = fundingCycle.weight - let interimStart: BigNumber = fundingCycle.start - let interimNumber: BigNumber = fundingCycle.number - - while (interimIndex < numInterimFundingCycles) { - // This is to prevent doubling up of an extrapolated FC and the first FC - // of the next configuration. - if ( - !isLastConfiguration && - interimIndex === numInterimFundingCycles - 1 - ) { - break - } - const nextInterimWeight = interimWeight.sub( - interimWeight.mul(currentDiscountRate).div(constants.WeiPerEther), - ) - const nextInterimStart = interimStart.add(currentDuration) - const nextInterimNumber = interimNumber.add(1) - - const nextFundingCycle = { - duration: fundingCycle.duration, - weight: nextInterimWeight, - discountRate: fundingCycle.discountRate, - ballot: fundingCycle.ballot, - number: nextInterimNumber, - configuration: fundingCycle.configuration, - start: nextInterimStart, - metadata: fundingCycle.metadata, - } as V2V3FundingCycle - - interimWeight = nextInterimWeight - interimStart = nextInterimStart - interimNumber = nextInterimNumber - interimIndex += 1 - - allFundingCycles.push([nextFundingCycle, fundingCycleMetadata]) - } - }, - ) - - return allFundingCycles -} - -export const fetchPastFundingCycles = async ({ - projectId, - currentFundingCycle, - JBController, -}: { - projectId: number - currentFundingCycle: V2V3FundingCycle - JBController: Contract -}): Promise<[V2V3FundingCycle, V2V3FundingCycleMetadata][]> => { - const firstFCOfCurrentConfiguration = (await JBController.getFundingCycleOf( - projectId, - currentFundingCycle.configuration, - )) as [V2V3FundingCycle, V2V3FundingCycleMetadata] - - let firstFCOfEachConfiguration: [ - V2V3FundingCycle, - V2V3FundingCycleMetadata, - ][] = [firstFCOfCurrentConfiguration] - - let previousReconfiguration = currentFundingCycle.basedOn - // Get first funding cycle of each configuration using basedOn - while (!previousReconfiguration.eq(BigNumber.from(0))) { - const previousReconfigurationFirstFundingCycle = - (await JBController.getFundingCycleOf( - projectId, - previousReconfiguration, - )) as [V2V3FundingCycle, V2V3FundingCycleMetadata] - - if (previousReconfigurationFirstFundingCycle) { - // Add it to the start of list - firstFCOfEachConfiguration = [ - previousReconfigurationFirstFundingCycle, - ].concat(firstFCOfEachConfiguration) - previousReconfiguration = - previousReconfigurationFirstFundingCycle[0].basedOn - } - } - - const allFundingCycles = deriveFundingCyclesBetweenEachConfiguration({ - firstFCOfEachConfiguration, - currentFundingCycle, - }) - - // Cut off the current funding cycle - const allPastFundingCycles = allFundingCycles.slice(0, -1) - - return allPastFundingCycles.reverse() -} diff --git a/src/components/v2v3/shared/FundingCycleConfigurationDrawers/NftDrawer/index.tsx b/src/components/v2v3/shared/FundingCycleConfigurationDrawers/NftDrawer/index.tsx deleted file mode 100644 index 46da5ce7ad..0000000000 --- a/src/components/v2v3/shared/FundingCycleConfigurationDrawers/NftDrawer/index.tsx +++ /dev/null @@ -1 +0,0 @@ -export * from './NftDrawer' diff --git a/src/constants/fileTypes.ts b/src/constants/fileTypes.ts index b1a17db31b..cd7cf429aa 100644 --- a/src/constants/fileTypes.ts +++ b/src/constants/fileTypes.ts @@ -1,9 +1,9 @@ import { NftFileType } from 'components/inputs/UploadNoStyle' -export const MP4_FILE_TYPE = 'video/mp4' -export const MOV_FILE_TYPE = 'video/quicktime' -export const WEBM_FILE_TYPE = 'video/webm' -export const M4V_FILE_TYPE = 'video/x-m4v' +const MP4_FILE_TYPE = 'video/mp4' +const MOV_FILE_TYPE = 'video/quicktime' +const WEBM_FILE_TYPE = 'video/webm' +const M4V_FILE_TYPE = 'video/x-m4v' export const VIDEO_FILE_TYPES: NftFileType[] = [ MP4_FILE_TYPE, MOV_FILE_TYPE, diff --git a/src/constants/v2v3/ballotStrategies/index.ts b/src/constants/v2v3/ballotStrategies/index.ts index 867e8ca74a..b6ebb97feb 100644 --- a/src/constants/v2v3/ballotStrategies/index.ts +++ b/src/constants/v2v3/ballotStrategies/index.ts @@ -13,21 +13,6 @@ type BallotOption = Record< Partial> > -// based on @jbx-protocol/v2-contracts@4.0.0 -export const DEPRECATED_BALLOT_ADDRESSES: BallotOption = { - ONE_DAY: { - // No 1 day delay contract deployed with original V2 - mainnet: constants.AddressZero, - }, - THREE_DAY: { - mainnet: '0x9733F02d3A1068A11B07516fa2f3C3BaEf90e7eF', - }, - SEVEN_DAY: { - // No 7 day delay contract deployed with original V2 - mainnet: constants.AddressZero, - }, -} - const V2_BALLOT_ADDRESSES: BallotOption = { ONE_DAY: { // No 1 day delay contract deployed with V2 @@ -41,7 +26,7 @@ const V2_BALLOT_ADDRESSES: BallotOption = { }, } -export const BALLOT_ADDRESSES: BallotOption = { +const BALLOT_ADDRESSES: BallotOption = { ONE_DAY: { mainnet: '0xDd9303491328F899796319C2b6bD614324b86314', goerli: '0x9d5687A9A175308773Bb289159Aa61D326E3aDB5', diff --git a/src/hooks/JB721Delegate/contracts/useJB721TieredGovernance.ts b/src/hooks/JB721Delegate/contracts/useJB721TieredGovernance.ts deleted file mode 100644 index ed7cafca8f..0000000000 --- a/src/hooks/JB721Delegate/contracts/useJB721TieredGovernance.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { Contract } from 'ethers' -import { useLoadContractFromAddress } from 'hooks/useLoadContractFromAddress' -import { JB721DelegateVersion } from 'models/v2v3/contracts' -import { useJB721DelegateAbi } from './useJB721DelegateAbi' - -export function useJB721TieredGovernance({ - address, - version, -}: { - address: string | undefined - version: JB721DelegateVersion | undefined -}): Contract | undefined { - const JB721TieredGovernanceJson = useJB721DelegateAbi( - 'JB721TieredGovernance', - address ? version : undefined, // only load if address is given. - ) - return useLoadContractFromAddress({ - address, - abi: JB721TieredGovernanceJson, - }) -} diff --git a/src/utils/antdRules/allocationTotalPercentDoNotExceedTotalRule.ts b/src/utils/antdRules/allocationTotalPercentDoNotExceedTotalRule.ts deleted file mode 100644 index 120f072b9c..0000000000 --- a/src/utils/antdRules/allocationTotalPercentDoNotExceedTotalRule.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { RuleObject } from 'antd/lib/form' -import { AllocationSplit } from 'components/v2v3/shared/Allocation/Allocation' - -export const allocationTotalPercentDoNotExceedTotalRule = () => ({ - validator: (rule: RuleObject, value: unknown) => { - if (value === undefined || value === null) return Promise.resolve() - if (typeof value !== 'object') - return Promise.reject('Invalid type - contact Juicebox Support') - const total = (value as AllocationSplit[]).reduce( - (acc: number, { percent }) => acc + percent, - 0, - ) - if (total > 100) { - return Promise.reject('Total percent cannot exceed 100') - } - return Promise.resolve() - }, -}) diff --git a/src/utils/antdRules/index.ts b/src/utils/antdRules/index.ts index acf854f6c6..a3ac755a81 100644 --- a/src/utils/antdRules/index.ts +++ b/src/utils/antdRules/index.ts @@ -1,5 +1,4 @@ export * from './allocationInputAlreadyExistsRule' -export * from './allocationTotalPercentDoNotExceedTotalRule' export * from './durationMustExistRule' export * from './inputIsIntegerRule' export * from './inputIsValidUrlRule' diff --git a/src/utils/v2v3/fundingCycle.ts b/src/utils/v2v3/fundingCycle.ts index 7e1e4470b7..2168af4a9d 100644 --- a/src/utils/v2v3/fundingCycle.ts +++ b/src/utils/v2v3/fundingCycle.ts @@ -109,19 +109,6 @@ export const getUnsafeV2V3FundingCycleProperties = ( }) } -/** - * Return number of risk indicators for a funding cycle. - * 0 if we deem a project "safe" to contribute to. - */ -export const getV2V3FundingCycleRiskCount = ( - fundingCycle: V2V3FundingCycle, - fundingCycleMetadata: V2V3FundingCycleMetadata, -): number => { - return Object.values( - getUnsafeV2V3FundingCycleProperties(fundingCycle, fundingCycleMetadata), - ).filter(v => v === true).length -} - /** * _mustStartAtOrAfter + _duration > type(uint54).max * @param mustStartAtOrAfter diff --git a/src/utils/v2v3/serializers.ts b/src/utils/v2v3/serializers.ts index d0036a0e51..d09f713751 100644 --- a/src/utils/v2v3/serializers.ts +++ b/src/utils/v2v3/serializers.ts @@ -7,7 +7,7 @@ import { V2V3FundingCycleMetadata, } from 'models/v2v3/fundingCycle' import { V3FundingCycleMetadata } from 'models/v3/fundingCycle' -import { fromWad, parseWad } from 'utils/format/formatNumber' +import { parseWad } from 'utils/format/formatNumber' type V2FundingCycleMetadataStrings = Record< keyof Pick< @@ -210,21 +210,6 @@ export const deserializeV2V3FundingCycleData = ( ballot: serializedFundingCycleData.ballot, // hex, contract address }) -export const serializeFundAccessConstraint = ( - fundAccessConstraint: V2V3FundAccessConstraint, -): SerializedV2V3FundAccessConstraint => { - return { - terminal: fundAccessConstraint.terminal, - token: fundAccessConstraint.token, - distributionLimit: fromWad(fundAccessConstraint.distributionLimit), - distributionLimitCurrency: - fundAccessConstraint.distributionLimitCurrency.toString(), - overflowAllowance: fromWad(fundAccessConstraint.overflowAllowance), - overflowAllowanceCurrency: - fundAccessConstraint.overflowAllowanceCurrency.toString(), - } -} - export const deserializeFundAccessConstraint = ( fundAccessConstraint: SerializedV2V3FundAccessConstraint, ): V2V3FundAccessConstraint => {