From 0c6223a21c718cec74ff42ea6684d7c9f435c395 Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Thu, 4 Aug 2022 14:14:30 +0530 Subject: [PATCH] update balance --- .../src/lib/components/universalDappUI.tsx | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/libs/remix-ui/run-tab/src/lib/components/universalDappUI.tsx b/libs/remix-ui/run-tab/src/lib/components/universalDappUI.tsx index 7d1ada661b..6156f82b5f 100644 --- a/libs/remix-ui/run-tab/src/lib/components/universalDappUI.tsx +++ b/libs/remix-ui/run-tab/src/lib/components/universalDappUI.tsx @@ -34,10 +34,7 @@ export function UniversalDappUI (props: UdappProps) { useEffect(() => { if (props.instance.address) { - props.blockchain.getBalanceInEther(props.instance.address, (err, balInEth) => { - if (!err) setContractBal(balInEth) - }) - + updateBalance() // @ts-ignore let address = (props.instance.address.slice(0, 2) === '0x' ? '' : '0x') + props.instance.address.toString('hex') @@ -52,6 +49,16 @@ export function UniversalDappUI (props: UdappProps) { } }, [props.instance.contractData]) + props.blockchain.event.register('transactionExecuted', (error, from, to, data, call, txResult, timestamp, _payload) => { + if (!error) updateBalance() + }) + + const updateBalance = () => { + props.blockchain.getBalanceInEther(props.instance.address, (err, balInEth) => { + if (!err) setContractBal(balInEth) + }) + } + const sendData = () => { setLlIError('') const fallback = txHelper.getFallbackInterface(contractABI)