Update check for displaying deploy button
This commit is contained in:
parent
8e8aec1442
commit
ffa23fc874
@ -422,7 +422,7 @@ const Configure = () => {
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if(isAccountsDataReceived) {
|
||||
if (isAccountsDataReceived) {
|
||||
checkBalance();
|
||||
}
|
||||
}, [amountToBePaid, selectedAccount, selectedDeployer, isAccountsDataReceived]);
|
||||
@ -589,31 +589,29 @@ const Configure = () => {
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex gap-4">
|
||||
{selectedAccount && (
|
||||
<Button
|
||||
{...buttonSize}
|
||||
type="submit"
|
||||
shape="default"
|
||||
disabled={
|
||||
isLoading || isPaymentLoading || !selectedAccount || !isBalanceSufficient
|
||||
}
|
||||
rightIcon={
|
||||
isLoading || isPaymentLoading ? (
|
||||
<LoadingIcon className="animate-spin" />
|
||||
) : (
|
||||
<ArrowRightCircleFilledIcon />
|
||||
)
|
||||
}
|
||||
>
|
||||
{!isPaymentDone
|
||||
? isPaymentLoading
|
||||
? 'Transaction Requested'
|
||||
: 'Pay and Deploy'
|
||||
: isLoading
|
||||
? 'Deploying'
|
||||
: 'Deploy'}
|
||||
</Button>
|
||||
)}
|
||||
<Button
|
||||
{...buttonSize}
|
||||
type="submit"
|
||||
shape="default"
|
||||
disabled={
|
||||
isLoading || isPaymentLoading || !selectedAccount || !isBalanceSufficient
|
||||
}
|
||||
rightIcon={
|
||||
isLoading || isPaymentLoading ? (
|
||||
<LoadingIcon className="animate-spin" />
|
||||
) : (
|
||||
<ArrowRightCircleFilledIcon />
|
||||
)
|
||||
}
|
||||
>
|
||||
{!isPaymentDone
|
||||
? isPaymentLoading
|
||||
? 'Transaction Requested'
|
||||
: 'Pay and Deploy'
|
||||
: isLoading
|
||||
? 'Deploying'
|
||||
: 'Deploy'}
|
||||
</Button>
|
||||
|
||||
{isAccountsDataReceived && isBalanceSufficient !== undefined ? (
|
||||
(!selectedAccount || !isBalanceSufficient) ? (
|
||||
|
@ -3,9 +3,7 @@ import { useState, useEffect, useCallback } from 'react';
|
||||
import { VITE_LACONICD_CHAIN_ID } from 'utils/constants';
|
||||
|
||||
const useCheckBalance = (amount: string, iframeId: string) => {
|
||||
const [isBalanceSufficient, setIsBalanceSufficient] = useState<boolean | undefined>(undefined);
|
||||
|
||||
const chainId = VITE_LACONICD_CHAIN_ID;
|
||||
const [isBalanceSufficient, setIsBalanceSufficient] = useState<boolean>();
|
||||
|
||||
const checkBalance = useCallback(() => {
|
||||
const iframe = document.getElementById(iframeId) as HTMLIFrameElement;
|
||||
@ -18,16 +16,17 @@ const useCheckBalance = (amount: string, iframeId: string) => {
|
||||
iframe.contentWindow.postMessage(
|
||||
{
|
||||
type: 'CHECK_BALANCE',
|
||||
chainId,
|
||||
chainId: VITE_LACONICD_CHAIN_ID,
|
||||
amount,
|
||||
},
|
||||
import.meta.env.VITE_WALLET_IFRAME_URL
|
||||
);
|
||||
}, [iframeId, chainId, amount]);
|
||||
}, [iframeId, amount]);
|
||||
|
||||
useEffect(() => {
|
||||
const handleMessage = (event: MessageEvent) => {
|
||||
if (event.origin !== import.meta.env.VITE_WALLET_IFRAME_URL) return;
|
||||
|
||||
if (event.data.type !== 'IS_SUFFICIENT') return;
|
||||
|
||||
setIsBalanceSufficient(event.data.data);
|
||||
|
Loading…
Reference in New Issue
Block a user