mirror of
https://github.com/oceanprotocol-archive/squid-js.git
synced 2024-02-02 15:31:51 +01:00
add new signature support
This commit is contained in:
parent
7de1b110b0
commit
0b7eb1c067
@ -119,8 +119,13 @@ export class Brizo extends Instantiable {
|
||||
jobId?: string,
|
||||
output?: Output
|
||||
): Promise<ComputeJob | ComputeJob[]> {
|
||||
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<string> {
|
||||
public async createSignature(account: Account, message: string): Promise<string> {
|
||||
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
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user