1
0
mirror of https://github.com/oceanprotocol/ocean.js.git synced 2024-11-26 20:39:05 +01:00
ocean.js/src/utils/DdoHelpers.ts
Bogdan Fazakas ec601a66d2
Fix get compute results (#1386)
* wip special chars

* clean ups

* update sha256 import from cryptojs lib

* update compute result and use alpha-26 contracts

* re-build with package-lock v1 and with dist

* ignore build files from dist

* delete build files

* removed console logs and updated ComputeResultType typing

* update compute integration test

* added more tests

* added some logs

* update file download method

* use fetch data

* remove download part

* delete console logs

* review fixes

* more fixes

Co-authored-by: Soon Huat <soon_huat.phan@daimler.com>
2022-04-14 23:58:25 +01:00

18 lines
514 B
TypeScript

import sha256 from 'crypto-js/sha256'
import Web3 from 'web3'
import LoggerInstance from './Logger'
export function generateDid(erc721Address: string, chainId: number): string {
erc721Address = Web3.utils.toChecksumAddress(erc721Address)
const checksum = sha256(erc721Address + chainId.toString(10))
return `did:op:${checksum.toString()}`
}
export function getHash(data: any): string {
try {
return sha256(data).toString()
} catch (e) {
LoggerInstance.error('getHash error: ', e.message)
}
}