From a0ee033a52620d78808ad353bc6dc7c1e5984022 Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Tue, 9 Aug 2022 10:35:36 +0530 Subject: [PATCH] add method --- libs/remix-ui/run-tab/src/lib/actions/deploy.ts | 10 ++++++++++ libs/remix-ui/run-tab/src/lib/actions/index.ts | 10 ++-------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/libs/remix-ui/run-tab/src/lib/actions/deploy.ts b/libs/remix-ui/run-tab/src/lib/actions/deploy.ts index 440d805664..caf8e6de8a 100644 --- a/libs/remix-ui/run-tab/src/lib/actions/deploy.ts +++ b/libs/remix-ui/run-tab/src/lib/actions/deploy.ts @@ -300,4 +300,14 @@ export const runTransactions = ( export const getFuncABIInputs = (plugin: RunTab, funcABI: FuncABI) => { return plugin.blockchain.getInputs(funcABI) +} + +export const updateInstanceBalance = (plugin: RunTab) => { + if (plugin.REACT_API?.instances?.instanceList?.length) { + for (const instance of plugin.REACT_API.instances.instanceList) { + plugin.blockchain.getBalanceInEther(instance.address, (err, balInEth) => { + if (!err) instance.balance = balInEth + }) + } + } } \ No newline at end of file diff --git a/libs/remix-ui/run-tab/src/lib/actions/index.ts b/libs/remix-ui/run-tab/src/lib/actions/index.ts index bbf375eaed..6a20e9470d 100644 --- a/libs/remix-ui/run-tab/src/lib/actions/index.ts +++ b/libs/remix-ui/run-tab/src/lib/actions/index.ts @@ -6,7 +6,7 @@ import { createNewBlockchainAccount, fillAccountsList, setExecutionContext, sign import { clearInstances, clearPopUp, removeInstance, setAccount, setGasFee, setMatchPassphrasePrompt, setNetworkNameFromProvider, setPassphrasePrompt, setSelectedContract, setSendTransactionValue, setUnit, updateBaseFeePerGas, updateConfirmSettings, updateGasPrice, updateGasPriceStatus, updateMaxFee, updateMaxPriorityFee, updateScenarioPath, updateTxFeeContent } from './actions' -import { createInstance, getContext, getFuncABIInputs, getSelectedContract, loadAddress, runTransactions } from './deploy' +import { createInstance, getContext, getFuncABIInputs, getSelectedContract, loadAddress, runTransactions, updateInstanceBalance } from './deploy' import { CompilerAbstract as CompilerAbstractType } from '@remix-project/remix-solidity-ts' import { ContractData, FuncABI } from "@remix-project/core-plugin" import { DeployMode, MainnetPrompt } from '../types' @@ -28,13 +28,7 @@ export const initRunTab = (udapp: RunTab) => async (reducerDispatch: React.Dispa setupEvents(plugin, dispatch) setInterval(() => { fillAccountsList(plugin, dispatch) - if (plugin.REACT_API?.instances?.instanceList?.length){ - for (const instance of plugin.REACT_API.instances.instanceList) { - plugin.blockchain.getBalanceInEther(instance.address, (err, balInEth) => { - if (!err) instance.balance = balInEth - }) - } - } + updateInstanceBalance(plugin) }, 1000) }