Update check for displaying deploy button

This commit is contained in:
IshaVenikar 2025-02-11 12:06:26 +05:30
parent 8e8aec1442
commit ffa23fc874
2 changed files with 28 additions and 31 deletions

View File

@ -589,7 +589,6 @@ const Configure = () => {
</div> </div>
) : ( ) : (
<div className="flex gap-4"> <div className="flex gap-4">
{selectedAccount && (
<Button <Button
{...buttonSize} {...buttonSize}
type="submit" type="submit"
@ -613,7 +612,6 @@ const Configure = () => {
? 'Deploying' ? 'Deploying'
: 'Deploy'} : 'Deploy'}
</Button> </Button>
)}
{isAccountsDataReceived && isBalanceSufficient !== undefined ? ( {isAccountsDataReceived && isBalanceSufficient !== undefined ? (
(!selectedAccount || !isBalanceSufficient) ? ( (!selectedAccount || !isBalanceSufficient) ? (

View File

@ -3,9 +3,7 @@ import { useState, useEffect, useCallback } from 'react';
import { VITE_LACONICD_CHAIN_ID } from 'utils/constants'; import { VITE_LACONICD_CHAIN_ID } from 'utils/constants';
const useCheckBalance = (amount: string, iframeId: string) => { const useCheckBalance = (amount: string, iframeId: string) => {
const [isBalanceSufficient, setIsBalanceSufficient] = useState<boolean | undefined>(undefined); const [isBalanceSufficient, setIsBalanceSufficient] = useState<boolean>();
const chainId = VITE_LACONICD_CHAIN_ID;
const checkBalance = useCallback(() => { const checkBalance = useCallback(() => {
const iframe = document.getElementById(iframeId) as HTMLIFrameElement; const iframe = document.getElementById(iframeId) as HTMLIFrameElement;
@ -18,16 +16,17 @@ const useCheckBalance = (amount: string, iframeId: string) => {
iframe.contentWindow.postMessage( iframe.contentWindow.postMessage(
{ {
type: 'CHECK_BALANCE', type: 'CHECK_BALANCE',
chainId, chainId: VITE_LACONICD_CHAIN_ID,
amount, amount,
}, },
import.meta.env.VITE_WALLET_IFRAME_URL import.meta.env.VITE_WALLET_IFRAME_URL
); );
}, [iframeId, chainId, amount]); }, [iframeId, amount]);
useEffect(() => { useEffect(() => {
const handleMessage = (event: MessageEvent) => { const handleMessage = (event: MessageEvent) => {
if (event.origin !== import.meta.env.VITE_WALLET_IFRAME_URL) return; if (event.origin !== import.meta.env.VITE_WALLET_IFRAME_URL) return;
if (event.data.type !== 'IS_SUFFICIENT') return; if (event.data.type !== 'IS_SUFFICIENT') return;
setIsBalanceSufficient(event.data.data); setIsBalanceSufficient(event.data.data);