From d885eb686e8f47e71e51002625632412908042a3 Mon Sep 17 00:00:00 2001 From: samelamin Date: Wed, 15 Nov 2023 20:53:37 +0000 Subject: [PATCH] fix for grant submission --- src/pages/grants/new.tsx | 69 +++++++++++++++++++++++----------------- 1 file changed, 40 insertions(+), 29 deletions(-) diff --git a/src/pages/grants/new.tsx b/src/pages/grants/new.tsx index a3f6fac9..9f032ebb 100644 --- a/src/pages/grants/new.tsx +++ b/src/pages/grants/new.tsx @@ -77,7 +77,7 @@ const GrantApplication = (): JSX.Element => { const [copied, setCopied] = useState(false); const [disableSubmit, setDisableSubmit] = useState(false); const [accounts, setAccounts] = useState([]); - + const IMBUE_DEPOSIT_REQURED = 500; const copyAddress = () => { setCopied(true); @@ -202,6 +202,19 @@ const GrantApplication = (): JSX.Element => { message: 'Total cost must be Less than 100,000,000', }); + + const imbueApi = await initImbueAPIInfo(); + const chainService = new ChainService(imbueApi, user); + const balance: any = await chainService.getBalance( + account.address, + Currency.IMBU + ); + + if (Number(balance) < IMBUE_DEPOSIT_REQURED) + return setError({ + message: `Account has insufficient $IMBU (${IMBUE_DEPOSIT_REQURED} $IMBU) to cover the deposit fees`, + }); + setLoading(true); try { @@ -233,8 +246,6 @@ const GrantApplication = (): JSX.Element => { approvers, }; - const imbueApi = await initImbueAPIInfo(); - const chainService = new ChainService(imbueApi, user); const grantMilestones = grant.milestones.map((m) => ({ percentageToUnlock: m.percentage_to_unlock, @@ -593,33 +604,33 @@ const GrantApplication = (): JSX.Element => { {currencyId >= 100 && ( -
-

Payment Address:

-
- {accounts.length == 0 ? ( - - ) : ( - setPaymentAddress(e.target.value)} + placeholder='Select a payment address' + className='bg-transparent round border border-imbue-purple rounded-[5px] text-base px-5 py-3 mt-4 w-full text-content-primary outline-content-primary' + required > - {account} - - ))} - - )} -
-
+ {accounts.map((account: string) => ( + + ))} + + )} + + )}