From c5a37159823c7a22514ed9c1ce08867b0649a86d Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Sat, 18 Jul 2020 01:52:08 +0200 Subject: [PATCH] code splitting and cleanup --- src/@types/MetaData.d.ts | 10 ++++++---- src/components/Layout.module.css | 2 +- src/components/molecules/Menu.tsx | 4 +++- src/components/molecules/Wallet/index.module.css | 0 src/components/molecules/Wallet/index.tsx | 1 - src/components/organisms/AssetActions/Consume.tsx | 5 ++--- src/components/pages/Publish/validation.ts | 2 +- src/utils/wallet.ts | 8 ++++---- 8 files changed, 17 insertions(+), 15 deletions(-) delete mode 100644 src/components/molecules/Wallet/index.module.css diff --git a/src/@types/MetaData.d.ts b/src/@types/MetaData.d.ts index c60b75209..766651bb0 100644 --- a/src/@types/MetaData.d.ts +++ b/src/@types/MetaData.d.ts @@ -1,7 +1,9 @@ -import { Metadata } from '@oceanprotocol/lib' -import { AdditionalInformation } from '@oceanprotocol/lib/dist/node/ddo/interfaces/AdditionalInformation' -import { File } from '@oceanprotocol/lib/dist/node/ddo/interfaces/File' -import { ServiceMetadata } from '@oceanprotocol/lib/dist/node/ddo/interfaces/Service' +import { + Metadata, + File, + AdditionalInformation, + ServiceMetadata +} from '@oceanprotocol/lib' export declare type AccessType = 'Download' | 'Compute' diff --git a/src/components/Layout.module.css b/src/components/Layout.module.css index 8baa0a8ba..ba398cbff 100644 --- a/src/components/Layout.module.css +++ b/src/components/Layout.module.css @@ -1,7 +1,7 @@ .app { height: 100%; background: url('../../node_modules/@oceanprotocol/art/waves/waves.svg') - no-repeat center 10rem; + no-repeat center 11rem; /* sticky footer technique */ display: flex; diff --git a/src/components/molecules/Menu.tsx b/src/components/molecules/Menu.tsx index 5d841a5ad..ddfcbb620 100644 --- a/src/components/molecules/Menu.tsx +++ b/src/components/molecules/Menu.tsx @@ -1,12 +1,14 @@ import React, { ReactElement } from 'react' import { Link } from 'gatsby' import { useLocation } from '@reach/router' +import loadable from '@loadable/component' import styles from './Menu.module.css' import { useSiteMetadata } from '../../hooks/useSiteMetadata' -import Wallet from './Wallet' import { ReactComponent as Logo } from '@oceanprotocol/art/logo/logo.svg' import Container from '../atoms/Container' +const Wallet = loadable(() => import('./Wallet')) + declare type MenuItem = { name: string link: string diff --git a/src/components/molecules/Wallet/index.module.css b/src/components/molecules/Wallet/index.module.css deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/components/molecules/Wallet/index.tsx b/src/components/molecules/Wallet/index.tsx index 11695e696..5988254cf 100644 --- a/src/components/molecules/Wallet/index.tsx +++ b/src/components/molecules/Wallet/index.tsx @@ -3,7 +3,6 @@ import loadable from '@loadable/component' import { useSpring, animated } from 'react-spring' import Account from './Account' import Details from './Details' -import styles from './index.module.css' import { useOcean } from '@oceanprotocol/react' const Tippy = loadable(() => import('@tippyjs/react/headless')) diff --git a/src/components/organisms/AssetActions/Consume.tsx b/src/components/organisms/AssetActions/Consume.tsx index f4ff580ee..c8c9f4246 100644 --- a/src/components/organisms/AssetActions/Consume.tsx +++ b/src/components/organisms/AssetActions/Consume.tsx @@ -1,5 +1,5 @@ import React, { ReactElement } from 'react' -import Web3 from 'web3' +import { fromWei } from 'web3-utils' import compareAsBN, { Comparisson } from '../../../utils/compareAsBN' import Button from '../../atoms/Button' import File from '../../atoms/File' @@ -23,8 +23,7 @@ export default function Consume({ const file = metadata.main.files[0] const isFree = price === '0' const isBalanceSufficient = - isFree || - compareAsBN(balanceInOcean, Web3.utils.fromWei(price), Comparisson.gte) + isFree || compareAsBN(balanceInOcean, fromWei(price), Comparisson.gte) const isDisabled = !ocean || !isBalanceSufficient || isLoading const PurchaseButton = () => { diff --git a/src/components/pages/Publish/validation.ts b/src/components/pages/Publish/validation.ts index fc9508826..6e629adec 100644 --- a/src/components/pages/Publish/validation.ts +++ b/src/components/pages/Publish/validation.ts @@ -1,5 +1,5 @@ import { MetadataPublishForm } from '../../../@types/Metadata' -import { File as FileMetadata } from '@oceanprotocol/lib/dist/node/ddo/interfaces/File' +import { File as FileMetadata } from '@oceanprotocol/lib' import * as Yup from 'yup' export const validationSchema = Yup.object().shape({ diff --git a/src/utils/wallet.ts b/src/utils/wallet.ts index 1daab1fbf..154470266 100644 --- a/src/utils/wallet.ts +++ b/src/utils/wallet.ts @@ -1,5 +1,4 @@ import { OceanProviderValue } from '@oceanprotocol/react' -import atlas from '@ethereum-navigator/atlas' import { networks, infuraProjectId } from '../../app.config' const web3ModalTheme = { @@ -17,12 +16,13 @@ export async function connectWallet( '@walletconnect/web3-provider' ) + // Provider Options + // https://github.com/Web3Modal/web3modal#provider-options const providerOptions = { - /* See Provider Options Section */ walletconnect: { - package: WalletConnectProvider, // required + package: WalletConnectProvider, options: { - infuraId: infuraProjectId // required + infuraId: infuraProjectId } } }