Skip to content

Commit 8013aff

Browse files
Merge pull request #663 from LIT-Protocol/feature/lit-3918-no-globalthis-variables-anymore
Feature/lit 3918 no globalthis variables anymore
2 parents c934591 + 42ffd7c commit 8013aff

File tree

19 files changed

+25
-335
lines changed

19 files changed

+25
-335
lines changed

packages/access-control-conditions/README.md

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,3 @@ This submodule provides functionalities for formatting and canonicalizing data,
77
```
88
yarn add @lit-protocol/access-control-conditions
99
```
10-
11-
### Vanilla JS (UMD)
12-
13-
```js
14-
<script src="https://cdn.jsdelivr.net/npm/@lit-protocol/access-control-conditions-vanilla/access-control-conditions.js"></script>
15-
<script>
16-
console.log(LitJsSdk_accessControlConditions);
17-
</script>
18-
```

packages/auth-browser/README.md

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,6 @@ This submodule provides functionalities from various modules within the Lit SDK,
88
yarn add @lit-protocol/auth-browser
99
```
1010

11-
### Vanilla JS (UMD)
12-
13-
```js
14-
<script src="https://cdn.jsdelivr.net/npm/@lit-protocol/auth-browser-vanilla/auth-browser.js"></script>
15-
<script>
16-
console.log(LitJsSdk_authBrowser);
17-
</script>
18-
```
19-
2011
## Generate an authSig with long expiration
2112

2213
```

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',

packages/auth-helpers/README.md

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,3 @@ This submodule manages permissions and capabilities related to accessing specifi
77
```
88
yarn add @lit-protocol/auth-helpers
99
```
10-
11-
### Vanilla JS (UMD)
12-
13-
```js
14-
<script src="https://cdn.jsdelivr.net/npm/@lit-protocol/auth-helpers-vanilla/auth-helpers.js"></script>
15-
<script>
16-
console.log(LitJsSdk_authHelpers);
17-
</script>
18-
```

packages/constants/README.md

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,3 @@ This submodule exports various modules, constants, interfaces, errors, utilities
77
```
88
yarn add @lit-protocol/constants
99
```
10-
11-
### Vanilla JS (UMD)
12-
13-
```js
14-
<script src="https://cdn.jsdelivr.net/npm/@lit-protocol/constants-vanilla/constants.js"></script>
15-
<script>
16-
console.log(LitJsSdk_constants);
17-
</script>
18-
```

packages/contracts-sdk/README.md

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,8 @@ Demo: https://demo-contracts-sdk-react.vercel.app/
66

77
# Installation
88

9-
```js
10-
yarn add @lit-protocol/contracts-sdk
119
```
12-
13-
# Vanilla JS (UMD)
14-
15-
```html
16-
<script src="https://cdn.jsdelivr.net/npm/@lit-protocol/contracts-sdk-vanilla/contracts-sdk.js"></script>
17-
<script>
18-
(async () => {
19-
const { LitContracts } = LitJsSdk_contractsSdk;
20-
21-
const litContracts = new LitContracts();
22-
await litContracts.connect();
23-
})();
24-
</script>
10+
yarn add @lit-protocol/contracts-sdk
2511
```
2612

2713
# Quick Start

packages/core/src/lib/lit-core.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ import {
5151
logWithRequestId,
5252
mostCommonString,
5353
sendRequest,
54+
setMiscLitConfig,
5455
} from '@lit-protocol/misc';
5556
import {
5657
AuthSig,
@@ -200,7 +201,7 @@ export class LitCore {
200201
this.setCustomBootstrapUrls();
201202

202203
// -- set global variables
203-
globalThis.litConfig = this.config;
204+
setMiscLitConfig(this.config);
204205
bootstrapLogManager(
205206
'core',
206207
this.config.debug ? LogLevel.DEBUG : LogLevel.OFF
@@ -392,7 +393,7 @@ export class LitCore {
392393

393394
this._stopListeningForNewEpoch();
394395
// this._stopNetworkPolling();
395-
if (globalThis.litConfig) delete globalThis.litConfig;
396+
setMiscLitConfig(undefined);
396397
}
397398

398399
// _stopNetworkPolling() {
@@ -537,9 +538,6 @@ export class LitCore {
537538
// this._scheduleNetworkSync();
538539
this._listenForNewEpoch();
539540

540-
// FIXME: don't create global singleton; multiple instances of `core` should not all write to global
541-
// @ts-expect-error typeof globalThis is not defined. We're going to get rid of the global soon.
542-
globalThis.litNodeClient = this;
543541
this.ready = true;
544542

545543
log(`🔥 lit is ready. "litNodeClient" variable is ready to use globally.`);

packages/crypto/README.md

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,3 @@ The crypto.ts file in the Lit SDK handles cryptographic operations, including th
77
```
88
yarn add @lit-protocol/crypto
99
```
10-
11-
### Vanilla JS (UMD)
12-
13-
```js
14-
<script src="https://cdn.jsdelivr.net/npm/@lit-protocol/crypto-vanilla/crypto.js"></script>
15-
<script>
16-
console.log(LitJsSdk_crypto);
17-
</script>
18-
```

packages/encryption/README.md

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,3 @@ This submodule provides encryption and decryption of contents (string, file, etc
77
```
88
yarn add @lit-protocol/encryption
99
```
10-
11-
### Vanilla JS (UMD)
12-
13-
```js
14-
<script src="https://cdn.jsdelivr.net/npm/@lit-protocol/encryption-vanilla/encryption.js"></script>
15-
<script>
16-
console.log(LitJsSdk_encryption);
17-
</script>
18-
```

packages/lit-node-client-nodejs/src/index.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,5 @@
11
import 'cross-fetch/dist/node-polyfill.js';
22

3-
import * as _LitNodeClientNodeJs from './lib/lit-node-client-nodejs';
4-
// ==================== Environment ====================
5-
6-
declare global {
7-
// This `declare global` hackery _must_ use var to work.
8-
// eslint-disable-next-line no-var, @typescript-eslint/no-explicit-any
9-
var LitNodeClientNodeJs: any;
10-
}
11-
12-
const LitNodeClientNodeJs = _LitNodeClientNodeJs.LitNodeClientNodeJs;
13-
if (!globalThis.LitNodeClientNodeJs) {
14-
globalThis.LitNodeClientNodeJs = LitNodeClientNodeJs;
15-
}
16-
173
// ==================== Exports ====================
184
export * from './lib/lit-node-client-nodejs';
195

0 commit comments

Comments
 (0)