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:
parent
0c64b1e5e7
commit
ee0f276fcd
@ -2,7 +2,7 @@ import { Asset, LoggerInstance } from '@oceanprotocol/lib'
|
|||||||
import { AssetSelectionAsset } from '@shared/FormInput/InputElement/AssetSelection'
|
import { AssetSelectionAsset } from '@shared/FormInput/InputElement/AssetSelection'
|
||||||
import axios, { CancelToken, AxiosResponse } from 'axios'
|
import axios, { CancelToken, AxiosResponse } from 'axios'
|
||||||
import { OrdersData_orders as OrdersData } from '../../@types/subgraph/OrdersData'
|
import { OrdersData_orders as OrdersData } from '../../@types/subgraph/OrdersData'
|
||||||
import { metadataCacheUri } from '../../../app.config'
|
import { chainIdsSupported, metadataCacheUri } from '../../../app.config'
|
||||||
import {
|
import {
|
||||||
SortDirectionOptions,
|
SortDirectionOptions,
|
||||||
SortTermOptions
|
SortTermOptions
|
||||||
@ -220,7 +220,7 @@ export async function getAlgorithmDatasetsForCompute(
|
|||||||
cancelToken?: CancelToken
|
cancelToken?: CancelToken
|
||||||
): Promise<AssetSelectionAsset[]> {
|
): Promise<AssetSelectionAsset[]> {
|
||||||
const baseQueryParams = {
|
const baseQueryParams = {
|
||||||
chainIds: [datasetChainId],
|
chainIds: chainIdsSupported,
|
||||||
nestedQuery: {
|
nestedQuery: {
|
||||||
must: {
|
must: {
|
||||||
match: {
|
match: {
|
||||||
@ -241,7 +241,6 @@ export async function getAlgorithmDatasetsForCompute(
|
|||||||
if (computeDatasets?.totalResults === 0) return []
|
if (computeDatasets?.totalResults === 0) return []
|
||||||
|
|
||||||
const datasets = await transformAssetToAssetSelection(
|
const datasets = await transformAssetToAssetSelection(
|
||||||
datasetProviderUri,
|
|
||||||
computeDatasets.results,
|
computeDatasets.results,
|
||||||
[]
|
[]
|
||||||
)
|
)
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
import { getAccessDetailsForAssets } from './accessDetailsAndPricing'
|
import { getAccessDetailsForAssets } from './accessDetailsAndPricing'
|
||||||
import { PublisherTrustedAlgorithm, Asset } from '@oceanprotocol/lib'
|
import { PublisherTrustedAlgorithm, Asset } from '@oceanprotocol/lib'
|
||||||
import { AssetSelectionAsset } from '@shared/FormInput/InputElement/AssetSelection'
|
import { AssetSelectionAsset } from '@shared/FormInput/InputElement/AssetSelection'
|
||||||
import { getServiceByName } from './ddo'
|
|
||||||
import { chainIds } from 'app.config'
|
|
||||||
|
|
||||||
export async function transformAssetToAssetSelection(
|
export async function transformAssetToAssetSelection(
|
||||||
datasetProviderEndpoint: string,
|
|
||||||
assets: Asset[],
|
assets: Asset[],
|
||||||
selectedAlgorithms?: PublisherTrustedAlgorithm[]
|
selectedAlgorithms?: PublisherTrustedAlgorithm[]
|
||||||
): Promise<AssetSelectionAsset[]> {
|
): Promise<AssetSelectionAsset[]> {
|
||||||
@ -15,13 +12,7 @@ export async function transformAssetToAssetSelection(
|
|||||||
const algorithmList: AssetSelectionAsset[] = []
|
const algorithmList: AssetSelectionAsset[] = []
|
||||||
|
|
||||||
for (const asset of extendedAssets) {
|
for (const asset of extendedAssets) {
|
||||||
const algoService =
|
if (asset?.accessDetails?.price) {
|
||||||
getServiceByName(asset, 'compute') || getServiceByName(asset, 'access')
|
|
||||||
|
|
||||||
if (
|
|
||||||
asset?.accessDetails?.price &&
|
|
||||||
algoService?.serviceEndpoint === datasetProviderEndpoint
|
|
||||||
) {
|
|
||||||
let selected = false
|
let selected = false
|
||||||
selectedAlgorithms?.forEach((algorithm: PublisherTrustedAlgorithm) => {
|
selectedAlgorithms?.forEach((algorithm: PublisherTrustedAlgorithm) => {
|
||||||
if (algorithm.did === asset.id) {
|
if (algorithm.did === asset.id) {
|
||||||
|
@ -167,7 +167,6 @@ export function getQueryString(
|
|||||||
trustedPublishersList?.length > 0 &&
|
trustedPublishersList?.length > 0 &&
|
||||||
baseParams.filters.push(getFilterTerm('nft.owner', trustedPublishersList))
|
baseParams.filters.push(getFilterTerm('nft.owner', trustedPublishersList))
|
||||||
const query = generateBaseQuery(baseParams)
|
const query = generateBaseQuery(baseParams)
|
||||||
|
|
||||||
return query
|
return query
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,8 +187,7 @@ export async function getAlgorithmsForAsset(
|
|||||||
const gueryResults = await queryMetadata(
|
const gueryResults = await queryMetadata(
|
||||||
getQueryString(
|
getQueryString(
|
||||||
computeService.compute.publisherTrustedAlgorithms,
|
computeService.compute.publisherTrustedAlgorithms,
|
||||||
computeService.compute.publisherTrustedAlgorithmPublishers,
|
computeService.compute.publisherTrustedAlgorithmPublishers
|
||||||
asset.chainId
|
|
||||||
),
|
),
|
||||||
token
|
token
|
||||||
)
|
)
|
||||||
@ -208,7 +206,6 @@ export async function getAlgorithmAssetSelectionList(
|
|||||||
algorithmSelectionList = []
|
algorithmSelectionList = []
|
||||||
} else {
|
} else {
|
||||||
algorithmSelectionList = await transformAssetToAssetSelection(
|
algorithmSelectionList = await transformAssetToAssetSelection(
|
||||||
computeService?.serviceEndpoint,
|
|
||||||
algorithms,
|
algorithms,
|
||||||
[]
|
[]
|
||||||
)
|
)
|
||||||
|
@ -18,6 +18,7 @@ import { transformAssetToAssetSelection } from '@utils/assetConvertor'
|
|||||||
import { ComputeEditForm } from './_types'
|
import { ComputeEditForm } from './_types'
|
||||||
import content from '../../../../content/pages/editComputeDataset.json'
|
import content from '../../../../content/pages/editComputeDataset.json'
|
||||||
import { getFieldContent } from '@utils/form'
|
import { getFieldContent } from '@utils/form'
|
||||||
|
import { chainIdsSupported } from 'app.config'
|
||||||
|
|
||||||
export default function FormEditComputeDataset(): ReactElement {
|
export default function FormEditComputeDataset(): ReactElement {
|
||||||
const { asset } = useAsset()
|
const { asset } = useAsset()
|
||||||
@ -31,16 +32,14 @@ export default function FormEditComputeDataset(): ReactElement {
|
|||||||
publisherTrustedAlgorithms: PublisherTrustedAlgorithm[]
|
publisherTrustedAlgorithms: PublisherTrustedAlgorithm[]
|
||||||
): Promise<AssetSelectionAsset[]> => {
|
): Promise<AssetSelectionAsset[]> => {
|
||||||
const baseParams = {
|
const baseParams = {
|
||||||
chainIds: [asset.chainId],
|
chainIds: chainIdsSupported,
|
||||||
sort: { sortBy: SortTermOptions.Created },
|
sort: { sortBy: SortTermOptions.Created },
|
||||||
filters: [getFilterTerm('metadata.type', 'algorithm')]
|
filters: [getFilterTerm('metadata.type', 'algorithm')]
|
||||||
} as BaseQueryParams
|
} as BaseQueryParams
|
||||||
|
|
||||||
const query = generateBaseQuery(baseParams)
|
const query = generateBaseQuery(baseParams)
|
||||||
const queryResult = await queryMetadata(query, newCancelToken())
|
const queryResult = await queryMetadata(query, newCancelToken())
|
||||||
const datasetComputeService = getServiceByName(asset, 'compute')
|
|
||||||
const algorithmSelectionList = await transformAssetToAssetSelection(
|
const algorithmSelectionList = await transformAssetToAssetSelection(
|
||||||
datasetComputeService?.serviceEndpoint,
|
|
||||||
queryResult?.results,
|
queryResult?.results,
|
||||||
publisherTrustedAlgorithms
|
publisherTrustedAlgorithms
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user