1
0
mirror of https://github.com/oceanprotocol/react.git synced 2024-11-26 12:29:01 +01:00

method move

This commit is contained in:
Matthias Kretschmann 2020-07-30 23:31:33 +02:00
parent 30f8e0fdd3
commit 07e35da469
Signed by: m
GPG Key ID: 606EEEF3C479A91F
3 changed files with 17 additions and 16 deletions

View File

@ -10,7 +10,7 @@ import ProviderStatus from './ProviderStatus'
import { Ocean, Logger, Account, Config } from '@oceanprotocol/lib'
import Web3Modal, { ICoreOptions } from 'web3modal'
import { getDefaultProviders } from './getDefaultProviders'
import { getAccountId, getBalance } from '../..'
import { getAccountId, getBalance } from '../../utils'
interface Balance {
eth: string | undefined

View File

@ -1,7 +1,3 @@
import Web3 from 'web3'
import { Account } from '@oceanprotocol/lib'
import { Balance } from '../providers'
export function readFileContent(file: File): Promise<string> {
return new Promise((resolve, reject) => {
const reader = new FileReader()
@ -30,14 +26,4 @@ export const publishFeedback: { [key in number]: string } = {
4: '4/4 Asset published succesfully'
}
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 }
}
export * from './web3'

15
src/utils/web3.ts Normal file
View 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 }
}