1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-12-02 05:57:29 +01: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 { transformAssetToAssetSelection } from './assetConvertor'
import { AssetExtended } from 'src/@types/AssetExtended' import { AssetExtended } from 'src/@types/AssetExtended'
import { ComputeEditForm } from 'src/components/Asset/Edit/_types' import { ComputeEditForm } from 'src/components/Asset/Edit/_types'
import { getFileDidInfo } from './provider'
const getComputeOrders = gql` const getComputeOrders = gql`
query ComputeOrders($user: String!) { query ComputeOrders($user: String!) {
@ -352,12 +353,18 @@ export async function createTrustedAlgorithmList(
tag: selectedAlgorithm.metadata.algorithm.container.tag, tag: selectedAlgorithm.metadata.algorithm.container.tag,
checksum: selectedAlgorithm.metadata.algorithm.container.checksum checksum: selectedAlgorithm.metadata.algorithm.container.checksum
} }
const filesChecksum = await getFileDidInfo(
selectedAlgorithm?.id,
selectedAlgorithm?.services?.[0].id,
selectedAlgorithm?.services?.[0]?.serviceEndpoint,
true
)
const trustedAlgorithm = { const trustedAlgorithm = {
did: selectedAlgorithm.id, did: selectedAlgorithm.id,
containerSectionChecksum: getHash( containerSectionChecksum: getHash(
JSON.stringify(sanitizedAlgorithmContainer) JSON.stringify(sanitizedAlgorithmContainer)
), ),
filesChecksum: getHash(selectedAlgorithm.services[0].files) filesChecksum: filesChecksum?.[0]?.checksum
} }
trustedAlgorithms.push(trustedAlgorithm) trustedAlgorithms.push(trustedAlgorithm)
} }

View File

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