From b79d5f02c2eb925183f1410704012341aec412e9 Mon Sep 17 00:00:00 2001 From: Bogdan Fazakas Date: Fri, 15 Apr 2022 11:07:14 +0300 Subject: [PATCH] get provier uri for compute results based on job input did --- .../Profile/History/ComputeJobs/Results.tsx | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/components/Profile/History/ComputeJobs/Results.tsx b/src/components/Profile/History/ComputeJobs/Results.tsx index 13703cf67..96617fd60 100644 --- a/src/components/Profile/History/ComputeJobs/Results.tsx +++ b/src/components/Profile/History/ComputeJobs/Results.tsx @@ -4,13 +4,15 @@ import { LoggerInstance, Provider } from '@oceanprotocol/lib' -import React, { ReactElement, useState } from 'react' +import React, { ReactElement, useEffect, useState } from 'react' import { ListItem } from '@shared/atoms/Lists' import Button from '@shared/atoms/Button' import styles from './Results.module.css' import FormHelp from '@shared/FormInput/Help' import content from '../../../../../content/pages/history.json' import { useWeb3 } from '@context/Web3' +import { useCancelToken } from '@hooks/useCancelToken' +import { retrieveAsset } from '@utils/aquarius' export default function Results({ job @@ -22,6 +24,16 @@ export default function Results({ const [isLoading, setIsLoading] = useState(false) const isFinished = job.dateFinished !== null + const [datasetProvider, setDatasetProvider] = useState() + const newCancelToken = useCancelToken() + useEffect(() => { + async function getAssetMetadata() { + const ddo = await retrieveAsset(job.inputDID[0], newCancelToken()) + setDatasetProvider(ddo.services[0].serviceEndpoint) + } + getAssetMetadata() + }, [job.inputDID[0]]) + function getDownloadButtonValue(type: ComputeResultType): string { let buttonName switch (type) { @@ -50,7 +62,7 @@ export default function Results({ try { setIsLoading(true) const jobResult = await providerInstance.getComputeResultUrl( - 'https://v4.provider.rinkeby.oceanprotocol.com/', + datasetProvider, web3, accountId, job.jobId,