From 7506fda27a7830ec437c25fdef455547165023fd Mon Sep 17 00:00:00 2001 From: Kirk Date: Mon, 16 Oct 2023 14:10:03 +0300 Subject: [PATCH 01/23] Prepolutaing the Deposit Max Amount --- components/DepositTokensButton.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/components/DepositTokensButton.tsx b/components/DepositTokensButton.tsx index 4479c76079..973a3ec8a3 100644 --- a/components/DepositTokensButton.tsx +++ b/components/DepositTokensButton.tsx @@ -30,12 +30,11 @@ export const DepositTokensButton = ({ const depositTooltipContent = !connected ? 'Connect your wallet to deposit' : !hasTokensInWallet - ? "You don't have any governance tokens in your wallet to deposit." - : undefined + ? "You don't have any governance tokens in your wallet to deposit." + : undefined const ButtonToUse = as === 'primary' ? Button : SecondaryButton const [openModal, setOpenModal] = useState(false) - const [amount, setAmount] = useState('') const mint = useGoverningTokenMint(role) const mintInfo = useMintInfoByPubkeyQuery(mint).data?.result @@ -44,6 +43,8 @@ export const DepositTokensButton = ({ ? undefined : depositAmount.shiftedBy(-mintInfo.decimals).toNumber() + const [amount, setAmount] = useState(humanReadableMax) + const deposit = useDepositCallback(role) return ( <> From 5b4578f0d99606df05056030cf24a008ecb948a7 Mon Sep 17 00:00:00 2001 From: Kirk Date: Mon, 16 Oct 2023 11:27:22 +0000 Subject: [PATCH 02/23] Added minor error handling for input value being parsed --- components/DepositTokensButton.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/components/DepositTokensButton.tsx b/components/DepositTokensButton.tsx index 973a3ec8a3..178f04c9d6 100644 --- a/components/DepositTokensButton.tsx +++ b/components/DepositTokensButton.tsx @@ -65,7 +65,16 @@ export const DepositTokensButton = ({ type="number" label="Amount to deposit" value={amount} - onChange={(e) => setAmount(e.target.value)} + onChange={(e) => { + const inputValue = e.target.value; + const parsedValue = parseFloat(inputValue); // or parseInt for integers + + if (!isNaN(parsedValue)) { + setAmount(parsedValue); + } else { + setAmount(undefined); + } + }} max={humanReadableMax} /> From 0f6e1f70db2cbce4f00757f87e539fbaea7c4ae0 Mon Sep 17 00:00:00 2001 From: Kirk Date: Mon, 16 Oct 2023 12:54:20 +0000 Subject: [PATCH 17/23] Added additional undefined check for humanReadableMax --- components/DepositTokensButton.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/DepositTokensButton.tsx b/components/DepositTokensButton.tsx index 967b95ac95..7f16dd4ec0 100644 --- a/components/DepositTokensButton.tsx +++ b/components/DepositTokensButton.tsx @@ -68,7 +68,7 @@ export const DepositTokensButton = ({

Deposit tokens

humanReadableMax} + disabled={humanReadableMax !== undefined && parseInt(amount) > humanReadableMax && parseInt(amount) > 0} > Confirm From 6498f4d18025219373d1632a7890964ec72192a2 Mon Sep 17 00:00:00 2001 From: Kirk Date: Mon, 16 Oct 2023 13:46:16 +0000 Subject: [PATCH 23/23] Fixed conditional statement for confirm --- components/DepositTokensButton.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/DepositTokensButton.tsx b/components/DepositTokensButton.tsx index 661ef21684..583b845a74 100644 --- a/components/DepositTokensButton.tsx +++ b/components/DepositTokensButton.tsx @@ -88,7 +88,7 @@ export const DepositTokensButton = ({ await deposit(nativeAmount) setOpenModal(false) }} - disabled={humanReadableMax !== undefined && parseInt(amount) > humanReadableMax && parseInt(amount) > 0} + disabled={humanReadableMax !== undefined && (parseInt(amount) > humanReadableMax || parseInt(amount) > 0)} > Confirm