1
0
mirror of https://github.com/oceanprotocol-archive/squid-js.git synced 2024-02-02 15:31:51 +01:00

add detection for meta mask

This commit is contained in:
Sebastian Gerske 2018-12-18 15:50:37 +01:00
parent 0c08a2348b
commit 724a29ee80

View File

@ -86,8 +86,14 @@ export default class ServiceAgreement extends OceanBase {
valueHashes, valueHashes,
timeoutValues) timeoutValues)
const serviceAgreementHashSignature = await Web3Provider let serviceAgreementHashSignature: string
.getWeb3().eth.sign(serviceAgreementHash, consumer.getId()) const web3 = Web3Provider.getWeb3()
if (web3.currentProvider.isMetaMask) {
// password is injected by metamask, dont try to set it!
serviceAgreementHashSignature = await web3.eth.personal.sign(serviceAgreementHash, consumer.getId(), null)
} else {
serviceAgreementHashSignature = await web3.eth.sign(serviceAgreementHash, consumer.getId())
}
return serviceAgreementHashSignature return serviceAgreementHashSignature
} }