From ee0f276fcd89b0287adfbe3d853b1ba795172e9f Mon Sep 17 00:00:00 2001 From: Jamie Hewitt Date: Thu, 8 Dec 2022 16:27:24 +0300 Subject: [PATCH] Showing algorithms from other networks in the algo selection on edit form --- src/@utils/aquarius/index.ts | 5 ++--- src/@utils/assetConvertor.ts | 11 +---------- src/@utils/compute.ts | 5 +---- src/components/Asset/Edit/FormEditComputeDataset.tsx | 5 ++--- 4 files changed, 6 insertions(+), 20 deletions(-) diff --git a/src/@utils/aquarius/index.ts b/src/@utils/aquarius/index.ts index a29ce37d0..0a7e8409f 100644 --- a/src/@utils/aquarius/index.ts +++ b/src/@utils/aquarius/index.ts @@ -2,7 +2,7 @@ import { Asset, LoggerInstance } from '@oceanprotocol/lib' import { AssetSelectionAsset } from '@shared/FormInput/InputElement/AssetSelection' import axios, { CancelToken, AxiosResponse } from 'axios' import { OrdersData_orders as OrdersData } from '../../@types/subgraph/OrdersData' -import { metadataCacheUri } from '../../../app.config' +import { chainIdsSupported, metadataCacheUri } from '../../../app.config' import { SortDirectionOptions, SortTermOptions @@ -220,7 +220,7 @@ export async function getAlgorithmDatasetsForCompute( cancelToken?: CancelToken ): Promise { const baseQueryParams = { - chainIds: [datasetChainId], + chainIds: chainIdsSupported, nestedQuery: { must: { match: { @@ -241,7 +241,6 @@ export async function getAlgorithmDatasetsForCompute( if (computeDatasets?.totalResults === 0) return [] const datasets = await transformAssetToAssetSelection( - datasetProviderUri, computeDatasets.results, [] ) diff --git a/src/@utils/assetConvertor.ts b/src/@utils/assetConvertor.ts index 6096955d6..949f6c519 100644 --- a/src/@utils/assetConvertor.ts +++ b/src/@utils/assetConvertor.ts @@ -1,11 +1,8 @@ import { getAccessDetailsForAssets } from './accessDetailsAndPricing' import { PublisherTrustedAlgorithm, Asset } from '@oceanprotocol/lib' import { AssetSelectionAsset } from '@shared/FormInput/InputElement/AssetSelection' -import { getServiceByName } from './ddo' -import { chainIds } from 'app.config' export async function transformAssetToAssetSelection( - datasetProviderEndpoint: string, assets: Asset[], selectedAlgorithms?: PublisherTrustedAlgorithm[] ): Promise { @@ -15,13 +12,7 @@ export async function transformAssetToAssetSelection( const algorithmList: AssetSelectionAsset[] = [] for (const asset of extendedAssets) { - const algoService = - getServiceByName(asset, 'compute') || getServiceByName(asset, 'access') - - if ( - asset?.accessDetails?.price && - algoService?.serviceEndpoint === datasetProviderEndpoint - ) { + if (asset?.accessDetails?.price) { let selected = false selectedAlgorithms?.forEach((algorithm: PublisherTrustedAlgorithm) => { if (algorithm.did === asset.id) { diff --git a/src/@utils/compute.ts b/src/@utils/compute.ts index 348d9febb..47864ec17 100644 --- a/src/@utils/compute.ts +++ b/src/@utils/compute.ts @@ -167,7 +167,6 @@ export function getQueryString( trustedPublishersList?.length > 0 && baseParams.filters.push(getFilterTerm('nft.owner', trustedPublishersList)) const query = generateBaseQuery(baseParams) - return query } @@ -188,8 +187,7 @@ export async function getAlgorithmsForAsset( const gueryResults = await queryMetadata( getQueryString( computeService.compute.publisherTrustedAlgorithms, - computeService.compute.publisherTrustedAlgorithmPublishers, - asset.chainId + computeService.compute.publisherTrustedAlgorithmPublishers ), token ) @@ -208,7 +206,6 @@ export async function getAlgorithmAssetSelectionList( algorithmSelectionList = [] } else { algorithmSelectionList = await transformAssetToAssetSelection( - computeService?.serviceEndpoint, algorithms, [] ) diff --git a/src/components/Asset/Edit/FormEditComputeDataset.tsx b/src/components/Asset/Edit/FormEditComputeDataset.tsx index 7d1aef017..f380f5bf9 100644 --- a/src/components/Asset/Edit/FormEditComputeDataset.tsx +++ b/src/components/Asset/Edit/FormEditComputeDataset.tsx @@ -18,6 +18,7 @@ import { transformAssetToAssetSelection } from '@utils/assetConvertor' import { ComputeEditForm } from './_types' import content from '../../../../content/pages/editComputeDataset.json' import { getFieldContent } from '@utils/form' +import { chainIdsSupported } from 'app.config' export default function FormEditComputeDataset(): ReactElement { const { asset } = useAsset() @@ -31,16 +32,14 @@ export default function FormEditComputeDataset(): ReactElement { publisherTrustedAlgorithms: PublisherTrustedAlgorithm[] ): Promise => { const baseParams = { - chainIds: [asset.chainId], + chainIds: chainIdsSupported, sort: { sortBy: SortTermOptions.Created }, filters: [getFilterTerm('metadata.type', 'algorithm')] } as BaseQueryParams const query = generateBaseQuery(baseParams) const queryResult = await queryMetadata(query, newCancelToken()) - const datasetComputeService = getServiceByName(asset, 'compute') const algorithmSelectionList = await transformAssetToAssetSelection( - datasetComputeService?.serviceEndpoint, queryResult?.results, publisherTrustedAlgorithms )