on master help sign in
metamask: strange personal_sign ritual
commit1da49991383538068b9acd906ed319b5a4529424 authorfang <github@fang.io> dateThu 16 Sep 2021, 20:51 (5 years ago) parentbd63593
1 file changed+13−1
src/lib/authToken.ts+13−1
src/lib/authToken.ts+13−1
@@ -57,7 +57,19 @@ type GetAuthTokenArgs =
5757 | DefaultAuthTokenArgs;
5858
5959const getMetamaskAuthToken = ({ address, web3 }: MetamaskAuthTokenArgs) => {
60− return web3.eth.personal.sign(MESSAGE, address, '');
60+ if (window.ethereum) {
61+ //NOTE this doesn't _seem_ to be affected by #596,
62+ // but web3.eth.personal.sign hits it semi-reliably?
63+ // no idea what's going on, we should figure it out,
64+ // but we apply this bandaid to hopefully stop the bleeding.
65+ return window.ethereum.request({
66+ method: 'personal_sign',
67+ params: [MESSAGE, address],
68+ from: address,
69+ });
70+ } else {
71+ return web3.eth.personal.sign(MESSAGE, address, '');
72+ }
6173};
6274
6375const getLedgerAuthToken = ({ walletHdPath }: LedgerAuthTokenArgs) => {