From 8ac4f59deee3276e9ba81fa2f32a9eb776ae49ce Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Fri, 11 Jun 2021 15:35:28 +0200 Subject: [PATCH] temporary ddo.chainId typing --- src/providers/Ocean.tsx | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/providers/Ocean.tsx b/src/providers/Ocean.tsx index ccce14f0d..5efecc0c7 100644 --- a/src/providers/Ocean.tsx +++ b/src/providers/Ocean.tsx @@ -7,7 +7,13 @@ import React, { ReactNode, useEffect } from 'react' -import { Ocean, Logger, Account, ConfigHelperConfig } from '@oceanprotocol/lib' +import { + Ocean, + Logger, + Account, + ConfigHelperConfig, + DDO +} from '@oceanprotocol/lib' import { useWeb3 } from './Web3' import { getDevelopmentConfig, getOceanConfig } from '../utils/ocean' @@ -22,6 +28,11 @@ interface OceanProviderValue { const OceanContext = createContext({} as OceanProviderValue) +// TODO: remove temporary typing once ddo.chainId is present in ocean.js +interface DDO_TEMPORARY extends DDO { + chainId: number +} + function OceanProvider({ children }: { children: ReactNode }): ReactElement { const { web3, accountId } = useWeb3() const { ddo } = useAsset() @@ -62,10 +73,10 @@ function OceanProvider({ children }: { children: ReactNode }): ReactElement { // if (!ddo?.chainId) return const config = { - ...getOceanConfig(ddo?.chainId || 1), + ...getOceanConfig((ddo as DDO_TEMPORARY)?.chainId || 1), // add local dev values - ...(ddo?.chainId === 8996 && { + ...((ddo as DDO_TEMPORARY)?.chainId === 8996 && { ...getDevelopmentConfig() }) } @@ -74,7 +85,7 @@ function OceanProvider({ children }: { children: ReactNode }): ReactElement { await connect(config) } init() - }, [connect, ddo?.chainId]) + }, [connect, ddo]) // ----------------------------------- // Get user info, handle account change from web3