1
0
mirror of https://github.com/oceanprotocol/react.git synced 2024-11-23 02:00:27 +01:00

use ocean methods for all balances

This commit is contained in:
Matthias Kretschmann 2020-07-20 13:33:20 +02:00
parent e189aa60ae
commit 941ca71d1d
Signed by: m
GPG Key ID: 606EEEF3C479A91F

View File

@ -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 }
}
//