diff --git a/src/@utils/compute.ts b/src/@utils/compute.ts index d0695dafa..066fb72a9 100644 --- a/src/@utils/compute.ts +++ b/src/@utils/compute.ts @@ -149,11 +149,13 @@ export function getQuerryString( sort: { sortBy: SortTermOptions.Created }, filters: [ getFilterTerm('metadata.type', 'algorithm'), - getFilterTerm('_id', algorithmDidList) + algorithmDidList.length > 0 && getFilterTerm('_id', algorithmDidList) ] } as BaseQueryParams const query = generateBaseQuery(baseParams) + console.log('query', query) + return query } @@ -162,22 +164,29 @@ export async function getAlgorithmsForAsset( token: CancelToken ): Promise { const computeService: Service = getServiceByName(asset, 'compute') + const publisherTrustedAlgorithms = + computeService.compute.publisherTrustedAlgorithms || [] + console.log('asset', asset) + console.log('computeService', computeService) + let algorithms: Asset[] if ( - !computeService.compute || - !computeService.compute.publisherTrustedAlgorithms || - computeService.compute.publisherTrustedAlgorithms.length === 0 + !computeService.compute + // !computeService.compute.publisherTrustedAlgorithms || + // computeService.compute.publisherTrustedAlgorithms.length === 0 ) { algorithms = [] } else { + console.log( + 'computeService.compute.publisherTrustedAlgorithms', + publisherTrustedAlgorithms + ) const gueryResults = await queryMetadata( - getQuerryString( - computeService.compute.publisherTrustedAlgorithms, - asset.chainId - ), + getQuerryString(publisherTrustedAlgorithms, asset.chainId), token ) algorithms = gueryResults?.results + console.log('algorithms', algorithms) } return algorithms } @@ -188,11 +197,7 @@ export async function getAlgorithmAssetSelectionList( ): Promise { const computeService: Service = getServiceByName(asset, 'compute') let algorithmSelectionList: AssetSelectionAsset[] - if ( - !computeService.compute || - !computeService.compute.publisherTrustedAlgorithms || - computeService.compute.publisherTrustedAlgorithms.length === 0 - ) { + if (!computeService.compute) { algorithmSelectionList = [] } else { algorithmSelectionList = await transformAssetToAssetSelection( diff --git a/src/components/Asset/AssetActions/Compute/index.tsx b/src/components/Asset/AssetActions/Compute/index.tsx index 2f19d32a0..eb94d3a6f 100644 --- a/src/components/Asset/AssetActions/Compute/index.tsx +++ b/src/components/Asset/AssetActions/Compute/index.tsx @@ -128,7 +128,6 @@ export default function Compute({ !isAlgoConsumablePrice) async function checkAssetDTBalance(asset: DDO) { - console.log('checkAssetDTBalance asset ', asset) if (!asset?.services[0].datatokenAddress) return const datatokenInstance = new Datatoken(web3) const dtBalance = await datatokenInstance.balance( @@ -136,38 +135,9 @@ export default function Compute({ accountId ) setAlgorithmDTBalance(new Decimal(dtBalance).toString()) - console.log('dtBalance ', dtBalance) setHasAlgoAssetDatatoken(Number(dtBalance) >= 1) } - async function getAlgorithmList(): Promise { - const computeService = asset?.services[0] - let algorithmSelectionList: AssetSelectionAsset[] - if ( - !computeService.compute || - !computeService.compute.publisherTrustedAlgorithms || - computeService.compute.publisherTrustedAlgorithms.length === 0 - ) { - algorithmSelectionList = [] - } else { - const gueryResults = await queryMetadata( - getQuerryString( - computeService.compute.publisherTrustedAlgorithms, - asset.chainId - ), - newCancelToken() - ) - setDdoAlgorithmList(gueryResults.results) - - algorithmSelectionList = await transformAssetToAssetSelection( - computeService?.serviceEndpoint, - gueryResults.results, - [] - ) - } - return algorithmSelectionList - } - useEffect(() => { if (!asset?.accessDetails || !accountId) return @@ -179,14 +149,12 @@ export default function Compute({ if (asset?.accessDetails?.addressOrId === ZERO_ADDRESS) return const validUntil = getValidUntilTime() const computeEnv = await getComputeEnviroment(asset) - console.log('asset compute env', computeEnv) const orderPriceAndFees = await getOrderPriceAndFees( asset, computeEnv.id, validUntil, ZERO_ADDRESS ) - console.log('asset orderPriceAndFees', orderPriceAndFees) setOrderPriceAndFees(orderPriceAndFees) } init() @@ -390,7 +358,7 @@ export default function Compute({ computeAlgorithm, newAbortController(), null, - output + null ) if (!response) { setError('Error starting compute job.')