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

Showing algorithms from all chains on the asset detail page

This commit is contained in:
Jamie Hewitt 2022-12-08 18:25:25 +03:00
parent 6b8486cde9
commit 7f79b86b5b
3 changed files with 12 additions and 4 deletions

View File

@ -6,11 +6,14 @@ export async function transformAssetToAssetSelection(
assets: Asset[], assets: Asset[],
selectedAlgorithms?: PublisherTrustedAlgorithm[] selectedAlgorithms?: PublisherTrustedAlgorithm[]
): Promise<AssetSelectionAsset[]> { ): Promise<AssetSelectionAsset[]> {
console.log(`assets: ${JSON.stringify(assets)}`)
console.log(`selectedAlgorithms: ${JSON.stringify(selectedAlgorithms)}`)
const extendedAssets: AssetExtended[] = await getAccessDetailsForAssets( const extendedAssets: AssetExtended[] = await getAccessDetailsForAssets(
assets assets
) )
const algorithmList: AssetSelectionAsset[] = [] const algorithmList: AssetSelectionAsset[] = []
console.log(`extendedAssets: ${JSON.stringify(extendedAssets)}`)
for (const asset of extendedAssets) { for (const asset of extendedAssets) {
if (asset?.accessDetails?.price) { if (asset?.accessDetails?.price) {
let selected = false let selected = false

View File

@ -26,6 +26,7 @@ import { AssetSelectionAsset } from '@shared/FormInput/InputElement/AssetSelecti
import { transformAssetToAssetSelection } from './assetConvertor' import { transformAssetToAssetSelection } from './assetConvertor'
import { ComputeEditForm } from '../components/Asset/Edit/_types' import { ComputeEditForm } from '../components/Asset/Edit/_types'
import { getFileDidInfo } from './provider' import { getFileDidInfo } from './provider'
import { chainIdsSupported } from 'app.config'
const getComputeOrders = gql` const getComputeOrders = gql`
query ComputeOrders($user: String!) { query ComputeOrders($user: String!) {
@ -158,7 +159,7 @@ export function getQueryString(
const algorithmDidList = trustedAlgorithmList?.map((x) => x.did) const algorithmDidList = trustedAlgorithmList?.map((x) => x.did)
const baseParams = { const baseParams = {
chainIds: [chainId], chainIds: chainId ? [chainId] : chainIdsSupported,
sort: { sortBy: SortTermOptions.Created }, sort: { sortBy: SortTermOptions.Created },
filters: [getFilterTerm('metadata.type', 'algorithm')] filters: [getFilterTerm('metadata.type', 'algorithm')]
} as BaseQueryParams } as BaseQueryParams
@ -174,6 +175,7 @@ export async function getAlgorithmsForAsset(
asset: Asset, asset: Asset,
token: CancelToken token: CancelToken
): Promise<Asset[]> { ): Promise<Asset[]> {
console.log(`getAlgorithmsForAsset`, asset)
const computeService: Service = getServiceByName(asset, 'compute') const computeService: Service = getServiceByName(asset, 'compute')
if ( if (
@ -191,8 +193,9 @@ export async function getAlgorithmsForAsset(
), ),
token token
) )
console.log('gueryResults', gueryResults)
const algorithms: Asset[] = gueryResults?.results const algorithms: Asset[] = gueryResults?.results
console.log('algorithms', algorithms)
return algorithms return algorithms
} }
@ -205,6 +208,7 @@ export async function getAlgorithmAssetSelectionList(
if (!computeService.compute) { if (!computeService.compute) {
algorithmSelectionList = [] algorithmSelectionList = []
} else { } else {
console.log('1 algorithms', algorithms)
algorithmSelectionList = await transformAssetToAssetSelection( algorithmSelectionList = await transformAssetToAssetSelection(
algorithms, algorithms,
[] []

View File

@ -247,9 +247,10 @@ export default function Compute({
useEffect(() => { useEffect(() => {
if (!asset?.accessDetails || isUnsupportedPricing) return if (!asset?.accessDetails || isUnsupportedPricing) return
console.log('asset', asset)
getAlgorithmsForAsset(asset, newCancelToken()).then((algorithmsAssets) => { getAlgorithmsForAsset(asset, newCancelToken()).then((algorithmsAssets) => {
setDdoAlgorithmList(algorithmsAssets) setDdoAlgorithmList(algorithmsAssets)
console.log('algorithmsAssets', algorithmsAssets)
getAlgorithmAssetSelectionList(asset, algorithmsAssets).then( getAlgorithmAssetSelectionList(asset, algorithmsAssets).then(
(algorithmSelectionList) => { (algorithmSelectionList) => {
setAlgorithmList(algorithmSelectionList) setAlgorithmList(algorithmSelectionList)