From 796fc6be81ba51b55d0429424de94a46e13871b3 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Fri, 4 Jun 2021 15:50:24 +0200 Subject: [PATCH] get all screens to render again --- app.config.js | 5 ++++- src/components/atoms/AssetType.tsx | 4 ++-- src/components/atoms/ExplorerLink.tsx | 4 ++-- .../molecules/FormFields/FilesInput/index.tsx | 13 +++++-------- src/components/organisms/AssetContent/index.tsx | 2 +- src/components/pages/History/PublishedList.tsx | 9 ++++++--- src/components/pages/Home.tsx | 3 --- src/providers/Ocean.tsx | 6 +++++- 8 files changed, 25 insertions(+), 21 deletions(-) diff --git a/app.config.js b/app.config.js index cdcfe7228..4d3c8f82a 100644 --- a/app.config.js +++ b/app.config.js @@ -1,5 +1,8 @@ module.exports = { - metadataCacheUri: 'https://aquarius.mainnet.oceanprotocol.com', + metadataCacheUri: + process.env.METADATACACHE_URI || + 'https://aquarius.mainnet.oceanprotocol.com', + // List of supported chainIds which metadata cache queries // will return by default chainIds: [1, 3, 4, 137, 1287], diff --git a/src/components/atoms/AssetType.tsx b/src/components/atoms/AssetType.tsx index 235d72b5d..7a3878551 100644 --- a/src/components/atoms/AssetType.tsx +++ b/src/components/atoms/AssetType.tsx @@ -37,9 +37,9 @@ export default function AssetType({ {type === 'dataset' ? 'data set' : 'algorithm'} {/* TODO: networkId needs to come from the multinetwork DDO for each asset */} - {config?.networkId && ( + {(config?.networkId || 1) && ( diff --git a/src/components/atoms/ExplorerLink.tsx b/src/components/atoms/ExplorerLink.tsx index 4104e4e86..bde8f5fad 100644 --- a/src/components/atoms/ExplorerLink.tsx +++ b/src/components/atoms/ExplorerLink.tsx @@ -26,13 +26,13 @@ export default function ExplorerLink({ }) useEffect(() => { - setUrl((config as ConfigHelperConfig).explorerUri) + setUrl((config as ConfigHelperConfig)?.explorerUri) }, [config]) return ( () - const { config } = useOcean() function loadFileInfo() { const source = axios.CancelToken.source() async function validateUrl() { + // TODO: get the providerUri + const providerUri = '' + try { setIsLoading(true) - const checkedFile = await fileinfo( - fileUrl, - config.providerUri, - source.token - ) + const checkedFile = await fileinfo(fileUrl, providerUri, source.token) checkedFile && helpers.setValue([checkedFile]) } catch (error) { toast.error('Could not fetch file info. Please check URL and try again') @@ -43,7 +40,7 @@ export default function FilesInput(props: InputProps): ReactElement { useEffect(() => { loadFileInfo() - }, [fileUrl, config.providerUri]) + }, [fileUrl]) async function handleButtonClick(e: React.SyntheticEvent, url: string) { // hack so the onBlur-triggered validation does not show, diff --git a/src/components/organisms/AssetContent/index.tsx b/src/components/organisms/AssetContent/index.tsx index abd48cbe6..ef4550209 100644 --- a/src/components/organisms/AssetContent/index.tsx +++ b/src/components/organisms/AssetContent/index.tsx @@ -80,7 +80,7 @@ export default function AssetContent(props: AssetContentProps): ReactElement { {showPricing && }
- + {/* */} {isInPurgatory ? ( () const [isLoading, setIsLoading] = useState(false) @@ -20,6 +21,8 @@ export default function PublishedList(): ReactElement { useEffect(() => { async function getPublished() { if (!accountId) return + + // TODO: this query needs to adapt to chainIds const queryPublishedAssets = { page: page, offset: 9, @@ -34,7 +37,7 @@ export default function PublishedList(): ReactElement { queryResult || setIsLoading(true) const result = await queryMetadata( queryPublishedAssets, - metadataCacheUri, + appConfig.metadataCacheUri, source.token ) setQueryResult(result) @@ -45,7 +48,7 @@ export default function PublishedList(): ReactElement { } } getPublished() - }, [accountId, page, metadataCacheUri]) + }, [accountId, page, appConfig.metadataCacheUri]) return accountId ? ( Promise } @@ -33,6 +34,7 @@ function OceanProvider({ children }: { children: ReactNode }): ReactElement { const [ocean, setOcean] = useState() const [account, setAccount] = useState() + const [config, setConfig] = useState() // ----------------------------------- // Helper: Create Ocean instance @@ -50,6 +52,7 @@ function OceanProvider({ children }: { children: ReactNode }): ReactElement { Logger.log('[ocean] Connecting Ocean...', newConfig) const newOcean = await Ocean.getInstance(newConfig) setOcean(newOcean) + setConfig(newConfig) Logger.log('[ocean] Ocean instance created.', newOcean) } catch (error) { Logger.error('[ocean] Error: ', error.message) @@ -99,7 +102,8 @@ function OceanProvider({ children }: { children: ReactNode }): ReactElement { { ocean, account, - connect + connect, + config // refreshBalance } as OceanProviderValue }