diff --git a/pages/dao/[symbol]/proposal/components/instructions/SplTokenTransfer.tsx b/pages/dao/[symbol]/proposal/components/instructions/SplTokenTransfer.tsx index 24f2bce35..d2c940b66 100644 --- a/pages/dao/[symbol]/proposal/components/instructions/SplTokenTransfer.tsx +++ b/pages/dao/[symbol]/proposal/components/instructions/SplTokenTransfer.tsx @@ -1,7 +1,8 @@ import React, { useContext, useEffect, useState } from 'react' import Input from '@components/inputs/Input' +import { LinkButton } from '@components/Button' import useRealm from '@hooks/useRealm' -import { getMintMinAmountAsDecimal } from '@tools/sdk/units' +import { getMintDecimalAmount, getMintMinAmountAsDecimal } from '@tools/sdk/units' import { PublicKey } from '@solana/web3.js' import { precision } from '@utils/formatting' import { @@ -73,6 +74,17 @@ const SplTokenTransfer = ({ propertyName: 'amount', }) } + const setMaxAmount = () => { + const mintAccount = form.governedTokenAccount?.extensions?.mint?.account + const amount = form.governedTokenAccount?.extensions?.amount + if (!mintAccount || !amount) return + + const maxAmount = getMintDecimalAmount(mintAccount, amount).toNumber() + handleSetForm({ + value: maxAmount, + propertyName: 'amount', + }) + } const validateAmountOnBlur = () => { const value = form.amount @@ -192,16 +204,28 @@ const SplTokenTransfer = ({
{destinationAccountName}
)} - +
+
+ Amount +
+ + Max + +
+
+ +
) }