From 941ca71d1d1e9d6188daec5f8716f6f7c00b40f0 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Mon, 20 Jul 2020 13:33:20 +0200 Subject: [PATCH] use ocean methods for all balances --- src/providers/OceanProvider/OceanProvider.tsx | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/providers/OceanProvider/OceanProvider.tsx b/src/providers/OceanProvider/OceanProvider.tsx index 6f10c85..7caa698 100644 --- a/src/providers/OceanProvider/OceanProvider.tsx +++ b/src/providers/OceanProvider/OceanProvider.tsx @@ -100,7 +100,7 @@ function OceanProvider({ setAccountId(accountId) Logger.log('account id', accountId) - const balance = await getBalance(web3, account) + const balance = await getBalance(account) setBalance(balance) Logger.log('balance', JSON.stringify(balance)) @@ -119,14 +119,11 @@ function OceanProvider({ return accounts[0] } - async function getBalance(web3: Web3, account: Account) { - const balanceEth = await web3.eth.getBalance(await getAccountId(web3)) // returns wei - const balanceOcean = await account.getOceanBalance() // returns ocean + async function getBalance(account: Account) { + const eth = await account.getEtherBalance() + const ocean = await account.getOceanBalance() - return { - eth: Web3.utils.fromWei(balanceEth), - ocean: balanceOcean - } + return { eth, ocean } } //