mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
get ocean balance
This commit is contained in:
parent
6e996a1767
commit
eec3267281
13
package-lock.json
generated
13
package-lock.json
generated
@ -3971,13 +3971,13 @@
|
|||||||
"integrity": "sha512-wu5Ub5F50vCAON0GKyv4anPPLm+oWfHViksiAewVS/xvbbnSCt4gHws2Uc1ct25tiO/2AHAyJkqEiC0ep8SHeQ=="
|
"integrity": "sha512-wu5Ub5F50vCAON0GKyv4anPPLm+oWfHViksiAewVS/xvbbnSCt4gHws2Uc1ct25tiO/2AHAyJkqEiC0ep8SHeQ=="
|
||||||
},
|
},
|
||||||
"@oceanprotocol/lib": {
|
"@oceanprotocol/lib": {
|
||||||
"version": "0.1.2",
|
"version": "0.1.3",
|
||||||
"resolved": "https://registry.npmjs.org/@oceanprotocol/lib/-/lib-0.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/@oceanprotocol/lib/-/lib-0.1.3.tgz",
|
||||||
"integrity": "sha512-v4Y0u7WnhhA33uIMuGKlWqGdlZLen7xRcwCBMvTlLp13Z3K+lOcg7UTByVxnKy2Tg2//wMYUWfuhSsk4nDA/DA==",
|
"integrity": "sha512-rJqPoVoSh71YI3jZRXmJ5LS7tzeAKqMLb6cKL5NC4IfBQ6p9KWIeXIITnFtgT7+H/aZO/SL9REL+TJbPdIBrNw==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@ethereum-navigator/navigator": "^0.5.0",
|
"@ethereum-navigator/navigator": "^0.5.0",
|
||||||
|
"@oceanprotocol/contracts": "^0.2.2",
|
||||||
"bignumber.js": "^9.0.0",
|
"bignumber.js": "^9.0.0",
|
||||||
"deprecated-decorator": "^0.1.6",
|
|
||||||
"fs": "0.0.1-security",
|
"fs": "0.0.1-security",
|
||||||
"node-fetch": "^2.6.0",
|
"node-fetch": "^2.6.0",
|
||||||
"save-file": "^2.3.1",
|
"save-file": "^2.3.1",
|
||||||
@ -11507,11 +11507,6 @@
|
|||||||
"resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz",
|
||||||
"integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak="
|
"integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak="
|
||||||
},
|
},
|
||||||
"deprecated-decorator": {
|
|
||||||
"version": "0.1.6",
|
|
||||||
"resolved": "https://registry.npmjs.org/deprecated-decorator/-/deprecated-decorator-0.1.6.tgz",
|
|
||||||
"integrity": "sha1-AJZjF7ehL+kvPMgx91g68ym4bDc="
|
|
||||||
},
|
|
||||||
"des.js": {
|
"des.js": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/des.js/-/des.js-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/des.js/-/des.js-1.0.1.tgz",
|
||||||
|
@ -22,8 +22,7 @@
|
|||||||
"@loadable/component": "^5.13.1",
|
"@loadable/component": "^5.13.1",
|
||||||
"@now/node": "^1.7.2",
|
"@now/node": "^1.7.2",
|
||||||
"@oceanprotocol/art": "^3.0.0",
|
"@oceanprotocol/art": "^3.0.0",
|
||||||
"@oceanprotocol/contracts": "^0.2.2",
|
"@oceanprotocol/lib": "^0.1.3",
|
||||||
"@oceanprotocol/lib": "^0.1.2",
|
|
||||||
"@oceanprotocol/react": "^0.0.12",
|
"@oceanprotocol/react": "^0.0.12",
|
||||||
"@oceanprotocol/typographies": "^0.1.0",
|
"@oceanprotocol/typographies": "^0.1.0",
|
||||||
"@sindresorhus/slugify": "^1.0.0",
|
"@sindresorhus/slugify": "^1.0.0",
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React, { ReactElement } from 'react'
|
import React, { ReactElement, useEffect, useState } from 'react'
|
||||||
import Button from '../../atoms/Button'
|
import Button from '../../atoms/Button'
|
||||||
import styles from './Details.module.css'
|
import styles from './Details.module.css'
|
||||||
import { useOcean } from '@oceanprotocol/react'
|
import { useOcean } from '@oceanprotocol/react'
|
||||||
@ -8,14 +8,25 @@ import { connectWallet } from '../../../utils/wallet'
|
|||||||
import { getInjectedProviderName } from 'web3modal'
|
import { getInjectedProviderName } from 'web3modal'
|
||||||
|
|
||||||
export default function Details({ attrs }: { attrs: any }): ReactElement {
|
export default function Details({ attrs }: { attrs: any }): ReactElement {
|
||||||
const { balance, connect, logout, web3Provider } = useOcean()
|
const { ocean, balance, connect, logout } = useOcean()
|
||||||
const oceanBalance = 'Hello Test'
|
const [balanceOcean, setBalanceOcean] = useState('0')
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
async function init() {
|
||||||
|
if (!ocean) return
|
||||||
|
|
||||||
|
const accounts = await ocean.accounts.list()
|
||||||
|
const newBalanceOcean = await ocean.accounts.getOceanBalance(accounts[0])
|
||||||
|
newBalanceOcean && setBalanceOcean(newBalanceOcean)
|
||||||
|
}
|
||||||
|
init()
|
||||||
|
}, [ocean])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.details} {...attrs}>
|
<div className={styles.details} {...attrs}>
|
||||||
<ul>
|
<ul>
|
||||||
<li className={styles.balance}>
|
<li className={styles.balance}>
|
||||||
<span>OCEAN</span> {oceanBalance}
|
<span>OCEAN</span> {balanceOcean}
|
||||||
</li>
|
</li>
|
||||||
<li className={styles.balance}>
|
<li className={styles.balance}>
|
||||||
<span>ETH</span> {formatNumber(Number(balance))}
|
<span>ETH</span> {formatNumber(Number(balance))}
|
||||||
|
Loading…
Reference in New Issue
Block a user