1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-06-23 01:36:47 +02:00

update filechecksum logic

This commit is contained in:
Bogdan Fazakas 2022-07-08 07:43:58 +03:00
parent f8bbda0594
commit 3d541e7038
2 changed files with 13 additions and 4 deletions

View File

@ -26,6 +26,7 @@ import { AssetSelectionAsset } from '@shared/FormFields/AssetSelection'
import { transformAssetToAssetSelection } from './assetConvertor'
import { AssetExtended } from 'src/@types/AssetExtended'
import { ComputeEditForm } from 'src/components/Asset/Edit/_types'
import { getFileDidInfo } from './provider'
const getComputeOrders = gql`
query ComputeOrders($user: String!) {
@ -352,12 +353,18 @@ export async function createTrustedAlgorithmList(
tag: selectedAlgorithm.metadata.algorithm.container.tag,
checksum: selectedAlgorithm.metadata.algorithm.container.checksum
}
const filesChecksum = await getFileDidInfo(
selectedAlgorithm?.id,
selectedAlgorithm?.services?.[0].id,
selectedAlgorithm?.services?.[0]?.serviceEndpoint,
true
)
const trustedAlgorithm = {
did: selectedAlgorithm.id,
containerSectionChecksum: getHash(
JSON.stringify(sanitizedAlgorithmContainer)
),
filesChecksum: getHash(selectedAlgorithm.services[0].files)
filesChecksum: filesChecksum?.[0]?.checksum
}
trustedAlgorithms.push(trustedAlgorithm)
}

View File

@ -67,13 +67,15 @@ export async function getEncryptedFiles(
export async function getFileDidInfo(
did: string,
serviceId: string,
providerUrl: string
providerUrl: string,
withChecksum: boolean = false
): Promise<FileInfo[]> {
try {
const response = await ProviderInstance.checkDidFiles(
did,
serviceId as any, // TODO: why does ocean.js want a number here?
providerUrl
serviceId,
providerUrl,
withChecksum
)
return response
} catch (error) {