From 778007dbac6c76f38028584d3feabf967ad7a654 Mon Sep 17 00:00:00 2001 From: aniket-engg Date: Fri, 9 Feb 2024 18:27:54 +0530 Subject: [PATCH] fix dot at balance end --- apps/remix-ide/src/blockchain/providers/injected.ts | 3 ++- apps/remix-ide/src/blockchain/providers/node.ts | 3 ++- apps/remix-ide/src/blockchain/providers/vm.ts | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/apps/remix-ide/src/blockchain/providers/injected.ts b/apps/remix-ide/src/blockchain/providers/injected.ts index 76c211a0ff..32b4938f70 100644 --- a/apps/remix-ide/src/blockchain/providers/injected.ts +++ b/apps/remix-ide/src/blockchain/providers/injected.ts @@ -29,7 +29,8 @@ export class InjectedProvider { async getBalanceInEther (address) { const balance = await this.executionContext.web3().eth.getBalance(address) - return Web3.utils.fromWei(balance.toString(10), 'ether') + const balInString = balance.toString(10) + return balInString === '0' ? balInString : Web3.utils.fromWei(balInString, 'ether') } getGasPrice (cb) { diff --git a/apps/remix-ide/src/blockchain/providers/node.ts b/apps/remix-ide/src/blockchain/providers/node.ts index 1dcf1b6c40..c77421e045 100644 --- a/apps/remix-ide/src/blockchain/providers/node.ts +++ b/apps/remix-ide/src/blockchain/providers/node.ts @@ -35,7 +35,8 @@ export class NodeProvider { async getBalanceInEther (address) { const balance = await this.executionContext.web3().eth.getBalance(address) - return Web3.utils.fromWei(balance.toString(10), 'ether') + const balInString = balance.toString(10) + return balInString === '0' ? balInString : Web3.utils.fromWei(balInString, 'ether') } getGasPrice (cb) { diff --git a/apps/remix-ide/src/blockchain/providers/vm.ts b/apps/remix-ide/src/blockchain/providers/vm.ts index 3ae7f6a154..67357b347e 100644 --- a/apps/remix-ide/src/blockchain/providers/vm.ts +++ b/apps/remix-ide/src/blockchain/providers/vm.ts @@ -97,7 +97,8 @@ export class VMProvider { async getBalanceInEther (address) { const balance = await this.web3.eth.getBalance(address, undefined, { number: FMT_NUMBER.HEX, bytes: FMT_BYTES.HEX }) - return fromWei(toBigInt(balance).toString(10), 'ether') + const balInString = toBigInt(balance).toString(10) + return balInString === '0' ? balInString : fromWei(balInString, 'ether') } getGasPrice (cb) {