mirror of
https://github.com/oceanprotocol/react.git
synced 2025-02-14 21:10:38 +01:00
no ocean balance conversion
This commit is contained in:
parent
35a8878fc9
commit
49ad47493c
@ -12,8 +12,8 @@ import Web3Modal, { ICoreOptions } from 'web3modal'
|
|||||||
import { getDefaultProviders } from './getDefaultProviders'
|
import { getDefaultProviders } from './getDefaultProviders'
|
||||||
|
|
||||||
interface Balance {
|
interface Balance {
|
||||||
eth: string
|
eth: string | undefined
|
||||||
ocean: string
|
ocean: string | undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
interface OceanProviderValue {
|
interface OceanProviderValue {
|
||||||
@ -47,7 +47,10 @@ function OceanProvider({
|
|||||||
const [chainId, setChainId] = useState<number | undefined>()
|
const [chainId, setChainId] = useState<number | undefined>()
|
||||||
const [account, setAccount] = useState<Account | undefined>()
|
const [account, setAccount] = useState<Account | undefined>()
|
||||||
const [accountId, setAccountId] = useState<string | 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>(
|
const [status, setStatus] = useState<ProviderStatus>(
|
||||||
ProviderStatus.NOT_AVAILABLE
|
ProviderStatus.NOT_AVAILABLE
|
||||||
)
|
)
|
||||||
@ -117,12 +120,12 @@ function OceanProvider({
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function getBalance(web3: Web3, account: Account) {
|
async function getBalance(web3: Web3, account: Account) {
|
||||||
const balanceEth = await web3.eth.getBalance(account.getId())
|
const balanceEth = await web3.eth.getBalance(await getAccountId(web3)) // returns wei
|
||||||
const balanceOcean = await account.getOceanBalance()
|
const balanceOcean = await account.getOceanBalance() // returns ocean
|
||||||
|
|
||||||
return {
|
return {
|
||||||
eth: Web3.utils.fromWei(balanceEth),
|
eth: Web3.utils.fromWei(balanceEth),
|
||||||
ocean: Web3.utils.fromWei(balanceOcean)
|
ocean: balanceOcean
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user