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

Restrict AssetSelection list to only show same network assets (#708)

* wip added check chainId check for asset selection list

* updated condition and update oceanJs lib

* update lock file

* removed config metadatacacheUri since it was not used anymore

* refactor get only chain algos from aqua

* manually added lock file from multinetwork branch
This commit is contained in:
Bogdan Fazakas 2021-07-20 09:58:45 +03:00 committed by GitHub
parent 645041a50a
commit 38a8358762
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 11 deletions

View File

@ -122,7 +122,8 @@ export default function Compute({
}
function getQuerryString(
trustedAlgorithmList: publisherTrustedAlgorithm[]
trustedAlgorithmList: publisherTrustedAlgorithm[],
chainId?: number
): SearchQuery {
let algoQuerry = ''
trustedAlgorithmList.forEach((trusteAlgo) => {
@ -137,7 +138,7 @@ export default function Compute({
offset: 500,
query: {
query_string: {
query: `${algorithmQuery} service.attributes.main.type:algorithm -isInPurgatory:true`
query: `${algorithmQuery} service.attributes.main.type:algorithm AND chainId:${chainId} -isInPurgatory:true`
}
},
sort: { created: -1 }
@ -160,7 +161,8 @@ export default function Compute({
} else {
const gueryResults = await queryMetadata(
getQuerryString(
computeService.attributes.main.privacy.publisherTrustedAlgorithms
computeService.attributes.main.privacy.publisherTrustedAlgorithms,
ddo.chainId
),
source.token
)

View File

@ -46,7 +46,7 @@ export default function FormEditComputeDataset({
offset: 500,
query: {
query_string: {
query: `service.attributes.main.type:algorithm -isInPurgatory:true`
query: `service.attributes.main.type:algorithm AND chainId:${ddo.chainId} -isInPurgatory:true`
}
},
sort: { created: -1 }

View File

@ -3,7 +3,6 @@ import styles from './AlgorithmDatasetsListForCompute.module.css'
import { getAlgorithmDatasetsForCompute } from '../../../utils/aquarius'
import { AssetSelectionAsset } from '../../molecules/FormFields/AssetSelection'
import AssetComputeList from '../../molecules/AssetComputeList'
import { useOcean } from '../../../providers/Ocean'
import { useAsset } from '../../../providers/Asset'
import { DDO } from '@oceanprotocol/lib'
@ -14,7 +13,6 @@ export default function AlgorithmDatasetsListForCompute({
algorithmDid: string
dataset: DDO
}): ReactElement {
const { config } = useOcean()
const { type } = useAsset()
const [datasetsForCompute, setDatasetsForCompute] =
useState<AssetSelectionAsset[]>()
@ -28,7 +26,7 @@ export default function AlgorithmDatasetsListForCompute({
const datasets = await getAlgorithmDatasetsForCompute(
algorithmDid,
datasetComputeService?.serviceEndpoint,
config.metadataCacheUri
dataset?.chainId
)
setDatasetsForCompute(datasets)
}

View File

@ -13,11 +13,11 @@ import { AssetSelectionAsset } from '../components/molecules/FormFields/AssetSel
import { PriceList, getAssetsPriceList } from './subgraph'
import axios, { CancelToken, AxiosResponse } from 'axios'
function getQueryForAlgorithmDatasets(algorithmDid: string) {
function getQueryForAlgorithmDatasets(algorithmDid: string, chainId?: number) {
return {
query: {
query_string: {
query: `service.attributes.main.privacy.publisherTrustedAlgorithms.did:${algorithmDid}`
query: `service.attributes.main.privacy.publisherTrustedAlgorithms.did:${algorithmDid} AND chainId:${chainId}`
}
},
sort: { created: -1 }
@ -177,11 +177,11 @@ export async function transformDDOToAssetSelection(
export async function getAlgorithmDatasetsForCompute(
algorithmId: string,
datasetProviderUri: string,
metadataCacheUri: string
datasetChainId?: number
): Promise<AssetSelectionAsset[]> {
const source = axios.CancelToken.source()
const computeDatasets = await queryMetadata(
getQueryForAlgorithmDatasets(algorithmId),
getQueryForAlgorithmDatasets(algorithmId, datasetChainId),
source.token
)
const computeDatasetsForCurrentAlgorithm: DDO[] = []