1
0
mirror of https://github.com/oceanprotocol/ocean.js.git synced 2024-11-26 20:39:05 +01:00

remove ddo prof

This commit is contained in:
alexcos20 2020-10-13 06:34:57 -07:00
parent 8003bd133f
commit 2c73c6e06d
2 changed files with 28 additions and 5 deletions

View File

@ -157,4 +157,27 @@ export class DDO {
}
this.proof = await this.generateProof(ocean, publicKey, password)
}
/**
* Generates and adds a simple proof
* @param {Ocean} ocean Ocean instance.
* @param {string} publicKey Public key to be used on personal sign.
* @param {string} password Password if it's required.
* @return {Promise<Proof>} Proof object.
*/
public async addSimpleProof(ocean: Ocean, publicKey: string): Promise<void> {
if (this.proof) {
throw new Error('Proof already exists')
}
this.proof = {
created: new Date().toISOString().replace(/\.[0-9]{3}/, ''),
creator: publicKey,
type: 'AddressHash',
signatureValue: Web3Provider.getWeb3()
.utils.sha3(publicKey)
// TODO: security/detect-unsafe-regex
.replace(/^0x([a-f0-9]{64})(:!.+)?$/i, '0x$1')
}
}
}

View File

@ -188,11 +188,11 @@ export class Assets extends Instantiable {
index: indexCount++
})) as Service[]
})
this.logger.log('Generating proof')
observer.next(CreateProgressStep.GeneratingProof)
await ddo.addProof(this.ocean, publisher.getId(), publisher.getPassword())
this.logger.log('Proof generated')
observer.next(CreateProgressStep.ProofGenerated)
// this.logger.log('Generating proof')
// observer.next(CreateProgressStep.GeneratingProof)
await ddo.addSimpleProof(this.ocean, publisher.getId())
// this.logger.log('Proof generated')
// observer.next(CreateProgressStep.ProofGenerated)
this.logger.log('Storing DDO')
observer.next(CreateProgressStep.StoringDdo)
// const storedDdo = await this.ocean.metadatastore.storeDDO(ddo)