1
0
mirror of https://github.com/oceanprotocol/ocean.js.git synced 2024-11-26 20:39:05 +01:00

staged helper file

This commit is contained in:
Bogdan Fazakas 2021-06-08 09:08:51 +03:00
parent c88680f100
commit 200e0d8832

View File

@ -0,0 +1,25 @@
import { DDO } from '../ddo/DDO'
import { Ocean } from '../ocean/Ocean'
export interface AssetResolver {
did: string
ddo: DDO
}
function isDdo(arg: any): arg is DDO {
return arg.id !== undefined
}
export async function assetResolve(asset: DDO | string): Promise<AssetResolver> {
let ocean: Ocean
if (isDdo(asset)) {
const did = asset.id
const ddo = asset
return { did, ddo }
} else {
const ddo = await ocean.assets.resolve(asset)
const did = ddo.id
return { did, ddo }
}
}