From deb74f17206a2d4753684bba90fb8f6ceacc673a Mon Sep 17 00:00:00 2001 From: snoopy1412 Date: Tue, 24 Sep 2024 10:29:12 +0800 Subject: [PATCH] update .env (#3) * update .env * fix bug * fix bugs * fix: fix bugs * remove debounce amount * fix error word * fix bugs * Refactor focus styles in amount input and tabs components * Refactor stake-ring component and update non-transferable note * Refactor focus styles in tab components * Refactor token ID display in deposit and unstake components * Refactor label font size in deposit component * Refactor footer component to update the organization name * Refactor stake and deposit hooks to log stakeRING function calls * Refactor deposit and unstake components to use FormattedNumberTooltip * Refactor deposit component to set minimum deposit amount * Refactor RING_DAO_GOVERNANCE_URL_MAP to RING_DAO_GOVERNANCE_MAP --- .env | 1 - public/images/social/twitter-dark.svg | 2 +- public/images/social/twitter-light.svg | 4 +- src/components/amount-input-with-balance.tsx | 48 ++++++++++++++----- src/components/balance-description.tsx | 2 +- src/components/collator/_hooks/collator.ts | 2 +- .../collator/_hooks/update-commission.ts | 2 +- src/components/collator/collator-tabs.tsx | 2 +- src/components/deposit-item.tsx | 22 +++++---- src/components/footer.tsx | 2 +- src/components/formatted-number-tooltip.tsx | 2 +- src/components/transaction-status/pending.tsx | 2 +- src/components/unstake-deposit-item.tsx | 22 +++++---- src/config/chains/index.ts | 32 +++++++++++-- src/config/social.ts | 8 +--- src/config/tabs.ts | 2 +- src/hooks/useAssetsToVotes.ts | 3 +- src/hooks/useDebouncedState.ts | 29 ++++++----- src/hooks/useService.ts | 2 + src/hooks/useWalletStatus.ts | 6 +-- src/layout/tabs.tsx | 3 +- src/view/claim/_components/item.tsx | 16 +++---- src/view/deposit/_components/index.tsx | 38 ++++++--------- src/view/deposit/_components/records.tsx | 17 ++++--- src/view/deposit/_components/rewards.tsx | 2 +- .../stake/_components/manage/stake-more.tsx | 21 +++----- src/view/stake/_components/manage/unstake.tsx | 18 ++----- .../new/collator-active-selection-table.tsx | 8 +++- .../new/collator-waiting-selection-table.tsx | 10 ++-- src/view/stake/_components/new/index.tsx | 2 +- .../stake/_components/new/stake-deposit.tsx | 16 ++----- src/view/stake/_components/new/stake-ring.tsx | 47 ++++++++---------- src/view/stake/_hooks/stake.ts | 11 +++++ 33 files changed, 223 insertions(+), 181 deletions(-) diff --git a/.env b/.env index 286a21a..6024c91 100644 --- a/.env +++ b/.env @@ -2,5 +2,4 @@ VITE_PROJECT_ID = 2719448e2ce94fdd269a3c8587123bcc VITE_DEPLOYMENT_MODE = testnet VITE_APP_NAME = "Collator Staking - RingDAO" VITE_APP_DESCRIPTION = "Elevate your earnings and effortlessly manage your staking positions with the RingDAO collator staking page." - VITE_GRAPHQL_API_URL = "https://indexer.bigdevenergy.link/a15d18a/v1/graphql" diff --git a/public/images/social/twitter-dark.svg b/public/images/social/twitter-dark.svg index 542492e..7adba89 100644 --- a/public/images/social/twitter-dark.svg +++ b/public/images/social/twitter-dark.svg @@ -1,4 +1,4 @@ - + \ No newline at end of file diff --git a/public/images/social/twitter-light.svg b/public/images/social/twitter-light.svg index 89164fd..9fe0c64 100644 --- a/public/images/social/twitter-light.svg +++ b/public/images/social/twitter-light.svg @@ -1,4 +1,4 @@ - - + + \ No newline at end of file diff --git a/src/components/amount-input-with-balance.tsx b/src/components/amount-input-with-balance.tsx index 4ff58fb..7230662 100644 --- a/src/components/amount-input-with-balance.tsx +++ b/src/components/amount-input-with-balance.tsx @@ -1,9 +1,13 @@ import React, { useCallback, useMemo } from 'react'; import { Button, cn } from '@nextui-org/react'; import { BigNumber } from 'bignumber.js'; - import BalanceDescription from './balance-description'; +BigNumber.config({ + EXPONENTIAL_AT: [-1000, 1000], + DECIMAL_PLACES: 1000 +}); + interface AmountInputWithBalanceProps { symbol?: string; className?: string; @@ -39,26 +43,43 @@ const AmountInputWithBalance = ({ (e: React.ChangeEvent) => { if (isDisabled) return; const newValue = e.target.value; - const numValue = new BigNumber(newValue); - - if (newValue === '' || numValue.isNaN()) { - onChange?.(e); - } else { - const minValue = new BigNumber(min); - const result = BigNumber.max(BigNumber.min(numValue, maxValue), minValue); - onChange?.({ target: { value: result.toString() } } as React.ChangeEvent); + // // 允许输入小数点和数字 + if (newValue === '' || /^[0-9]*\.?[0-9]*$/.test(newValue)) { + onChange?.({ + target: { value: newValue } + } as React.ChangeEvent); } }, - [onChange, min, maxValue, isDisabled] + [isDisabled, onChange] ); + const handleInputBlur = useCallback(() => { + if (value === '' || value === '.') { + onChange?.({ + target: { value: '0' } + } as React.ChangeEvent); + return; + } + + const numValue = new BigNumber(value || '0'); + const minValue = new BigNumber(min); + const result = BigNumber.max(BigNumber.min(numValue, maxValue), minValue); + const formattedResult = result.decimalPlaces(18, BigNumber.ROUND_DOWN); + + onChange?.({ + target: { value: formattedResult?.toString() } + } as React.ChangeEvent); + }, [value, onChange, min, maxValue]); + const handleMaxClick = useCallback(() => { - onChange?.({ target: { value: balance || '0' } } as React.ChangeEvent); - }, [balance, onChange]); + onChange?.({ + target: { value: maxValue?.toString() } + } as React.ChangeEvent); + }, [maxValue, onChange]); return (
-
+
Amount
diff --git a/src/components/balance-description.tsx b/src/components/balance-description.tsx index b1de9f5..2dad8cc 100644 --- a/src/components/balance-description.tsx +++ b/src/components/balance-description.tsx @@ -15,7 +15,7 @@ const BalanceDescription = ({ balance, symbol, isLoading, - fractionDigits = 2, + fractionDigits = 3, text = 'Balance' }: BalanceDescriptionProps) => { const balanceBN = new BigNumber(balance || '0'); diff --git a/src/components/collator/_hooks/collator.ts b/src/components/collator/_hooks/collator.ts index a80df1e..057d3fe 100644 --- a/src/components/collator/_hooks/collator.ts +++ b/src/components/collator/_hooks/collator.ts @@ -77,7 +77,7 @@ export const useCreateCollator = ({ functionName: 'assetsToVotes', args: [stakedOf ?? 0n, commission], query: { - enabled: isEnabled && !!commission && !!stakedOf && enabled + enabled: isEnabled && !!stakedOf && enabled } }); diff --git a/src/components/collator/_hooks/update-commission.ts b/src/components/collator/_hooks/update-commission.ts index 3b75861..b094d40 100644 --- a/src/components/collator/_hooks/update-commission.ts +++ b/src/components/collator/_hooks/update-commission.ts @@ -27,7 +27,7 @@ const useUpdateCommission = ({ functionName: 'assetsToVotes', args: [totalAssets, newCommission], query: { - enabled: !!newCommission && !isNil(totalAssets) + enabled: !isNil(totalAssets) } }); diff --git a/src/components/collator/collator-tabs.tsx b/src/components/collator/collator-tabs.tsx index 913ea61..91c0b4b 100644 --- a/src/components/collator/collator-tabs.tsx +++ b/src/components/collator/collator-tabs.tsx @@ -85,7 +85,7 @@ const CollatorTabs = ({ onClose, isOpen }: CollatorTabsProps) => { classNames={{ tabList: 'gap-6 w-full relative rounded-none p-0 border-b border-divider', cursor: 'w-full bg-foreground font-bold', - tab: 'max-w-fit px-0 h-12', + tab: 'max-w-fit px-0 h-12 !outline-none', tabContent: 'group-data-[selected=true]:text-foreground font-bold' }} > diff --git a/src/components/deposit-item.tsx b/src/components/deposit-item.tsx index a627a02..d027701 100644 --- a/src/components/deposit-item.tsx +++ b/src/components/deposit-item.tsx @@ -1,9 +1,8 @@ import { Checkbox, Progress, Tooltip } from '@nextui-org/react'; - -import type { DepositInfo } from '@/hooks/useUserDepositDetails'; -import { formatNumericValue } from '@/utils'; -import { formatEther } from 'viem'; import dayjs from 'dayjs'; +import { formatEther } from 'viem'; +import FormattedNumberTooltip from './formatted-number-tooltip'; +import type { DepositInfo } from '@/hooks/useUserDepositDetails'; interface DepositItemProps { item: DepositInfo; @@ -13,7 +12,7 @@ interface DepositItemProps { } const DepositItem = ({ item, isChecked, symbol, onChange }: DepositItemProps) => { - const formattedValue = formatNumericValue(formatEther(item?.value || 0n), 3); + const value = formatEther(item?.value || 0n); const startAtDate = dayjs(item?.startAt * 1000).format('YYYY-MM-DD'); const endAtDate = dayjs(item?.endAt * 1000).format('YYYY-MM-DD'); const now = dayjs().unix(); @@ -46,12 +45,17 @@ const DepositItem = ({ item, isChecked, symbol, onChange }: DepositItemProps) => label={
- ID# {item?.tokenId?.toString()} + Token ID [{item?.tokenId?.toString()}]
- - {formattedValue.fixed} - + + {(formattedValue) => ( + + {formattedValue} + + )} + + {symbol || ''}
diff --git a/src/components/footer.tsx b/src/components/footer.tsx index 4b0e4d3..2747b0b 100644 --- a/src/components/footer.tsx +++ b/src/components/footer.tsx @@ -8,7 +8,7 @@ const Footer = () => {