Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export async function signMessage(messageDict: MessageDict) {
const signerAccount = await getUserAccount()
if (!signerAccount) {
throw new Error(`Not a web3 game session`)
}
const messageToSign = await messageToString(messageDict)
if (messageToSign.indexOf('# DCL Signed message') === -1) {
throw new Error(`Message is not in a right format.`)
}
const hexEncodedMessage = toHex(messageToSign)
try {
const signature = await requestManager.personal_sign(hexEncodedMessage, signerAccount, '')
return { message: messageToSign, hexEncodedMessage, signature }
} catch (err) {
throw new Error(err)
}
}