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

Showing algorithms from other networks in the algo selection on edit form

This commit is contained in:
Jamie Hewitt 2022-12-08 16:27:24 +03:00
parent 0c64b1e5e7
commit ee0f276fcd
4 changed files with 6 additions and 20 deletions

View File

@ -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<AssetSelectionAsset[]> {
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,
[]
)

View File

@ -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<AssetSelectionAsset[]> {
@ -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) {

View File

@ -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,
[]
)

View File

@ -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<AssetSelectionAsset[]> => {
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
)