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:
parent
2b025ea38c
commit
aa37155a16
@ -151,19 +151,20 @@ export async function getComputeEnviroment(
|
||||
|
||||
export function getQueryString(
|
||||
trustedAlgorithmList: PublisherTrustedAlgorithm[],
|
||||
trustedPublishersList: string[],
|
||||
chainId?: number
|
||||
): SearchQuery {
|
||||
const algorithmDidList = trustedAlgorithmList.map((x) => x.did)
|
||||
const algorithmDidList = trustedAlgorithmList?.map((x) => x.did)
|
||||
|
||||
const baseParams = {
|
||||
chainIds: [chainId],
|
||||
sort: { sortBy: SortTermOptions.Created },
|
||||
filters: [
|
||||
getFilterTerm('metadata.type', 'algorithm'),
|
||||
algorithmDidList.length > 0 && getFilterTerm('_id', algorithmDidList)
|
||||
]
|
||||
filters: [getFilterTerm('metadata.type', 'algorithm')]
|
||||
} 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)
|
||||
|
||||
return query
|
||||
@ -174,17 +175,24 @@ export async function getAlgorithmsForAsset(
|
||||
token: CancelToken
|
||||
): Promise<Asset[]> {
|
||||
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 []
|
||||
}
|
||||
|
||||
const gueryResults = await queryMetadata(
|
||||
getQueryString(publisherTrustedAlgorithms, asset.chainId),
|
||||
getQueryString(
|
||||
computeService.compute.publisherTrustedAlgorithms,
|
||||
computeService.compute.publisherTrustedAlgorithmPublishers,
|
||||
asset.chainId
|
||||
),
|
||||
token
|
||||
)
|
||||
|
||||
const algorithms: Asset[] = gueryResults?.results
|
||||
return algorithms
|
||||
}
|
||||
|
@ -277,7 +277,6 @@ export default function Compute({
|
||||
|
||||
useEffect(() => {
|
||||
if (!asset) return
|
||||
|
||||
getAlgorithmsForAsset(asset, newCancelToken()).then((algorithmsAssets) => {
|
||||
setDdoAlgorithmList(algorithmsAssets)
|
||||
getAlgorithmAssetSelectionList(asset, algorithmsAssets).then(
|
||||
|
Loading…
Reference in New Issue
Block a user