diff --git a/src/packages/v4/components/ProjectDashboard/V4PayRedeemCard/PayProjectModal/hooks/usePayProjectModal/usePayProjectTx.ts b/src/packages/v4/components/ProjectDashboard/V4PayRedeemCard/PayProjectModal/hooks/usePayProjectModal/usePayProjectTx.ts index d8505803e0..1909d8d166 100644 --- a/src/packages/v4/components/ProjectDashboard/V4PayRedeemCard/PayProjectModal/hooks/usePayProjectModal/usePayProjectTx.ts +++ b/src/packages/v4/components/ProjectDashboard/V4PayRedeemCard/PayProjectModal/hooks/usePayProjectModal/usePayProjectTx.ts @@ -1,12 +1,8 @@ +import { waitForTransactionReceipt } from '@wagmi/core' +import { TxHistoryContext } from 'contexts/Transaction/TxHistoryContext' import { FormikHelpers } from 'formik' import { useWallet } from 'hooks/Wallet' import { useCurrencyConverter } from 'hooks/useCurrencyConverter' -import { useProjectSelector } from 'packages/v4/components/ProjectDashboard/redux/hooks' -import { ProjectPayReceipt } from 'packages/v4/views/V4ProjectDashboard/hooks/useProjectPageQueries' -// import { NftRewardsContext } from 'packages/v4/contexts/NftRewards/NftRewardsContext' -// import { useProjectHasErc20 } from 'packages/v4/hooks/useProjectHasErc20' -import { waitForTransactionReceipt } from '@wagmi/core' -import { TxHistoryContext } from 'contexts/Transaction/TxHistoryContext' import { DEFAULT_METADATA, NATIVE_TOKEN } from 'juice-sdk-core' import { useJBContractContext, @@ -14,9 +10,10 @@ import { usePreparePayMetadata, useWriteJbMultiTerminalPay, } from 'juice-sdk-react' -// import { useProjectHasErc20 } from 'packages/v2v3/hooks/useProjectHasErc20' +import { useProjectSelector } from 'packages/v4/components/ProjectDashboard/redux/hooks' import { useV4NftRewards } from 'packages/v4/contexts/V4NftRewards/V4NftRewardsProvider' import { V4_CURRENCY_ETH } from 'packages/v4/utils/currency' +import { ProjectPayReceipt } from 'packages/v4/views/V4ProjectDashboard/hooks/useProjectPageQueries' import { wagmiConfig } from 'packages/v4/wagmiConfig' import { useCallback, useContext, useMemo } from 'react' import { buildPaymentMemo } from 'utils/buildPaymentMemo' @@ -134,10 +131,15 @@ export const usePayProjectTx = ({ beneficiary, 0n, memo, - // metadata ?? DEFAULT_METADATA, - DEFAULT_METADATA, + metadata ?? DEFAULT_METADATA, ] as const + // SIMULATE TRANSACTION: + // const encodedData = encodeFunctionData({ + // abi: jbMultiTerminalAbi, // ABI of the contract + // functionName: 'pay', + // args, + // }) try { const hash = await writePay({ address: contracts.primaryNativeTerminal.data, diff --git a/src/packages/v4/hooks/useLaunchProjectWithNftsTx.ts b/src/packages/v4/hooks/useLaunchProjectWithNftsTx.ts index bf24a7ccc1..3ffd953e5b 100644 --- a/src/packages/v4/hooks/useLaunchProjectWithNftsTx.ts +++ b/src/packages/v4/hooks/useLaunchProjectWithNftsTx.ts @@ -1,4 +1,8 @@ -import { DEFAULT_MEMO, NATIVE_TOKEN, NATIVE_TOKEN_DECIMALS } from 'juice-sdk-core' +import { + DEFAULT_MEMO, + NATIVE_TOKEN, + NATIVE_TOKEN_DECIMALS, +} from 'juice-sdk-core' import { jbPricesAddress, useJBContractContext, @@ -23,7 +27,7 @@ import { import { LaunchTxOpts, SUPPORTED_JB_CONTROLLER_ADDRESS, - SUPPORTED_JB_MULTITERMINAL_ADDRESS + SUPPORTED_JB_MULTITERMINAL_ADDRESS, } from './useLaunchProjectTx' import { waitForTransactionReceipt } from '@wagmi/core' @@ -51,8 +55,7 @@ function createSalt() { export const getProjectIdFromNftLaunchReceipt = ( txReceipt: WaitForTransactionReceiptReturnType, ): number => { - const projectIdHex: string | undefined = - txReceipt?.logs[0]?.topics?.[1] + const projectIdHex: string | undefined = txReceipt?.logs[0]?.topics?.[1] if (!projectIdHex) return 0 const projectId = parseInt(projectIdHex, 16) @@ -80,7 +83,8 @@ export function useLaunchProjectWithNftsTx() { const { userAddress } = useWallet() const chainId = useChainId() - const chainIdStr = chainId?.toString() as keyof typeof SUPPORTED_JB_MULTITERMINAL_ADDRESS + const chainIdStr = + chainId?.toString() as keyof typeof SUPPORTED_JB_MULTITERMINAL_ADDRESS const defaultJBController = chainId ? SUPPORTED_JB_CONTROLLER_ADDRESS[chainIdStr] @@ -93,7 +97,7 @@ export function useLaunchProjectWithNftsTx() { : undefined const { writeContractAsync: writeLaunchProject } = - useWriteJb721TiersHookProjectDeployerLaunchProjectFor() + useWriteJb721TiersHookProjectDeployerLaunchProjectFor() return async ( { diff --git a/src/packages/v4/utils/editRuleset.ts b/src/packages/v4/utils/editRuleset.ts index ca46980f54..38f28dbd09 100644 --- a/src/packages/v4/utils/editRuleset.ts +++ b/src/packages/v4/utils/editRuleset.ts @@ -1,9 +1,9 @@ -import { NATIVE_TOKEN } from "juice-sdk-core"; -import round from "lodash/round"; -import { issuanceRateFrom } from "packages/v2v3/utils/math"; -import { parseWad } from "utils/format/formatNumber"; -import { otherUnitToSeconds } from "utils/format/formatTime"; -import { EditCycleFormFields } from "../views/V4ProjectSettings/EditCyclePage/EditCycleFormFields"; +import { NATIVE_TOKEN } from 'juice-sdk-core' +import round from 'lodash/round' +import { issuanceRateFrom } from 'packages/v2v3/utils/math' +import { parseWad } from 'utils/format/formatNumber' +import { otherUnitToSeconds } from 'utils/format/formatTime' +import { EditCycleFormFields } from '../views/V4ProjectSettings/EditCyclePage/EditCycleFormFields' export function transformEditCycleFormFieldsToTxArgs({ formValues, @@ -11,21 +11,21 @@ export function transformEditCycleFormFieldsToTxArgs({ tokenAddress, projectId, }: { - formValues: EditCycleFormFields; - primaryNativeTerminal: `0x${string}`; - tokenAddress: `0x${string}`; - projectId: bigint; + formValues: EditCycleFormFields + primaryNativeTerminal: `0x${string}` + tokenAddress: `0x${string}` + projectId: bigint }) { - const now = round(new Date().getTime() / 1000); - const mustStartAtOrAfter = now; + const now = round(new Date().getTime() / 1000) + const mustStartAtOrAfter = now const duration = otherUnitToSeconds({ duration: formValues.duration, unit: formValues.durationUnit.value, }) - const weight = BigInt(issuanceRateFrom(formValues.issuanceRate.toString())); - const decayPercent = round(formValues.decayPercent * 10000000); - const approvalHook = formValues.approvalHook; + const weight = BigInt(issuanceRateFrom(formValues.issuanceRate.toString())) + const decayPercent = round(formValues.decayPercent * 10000000) + const approvalHook = formValues.approvalHook const rulesetConfigurations = [ { @@ -54,15 +54,15 @@ export function transformEditCycleFormFieldsToTxArgs({ useTotalSurplusForRedemptions: false, // Defaulting to false as it's not in formValues useDataHookForPay: false, // Defaulting to false as it's not in formValues useDataHookForRedeem: false, // Defaulting to false as it's not in formValues - dataHook: "0x0000000000000000000000000000000000000000" as `0x${string}`, // Defaulting to a null address + dataHook: '0x0000000000000000000000000000000000000000' as `0x${string}`, // Defaulting to a null address metadata: 0, // Assuming no additional metadata is provided - allowCrosschainSuckerExtension: false + allowCrosschainSuckerExtension: false, }, splitGroups: [ { groupId: BigInt(NATIVE_TOKEN), - splits: formValues.payoutSplits.map((split) => ({ + splits: formValues.payoutSplits.map(split => ({ preferAddToBalance: Boolean(split.preferAddToBalance), percent: Number(split.percent.value), projectId: BigInt(split.projectId), @@ -73,7 +73,7 @@ export function transformEditCycleFormFieldsToTxArgs({ }, { groupId: BigInt(1), - splits: formValues.reservedTokensSplits.map((split) => ({ + splits: formValues.reservedTokensSplits.map(split => ({ preferAddToBalance: Boolean(split.preferAddToBalance), percent: Number(split.percent.value), projectId: BigInt(split.projectId), @@ -103,11 +103,7 @@ export function transformEditCycleFormFieldsToTxArgs({ }, ], }, - ]; + ] - return [ - projectId, - rulesetConfigurations, - formValues.memo ?? "", - ] as const; + return [projectId, rulesetConfigurations, formValues.memo ?? ''] as const } diff --git a/src/packages/v4/utils/launchProjectTransformers.ts b/src/packages/v4/utils/launchProjectTransformers.ts index d5cfb39edb..41104cf698 100644 --- a/src/packages/v4/utils/launchProjectTransformers.ts +++ b/src/packages/v4/utils/launchProjectTransformers.ts @@ -127,7 +127,7 @@ type LaunchProjectJBSplit = Omit & { percent: number } export type LaunchV4ProjectGroupedSplit = Omit< V4GroupedSplits, 'splits' | 'groupId' -> & { splits: LaunchProjectJBSplit[], groupId: bigint } +> & { splits: LaunchProjectJBSplit[]; groupId: bigint } export function transformV2V3SplitsToV4({ v2v3Splits, @@ -135,8 +135,7 @@ export function transformV2V3SplitsToV4({ v2v3Splits: V2V3GroupedSplits[] }): LaunchV4ProjectGroupedSplit[] { return v2v3Splits.map(group => ({ - groupId: - group.group === SplitGroup.ETHPayout ? BigInt(NATIVE_TOKEN) : 1n, // TODO dont hardcode reserved token group as 1n + groupId: group.group === SplitGroup.ETHPayout ? BigInt(NATIVE_TOKEN) : 1n, // TODO dont hardcode reserved token group as 1n splits: group.splits.map(split => ({ preferAddToBalance: Boolean(split.preferClaimed), percent: split.percent, diff --git a/src/packages/v4/views/V4ProjectDashboard/V4ProjectTabs/V4ActivityPanel/V4ActivityList.tsx b/src/packages/v4/views/V4ProjectDashboard/V4ProjectTabs/V4ActivityPanel/V4ActivityList.tsx index e5d99c2d2d..a6f83fd979 100644 --- a/src/packages/v4/views/V4ProjectDashboard/V4ProjectTabs/V4ActivityPanel/V4ActivityList.tsx +++ b/src/packages/v4/views/V4ProjectDashboard/V4ProjectTabs/V4ActivityPanel/V4ActivityList.tsx @@ -1,23 +1,20 @@ import { t } from '@lingui/macro' import Loading from 'components/Loading' -import { - NativeTokenValue, - useJBContractContext, - useJBTokenContext, -} from 'juice-sdk-react' +import RichNote from 'components/RichNote/RichNote' +import { NativeTokenValue, useJBContractContext } from 'juice-sdk-react' import { OrderDirection, PayEvent_OrderBy, PayEventsDocument, } from 'packages/v4/graphql/client/graphql' import { useSubgraphQuery } from 'packages/v4/graphql/useSubgraphQuery' +import React from 'react' import { ActivityEvent } from './activityEventElems/ActivityElement' import { ActivityOptions } from './ActivityOptions' import { PayEvent } from './models/ActivityEvents' import { transformPayEventsRes } from './utils/transformEventsData' export function V4ActivityList() { - const { token } = useJBTokenContext() const { projectId } = useJBContractContext() // TODO: pageSize (pagination) @@ -32,7 +29,10 @@ export function V4ActivityList() { }, }) - const payEvents = transformPayEventsRes(payEventsData) ?? [] + const payEvents = React.useMemo( + () => transformPayEventsRes(payEventsData) ?? [], + [payEventsData], + ) return (
@@ -65,12 +65,7 @@ export function V4ActivityList() { } - extra={ - - bought {event.beneficiaryTokenCount?.format(6)}{' '} - {token.data?.symbol ?? 'tokens'} - - } + extra={} />
) diff --git a/src/packages/v4/views/V4ProjectDashboard/V4ProjectTabs/V4ActivityPanel/models/ActivityEvents.ts b/src/packages/v4/views/V4ProjectDashboard/V4ProjectTabs/V4ActivityPanel/models/ActivityEvents.ts index f960855f98..3e3c623afb 100644 --- a/src/packages/v4/views/V4ProjectDashboard/V4ProjectTabs/V4ActivityPanel/models/ActivityEvents.ts +++ b/src/packages/v4/views/V4ProjectDashboard/V4ProjectTabs/V4ActivityPanel/models/ActivityEvents.ts @@ -7,6 +7,7 @@ export type PayEvent = { amountUSD: Ether | undefined beneficiary: Address beneficiaryTokenCount?: JBProjectToken + note: string timestamp: number txHash: string } diff --git a/src/packages/v4/views/V4ProjectDashboard/V4ProjectTabs/V4ActivityPanel/utils/transformEventsData.ts b/src/packages/v4/views/V4ProjectDashboard/V4ProjectTabs/V4ActivityPanel/utils/transformEventsData.ts index 243a00239d..4083ca7de4 100644 --- a/src/packages/v4/views/V4ProjectDashboard/V4ProjectTabs/V4ActivityPanel/utils/transformEventsData.ts +++ b/src/packages/v4/views/V4ProjectDashboard/V4ProjectTabs/V4ActivityPanel/utils/transformEventsData.ts @@ -9,11 +9,14 @@ export function transformPayEventsRes( return { id: event.id, amount: new Ether(BigInt(event.amount)), - amountUSD: event.amountUSD ? new Ether(BigInt(event.amountUSD)) : undefined, + amountUSD: event.amountUSD + ? new Ether(BigInt(event.amountUSD)) + : undefined, beneficiary: event.beneficiary, beneficiaryTokenCount: new JBProjectToken( BigInt(event.beneficiaryTokenCount), ), + note: event.note, timestamp: event.timestamp, txHash: event.txHash, } diff --git a/src/packages/v4/views/V4ProjectDashboard/V4ProjectTabs/V4NftRewardsPanel/RedeemNftsSection/RedeemNftsSection.tsx b/src/packages/v4/views/V4ProjectDashboard/V4ProjectTabs/V4NftRewardsPanel/RedeemNftsSection/RedeemNftsSection.tsx index 443e3c7f5b..516f96aa61 100644 --- a/src/packages/v4/views/V4ProjectDashboard/V4ProjectTabs/V4NftRewardsPanel/RedeemNftsSection/RedeemNftsSection.tsx +++ b/src/packages/v4/views/V4ProjectDashboard/V4ProjectTabs/V4NftRewardsPanel/RedeemNftsSection/RedeemNftsSection.tsx @@ -1,78 +1,73 @@ -import { Trans } from '@lingui/macro' -import { Button } from 'antd' import { useWallet } from 'hooks/Wallet' -import { RedeemNftsModal } from 'packages/v2v3/components/V2V3Project/ManageNftsSection/RedeemNftsModal/RedeemNftsModal' -import { V2V3ProjectContext } from 'packages/v2v3/contexts/Project/V2V3ProjectContext' -import { useNftAccountBalance } from 'packages/v2v3/hooks/JB721Delegate/useNftAccountBalance' -import { useNftCredits } from 'packages/v2v3/hooks/JB721Delegate/useNftCredits' -import { useContext, useState } from 'react' -import { NftCreditsSection } from './NftCreditsSection' -import { RedeemNftTiles } from './RedeemNftTiles' +import { useState } from 'react' export function RedeemNftsSection() { const [redeemNftsModalVisible, setRedeemNftsModalVisible] = useState(false) const { userAddress } = useWallet() - const { fundingCycleMetadata, primaryTerminalCurrentOverflow } = - useContext(V2V3ProjectContext) - const { data, loading } = useNftAccountBalance({ - accountAddress: userAddress, - dataSourceAddress: fundingCycleMetadata?.dataSource, - }) - const { data: credits, loading: loadingCredits } = useNftCredits(userAddress) - const hasOverflow = primaryTerminalCurrentOverflow?.gt(0) - const hasRedemptionRate = fundingCycleMetadata?.redemptionRate.gt(0) - const canRedeem = - hasOverflow && - hasRedemptionRate && - fundingCycleMetadata?.useDataSourceForRedeem + // TODO: This needs to be implemented + return null + // const { fundingCycleMetadata, primaryTerminalCurrentOverflow } = + // useContext(V2V3ProjectContext) + // const { data, loading } = useNftAccountBalance({ + // accountAddress: userAddress, + // dataSourceAddress: fundingCycleMetadata?.dataSource, + // }) + // const { data: credits, loading: loadingCredits } = useNftCredits(userAddress) - const hasRedeemableNfts = (data?.nfts?.length ?? 0) > 0 + // const hasOverflow = primaryTerminalCurrentOverflow?.gt(0) + // const hasRedemptionRate = fundingCycleMetadata?.redemptionRate.gt(0) + // const canRedeem = + // hasOverflow && + // hasRedemptionRate && + // fundingCycleMetadata?.useDataSourceForRedeem - const showRedeemSection = !loading && hasRedeemableNfts && userAddress - const showCreditSection = !loadingCredits && credits && credits.gt(0) + // const hasRedeemableNfts = (data?.nfts?.length ?? 0) > 0 - if (!showRedeemSection && !showCreditSection) return null + // const showRedeemSection = !loading && hasRedeemableNfts && !!userAddress + // const showCreditSection = !loadingCredits && credits && credits.gt(0) - return ( -
- {showCreditSection ? ( -
- -
- ) : null} + // if (!showRedeemSection && !showCreditSection) return null - {showRedeemSection ? ( -
-
- Your NFTs -
+ // return ( + //
+ // {showCreditSection ? ( + //
+ // + //
+ // ) : null} -
- + // {showRedeemSection ? ( + //
+ //
+ // Your NFTs + //
- -
+ //
+ // - {redeemNftsModalVisible && ( - setRedeemNftsModalVisible(false)} - onConfirmed={() => setRedeemNftsModalVisible(false)} - /> - )} -
- ) : null} -
- ) + // + //
+ + // {redeemNftsModalVisible && ( + // setRedeemNftsModalVisible(false)} + // onConfirmed={() => setRedeemNftsModalVisible(false)} + // /> + // )} + //
+ // ) : null} + //
+ // ) }