From ea15f20cac94439a418e2afb267a78371c149098 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Fri, 11 Jun 2021 15:43:59 +0200 Subject: [PATCH] mock ddo.chainId response --- src/providers/Ocean.tsx | 2 +- src/utils/aquarius.ts | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/providers/Ocean.tsx b/src/providers/Ocean.tsx index 5efecc0c7..1fc47c1bf 100644 --- a/src/providers/Ocean.tsx +++ b/src/providers/Ocean.tsx @@ -29,7 +29,7 @@ interface OceanProviderValue { const OceanContext = createContext({} as OceanProviderValue) // TODO: remove temporary typing once ddo.chainId is present in ocean.js -interface DDO_TEMPORARY extends DDO { +export interface DDO_TEMPORARY extends DDO { chainId: number } diff --git a/src/utils/aquarius.ts b/src/utils/aquarius.ts index db8b09d83..12df4225b 100644 --- a/src/utils/aquarius.ts +++ b/src/utils/aquarius.ts @@ -12,6 +12,7 @@ import { import { AssetSelectionAsset } from '../components/molecules/FormFields/AssetSelection' import { PriceList, getAssetsPriceList } from './subgraph' import axios, { CancelToken, AxiosResponse } from 'axios' +import { DDO_TEMPORARY } from '../providers/Ocean' // TODO: import directly from ocean.js somehow. // Transforming Aquarius' direct response is needed for getting actual DDOs @@ -64,7 +65,7 @@ export async function retrieveDDO( did: string | DID, metadataCacheUri: string, cancelToken: CancelToken -): Promise { +): Promise { try { const response: AxiosResponse = await axios.get( `${metadataCacheUri}/api/v1/aquarius/assets/ddo/${did}`, @@ -72,7 +73,9 @@ export async function retrieveDDO( ) if (!response || response.status !== 200 || !response.data) return - return new DDO(response.data) + // TODO: remove hacking in chainId in DDO response once Aquarius gives us that + const data = { ...response.data, chainId: 1 } + return new DDO(data) as DDO_TEMPORARY } catch (error) { if (axios.isCancel(error)) { Logger.log(error.message)