diff --git a/src/brizo/Brizo.ts b/src/brizo/Brizo.ts index e5c20cb..a3429e1 100644 --- a/src/brizo/Brizo.ts +++ b/src/brizo/Brizo.ts @@ -119,8 +119,13 @@ export class Brizo extends Instantiable { jobId?: string, output?: Output ): Promise { - const signature = await this.createSignature(consumerAccount, serviceAgreementId) const address = consumerAccount.getId() + + let signatureMessage = address + signatureMessage += (jobId && `${jobId}`) || '' + signatureMessage += (serviceAgreementId && `${noZeroX(serviceAgreementId)}`) || '' + const signature = await this.createSignature(consumerAccount, signatureMessage) + let serviceEndpoint if (serviceAgreementId) serviceEndpoint = await this.getEndpointFromAgreement( @@ -189,13 +194,10 @@ export class Brizo extends Instantiable { return result } - public async createSignature(account: Account, agreementId: string): Promise { + public async createSignature(account: Account, message: string): Promise { const signature = (await account.getToken()) || - (await this.ocean.utils.signature.signText( - noZeroX(agreementId), - account.getId() - )) + (await this.ocean.utils.signature.signText(message, account.getId())) return signature } diff --git a/src/ocean/utils/SignatureUtils.ts b/src/ocean/utils/SignatureUtils.ts index 2f269ae..81a29d9 100644 --- a/src/ocean/utils/SignatureUtils.ts +++ b/src/ocean/utils/SignatureUtils.ts @@ -21,7 +21,8 @@ export class SignatureUtils { this.web3.currentProvider && (this.web3.currentProvider as any).isMetaMask try { - return await this.web3.eth.personal.sign(text, publicKey, password) + const hash = await this.getHash(text) + return await this.web3.eth.personal.sign(hash, publicKey, password) } catch (e) { if (isMetaMask) { throw e