Skip to content

Commit 778007d

Browse files
Aniket-Enggyann300
authored andcommitted
fix dot at balance end
1 parent aa77a3e commit 778007d

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

apps/remix-ide/src/blockchain/providers/injected.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ export class InjectedProvider {
2929

3030
async getBalanceInEther (address) {
3131
const balance = await this.executionContext.web3().eth.getBalance(address)
32-
return Web3.utils.fromWei(balance.toString(10), 'ether')
32+
const balInString = balance.toString(10)
33+
return balInString === '0' ? balInString : Web3.utils.fromWei(balInString, 'ether')
3334
}
3435

3536
getGasPrice (cb) {

apps/remix-ide/src/blockchain/providers/node.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ export class NodeProvider {
3535

3636
async getBalanceInEther (address) {
3737
const balance = await this.executionContext.web3().eth.getBalance(address)
38-
return Web3.utils.fromWei(balance.toString(10), 'ether')
38+
const balInString = balance.toString(10)
39+
return balInString === '0' ? balInString : Web3.utils.fromWei(balInString, 'ether')
3940
}
4041

4142
getGasPrice (cb) {

apps/remix-ide/src/blockchain/providers/vm.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ export class VMProvider {
9797

9898
async getBalanceInEther (address) {
9999
const balance = await this.web3.eth.getBalance(address, undefined, { number: FMT_NUMBER.HEX, bytes: FMT_BYTES.HEX })
100-
return fromWei(toBigInt(balance).toString(10), 'ether')
100+
const balInString = toBigInt(balance).toString(10)
101+
return balInString === '0' ? balInString : fromWei(balInString, 'ether')
101102
}
102103

103104
getGasPrice (cb) {

0 commit comments

Comments
 (0)