mirror of
https://github.com/oceanprotocol/react.git
synced 2024-11-26 12:29:01 +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 Web3Modal, { ICoreOptions } from 'web3modal'
|
||||
import { getDefaultProviders } from './getDefaultProviders'
|
||||
import { getAccountId, getBalance } from '../..'
|
||||
import { getAccountId, getBalance } from '../../utils'
|
||||
|
||||
interface Balance {
|
||||
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> {
|
||||
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
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