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

Improved signature helper using fallback non-personal sign method.

This commit is contained in:
Pedro Gutiérrez 2019-03-07 15:56:13 +01:00 committed by Pedro Gutiérrez
parent 51aa0fbf64
commit 4f28092014

View File

@ -7,10 +7,17 @@ export async function signText(text: string, publicKey: string, password?: strin
try {
return await web3.eth.personal.sign(text, publicKey, password)
} catch (e) {
Logger.error("Error on personal sign.")
Logger.error(e)
try {
return await web3.eth.sign(text, publicKey, password)
} catch(e2) {
Logger.error("Error on sign.")
Logger.error(e2)
throw new Error("Error executing personal sign")
}
}
}
export async function verifyText(text: string, signature: string): Promise<string> {
const web3 = Web3Provider.getWeb3()