on master help sign in
lib: fix metamask wonkiness with personal_sign
commit0f1adfee5f04eed476d7710cd91ee6d9ac749a19 authorpkova <pyry@urbit.org> dateTue 27 Oct 2026, 13:27 (4 days ago) parentd1fc830
1 file changed+4−3
src/lib/authToken.ts+4−3
src/lib/authToken.ts+4−3
@@ -1,7 +1,7 @@
11import { crypto } from 'bitcoinjs-lib';
22import { ecdsaSign } from 'secp256k1';
33import Web3 from 'web3';
4−import { hexToBytes } from 'web3-utils';
4+import { hexToBytes, utf8ToHex } from 'web3-utils';
55import { hashPersonalMessage } from '@ethereumjs/util';
66import { WALLET_TYPES } from './constants';
77import BridgeWallet from './types/BridgeWallet';
@@ -76,10 +76,11 @@ const getMetamaskAuthToken = ({ address, web3 }: MetamaskAuthTokenArgs) => {
7676 // but web3.eth.personal.sign hits it semi-reliably?
7777 // no idea what's going on, we should figure it out,
7878 // but we apply this bandaid to hopefully stop the bleeding.
79+ //NOTE personal_sign expects hex-encoded data; signing the hex of
80+ // MESSAGE yields the same signature as the other wallet types
7981 return window.ethereum.request({
8082 method: 'personal_sign',
81− params: [MESSAGE, address],
82− from: address,
83+ params: [utf8ToHex(MESSAGE), address],
8384 });
8485 } else {
8586 return web3.eth.personal.sign(MESSAGE, address, '');