mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
* add content on edit pages * display edit for user only * add form actions * add restore part of edit metadata logic * adjust edit metadata * wip edit compute settings * added console logs * wip edit compute * updated edit compute flow * updated style * fix pricing various fixes * fix edit acctions * add debug on edit compute tab * add debug on edit metadata tab * more fixes * lint fixes * add pricing to edit metada * restore timout edit * protect edit route * small fixes * fixes and add edit feetback, loading, error, succes on submit * timeout init values fix * added setNftMetadata helper * moved transfor asset to assetSelection from aquarius class * fixed links, removed dispenser hacks * fixed sample Co-authored-by: mihaisc <mihai@oceanprotocol.com>
44 lines
1.4 KiB
TypeScript
44 lines
1.4 KiB
TypeScript
import { getAccessDetailsForAssets } from './accessDetailsAndPricing'
|
|
import { AssetExtended } from 'src/@types/AssetExtended'
|
|
import { PublisherTrustedAlgorithm, Asset } from '@oceanprotocol/lib'
|
|
import { AssetSelectionAsset } from '@shared/FormFields/AssetSelection'
|
|
import { getServiceByName } from './ddo'
|
|
|
|
export async function transformAssetToAssetSelection(
|
|
datasetProviderEndpoint: string,
|
|
assets: Asset[],
|
|
selectedAlgorithms?: PublisherTrustedAlgorithm[]
|
|
): Promise<AssetSelectionAsset[]> {
|
|
const extendedAssets: AssetExtended[] = await getAccessDetailsForAssets(
|
|
assets
|
|
)
|
|
const algorithmList: AssetSelectionAsset[] = []
|
|
|
|
for (const asset of extendedAssets) {
|
|
const algoComputeService = getServiceByName(asset, 'compute')
|
|
|
|
if (
|
|
asset?.accessDetails.price &&
|
|
algoComputeService?.serviceEndpoint === datasetProviderEndpoint
|
|
) {
|
|
let selected = false
|
|
selectedAlgorithms?.forEach((algorithm: PublisherTrustedAlgorithm) => {
|
|
if (algorithm.did === asset.id) {
|
|
selected = true
|
|
}
|
|
})
|
|
const algorithmAsset: AssetSelectionAsset = {
|
|
did: asset.id,
|
|
name: asset.datatokens[0].name,
|
|
price: asset.accessDetails.price,
|
|
checked: selected,
|
|
symbol: asset.datatokens[0].symbol
|
|
}
|
|
selected
|
|
? algorithmList.unshift(algorithmAsset)
|
|
: algorithmList.push(algorithmAsset)
|
|
}
|
|
}
|
|
return algorithmList
|
|
}
|