From 03b44e6c5107313f8a8d59e698399b43d7570fce Mon Sep 17 00:00:00 2001 From: Meriem-BM Date: Tue, 30 Apr 2024 07:45:09 +0100 Subject: [PATCH 01/28] fix: add back project link input to contact verification --- .../projectContact/ProjectContactIndex.tsx | 25 ++++++++++++++++++- .../projectContact/common.types.ts | 2 ++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/components/views/verification/projectContact/ProjectContactIndex.tsx b/src/components/views/verification/projectContact/ProjectContactIndex.tsx index 605defcde4..052eaf22ee 100644 --- a/src/components/views/verification/projectContact/ProjectContactIndex.tsx +++ b/src/components/views/verification/projectContact/ProjectContactIndex.tsx @@ -7,13 +7,14 @@ import { neutralColors, IconTelegram, IconWhatsApp, + IconLink, P, IconInfoFilled, IconXSocial, } from '@giveth/ui-design-system'; import styled from 'styled-components'; import { useForm } from 'react-hook-form'; -import { validators } from '@/lib/constants/regex'; +import { requiredOptions, validators } from '@/lib/constants/regex'; import Input from '@/components/Input'; import { BtnContainer, ContentSeparator, OutlineStyled } from '../Common.sc'; @@ -167,6 +168,24 @@ export default function ProjectContactIndex() { buttonType='primary' /> )} + + {formatMessage({ + id: 'label.in_order_to_ensure_that_you_are_a_representative', + })} + +
+ } + error={errors['SocialLink']} + register={register} + registerName='SocialLink' + registerOptions={isDraft ? requiredOptions.website : {}} + disabled={!isDraft} + />
@@ -243,3 +262,7 @@ const FormContainer = styled.form` max-width: 100%; } `; + +const SocialLinkInfo = styled(P)` + max-width: fit-content; +`; diff --git a/src/components/views/verification/projectContact/common.types.ts b/src/components/views/verification/projectContact/common.types.ts index 546b80cdb8..7ed564fc06 100644 --- a/src/components/views/verification/projectContact/common.types.ts +++ b/src/components/views/verification/projectContact/common.types.ts @@ -3,6 +3,7 @@ export enum EMainSocials { Discord = 'Discord', Telegram = 'Telegram', WhatsApp = 'WhatsApp', + SocialLink = 'SocialLink', } export interface IMainSocials { @@ -10,4 +11,5 @@ export interface IMainSocials { [EMainSocials.Discord]: string; [EMainSocials.Telegram]: string; [EMainSocials.WhatsApp]: string; + [EMainSocials.SocialLink]: string; } From 1f45fb810e1395d6a4338ce29f172e3b96b35f77 Mon Sep 17 00:00:00 2001 From: Cherik Date: Tue, 30 Apr 2024 10:30:57 +0330 Subject: [PATCH 02/28] move coingeckoId to IToken --- src/types/superFluid.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types/superFluid.ts b/src/types/superFluid.ts index d5c6b5a623..a45afd248a 100644 --- a/src/types/superFluid.ts +++ b/src/types/superFluid.ts @@ -7,12 +7,12 @@ export type IToken = { decimals: number; isSuperToken?: boolean; underlyingToken?: IToken; + coingeckoId: string; }; export interface ISuperToken extends IToken { underlyingToken: IToken; isSuperToken: boolean; - coingeckoId: string; } export interface ISuperfluidStream { From 34bb01036483e4564ac5e4d3fcee378e9e425324 Mon Sep 17 00:00:00 2001 From: Cherik Date: Tue, 30 Apr 2024 10:31:10 +0330 Subject: [PATCH 03/28] add coingeckoId to underlyingToken --- src/config/development.tsx | 2 ++ src/config/production.tsx | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/src/config/development.tsx b/src/config/development.tsx index 2e85d3e7f4..84935b6b1c 100644 --- a/src/config/development.tsx +++ b/src/config/development.tsx @@ -387,6 +387,7 @@ const config: EnvConfig = { id: OPTIMISM_GIV_TOKEN_ADDRESS, name: 'Giveth', symbol: 'GIV', + coingeckoId: 'giveth', }, decimals: 18, id: '0xdfd824f6928b9776c031f7ead948090e2824ce8b', @@ -401,6 +402,7 @@ const config: EnvConfig = { symbol: 'ETH', decimals: 18, id: '0x0000000000000000000000000000000000000000', + coingeckoId: 'ethereum', }, decimals: 18, id: '0x0043d7c85c8b96a49a72a92c0b48cdc4720437d7', diff --git a/src/config/production.tsx b/src/config/production.tsx index f99e91739c..e29e7559e3 100644 --- a/src/config/production.tsx +++ b/src/config/production.tsx @@ -459,6 +459,7 @@ const config: EnvConfig = { id: '0x4200000000000000000000000000000000000042', name: 'Optimism', symbol: 'OP', + coingeckoId: 'optimism', }, decimals: 18, id: '0x1828bff08bd244f7990eddcd9b19cc654b33cdb4', @@ -473,6 +474,7 @@ const config: EnvConfig = { symbol: 'ETH', decimals: 18, id: '0x0000000000000000000000000000000000000000', + coingeckoId: 'ethereum', }, decimals: 18, id: '0x4ac8bd1bdae47beef2d1c6aa62229509b962aa0d', @@ -487,6 +489,7 @@ const config: EnvConfig = { id: '0x528cdc92eab044e1e39fe43b9514bfdab4412b98', name: 'Giveth Token', symbol: 'GIV', + coingeckoId: 'giveth', }, decimals: 18, id: '0x4cab5b9930210e2edc6a905b9c75d615872a1a7e', @@ -501,6 +504,7 @@ const config: EnvConfig = { id: '0xda10009cbd5d07dd0cecc66161fc93d7c9000da1', name: 'Dai Stablecoin', symbol: 'DAI', + coingeckoId: 'dai', }, decimals: 18, id: '0x7d342726b69c28d942ad8bfe6ac81b972349d524', @@ -515,6 +519,7 @@ const config: EnvConfig = { id: '0x7f5c764cbc14f9669b88837ca1490cca17c31607', name: 'USD Coin', symbol: 'USDC', + coingeckoId: 'usd-coin', }, decimals: 18, id: '0x8430f084b939208e2eded1584889c9a66b90562f', From 0ab675f39f05178b59dd2578948ec31d70340400 Mon Sep 17 00:00:00 2001 From: Cherik Date: Tue, 30 Apr 2024 10:41:22 +0330 Subject: [PATCH 04/28] fix available amount --- .../views/donate/ModifySuperToken/ModifySection.tsx | 2 +- src/components/views/donate/RecurringDonationCard.tsx | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/components/views/donate/ModifySuperToken/ModifySection.tsx b/src/components/views/donate/ModifySuperToken/ModifySection.tsx index a8d36e9ae6..206a1e4987 100644 --- a/src/components/views/donate/ModifySuperToken/ModifySection.tsx +++ b/src/components/views/donate/ModifySuperToken/ModifySection.tsx @@ -132,7 +132,7 @@ export const ModifySection: FC = ({ {balance ? truncateToDecimalPlaces( formatUnits(maxAmount, balance.decimals), - 6, + balance.decimals / 3, ) : '--'} diff --git a/src/components/views/donate/RecurringDonationCard.tsx b/src/components/views/donate/RecurringDonationCard.tsx index 3a9a448ce0..dc25f930b8 100644 --- a/src/components/views/donate/RecurringDonationCard.tsx +++ b/src/components/views/donate/RecurringDonationCard.tsx @@ -41,7 +41,7 @@ import { findUserActiveStreamOnSelectedToken, } from '@/helpers/donate'; import { ISuperfluidStream } from '@/types/superFluid'; -import { showToastError } from '@/lib/helpers'; +import { showToastError, truncateToDecimalPlaces } from '@/lib/helpers'; import config, { isRecurringActive } from '@/configuration'; import { WrongNetworkLayer } from './WrongNetworkLayer'; import { ModifySuperTokenModal } from './ModifySuperToken/ModifySuperTokenModal'; @@ -332,11 +332,12 @@ export const RecurringDonationCard = () => { id: 'label.available', })} :{' '} - {limitFraction( + {truncateToDecimalPlaces( formatUnits( balance.value, balance.decimals, ), + balance.decimals / 3, )} Date: Tue, 30 Apr 2024 10:48:26 +0330 Subject: [PATCH 05/28] fix limitFraction --- src/helpers/number.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/helpers/number.ts b/src/helpers/number.ts index 5437b2d096..03f6fc63f3 100644 --- a/src/helpers/number.ts +++ b/src/helpers/number.ts @@ -1,6 +1,7 @@ import BigNumber from 'bignumber.js'; import { formatEther } from 'viem'; import config from '@/configuration'; +import { truncateToDecimalPlaces } from '@/lib/helpers'; export const Zero = new BigNumber(0); @@ -79,7 +80,10 @@ export function limitFraction( return `<${smallestRepresentable.toFixed(maxDecimals)}`; } - let formattedNumber = number.toFixed(maxDecimals); + let formattedNumber = truncateToDecimalPlaces( + numberStr, + maxDecimals, + ).toString(); // If trim is true, remove trailing zeros after the decimal point, and also the decimal point if it becomes unnecessary. if (trim) { From 94cddb5e4d37ea6c0e54a2b1f701516db26cf32f Mon Sep 17 00:00:00 2001 From: Cherik Date: Tue, 30 Apr 2024 12:21:32 +0330 Subject: [PATCH 06/28] add ensureCorrectNetwork --- src/helpers/network.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/helpers/network.ts diff --git a/src/helpers/network.ts b/src/helpers/network.ts new file mode 100644 index 0000000000..f0242bee2e --- /dev/null +++ b/src/helpers/network.ts @@ -0,0 +1,16 @@ +import { getChainId, switchChain } from '@wagmi/core'; +import { wagmiConfig } from '@/wagmiConfigs'; + +export const ensureCorrectNetwork = async (targetChainId: number) => { + try { + const chainId = getChainId(wagmiConfig); + if (targetChainId === chainId) return true; + const chain = await switchChain(wagmiConfig, { + chainId: targetChainId, + }); + return chain.id === targetChainId; + } catch (error) { + console.log('error', error); + return false; + } +}; From b4787d8b2b45cca83063f2610f43e3e30d95c1f0 Mon Sep 17 00:00:00 2001 From: Cherik Date: Tue, 30 Apr 2024 13:47:18 +0330 Subject: [PATCH 07/28] check network on deposit --- .../views/donate/ModifySuperToken/DepositSuperToken.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/views/donate/ModifySuperToken/DepositSuperToken.tsx b/src/components/views/donate/ModifySuperToken/DepositSuperToken.tsx index 5875d1b99b..eda5437202 100644 --- a/src/components/views/donate/ModifySuperToken/DepositSuperToken.tsx +++ b/src/components/views/donate/ModifySuperToken/DepositSuperToken.tsx @@ -22,6 +22,7 @@ import { EModifySuperTokenSteps, actionButtonLabel } from './common'; import { wagmiConfig } from '@/wagmiConfigs'; import { getEthersProvider, getEthersSigner } from '@/helpers/ethers'; import { EToastType } from '@/components/toasts/InlineToast'; +import { ensureCorrectNetwork } from '@/helpers/network'; interface IDepositSuperTokenProps extends IModifySuperTokenInnerModalProps { token?: IToken; @@ -73,8 +74,9 @@ export const DepositSuperToken: FC = ({ const onApprove = async () => { console.log('Approve', amount, address, superToken, token); if (!address || !superToken || !token) return; - setStep(EModifySuperTokenSteps.APPROVING); try { + setStep(EModifySuperTokenSteps.APPROVING); + await ensureCorrectNetwork(config.OPTIMISM_NETWORK_NUMBER); const approve = await approveERC20tokenTransfer( amount, address, @@ -95,8 +97,9 @@ export const DepositSuperToken: FC = ({ }; const onDeposit = async () => { - setStep(EModifySuperTokenSteps.DEPOSITING); try { + setStep(EModifySuperTokenSteps.DEPOSITING); + await ensureCorrectNetwork(config.OPTIMISM_NETWORK_NUMBER); if (!address) { throw new Error('address not found1'); } From c9e7a95fc4a62c14843d0b6ecd2bed111cb519c9 Mon Sep 17 00:00:00 2001 From: Cherik Date: Tue, 30 Apr 2024 13:47:34 +0330 Subject: [PATCH 08/28] check network on withdraw --- .../views/donate/ModifySuperToken/WithDrawSuperToken.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/components/views/donate/ModifySuperToken/WithDrawSuperToken.tsx b/src/components/views/donate/ModifySuperToken/WithDrawSuperToken.tsx index 23050f0f40..98eada2df4 100644 --- a/src/components/views/donate/ModifySuperToken/WithDrawSuperToken.tsx +++ b/src/components/views/donate/ModifySuperToken/WithDrawSuperToken.tsx @@ -20,6 +20,7 @@ import { ONE_MONTH_SECONDS } from '@/lib/constants/constants'; import { wagmiConfig } from '@/wagmiConfigs'; import { getEthersProvider, getEthersSigner } from '@/helpers/ethers'; import { EToastType } from '@/components/toasts/InlineToast'; +import { ensureCorrectNetwork } from '@/helpers/network'; interface IWithDrawSuperTokenProps extends IModifySuperTokenInnerModalProps { token?: IToken; @@ -59,6 +60,7 @@ export const WithDrawSuperToken: FC = ({ const onWithdraw = async () => { setStep(EModifySuperTokenSteps.WITHDRAWING); try { + await ensureCorrectNetwork(config.OPTIMISM_NETWORK_NUMBER); if (!address) { throw new Error('address not found1'); } From 555c6418a6f205be2f3fc247060ccadaf263c6c8 Mon Sep 17 00:00:00 2001 From: Cherik Date: Tue, 30 Apr 2024 13:48:00 +0330 Subject: [PATCH 09/28] check network on create and modify recurring donation --- .../RecurringDonationModal.tsx | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/components/views/donate/RecurringDonationModal/RecurringDonationModal.tsx b/src/components/views/donate/RecurringDonationModal/RecurringDonationModal.tsx index 35913dacd2..f4da52de0f 100644 --- a/src/components/views/donate/RecurringDonationModal/RecurringDonationModal.tsx +++ b/src/components/views/donate/RecurringDonationModal/RecurringDonationModal.tsx @@ -40,6 +40,7 @@ import { import { getEthersProvider, getEthersSigner } from '@/helpers/ethers'; import { ERecurringDonationStatus } from '@/apollo/types/types'; import { findAnchorContractAddress } from '@/helpers/superfluid'; +import { ensureCorrectNetwork } from '@/helpers/network'; interface IRecurringDonationModalProps extends IModal { donationToGiveth: number; amount: bigint; @@ -143,15 +144,18 @@ const RecurringDonationInnerModal: FC = ({ }, [selectedToken, setStep]); const onApprove = async () => { - console.log( - 'amount', - formatUnits(amount, selectedToken?.token.decimals || 18), - ); - setStep(EDonationSteps.APPROVING); - if (!address || !selectedToken) return; - const superToken = findSuperTokenByTokenAddress(selectedToken.token.id); - if (!superToken) return; try { + await ensureCorrectNetwork(config.OPTIMISM_NETWORK_NUMBER); + console.log( + 'amount', + formatUnits(amount, selectedToken?.token.decimals || 18), + ); + setStep(EDonationSteps.APPROVING); + if (!address || !selectedToken) return; + const superToken = findSuperTokenByTokenAddress( + selectedToken.token.id, + ); + if (!superToken) throw new Error('SuperToken not found'); const approve = await approveERC20tokenTransfer( amount, address, @@ -171,8 +175,9 @@ const RecurringDonationInnerModal: FC = ({ }; const onDonate = async () => { - setStep(EDonationSteps.DONATING); try { + await ensureCorrectNetwork(config.OPTIMISM_NETWORK_NUMBER); + setStep(EDonationSteps.DONATING); const projectAnchorContract = findAnchorContractAddress( project?.anchorContracts, ); @@ -334,6 +339,8 @@ const RecurringDonationInnerModal: FC = ({ ); } + await ensureCorrectNetwork(config.OPTIMISM_NETWORK_NUMBER); + if (isBatch) { const batchOp = sf.batchCall(operations); tx = await batchOp.exec(signer); From 6e8a02b70dcf1e98f6acccb98857e7151a46028c Mon Sep 17 00:00:00 2001 From: Cherik Date: Tue, 30 Apr 2024 13:48:19 +0330 Subject: [PATCH 10/28] check network on update stream --- .../recurringTab/ModifyStreamModal/UpdateStreamInnerModal.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/components/views/userProfile/donationsTab/recurringTab/ModifyStreamModal/UpdateStreamInnerModal.tsx b/src/components/views/userProfile/donationsTab/recurringTab/ModifyStreamModal/UpdateStreamInnerModal.tsx index 6237c28719..30bce4219e 100644 --- a/src/components/views/userProfile/donationsTab/recurringTab/ModifyStreamModal/UpdateStreamInnerModal.tsx +++ b/src/components/views/userProfile/donationsTab/recurringTab/ModifyStreamModal/UpdateStreamInnerModal.tsx @@ -26,6 +26,7 @@ import { TXLink } from './TXLink'; import { useProfileDonateTabData } from '../ProfileDonateTab.context'; import { ERecurringDonationStatus } from '@/apollo/types/types'; import { findAnchorContractAddress } from '@/helpers/superfluid'; +import { ensureCorrectNetwork } from '@/helpers/network'; interface IModifyStreamInnerModalProps extends IModifyStreamModalProps { step: EDonationSteps; @@ -56,6 +57,7 @@ export const UpdateStreamInnerModal: FC = ({ const onDonate = async () => { setStep(EDonationSteps.DONATING); try { + await ensureCorrectNetwork(config.OPTIMISM_NETWORK_NUMBER); const projectAnchorContract = findAnchorContractAddress( donation.project.anchorContracts, ); From 03a63b89190621eae63f1494676c5ace1470d42a Mon Sep 17 00:00:00 2001 From: Cherik Date: Tue, 30 Apr 2024 13:48:27 +0330 Subject: [PATCH 11/28] check network on claim --- .../views/userProfile/projectsTab/ClaimWithdrawalModal.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/components/views/userProfile/projectsTab/ClaimWithdrawalModal.tsx b/src/components/views/userProfile/projectsTab/ClaimWithdrawalModal.tsx index 7298e734fe..a28cd8695d 100644 --- a/src/components/views/userProfile/projectsTab/ClaimWithdrawalModal.tsx +++ b/src/components/views/userProfile/projectsTab/ClaimWithdrawalModal.tsx @@ -25,6 +25,7 @@ import { formatTxLink } from '@/lib/helpers'; import { ChainType } from '@/types/config'; import { ClaimTransactionState } from './type'; import { wagmiConfig } from '@/wagmiConfigs'; +import { ensureCorrectNetwork } from '@/helpers/network'; interface IClaimWithdrawalModal extends IModal { selectedStream: ITokenWithBalance; project: IProject; @@ -85,6 +86,7 @@ const ClaimWithdrawalModal = ({ console.log('anchorContractAddress', anchorContractAddress); try { console.log('isETHx', isETHx); + await ensureCorrectNetwork(config.OPTIMISM_NETWORK_NUMBER); const encodedDowngradeTo = isETHx ? encodeFunctionData({ abi: ISETH.abi, From 96c29c76da2b7937e3240210bc344ab96bf34ddf Mon Sep 17 00:00:00 2001 From: Cherik Date: Tue, 30 Apr 2024 15:29:57 +0330 Subject: [PATCH 12/28] convert to string --- src/helpers/number.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/helpers/number.ts b/src/helpers/number.ts index 03f6fc63f3..0a988e6acf 100644 --- a/src/helpers/number.ts +++ b/src/helpers/number.ts @@ -81,7 +81,7 @@ export function limitFraction( } let formattedNumber = truncateToDecimalPlaces( - numberStr, + numberStr.toString(), maxDecimals, ).toString(); From da7be37c738d3fec8e1c557a35790e282b7bbefe Mon Sep 17 00:00:00 2001 From: Cherik Date: Tue, 30 Apr 2024 16:34:03 +0330 Subject: [PATCH 13/28] show less that one month --- .../donate/ModifySuperToken/StreamInfo.tsx | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/components/views/donate/ModifySuperToken/StreamInfo.tsx b/src/components/views/donate/ModifySuperToken/StreamInfo.tsx index b836744697..7049b3ed64 100644 --- a/src/components/views/donate/ModifySuperToken/StreamInfo.tsx +++ b/src/components/views/donate/ModifySuperToken/StreamInfo.tsx @@ -72,16 +72,20 @@ export const StreamInfo: FC = ({ })}{' '} {totalStreamPerSec > 0 ? ( - {streamRunOutInMonth < 0n - ? '0' - : streamRunOutInMonth.toString()}{' '} - {formatMessage( - { - id: 'label.months', - }, - { - count: streamRunOutInMonth.toString(), - }, + {streamRunOutInMonth < 1n ? ( + ' < 1 Month ' + ) : ( + <> + {streamRunOutInMonth.toString()}{' '} + {formatMessage( + { + id: 'label.months', + }, + { + count: streamRunOutInMonth.toString(), + }, + )} + )} ) : ( From 1c5d08e1e403fce16a3172f852d2441f4501ae1d Mon Sep 17 00:00:00 2001 From: Meriem-BM Date: Wed, 1 May 2024 06:13:57 +0100 Subject: [PATCH 14/28] hotfix: labels modifs --- src/components/views/projects/ActiveQFRoundStats.tsx | 9 ++++----- src/components/views/projects/ArchivedQFRoundStats.tsx | 5 ++--- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/components/views/projects/ActiveQFRoundStats.tsx b/src/components/views/projects/ActiveQFRoundStats.tsx index 2300a4f2b7..d4c42cbfa1 100644 --- a/src/components/views/projects/ActiveQFRoundStats.tsx +++ b/src/components/views/projects/ActiveQFRoundStats.tsx @@ -32,7 +32,7 @@ export const ActiveQFRoundStats = () => { {formatMessage({ id: 'label.matching_pool' })} - {data?.qfRoundStats?.matchingPool || '--'} $ + ${data?.qfRoundStats?.matchingPool || ' --'} @@ -40,8 +40,7 @@ export const ActiveQFRoundStats = () => { {formatMessage({ id: 'label.donations' })} - $  - {data?.qfRoundStats?.allDonationsUsdValue || '--'} + ${data?.qfRoundStats?.allDonationsUsdValue || ' --'} @@ -54,14 +53,14 @@ export const ActiveQFRoundStats = () => { - Round started + Round start {activeRound?.endDate ? formatDate(new Date(activeRound.beginDate)) : '--'} - Ends on + Round end {activeRound?.endDate ? formatDate(new Date(activeRound.endDate)) diff --git a/src/components/views/projects/ArchivedQFRoundStats.tsx b/src/components/views/projects/ArchivedQFRoundStats.tsx index f8977432c2..253bdc40d9 100644 --- a/src/components/views/projects/ArchivedQFRoundStats.tsx +++ b/src/components/views/projects/ArchivedQFRoundStats.tsx @@ -34,7 +34,7 @@ export const ArchivedQFRoundStats = () => { {formatMessage({ id: 'label.matching_pool' })} - {data?.qfRoundStats?.matchingPool || '--'} $ + ${data?.qfRoundStats?.matchingPool || ' --'} @@ -42,8 +42,7 @@ export const ArchivedQFRoundStats = () => { {formatMessage({ id: 'label.donations' })} - $  - {data?.qfRoundStats?.allDonationsUsdValue || '--'} + ${data?.qfRoundStats?.allDonationsUsdValue || ' --'} From 56af24d553f18fa72d1b239794d863dd2197c76e Mon Sep 17 00:00:00 2001 From: Cherik Date: Wed, 1 May 2024 13:48:21 +0330 Subject: [PATCH 15/28] update AmountInput --- src/components/AmountInput/AmountInput.tsx | 50 ++++++---------------- 1 file changed, 14 insertions(+), 36 deletions(-) diff --git a/src/components/AmountInput/AmountInput.tsx b/src/components/AmountInput/AmountInput.tsx index 5baad4ca10..ed9ae4d4f7 100644 --- a/src/components/AmountInput/AmountInput.tsx +++ b/src/components/AmountInput/AmountInput.tsx @@ -8,9 +8,10 @@ import { FC, useState, useCallback, Dispatch, SetStateAction } from 'react'; import styled from 'styled-components'; import { useIntl } from 'react-intl'; import { captureException } from '@sentry/nextjs'; -import BigNumber from 'bignumber.js'; +import { formatUnits, parseUnits } from 'viem'; import { formatWeiHelper } from '@/helpers/number'; import { BaseInput } from '../input/BaseInput'; +import { truncateToDecimalPlaces } from '@/lib/helpers'; export interface IAmountInput { setAmount: Dispatch>; @@ -21,8 +22,6 @@ export interface IAmountInput { showMax?: boolean; balanceUnit?: string; showPercentage?: boolean; - displayAmount?: string; - setDisplayAmount?: Dispatch>; } export const AmountInput: FC = ({ @@ -33,42 +32,24 @@ export const AmountInput: FC = ({ disabled = false, showMax = false, showPercentage = false, - displayAmount: externalDisplayAmount = undefined, - setDisplayAmount: externalSetDisplayAmount = undefined, }) => { const { formatMessage } = useIntl(); - const [internalDisplayAmount, internalSetDisplayAmount] = useState(''); const [activeStep, setActiveStep] = useState(0); - - // Determine which displayAmount and setDisplayAmount to use - const displayAmount = - externalDisplayAmount !== undefined - ? externalDisplayAmount - : internalDisplayAmount; - - const setDisplayAmount = - externalSetDisplayAmount !== undefined - ? externalSetDisplayAmount - : internalSetDisplayAmount; + const [displayAmount, setDisplayAmount] = useState(''); const setAmountPercentage = useCallback( (percentage: number): void => { if (!maxAmount) return; - const newAmount = new BigNumber(maxAmount.toString()) - .multipliedBy(percentage) - .div(100) - .toFixed(0); - const _displayAmount = formatWeiHelper(newAmount, 6, false); - setDisplayAmount(_displayAmount); - setAmount( + const newAmount = percentage === 100 ? maxAmount - : BigInt( - new BigNumber(_displayAmount) - .multipliedBy(10 ** decimals) - .toFixed(0), - ), - ); + : (maxAmount * BigInt(percentage)) / 100n; + const _displayAmount = truncateToDecimalPlaces( + formatUnits(newAmount, decimals), + decimals / 3, + ).toString(); + setDisplayAmount(_displayAmount); + setAmount(newAmount); }, [decimals, maxAmount, setAmount], ); @@ -76,16 +57,13 @@ export const AmountInput: FC = ({ const onUserInput = useCallback( (value: string) => { const [, _decimals] = value.split('.'); - if (_decimals?.length > 6) { - return; - } + if (_decimals?.length > 6) return; setDisplayAmount(value); setActiveStep(0); - let valueBn = new BigNumber(0); try { - valueBn = new BigNumber(value).multipliedBy(10 ** decimals); - setAmount(BigInt(valueBn.toFixed(0))); + let valueBn = parseUnits(value, decimals); + setAmount(valueBn); } catch (error) { setAmount(0n); console.debug( From da44d1b453598cd1fb806b2c909e6767880d937c Mon Sep 17 00:00:00 2001 From: Cherik Date: Wed, 1 May 2024 14:00:39 +0330 Subject: [PATCH 16/28] update AmountInput work only with amount --- src/components/AmountInput/AmountInput.tsx | 29 ++++++++++++++++------ 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/src/components/AmountInput/AmountInput.tsx b/src/components/AmountInput/AmountInput.tsx index ed9ae4d4f7..9c715df500 100644 --- a/src/components/AmountInput/AmountInput.tsx +++ b/src/components/AmountInput/AmountInput.tsx @@ -4,7 +4,14 @@ import { brandColors, Flex, } from '@giveth/ui-design-system'; -import { FC, useState, useCallback, Dispatch, SetStateAction } from 'react'; +import { + FC, + useState, + useCallback, + Dispatch, + SetStateAction, + useEffect, +} from 'react'; import styled from 'styled-components'; import { useIntl } from 'react-intl'; import { captureException } from '@sentry/nextjs'; @@ -14,6 +21,7 @@ import { BaseInput } from '../input/BaseInput'; import { truncateToDecimalPlaces } from '@/lib/helpers'; export interface IAmountInput { + amount: bigint; setAmount: Dispatch>; decimals?: number; className?: string; @@ -25,6 +33,7 @@ export interface IAmountInput { } export const AmountInput: FC = ({ + amount, maxAmount, setAmount, className, @@ -37,6 +46,16 @@ export const AmountInput: FC = ({ const [activeStep, setActiveStep] = useState(0); const [displayAmount, setDisplayAmount] = useState(''); + useEffect(() => { + console.log('amount', amount); + if (!amount) return; + const _displayAmount = truncateToDecimalPlaces( + formatUnits(amount, decimals), + decimals / 3, + ).toString(); + setDisplayAmount(_displayAmount); + }, [amount, decimals]); + const setAmountPercentage = useCallback( (percentage: number): void => { if (!maxAmount) return; @@ -44,14 +63,10 @@ export const AmountInput: FC = ({ percentage === 100 ? maxAmount : (maxAmount * BigInt(percentage)) / 100n; - const _displayAmount = truncateToDecimalPlaces( - formatUnits(newAmount, decimals), - decimals / 3, - ).toString(); - setDisplayAmount(_displayAmount); + setAmount(newAmount); }, - [decimals, maxAmount, setAmount], + [maxAmount, setAmount], ); const onUserInput = useCallback( From d1eb6727469a91053a133ffb4b6e865308128341 Mon Sep 17 00:00:00 2001 From: Cherik Date: Wed, 1 May 2024 14:01:03 +0330 Subject: [PATCH 17/28] pass amount to AmountInput --- src/components/modals/StakeLock/Lock.tsx | 1 + src/components/modals/StakeLock/Stake.tsx | 1 + src/components/modals/StakeLock/StakeGIV.tsx | 1 + src/components/modals/Unstake/UnStake.tsx | 1 + .../ModifySuperToken/DepositSuperToken.tsx | 1 + .../donate/ModifySuperToken/ModifySection.tsx | 23 +++++-------------- .../ModifySuperToken/WithDrawSuperToken.tsx | 1 + .../views/donate/RecurringDonationCard.tsx | 1 + 8 files changed, 13 insertions(+), 17 deletions(-) diff --git a/src/components/modals/StakeLock/Lock.tsx b/src/components/modals/StakeLock/Lock.tsx index fcba36aeb4..a8a36efa4d 100644 --- a/src/components/modals/StakeLock/Lock.tsx +++ b/src/components/modals/StakeLock/Lock.tsx @@ -135,6 +135,7 @@ const LockModal: FC = ({ })} = ({ = ({ })} = ({ = ({ >; balance?: GetBalanceReturnType; refetch: any; @@ -44,6 +45,7 @@ interface IModifySectionProps { export const ModifySection: FC = ({ titleLabel, token, + amount, setAmount, balance, refetch, @@ -54,17 +56,13 @@ export const ModifySection: FC = ({ modifySectionPlace, }) => { const { formatMessage } = useIntl(); - const [displayAmount, setDisplayAmount] = useState(''); const handleSetMaxAmount = () => { if (!balance || !balance.value) return; // If balance is not available, return - const maxAmountDisplay = truncateToDecimalPlaces( - formatUnits(maxAmount, balance.decimals), - 6, - ).toString(); // Convert your balance value to string properly - setDisplayAmount(maxAmountDisplay); // Update the display amount + console.log('balance.value', balance.value); setAmount(balance.value); // Set the amount to the balance value }; + console.log('amount1', amount); const _token = findTokenByAddress(token?.id); const ProperGlink = @@ -104,19 +102,10 @@ export const ModifySection: FC = ({ diff --git a/src/components/views/donate/ModifySuperToken/WithDrawSuperToken.tsx b/src/components/views/donate/ModifySuperToken/WithDrawSuperToken.tsx index 98eada2df4..cab0a5266a 100644 --- a/src/components/views/donate/ModifySuperToken/WithDrawSuperToken.tsx +++ b/src/components/views/donate/ModifySuperToken/WithDrawSuperToken.tsx @@ -150,6 +150,7 @@ export const WithDrawSuperToken: FC = ({ {

) : ( Date: Wed, 1 May 2024 14:04:59 +0330 Subject: [PATCH 18/28] set max --- .../views/donate/RecurringDonationCard.tsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/components/views/donate/RecurringDonationCard.tsx b/src/components/views/donate/RecurringDonationCard.tsx index e6058cd7f1..1a55f5c80a 100644 --- a/src/components/views/donate/RecurringDonationCard.tsx +++ b/src/components/views/donate/RecurringDonationCard.tsx @@ -328,7 +328,10 @@ export const RecurringDonationCard = () => { selectedToken !== undefined && balance !== undefined && ( - + setAmount(balance.value)} + > {formatMessage({ id: 'label.available', })} @@ -340,7 +343,7 @@ export const RecurringDonationCard = () => { ), balance.decimals / 3, )} - + !isRefetching && refetch()} > @@ -814,6 +817,13 @@ export const IconWrapper = styled.div` color: ${brandColors.giv[500]}; `; +const GLinkStyled = styled(GLink)` + &&:hover { + cursor: pointer; + text-decoration: underline; + } +`; + const SliderWrapper = styled.div` width: 100%; position: relative; From 9d27edc9af51ce408e79db495ac6619f64eb441c Mon Sep 17 00:00:00 2001 From: Cherik Date: Wed, 1 May 2024 14:06:43 +0330 Subject: [PATCH 19/28] remove logs --- src/components/AmountInput/AmountInput.tsx | 1 - src/components/views/donate/ModifySuperToken/ModifySection.tsx | 2 -- 2 files changed, 3 deletions(-) diff --git a/src/components/AmountInput/AmountInput.tsx b/src/components/AmountInput/AmountInput.tsx index 9c715df500..4289f312eb 100644 --- a/src/components/AmountInput/AmountInput.tsx +++ b/src/components/AmountInput/AmountInput.tsx @@ -47,7 +47,6 @@ export const AmountInput: FC = ({ const [displayAmount, setDisplayAmount] = useState(''); useEffect(() => { - console.log('amount', amount); if (!amount) return; const _displayAmount = truncateToDecimalPlaces( formatUnits(amount, decimals), diff --git a/src/components/views/donate/ModifySuperToken/ModifySection.tsx b/src/components/views/donate/ModifySuperToken/ModifySection.tsx index 82c01a23bf..39ac214cf0 100644 --- a/src/components/views/donate/ModifySuperToken/ModifySection.tsx +++ b/src/components/views/donate/ModifySuperToken/ModifySection.tsx @@ -59,10 +59,8 @@ export const ModifySection: FC = ({ const handleSetMaxAmount = () => { if (!balance || !balance.value) return; // If balance is not available, return - console.log('balance.value', balance.value); setAmount(balance.value); // Set the amount to the balance value }; - console.log('amount1', amount); const _token = findTokenByAddress(token?.id); const ProperGlink = From 9c86982b96a7a1ab3e3922248b6aaa45b9fd8719 Mon Sep 17 00:00:00 2001 From: Cherik Date: Wed, 1 May 2024 14:13:12 +0330 Subject: [PATCH 20/28] add isRecurring to ISuccessDonation --- src/context/donate.context.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/context/donate.context.tsx b/src/context/donate.context.tsx index 3c1b7a2ad0..f0922734c1 100644 --- a/src/context/donate.context.tsx +++ b/src/context/donate.context.tsx @@ -24,6 +24,7 @@ interface ISuccessDonation { txHash: TxHashWithChainType[]; givBackEligible?: boolean; excludeFromQF?: boolean; + isRecurring?: boolean; } interface IDonateContext { From 251957ceee7ab735a26116725bf89c41bc83404e Mon Sep 17 00:00:00 2001 From: Cherik Date: Wed, 1 May 2024 14:20:45 +0330 Subject: [PATCH 21/28] make right side's height 100% --- src/components/views/donate/SuccessView.tsx | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/components/views/donate/SuccessView.tsx b/src/components/views/donate/SuccessView.tsx index e85002e544..a9096f6053 100644 --- a/src/components/views/donate/SuccessView.tsx +++ b/src/components/views/donate/SuccessView.tsx @@ -98,11 +98,13 @@ export const SuccessView: FC = () => { - - {formatMessage({ id: 'label.youre_giver_now' })} - -
- {message} +
+ + {formatMessage({ id: 'label.youre_giver_now' })} + +
+ {message} +

{givBackEligible && ( <> @@ -209,8 +211,11 @@ const ImageWrapper = styled.div` overflow: hidden; `; -const RightSectionWrapper = styled.div` +const RightSectionWrapper = styled(Flex)` + flex-direction: column; + justify-content: center; background-color: ${neutralColors.gray[100]}; padding: 32px; border-radius: 16px; + height: 100%; `; From ad94b0ba9d07a279b5508132271ed6308c9b29e4 Mon Sep 17 00:00:00 2001 From: Cherik Date: Wed, 1 May 2024 14:27:12 +0330 Subject: [PATCH 22/28] add ManageRecurringDonation --- .../views/donate/ManageRecurringDonation.tsx | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/components/views/donate/ManageRecurringDonation.tsx diff --git a/src/components/views/donate/ManageRecurringDonation.tsx b/src/components/views/donate/ManageRecurringDonation.tsx new file mode 100644 index 0000000000..9df909a904 --- /dev/null +++ b/src/components/views/donate/ManageRecurringDonation.tsx @@ -0,0 +1,34 @@ +import { H5, P, brandColors } from '@giveth/ui-design-system'; +import Link from 'next/link'; +import React from 'react'; +import styled from 'styled-components'; + +export const ManageRecurringDonation = () => { + return ( + +
Managing your recurring donations
+
+

+ You can modify or delete your recurring donation as well as + top-up funds to your stream balance from the  + Recurring Donations page . +

+

+ To learn more about how recurring donations work, visit our{' '} + documentation article . +

+
+ ); +}; + +const Box = styled.div` + padding: 16px; + border-radius: 12px; + border: 1px solid ${brandColors.giv[200]}; + a { + color: ${brandColors.pinky[500]}; + &:hover { + color: ${brandColors.pinky[600]}; + } + } +`; From be7ebad15633a552762d90189fae1333d4555d6f Mon Sep 17 00:00:00 2001 From: Cherik Date: Wed, 1 May 2024 14:28:37 +0330 Subject: [PATCH 23/28] display ManageRecurringDonation if the donation is recurring --- src/components/views/donate/SuccessView.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/components/views/donate/SuccessView.tsx b/src/components/views/donate/SuccessView.tsx index a9096f6053..4625b85660 100644 --- a/src/components/views/donate/SuccessView.tsx +++ b/src/components/views/donate/SuccessView.tsx @@ -30,6 +30,7 @@ import links from '@/lib/constants/links'; import { EContentType } from '@/lib/constants/shareContent'; import QFToast from './QFToast'; import { DonationInfo } from './DonationInfo'; +import { ManageRecurringDonation } from './ManageRecurringDonation'; export const SuccessView: FC = () => { const { formatMessage } = useIntl(); @@ -38,6 +39,7 @@ export const SuccessView: FC = () => { givBackEligible, txHash = [], excludeFromQF, + isRecurring, } = successDonation || {}; const hasMultipleTxs = txHash.length > 1; const isSafeEnv = useIsSafeEnvironment(); @@ -134,6 +136,7 @@ export const SuccessView: FC = () => { hasActiveQFRound && passportState !== EPassportState.LOADING && isOnEligibleNetworks && } + {isRecurring && } Date: Wed, 1 May 2024 14:33:20 +0330 Subject: [PATCH 24/28] update links --- .../views/donate/ManageRecurringDonation.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/components/views/donate/ManageRecurringDonation.tsx b/src/components/views/donate/ManageRecurringDonation.tsx index 9df909a904..df907d7b65 100644 --- a/src/components/views/donate/ManageRecurringDonation.tsx +++ b/src/components/views/donate/ManageRecurringDonation.tsx @@ -2,6 +2,8 @@ import { H5, P, brandColors } from '@giveth/ui-design-system'; import Link from 'next/link'; import React from 'react'; import styled from 'styled-components'; +import Routes from '@/lib/constants/Routes'; +import links from '@/lib/constants/links'; export const ManageRecurringDonation = () => { return ( @@ -11,11 +13,17 @@ export const ManageRecurringDonation = () => {

You can modify or delete your recurring donation as well as top-up funds to your stream balance from the  - Recurring Donations page . + + Recurring Donations page + + .

To learn more about how recurring donations work, visit our{' '} - documentation article . + + documentation article + +  .

); From 71bc577a674ccd3e91f189eb40bb10a93d7f8045 Mon Sep 17 00:00:00 2001 From: Cherik Date: Wed, 1 May 2024 14:34:39 +0330 Subject: [PATCH 25/28] change title color --- src/components/views/donate/ManageRecurringDonation.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/views/donate/ManageRecurringDonation.tsx b/src/components/views/donate/ManageRecurringDonation.tsx index df907d7b65..2ca9b5eb0c 100644 --- a/src/components/views/donate/ManageRecurringDonation.tsx +++ b/src/components/views/donate/ManageRecurringDonation.tsx @@ -8,7 +8,7 @@ import links from '@/lib/constants/links'; export const ManageRecurringDonation = () => { return ( -
Managing your recurring donations
+ Managing your recurring donations

You can modify or delete your recurring donation as well as @@ -29,6 +29,10 @@ export const ManageRecurringDonation = () => { ); }; +const Title = styled(H5)` + color: ${brandColors.deep[800]}; +`; + const Box = styled.div` padding: 16px; border-radius: 12px; From 2d69e7e5632c8558b43d6be8077c43187bcb05f0 Mon Sep 17 00:00:00 2001 From: Cherik Date: Wed, 1 May 2024 14:35:20 +0330 Subject: [PATCH 26/28] open doc in new tab --- src/components/views/donate/ManageRecurringDonation.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/views/donate/ManageRecurringDonation.tsx b/src/components/views/donate/ManageRecurringDonation.tsx index 2ca9b5eb0c..a1e014014a 100644 --- a/src/components/views/donate/ManageRecurringDonation.tsx +++ b/src/components/views/donate/ManageRecurringDonation.tsx @@ -20,7 +20,7 @@ export const ManageRecurringDonation = () => {

To learn more about how recurring donations work, visit our{' '} - + documentation article  . From 059800fdbdf4289184f65adcbd1e33a28499b89a Mon Sep 17 00:00:00 2001 From: Cherik Date: Wed, 1 May 2024 17:12:32 +0330 Subject: [PATCH 27/28] pass isRecurring on recurring --- .../donate/RecurringDonationModal/RecurringDonationModal.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/components/views/donate/RecurringDonationModal/RecurringDonationModal.tsx b/src/components/views/donate/RecurringDonationModal/RecurringDonationModal.tsx index f4da52de0f..1066432775 100644 --- a/src/components/views/donate/RecurringDonationModal/RecurringDonationModal.tsx +++ b/src/components/views/donate/RecurringDonationModal/RecurringDonationModal.tsx @@ -454,11 +454,13 @@ const RecurringDonationInnerModal: FC = ({ { txHash: tx.hash, chainType: ChainType.EVM }, ], excludeFromQF: true, + isRecurring: true, }); } else { setSuccessDonation({ txHash: [{ txHash: tx.hash, chainType: ChainType.EVM }], excludeFromQF: true, + isRecurring: true, }); } } From 5825b0e3f02184189ed6d3069ad9920de86de04a Mon Sep 17 00:00:00 2001 From: Cherik Date: Wed, 1 May 2024 17:44:11 +0330 Subject: [PATCH 28/28] update version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0b4bc6725f..0af0c9d564 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "givethdapp", - "version": "2.25.0", + "version": "2.25.1", "private": true, "scripts": { "build": "next build",