mirror of
https://github.com/oceanprotocol/react.git
synced 2024-11-26 20:39:02 +01:00
method move
This commit is contained in:
parent
30f8e0fdd3
commit
07e35da469
@ -10,7 +10,7 @@ import ProviderStatus from './ProviderStatus'
|
|||||||
import { Ocean, Logger, Account, Config } from '@oceanprotocol/lib'
|
import { Ocean, Logger, Account, Config } from '@oceanprotocol/lib'
|
||||||
import Web3Modal, { ICoreOptions } from 'web3modal'
|
import Web3Modal, { ICoreOptions } from 'web3modal'
|
||||||
import { getDefaultProviders } from './getDefaultProviders'
|
import { getDefaultProviders } from './getDefaultProviders'
|
||||||
import { getAccountId, getBalance } from '../..'
|
import { getAccountId, getBalance } from '../../utils'
|
||||||
|
|
||||||
interface Balance {
|
interface Balance {
|
||||||
eth: string | undefined
|
eth: string | undefined
|
||||||
|
@ -1,7 +1,3 @@
|
|||||||
import Web3 from 'web3'
|
|
||||||
import { Account } from '@oceanprotocol/lib'
|
|
||||||
import { Balance } from '../providers'
|
|
||||||
|
|
||||||
export function readFileContent(file: File): Promise<string> {
|
export function readFileContent(file: File): Promise<string> {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const reader = new FileReader()
|
const reader = new FileReader()
|
||||||
@ -30,14 +26,4 @@ export const publishFeedback: { [key in number]: string } = {
|
|||||||
4: '4/4 Asset published succesfully'
|
4: '4/4 Asset published succesfully'
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getAccountId(web3: Web3): Promise<string> {
|
export * from './web3'
|
||||||
const accounts = await web3.eth.getAccounts()
|
|
||||||
return accounts[0]
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function getBalance(account: Account): Promise<Balance> {
|
|
||||||
const eth = await account.getEtherBalance()
|
|
||||||
const ocean = await account.getOceanBalance()
|
|
||||||
|
|
||||||
return { eth, ocean }
|
|
||||||
}
|
|
||||||
|
15
src/utils/web3.ts
Normal file
15
src/utils/web3.ts
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import Web3 from 'web3'
|
||||||
|
import { Account } from '@oceanprotocol/lib'
|
||||||
|
import { Balance } from '../providers'
|
||||||
|
|
||||||
|
export async function getAccountId(web3: Web3): Promise<string> {
|
||||||
|
const accounts = await web3.eth.getAccounts()
|
||||||
|
return accounts[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getBalance(account: Account): Promise<Balance> {
|
||||||
|
const eth = await account.getEtherBalance()
|
||||||
|
const ocean = await account.getOceanBalance()
|
||||||
|
|
||||||
|
return { eth, ocean }
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user