Skip to content

Commit cf4ea12

Browse files
committed
feat: replace litWCProvider global scope variable with module scoped one in auth-browsers/eth
1 parent c2777b5 commit cf4ea12

File tree

1 file changed

+9
-6
lines changed
  • packages/auth-browser/src/lib/chains

1 file changed

+9
-6
lines changed

packages/auth-browser/src/lib/chains/eth.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ import { toUtf8Bytes } from '@ethersproject/strings';
77

88
// import WalletConnectProvider from '@walletconnect/ethereum-provider';
99
import { verifyMessage } from '@ethersproject/wallet';
10-
import { EthereumProvider } from '@walletconnect/ethereum-provider';
10+
import {
11+
EthereumProvider,
12+
default as WalletConnectProvider,
13+
} from '@walletconnect/ethereum-provider';
1114
import { ethers } from 'ethers';
1215
import { getAddress } from 'ethers/lib/utils';
1316
import { SiweMessage } from 'siwe';
@@ -128,6 +131,8 @@ export type WALLET_ERROR_VALUES =
128131

129132
/** ---------- Local Helpers ---------- */
130133

134+
let litWCProvider: WalletConnectProvider | undefined;
135+
131136
/**
132137
*
133138
* Convert chain hex id to chain name
@@ -386,8 +391,7 @@ export const connectWeb3 = async ({
386391
};
387392

388393
if (isBrowser()) {
389-
// @ts-ignore
390-
globalThis.litWCProvider = wcProvider;
394+
litWCProvider = wcProvider;
391395
}
392396
}
393397

@@ -440,10 +444,9 @@ export const disconnectWeb3 = (): void => {
440444
}
441445

442446
// @ts-ignore
443-
if (isBrowser() && globalThis.litWCProvider) {
447+
if (isBrowser() && litWCProvider) {
444448
try {
445-
// @ts-ignore
446-
globalThis.litWCProvider.disconnect();
449+
litWCProvider.disconnect();
447450
} catch (err) {
448451
log(
449452
'Attempted to disconnect global WalletConnectProvider for lit-connect-modal',

0 commit comments

Comments
 (0)