Skip to content
This repository has been archived by the owner on Aug 3, 2021. It is now read-only.

Commit

Permalink
no ocean balance conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
kremalicious committed Jul 20, 2020
1 parent 35a8878 commit 49ad474
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/providers/OceanProvider/OceanProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import Web3Modal, { ICoreOptions } from 'web3modal'
import { getDefaultProviders } from './getDefaultProviders'

interface Balance {
eth: string
ocean: string
eth: string | undefined
ocean: string | undefined
}

interface OceanProviderValue {
Expand Down Expand Up @@ -47,7 +47,10 @@ function OceanProvider({
const [chainId, setChainId] = useState<number | undefined>()
const [account, setAccount] = useState<Account | undefined>()
const [accountId, setAccountId] = useState<string | undefined>()
const [balance, setBalance] = useState<Balance | undefined>()
const [balance, setBalance] = useState<Balance | undefined>({
eth: undefined,
ocean: undefined
})
const [status, setStatus] = useState<ProviderStatus>(
ProviderStatus.NOT_AVAILABLE
)
Expand Down Expand Up @@ -117,12 +120,12 @@ function OceanProvider({
}

async function getBalance(web3: Web3, account: Account) {
const balanceEth = await web3.eth.getBalance(account.getId())
const balanceOcean = await account.getOceanBalance()
const balanceEth = await web3.eth.getBalance(await getAccountId(web3)) // returns wei
const balanceOcean = await account.getOceanBalance() // returns ocean

return {
eth: Web3.utils.fromWei(balanceEth),
ocean: Web3.utils.fromWei(balanceOcean)
ocean: balanceOcean
}
}

Expand Down

0 comments on commit 49ad474

Please sign in to comment.