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

Correctly display trusted algorithms in compute asset (#1541)

* fix allowed algo

* fix trusted algo filter
This commit is contained in:
mihaisc 2022-06-23 08:06:09 -07:00 committed by GitHub
parent 2b025ea38c
commit aa37155a16
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 11 deletions

View File

@ -151,19 +151,20 @@ export async function getComputeEnviroment(
export function getQueryString( export function getQueryString(
trustedAlgorithmList: PublisherTrustedAlgorithm[], trustedAlgorithmList: PublisherTrustedAlgorithm[],
trustedPublishersList: string[],
chainId?: number chainId?: number
): SearchQuery { ): SearchQuery {
const algorithmDidList = trustedAlgorithmList.map((x) => x.did) const algorithmDidList = trustedAlgorithmList?.map((x) => x.did)
const baseParams = { const baseParams = {
chainIds: [chainId], chainIds: [chainId],
sort: { sortBy: SortTermOptions.Created }, sort: { sortBy: SortTermOptions.Created },
filters: [ filters: [getFilterTerm('metadata.type', 'algorithm')]
getFilterTerm('metadata.type', 'algorithm'),
algorithmDidList.length > 0 && getFilterTerm('_id', algorithmDidList)
]
} as BaseQueryParams } as BaseQueryParams
algorithmDidList?.length > 0 &&
baseParams.filters.push(getFilterTerm('_id', algorithmDidList))
trustedPublishersList?.length > 0 &&
baseParams.filters.push(getFilterTerm('nft.owner', trustedPublishersList))
const query = generateBaseQuery(baseParams) const query = generateBaseQuery(baseParams)
return query return query
@ -174,17 +175,24 @@ export async function getAlgorithmsForAsset(
token: CancelToken token: CancelToken
): Promise<Asset[]> { ): Promise<Asset[]> {
const computeService: Service = getServiceByName(asset, 'compute') const computeService: Service = getServiceByName(asset, 'compute')
const publisherTrustedAlgorithms =
computeService.compute.publisherTrustedAlgorithms || []
if (!computeService.compute || publisherTrustedAlgorithms.length === 0) { if (
!computeService.compute ||
(computeService.compute.publisherTrustedAlgorithms?.length === 0 &&
computeService.compute.publisherTrustedAlgorithmPublishers?.length === 0)
) {
return [] return []
} }
const gueryResults = await queryMetadata( const gueryResults = await queryMetadata(
getQueryString(publisherTrustedAlgorithms, asset.chainId), getQueryString(
computeService.compute.publisherTrustedAlgorithms,
computeService.compute.publisherTrustedAlgorithmPublishers,
asset.chainId
),
token token
) )
const algorithms: Asset[] = gueryResults?.results const algorithms: Asset[] = gueryResults?.results
return algorithms return algorithms
} }

View File

@ -277,7 +277,6 @@ export default function Compute({
useEffect(() => { useEffect(() => {
if (!asset) return if (!asset) return
getAlgorithmsForAsset(asset, newCancelToken()).then((algorithmsAssets) => { getAlgorithmsForAsset(asset, newCancelToken()).then((algorithmsAssets) => {
setDdoAlgorithmList(algorithmsAssets) setDdoAlgorithmList(algorithmsAssets)
getAlgorithmAssetSelectionList(asset, algorithmsAssets).then( getAlgorithmAssetSelectionList(asset, algorithmsAssets).then(