1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-12-02 05:57:29 +01:00

mock ddo.chainId response

This commit is contained in:
Matthias Kretschmann 2021-06-11 15:43:59 +02:00
parent 8ac4f59dee
commit ea15f20cac
Signed by: m
GPG Key ID: 606EEEF3C479A91F
2 changed files with 6 additions and 3 deletions

View File

@ -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
}

View File

@ -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<DDO> {
): Promise<DDO_TEMPORARY> {
try {
const response: AxiosResponse<DDO> = 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)