Skip to content

Commit

Permalink
Fallback to personal_sign if eth_sign fails (#7468)
Browse files Browse the repository at this point in the history
  • Loading branch information
mds1 authored Sep 21, 2020
1 parent 41b99c5 commit 865a6f1
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion app/assets/v2/js/cart.js
Original file line number Diff line number Diff line change
Expand Up @@ -1366,7 +1366,16 @@ Vue.component('grants-cart', {
const message = 'Access Gitcoin zkSync account.\n\nOnly sign this message for a trusted client!';

indicateMetamaskPopup();
const signature = await this.signer.signMessage(message); // web3 prompt to user is here
let signature;

signature = await this.signer.signMessage(message); // web3 prompt to user is here
if (!signature) {
// Fallback to personal_sign if eth_sign isn't supported (for Status and other wallets)
signature = await this.ethersProvider.send(
'personal_sign',
[ ethers.utils.hexlify(ethers.utils.toUtf8Bytes(message)), this.userAddress.toLowerCase() ]
);
}

indicateMetamaskPopup(true);
const privateKey = ethers.utils.sha256(signature);
Expand Down

0 comments on commit 865a6f1

Please sign in to comment.