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

fix mm signature (#1420)

* fix mm signature
This commit is contained in:
Alex Coseru 2022-04-14 18:19:56 +03:00 committed by GitHub
parent 628c2fc1fc
commit 29c5c8b60e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -109,14 +109,18 @@ export class Provider {
public async signProviderRequest( public async signProviderRequest(
web3: Web3, web3: Web3,
accountId: string, accountId: string,
message: string message: string,
password?: string
): Promise<string> { ): Promise<string> {
const consumerMessage = web3.utils.soliditySha3({ const consumerMessage = web3.utils.soliditySha3({
t: 'bytes', t: 'bytes',
v: web3.utils.utf8ToHex(message) v: web3.utils.utf8ToHex(message)
}) })
const consumerSignature = await web3.eth.sign(consumerMessage, accountId) const isMetaMask =
return consumerSignature web3 && web3.currentProvider && (web3.currentProvider as any).isMetaMask
if (isMetaMask)
return await web3.eth.personal.sign(consumerMessage, accountId, password)
else return await web3.eth.sign(consumerMessage, accountId)
} }
/** Encrypt data using the Provider's own symmetric key /** Encrypt data using the Provider's own symmetric key