on master help sign in
wc: handle METHOD_NOT_SUPPORTED on message signing
e1b0301Fang
src/lib/useWalletConnect.ts+20−7
@@ -3,7 +3,7 @@ import QRCodeModal from '@walletconnect/qrcode-modal';
3import { ITxData } from '@walletconnect/types';
3import { ITxData } from '@walletconnect/types';
4
4
5import { useEffect, useMemo, useState } from 'react';
5import { useEffect, useMemo, useState } from 'react';
6−import { Just } from 'folktale/maybe';
6+import { Just, Nothing } from 'folktale/maybe';
7
7
8import { useWallet } from 'store/wallet';
8import { useWallet } from 'store/wallet';
9import { getAuthToken } from './authToken';
9import { getAuthToken } from './authToken';
@@ -81,17 +81,30 @@ export const useWalletConnect = () => {
81 return;
81 return;
82 }
82 }
83
83
84+ let authToken = Nothing();
85+ try {
84− const authToken = await getAuthToken({
86+ const token = await getAuthToken({
85− address,
87+ address,
86− connector,
88+ connector,
87− walletType: WALLET_TYPES.WALLET_CONNECT,
89+ walletType: WALLET_TYPES.WALLET_CONNECT,
90+ });
91+ authToken = Just(token);
92+ } catch (e) {
93+ if (e.message === 'METHOD_NOT_SUPPORTED') {
94+ console.warn(
95+ 'wallet does not support message signing. proceeding without auth token.'
88− });
96+ );
97+ } else {
98+ throw e;
99+ //TODO should errors with this *really* prevent login?
100+ }
101+ }
89
102
90 const wallet: WalletConnectWallet = {
103 const wallet: WalletConnectWallet = {
91 address,
104 address,
92 };
105 };
93
106
94− setAuthToken(Just(authToken));
107+ setAuthToken(authToken);
95 setWallet(Just(wallet));
108 setWallet(Just(wallet));
96 };
109 };
97
110