Skip to content

Commit f1d03ce

Browse files
authored
Merge pull request #802 from LIT-Protocol/feature/lit-4238-clean-unnecessary-packages
Feature/lit 4238 clean unnecessary packages
2 parents aaf8c5f + a3041a5 commit f1d03ce

File tree

215 files changed

+3426
-9606
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

215 files changed

+3426
-9606
lines changed

README.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,19 +65,14 @@ If you're a tech-savvy user and wish to utilize only specific submodules that ou
6565
| [@lit-protocol/contracts-sdk](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/contracts-sdk) | ![contracts-sdk](https://img.shields.io/badge/-universal-8A6496 'contracts-sdk') | <a target="_blank" href="https://www.npmjs.com/package/@lit-protocol/contracts-sdk"><img src="https://img.shields.io/npm/v/@lit-protocol/contracts-sdk"/></a> |
6666
| [@lit-protocol/core](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/core) | ![core](https://img.shields.io/badge/-universal-8A6496 'core') | <a target="_blank" href="https://www.npmjs.com/package/@lit-protocol/core"><img src="https://img.shields.io/npm/v/@lit-protocol/core"/></a> |
6767
| [@lit-protocol/crypto](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/crypto) | ![crypto](https://img.shields.io/badge/-universal-8A6496 'crypto') | <a target="_blank" href="https://www.npmjs.com/package/@lit-protocol/crypto"><img src="https://img.shields.io/npm/v/@lit-protocol/crypto"/></a> |
68-
| [@lit-protocol/encryption](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/encryption) | ![encryption](https://img.shields.io/badge/-universal-8A6496 'encryption') | <a target="_blank" href="https://www.npmjs.com/package/@lit-protocol/encryption"><img src="https://img.shields.io/npm/v/@lit-protocol/encryption"/></a> |
6968
| [@lit-protocol/event-listener](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/event-listener) | ![event-listener](https://img.shields.io/badge/-universal-8A6496 'event-listener') | <a target="_blank" href="https://www.npmjs.com/package/@lit-protocol/event-listener"><img src="https://img.shields.io/npm/v/@lit-protocol/event-listener"/></a> |
70-
| [@lit-protocol/logger](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/logger) | ![logger](https://img.shields.io/badge/-universal-8A6496 'logger') | <a target="_blank" href="https://www.npmjs.com/package/@lit-protocol/logger"><img src="https://img.shields.io/npm/v/@lit-protocol/logger"/></a> |
71-
| [@lit-protocol/misc](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/misc) | ![misc](https://img.shields.io/badge/-universal-8A6496 'misc') | <a target="_blank" href="https://www.npmjs.com/package/@lit-protocol/misc"><img src="https://img.shields.io/npm/v/@lit-protocol/misc"/></a> |
72-
| [@lit-protocol/nacl](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/nacl) | ![nacl](https://img.shields.io/badge/-universal-8A6496 'nacl') | <a target="_blank" href="https://www.npmjs.com/package/@lit-protocol/nacl"><img src="https://img.shields.io/npm/v/@lit-protocol/nacl"/></a> |
7369
| [@lit-protocol/networks](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/networks) | ![networks](https://img.shields.io/badge/-universal-8A6496 'networks') | <a target="_blank" href="https://www.npmjs.com/package/@lit-protocol/networks"><img src="https://img.shields.io/npm/v/@lit-protocol/networks"/></a> |
7470
| [@lit-protocol/pkp-base](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/pkp-base) | ![pkp-base](https://img.shields.io/badge/-universal-8A6496 'pkp-base') | <a target="_blank" href="https://www.npmjs.com/package/@lit-protocol/pkp-base"><img src="https://img.shields.io/npm/v/@lit-protocol/pkp-base"/></a> |
7571
| [@lit-protocol/pkp-cosmos](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/pkp-cosmos) | ![pkp-cosmos](https://img.shields.io/badge/-universal-8A6496 'pkp-cosmos') | <a target="_blank" href="https://www.npmjs.com/package/@lit-protocol/pkp-cosmos"><img src="https://img.shields.io/npm/v/@lit-protocol/pkp-cosmos"/></a> |
7672
| [@lit-protocol/pkp-ethers](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/pkp-ethers) | ![pkp-ethers](https://img.shields.io/badge/-universal-8A6496 'pkp-ethers') | <a target="_blank" href="https://www.npmjs.com/package/@lit-protocol/pkp-ethers"><img src="https://img.shields.io/npm/v/@lit-protocol/pkp-ethers"/></a> |
7773
| [@lit-protocol/pkp-sui](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/pkp-sui) | ![pkp-sui](https://img.shields.io/badge/-universal-8A6496 'pkp-sui') | <a target="_blank" href="https://www.npmjs.com/package/@lit-protocol/pkp-sui"><img src="https://img.shields.io/npm/v/@lit-protocol/pkp-sui"/></a> |
7874
| [@lit-protocol/pkp-walletconnect](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/pkp-walletconnect) | ![pkp-walletconnect](https://img.shields.io/badge/-universal-8A6496 'pkp-walletconnect') | <a target="_blank" href="https://www.npmjs.com/package/@lit-protocol/pkp-walletconnect"><img src="https://img.shields.io/npm/v/@lit-protocol/pkp-walletconnect"/></a> |
7975
| [@lit-protocol/types](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/types) | ![types](https://img.shields.io/badge/-universal-8A6496 'types') | <a target="_blank" href="https://www.npmjs.com/package/@lit-protocol/types"><img src="https://img.shields.io/npm/v/@lit-protocol/types"/></a> |
80-
| [@lit-protocol/uint8arrays](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/uint8arrays) | ![uint8arrays](https://img.shields.io/badge/-universal-8A6496 'uint8arrays') | <a target="_blank" href="https://www.npmjs.com/package/@lit-protocol/uint8arrays"><img src="https://img.shields.io/npm/v/@lit-protocol/uint8arrays"/></a> |
8176
| [@lit-protocol/wasm](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/wasm) | ![wasm](https://img.shields.io/badge/-universal-8A6496 'wasm') | <a target="_blank" href="https://www.npmjs.com/package/@lit-protocol/wasm"><img src="https://img.shields.io/npm/v/@lit-protocol/wasm"/></a> |
8277
| [@lit-protocol/wrapped-keys](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/wrapped-keys) | ![wrapped-keys](https://img.shields.io/badge/-universal-8A6496 'wrapped-keys') | <a target="_blank" href="https://www.npmjs.com/package/@lit-protocol/wrapped-keys"><img src="https://img.shields.io/npm/v/@lit-protocol/wrapped-keys"/></a> |
8378
| [@lit-protocol/wrapped-keys-lit-actions](https://github.com/LIT-Protocol/js-sdk/tree/master/packages/wrapped-keys-lit-actions) | ![wrapped-keys-lit-actions](https://img.shields.io/badge/-universal-8A6496 'wrapped-keys-lit-actions') | <a target="_blank" href="https://www.npmjs.com/package/@lit-protocol/wrapped-keys-lit-actions"><img src="https://img.shields.io/npm/v/@lit-protocol/wrapped-keys-lit-actions"/></a> |
@@ -100,7 +95,7 @@ If you're a tech-savvy user and wish to utilize only specific submodules that ou
10095

10196
## Prerequisite
10297

103-
- node (v19.x or above)
98+
- node (v20.x or above)
10499
- rust (v1.70.00 or above)
105100
- [wasm-pack](https://github.com/rustwasm/wasm-pack)
106101

jest.setup.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@ global.TextEncoder = require('util').TextEncoder;
44
global.TextDecoder = require('util').TextDecoder;
55
global.crypto = crypto;
66

7+
if (!global.crypto.subtle) {
8+
global.crypto.subtle = {
9+
digest: async (algorithm, data) => {
10+
const algo = algorithm.toLowerCase().replace('-', '');
11+
const hash = crypto.createHash(algo);
12+
hash.update(Buffer.from(data));
13+
return hash.digest().buffer;
14+
},
15+
};
16+
}
17+
718
// If this is not included, you will get the following error when running it in Jest:
819
// (Error) Details: Request is not defined
920
// The problem is that Jest is running in a Node.js environment where the global Request API (part of the Fetch API) might not be available or properly configured. Bun, on the other hand, has this API built into its runtime by default, which is why it works.

local-tests/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,12 @@
8181
"synthetix-js": "^2.74.1",
8282
"tslib": "^2.3.0",
8383
"tweetnacl": "^1.0.3",
84-
"tweetnacl-util": "^0.15.1",
8584
"uint8arrays": "^4.0.3",
8685
"@openagenda/verror": "^3.1.4",
8786
"ipfs-unixfs-importer": "12.0.1",
8887
"@solana/web3.js": "^1.95.3",
8988
"bech32": "^2.0.0",
9089
"pako": "^2.1.0",
91-
"@lit-protocol/misc": "8.0.0-alpha.0",
9290
"@lit-protocol/lit-node-client": "8.0.0-alpha.0",
9391
"@lit-protocol/auth": "8.0.0-alpha.0",
9492
"@lit-protocol/contracts": "^0.0.71"

local-tests/setup/session-sigs/get-eoa-session-sigs.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
AuthSig,
1010
LitResourceAbilityRequest,
1111
} from '@lit-protocol/types';
12-
import { log } from '@lit-protocol/misc';
1312
import { ethers } from 'ethers';
1413
import {
1514
LIT_ABILITY,

local-tests/setup/session-sigs/get-pkp-session-sigs.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {
33
type AuthenticationContext,
44
LitResourceAbilityRequest,
55
} from '@lit-protocol/types';
6-
import { log } from '@lit-protocol/misc';
76
import {
87
LIT_ABILITY,
98
CENTRALISATION_BY_NETWORK,
@@ -43,7 +42,7 @@ export const getPkpAuthContext = (
4342
}),
4443
});
4544

46-
log('[getPkpAuthContext]: ', authContext);
45+
console.log('[getPkpAuthContext]: ', authContext);
4746

4847
return authContext;
4948
};

local-tests/setup/tinny-environment.ts

Lines changed: 37 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { LitContracts } from '@lit-protocol/contracts-sdk';
22
import { LitNodeClient } from '@lit-protocol/lit-node-client';
3+
import { getChildLogger } from '@lit-protocol/logger';
34
import {
45
AuthSig,
56
LitContractContext,
@@ -8,7 +9,6 @@ import {
89
import { ProcessEnvs, TinnyEnvConfig } from './tinny-config';
910
import { TinnyPerson } from './tinny-person';
1011

11-
import { createSiweMessage, generateAuthSig } from '@lit-protocol/auth-helpers';
1212
import {
1313
CENTRALISATION_BY_NETWORK,
1414
LIT_NETWORK,
@@ -20,7 +20,9 @@ import { ethers, Signer } from 'ethers';
2020
import { ShivaClient, TestnetClient } from './shiva-client';
2121
import { toErrorWithMessage } from './tinny-utils';
2222

23-
console.log('checking env', process.env['DEBUG']);
23+
const logger = getChildLogger({ module: 'tinny-environment' });
24+
25+
logger.info({ msg: 'checking env', env: process.env['DEBUG'] });
2426

2527
const DEFAULT_ANVIL_PRIVATE_KEYS = [
2628
'0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d',
@@ -49,7 +51,7 @@ export class TinnyEnvironment {
4951
DEBUG: process.env['DEBUG'] === 'true',
5052
REQUEST_PER_KILOSECOND:
5153
parseInt(process.env['REQUEST_PER_KILOSECOND']) ||
52-
(process.env['NETWORK'] as LIT_NETWORK_VALUES) === 'datil-dev'
54+
(process.env['NETWORK'] as LIT_NETWORK_VALUES) === LIT_NETWORK.NagaDev
5355
? 1
5456
: 200,
5557
LIT_RPC_URL: process.env['LIT_RPC_URL'],
@@ -147,10 +149,10 @@ export class TinnyEnvironment {
147149
);
148150
}
149151

150-
console.log(
151-
'[𐬺🧪 Tinny Environment𐬺] Done configuring environment current config: ',
152-
this.processEnvs
153-
);
152+
logger.info({
153+
msg: '[𐬺🧪 Tinny Environment𐬺] Done configuring environment current config: ',
154+
processEnvs: this.processEnvs,
155+
});
154156
}
155157

156158
world: Map<string, TinnyPerson> = new Map();
@@ -183,11 +185,12 @@ export class TinnyEnvironment {
183185
if (index !== -1) {
184186
// If an available key is found
185187
this.processEnvs.KEY_IN_USE[index] = true; // Mark the key as in use
186-
// console.log('[𐬺🧪 Tinny Environment𐬺] 🔑 Selected key at index', index); // Log a message indicating that we have selected a key
188+
// logger.info({ msg: '[𐬺🧪 Tinny Environment𐬺] 🔑 Selected key at index', index }); // Log a message indicating that we have selected a key
187189

188190
return { privateKey: this.processEnvs.PRIVATE_KEYS[index], index }; // Return the key and its index
189191
} else {
190-
console.log('[𐬺🧪 Tinny Environment𐬺] No available keys. Waiting...', {
192+
logger.info({
193+
msg: '[𐬺🧪 Tinny Environment𐬺] No available keys. Waiting...',
191194
keysInUse: this.processEnvs.KEY_IN_USE,
192195
}); // Log a message indicating that we are waiting
193196
// Wait for the specified interval before checking again
@@ -205,9 +208,9 @@ export class TinnyEnvironment {
205208
releasePrivateKeyFromUser(user: TinnyPerson) {
206209
const index = this.processEnvs.PRIVATE_KEYS.indexOf(user.privateKey);
207210
this.processEnvs.KEY_IN_USE[index] = false;
208-
// console.log(
209-
// `[𐬺🧪 Tinny Environment𐬺] 🪽 Released key at index ${index}. Thank you for your service!`
210-
// );
211+
// logger.info({
212+
// msg: `[𐬺🧪 Tinny Environment𐬺] 🪽 Released key at index ${index}. Thank you for your service!`
213+
// });
211214
}
212215

213216
/**
@@ -216,9 +219,9 @@ export class TinnyEnvironment {
216219
*/
217220
releasePrivateKey(index: number) {
218221
this.processEnvs.KEY_IN_USE[index] = false;
219-
// console.log(
220-
// `[𐬺🧪 Tinny Environment𐬺] 🪽 Released key at index ${index}. Thank you for your service!`
221-
// );
222+
// logger.info({
223+
// msg: `[𐬺🧪 Tinny Environment𐬺] 🪽 Released key at index ${index}. Thank you for your service!`
224+
// });
222225
}
223226

224227
/**
@@ -234,9 +237,9 @@ export class TinnyEnvironment {
234237
*/
235238

236239
async setupLitNodeClient() {
237-
console.log('[𐬺🧪 Tinny Environment𐬺] Setting up LitNodeClient');
240+
logger.info({ msg: '[𐬺🧪 Tinny Environment𐬺] Setting up LitNodeClient' });
238241

239-
console.log('this.network:', this.network);
242+
logger.info({ msg: 'network', network: this.network });
240243
const centralisation = CENTRALISATION_BY_NETWORK[this.network];
241244

242245
if (this.network === LIT_NETWORK.Custom || centralisation === 'unknown') {
@@ -324,7 +327,7 @@ export class TinnyEnvironment {
324327
* @throws Error if the name is not provided.
325328
*/
326329
async createNewPerson(name: string) {
327-
console.log('[𐬺🧪 Tinny Environment𐬺] Creating new person:', name);
330+
logger.info({ msg: '[𐬺🧪 Tinny Environment𐬺] Creating new person', name });
328331
if (!name) {
329332
throw new Error('Name is required');
330333
}
@@ -373,17 +376,17 @@ export class TinnyEnvironment {
373376
async init() {
374377
try {
375378
if (this.processEnvs.NO_SETUP) {
376-
console.log('[𐬺🧪 Tinny Environment𐬺] Skipping setup');
379+
logger.info({ msg: '[𐬺🧪 Tinny Environment𐬺] Skipping setup' });
377380
return;
378381
}
379382
if (this.network === LIT_NETWORK.Custom && this.processEnvs.USE_SHIVA) {
380383
this.testnet = await this._shivaClient.startTestnetManager();
381384
// wait for the testnet to be active before we start the tests.
382385
let state = await this.testnet.pollTestnetForActive();
383386
if (state === `UNKNOWN`) {
384-
console.log(
385-
'Testnet state found to be Unknown meaning there was an error with testnet creation. shutting down'
386-
);
387+
logger.info({
388+
msg: 'Testnet state found to be Unknown meaning there was an error with testnet creation. shutting down',
389+
});
387390
throw new Error(`Error while creating testnet, aborting test run`);
388391
}
389392

@@ -398,10 +401,10 @@ export class TinnyEnvironment {
398401
await this.setupSuperCapacityDelegationAuthSig();
399402
} catch (e) {
400403
const err = toErrorWithMessage(e);
401-
console.log(
402-
`[𐬺🧪 Tinny Environment𐬺] Failed to init() tinny ${err.message}`
403-
);
404-
console.log(err.stack);
404+
logger.error({
405+
msg: `[𐬺🧪 Tinny Environment𐬺] Failed to init() tinny ${err.message}`,
406+
stack: err.stack,
407+
});
405408
process.exit(1);
406409
}
407410
}
@@ -417,7 +420,7 @@ export class TinnyEnvironment {
417420
) {
418421
await this.testnet.stopTestnet();
419422
} else {
420-
console.log('skipping testnet shutdown.');
423+
logger.info('skipping testnet shutdown.');
421424
}
422425
}
423426
//============= END SHIVA ENDPOINTS =============
@@ -498,9 +501,9 @@ export class TinnyEnvironment {
498501

499502
// get wallet balance
500503
const balance = await wallet.getBalance();
501-
console.log('this.rpc:', rpc);
502-
console.log('this.wallet.address', wallet.address);
503-
console.log('Balance:', balance.toString());
504+
logger.info({ msg: 'this.rpc:', rpc });
505+
logger.info({ msg: 'this.wallet.address', address: wallet.address });
506+
logger.info({ msg: 'Balance:', balance: balance.toString() });
504507

505508
const transferTx = await wallet.sendTransaction({
506509
to: capacityCreditWallet.address,
@@ -520,7 +523,7 @@ export class TinnyEnvironment {
520523
}
521524

522525
if (!this.contractsClient) {
523-
console.log('❗️Contracts client not initialized');
526+
logger.info('❗️Contracts client not initialized');
524527
process.exit();
525528
}
526529

@@ -537,7 +540,7 @@ export class TinnyEnvironment {
537540
};
538541

539542
async mintSuperCapacityDelegationAuthSig(wallet: Signer) {
540-
console.log(
543+
logger.info(
541544
'[𐬺🧪 Tinny Environment𐬺] Mint a Capacity Credits NFT and get a capacity delegation authSig with it'
542545
);
543546

@@ -552,9 +555,9 @@ export class TinnyEnvironment {
552555
).capacityDelegationAuthSig;
553556
} catch (e: any) {
554557
if (e.message.includes(`Can't allocate capacity beyond the global max`)) {
555-
console.log('❗️Skipping capacity delegation auth sig setup.', e);
558+
logger.info('❗️Skipping capacity delegation auth sig setup.', e);
556559
} else {
557-
console.log(
560+
logger.info(
558561
'❗️Error while setting up capacity delegation auth sig',
559562
e
560563
);

local-tests/setup/tinny-person.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
import {
2-
AuthSig,
3-
generateAuthSig,
4-
createSiweMessage,
5-
} from '@lit-protocol/auth-helpers';
1+
import { generateAuthSig, createSiweMessage } from '@lit-protocol/auth-helpers';
62
import { LitContracts } from '@lit-protocol/contracts-sdk';
73
import {
84
AuthMethod,
5+
AuthSig,
96
BaseSiweMessage,
107
LitContractContext,
118
} from '@lit-protocol/types';

0 commit comments

Comments
 (0)