mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
fix asset.create
This commit is contained in:
parent
69fb8be4db
commit
5923e28530
@ -3,7 +3,7 @@ import { Authentication } from './interfaces/Authentication'
|
|||||||
import { Proof } from './interfaces/Proof'
|
import { Proof } from './interfaces/Proof'
|
||||||
import { PublicKey } from './interfaces/PublicKey'
|
import { PublicKey } from './interfaces/PublicKey'
|
||||||
import { Service, ServiceType } from './interfaces/Service'
|
import { Service, ServiceType } from './interfaces/Service'
|
||||||
|
import Web3Provider from '../datatokens/Web3Provider'
|
||||||
/**
|
/**
|
||||||
* DID Descriptor Object.
|
* DID Descriptor Object.
|
||||||
* Contains all the data related to an asset.
|
* Contains all the data related to an asset.
|
||||||
@ -92,10 +92,9 @@ export class DDO {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate the checksum using the current content.
|
* Generate the checksum using the current content.
|
||||||
* @param {Any} web3Provider
|
|
||||||
* @return {string[]} DDO checksum.
|
* @return {string[]} DDO checksum.
|
||||||
*/
|
*/
|
||||||
public getChecksum(web3Provider: any): string {
|
public getChecksum(): string {
|
||||||
const { attributes } = this.findServiceByType('metadata')
|
const { attributes } = this.findServiceByType('metadata')
|
||||||
const { files, name, author, license } = attributes.main
|
const { files, name, author, license } = attributes.main
|
||||||
|
|
||||||
@ -107,7 +106,7 @@ export class DDO {
|
|||||||
this.id
|
this.id
|
||||||
]
|
]
|
||||||
|
|
||||||
return web3Provider
|
return Web3Provider
|
||||||
.getWeb3()
|
.getWeb3()
|
||||||
.utils.sha3(values.join(''))
|
.utils.sha3(values.join(''))
|
||||||
.replace(/^0x([a-f0-9]{64})(:!.+)?$/i, '0x$1')
|
.replace(/^0x([a-f0-9]{64})(:!.+)?$/i, '0x$1')
|
||||||
@ -125,7 +124,7 @@ export class DDO {
|
|||||||
publicKey: string,
|
publicKey: string,
|
||||||
password?: string
|
password?: string
|
||||||
): Promise<Proof> {
|
): Promise<Proof> {
|
||||||
const checksum = this.getChecksum(ocean.web3Provider)
|
const checksum = this.getChecksum()
|
||||||
|
|
||||||
const signature = await ocean.utils.signature.signText(
|
const signature = await ocean.utils.signature.signText(
|
||||||
checksum,
|
checksum,
|
||||||
|
@ -309,7 +309,7 @@ export class Assets extends Instantiable {
|
|||||||
*/
|
*/
|
||||||
public async creator(did: string): Promise<string> {
|
public async creator(did: string): Promise<string> {
|
||||||
const ddo = await this.resolve(did)
|
const ddo = await this.resolve(did)
|
||||||
const checksum = ddo.getChecksum(this.ocean.web3Provider)
|
const checksum = ddo.getChecksum()
|
||||||
const { creator, signatureValue } = ddo.proof
|
const { creator, signatureValue } = ddo.proof
|
||||||
const signer = await this.ocean.utils.signature.verifyText(
|
const signer = await this.ocean.utils.signature.verifyText(
|
||||||
checksum,
|
checksum,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user