From 07e35da4698c8c6e3b864e3ded659182c3a3f60d Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Thu, 30 Jul 2020 23:31:33 +0200 Subject: [PATCH] method move --- src/providers/OceanProvider/OceanProvider.tsx | 2 +- src/utils/index.ts | 16 +--------------- src/utils/web3.ts | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 16 deletions(-) create mode 100644 src/utils/web3.ts diff --git a/src/providers/OceanProvider/OceanProvider.tsx b/src/providers/OceanProvider/OceanProvider.tsx index c33a90a..c30b44a 100644 --- a/src/providers/OceanProvider/OceanProvider.tsx +++ b/src/providers/OceanProvider/OceanProvider.tsx @@ -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 diff --git a/src/utils/index.ts b/src/utils/index.ts index 1b450b2..b068c83 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -1,7 +1,3 @@ -import Web3 from 'web3' -import { Account } from '@oceanprotocol/lib' -import { Balance } from '../providers' - export function readFileContent(file: File): Promise { 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 { - const accounts = await web3.eth.getAccounts() - return accounts[0] -} - -export async function getBalance(account: Account): Promise { - const eth = await account.getEtherBalance() - const ocean = await account.getOceanBalance() - - return { eth, ocean } -} +export * from './web3' diff --git a/src/utils/web3.ts b/src/utils/web3.ts new file mode 100644 index 0000000..f6fe619 --- /dev/null +++ b/src/utils/web3.ts @@ -0,0 +1,15 @@ +import Web3 from 'web3' +import { Account } from '@oceanprotocol/lib' +import { Balance } from '../providers' + +export async function getAccountId(web3: Web3): Promise { + const accounts = await web3.eth.getAccounts() + return accounts[0] +} + +export async function getBalance(account: Account): Promise { + const eth = await account.getEtherBalance() + const ocean = await account.getOceanBalance() + + return { eth, ocean } +}