Skip to content

Feature/lit 4238 clean unnecessary packages #802

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
527e07a
feat: replace logger package and log in misc with pino
FedericoAmura Feb 26, 2025
cfc3c34
feat: remove misc package with a lot of zod schemas, helper functions…
FedericoAmura Mar 3, 2025
c99d1f0
feat: changes in lit node client to remove misc, missed in previous c…
FedericoAmura Mar 4, 2025
21b33f8
feat: logger fixes
FedericoAmura Mar 6, 2025
3d2dc98
fix: remove unused stuff and type fixes
FedericoAmura Mar 6, 2025
4e2d35c
fix: localStorage.spec.ts
FedericoAmura Mar 6, 2025
fc17d03
fix: assemble-most-common-response when property types differ
FedericoAmura Mar 6, 2025
a2ca33e
feat: replace uint8arrays pkg with Buffer
FedericoAmura Mar 6, 2025
2eec105
feat: replace nacl pkg with noble curves
FedericoAmura Mar 6, 2025
a6fd6b9
feat: remove IEither pattern
FedericoAmura Mar 6, 2025
f1cc256
fix: linting
FedericoAmura Mar 6, 2025
a45c133
fix: run unit test for all packages
FedericoAmura Mar 7, 2025
bc87787
feat: unify localstorage usage in misc-browser
FedericoAmura Mar 7, 2025
fc73d7f
feat: lit errors
FedericoAmura Mar 7, 2025
e9cf2db
feat: remove full erc20 abi
FedericoAmura Mar 7, 2025
e4d66c9
feat: remove encryption package
FedericoAmura Mar 7, 2025
a36466b
feat: errors in relay
FedericoAmura Mar 7, 2025
50b9857
feat: abstract pino sdk logger singleton in previous logger package
FedericoAmura Mar 12, 2025
2b63d1e
feat: replace all javascript private properties with typescript priva…
FedericoAmura Mar 12, 2025
eb930e8
fix: remove removed tests references
FedericoAmura Mar 12, 2025
27d1e9e
feat: missing logger migrations
FedericoAmura Mar 13, 2025
cc83252
feat: make event listener use an action repository so action definiti…
FedericoAmura Mar 13, 2025
2016736
fix: remove module level loggers that were not updated if sdk logger …
FedericoAmura Mar 13, 2025
14a0ede
feat: add custom actions doc for event listener state machines
FedericoAmura Mar 14, 2025
9b63fd8
Merge branch 'LIT-4211-auth-refactor' into feature/lit-4238-clean-unn…
Ansonhkg Apr 3, 2025
a3041a5
chore: update yarn.lock
Ansonhkg Apr 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,14 @@ If you're a tech-savvy user and wish to utilize only specific submodules that ou
| [@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> |
| [@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> |
| [@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> |
| [@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> |
| [@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> |
| [@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> |
| [@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> |
| [@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> |
| [@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> |
| [@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> |
| [@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> |
| [@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> |
| [@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> |
| [@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> |
| [@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> |
| [@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> |
| [@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> |
| [@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> |
| [@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> |
Expand All @@ -100,7 +95,7 @@ If you're a tech-savvy user and wish to utilize only specific submodules that ou

## Prerequisite

- node (v19.x or above)
- node (v20.x or above)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v19 has gone out of maintenance a while ago
v20 is in maintenance and supports File (used in encryption)

https://nodejs.org/en/about/previous-releases

- rust (v1.70.00 or above)
- [wasm-pack](https://github.com/rustwasm/wasm-pack)

Expand Down
11 changes: 11 additions & 0 deletions jest.setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ global.TextEncoder = require('util').TextEncoder;
global.TextDecoder = require('util').TextDecoder;
global.crypto = crypto;

if (!global.crypto.subtle) {
global.crypto.subtle = {
digest: async (algorithm, data) => {
const algo = algorithm.toLowerCase().replace('-', '');
const hash = crypto.createHash(algo);
hash.update(Buffer.from(data));
return hash.digest().buffer;
},
};
}

// If this is not included, you will get the following error when running it in Jest:
// (Error) Details: Request is not defined
// 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.
Expand Down
2 changes: 0 additions & 2 deletions local-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,12 @@
"synthetix-js": "^2.74.1",
"tslib": "^2.3.0",
"tweetnacl": "^1.0.3",
"tweetnacl-util": "^0.15.1",
"uint8arrays": "^4.0.3",
"@openagenda/verror": "^3.1.4",
"ipfs-unixfs-importer": "12.0.1",
"@solana/web3.js": "^1.95.3",
"bech32": "^2.0.0",
"pako": "^2.1.0",
"@lit-protocol/misc": "8.0.0-alpha.0",
"@lit-protocol/lit-node-client": "8.0.0-alpha.0",
"@lit-protocol/auth": "8.0.0-alpha.0",
"@lit-protocol/contracts": "^0.0.71"
Expand Down
1 change: 0 additions & 1 deletion local-tests/setup/session-sigs/get-eoa-session-sigs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
AuthSig,
LitResourceAbilityRequest,
} from '@lit-protocol/types';
import { log } from '@lit-protocol/misc';
import { ethers } from 'ethers';
import {
LIT_ABILITY,
Expand Down
3 changes: 1 addition & 2 deletions local-tests/setup/session-sigs/get-pkp-session-sigs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
type AuthenticationContext,
LitResourceAbilityRequest,
} from '@lit-protocol/types';
import { log } from '@lit-protocol/misc';
import {
LIT_ABILITY,
CENTRALISATION_BY_NETWORK,
Expand Down Expand Up @@ -43,7 +42,7 @@ export const getPkpAuthContext = (
}),
});

log('[getPkpAuthContext]: ', authContext);
console.log('[getPkpAuthContext]: ', authContext);
Copy link
Contributor Author

@FedericoAmura FedericoAmura Mar 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing logs are more clear when using console than using pino


return authContext;
};
71 changes: 37 additions & 34 deletions local-tests/setup/tinny-environment.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { LitContracts } from '@lit-protocol/contracts-sdk';
import { LitNodeClient } from '@lit-protocol/lit-node-client';
import { getChildLogger } from '@lit-protocol/logger';
import {
AuthSig,
LitContractContext,
Expand All @@ -8,7 +9,6 @@ import {
import { ProcessEnvs, TinnyEnvConfig } from './tinny-config';
import { TinnyPerson } from './tinny-person';

import { createSiweMessage, generateAuthSig } from '@lit-protocol/auth-helpers';
import {
CENTRALISATION_BY_NETWORK,
LIT_NETWORK,
Expand All @@ -20,7 +20,9 @@ import { ethers, Signer } from 'ethers';
import { ShivaClient, TestnetClient } from './shiva-client';
import { toErrorWithMessage } from './tinny-utils';

console.log('checking env', process.env['DEBUG']);
const logger = getChildLogger({ module: 'tinny-environment' });

logger.info({ msg: 'checking env', env: process.env['DEBUG'] });

const DEFAULT_ANVIL_PRIVATE_KEYS = [
'0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d',
Expand Down Expand Up @@ -49,7 +51,7 @@ export class TinnyEnvironment {
DEBUG: process.env['DEBUG'] === 'true',
REQUEST_PER_KILOSECOND:
parseInt(process.env['REQUEST_PER_KILOSECOND']) ||
(process.env['NETWORK'] as LIT_NETWORK_VALUES) === 'datil-dev'
(process.env['NETWORK'] as LIT_NETWORK_VALUES) === LIT_NETWORK.NagaDev
? 1
: 200,
LIT_RPC_URL: process.env['LIT_RPC_URL'],
Expand Down Expand Up @@ -147,10 +149,10 @@ export class TinnyEnvironment {
);
}

console.log(
'[𐬺🧪 Tinny Environment𐬺] Done configuring environment current config: ',
this.processEnvs
);
logger.info({
msg: '[𐬺🧪 Tinny Environment𐬺] Done configuring environment current config: ',
processEnvs: this.processEnvs,
});
}

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

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

/**
Expand All @@ -216,9 +219,9 @@ export class TinnyEnvironment {
*/
releasePrivateKey(index: number) {
this.processEnvs.KEY_IN_USE[index] = false;
// console.log(
// `[𐬺🧪 Tinny Environment𐬺] 🪽 Released key at index ${index}. Thank you for your service!`
// );
// logger.info({
// msg: `[𐬺🧪 Tinny Environment𐬺] 🪽 Released key at index ${index}. Thank you for your service!`
// });
}

/**
Expand All @@ -234,9 +237,9 @@ export class TinnyEnvironment {
*/

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

console.log('this.network:', this.network);
logger.info({ msg: 'network', network: this.network });
const centralisation = CENTRALISATION_BY_NETWORK[this.network];

if (this.network === LIT_NETWORK.Custom || centralisation === 'unknown') {
Expand Down Expand Up @@ -324,7 +327,7 @@ export class TinnyEnvironment {
* @throws Error if the name is not provided.
*/
async createNewPerson(name: string) {
console.log('[𐬺🧪 Tinny Environment𐬺] Creating new person:', name);
logger.info({ msg: '[𐬺🧪 Tinny Environment𐬺] Creating new person', name });
if (!name) {
throw new Error('Name is required');
}
Expand Down Expand Up @@ -373,17 +376,17 @@ export class TinnyEnvironment {
async init() {
try {
if (this.processEnvs.NO_SETUP) {
console.log('[𐬺🧪 Tinny Environment𐬺] Skipping setup');
logger.info({ msg: '[𐬺🧪 Tinny Environment𐬺] Skipping setup' });
return;
}
if (this.network === LIT_NETWORK.Custom && this.processEnvs.USE_SHIVA) {
this.testnet = await this._shivaClient.startTestnetManager();
// wait for the testnet to be active before we start the tests.
let state = await this.testnet.pollTestnetForActive();
if (state === `UNKNOWN`) {
console.log(
'Testnet state found to be Unknown meaning there was an error with testnet creation. shutting down'
);
logger.info({
msg: 'Testnet state found to be Unknown meaning there was an error with testnet creation. shutting down',
});
throw new Error(`Error while creating testnet, aborting test run`);
}

Expand All @@ -398,10 +401,10 @@ export class TinnyEnvironment {
await this.setupSuperCapacityDelegationAuthSig();
} catch (e) {
const err = toErrorWithMessage(e);
console.log(
`[𐬺🧪 Tinny Environment𐬺] Failed to init() tinny ${err.message}`
);
console.log(err.stack);
logger.error({
msg: `[𐬺🧪 Tinny Environment𐬺] Failed to init() tinny ${err.message}`,
stack: err.stack,
});
process.exit(1);
}
}
Expand All @@ -417,7 +420,7 @@ export class TinnyEnvironment {
) {
await this.testnet.stopTestnet();
} else {
console.log('skipping testnet shutdown.');
logger.info('skipping testnet shutdown.');
}
}
//============= END SHIVA ENDPOINTS =============
Expand Down Expand Up @@ -498,9 +501,9 @@ export class TinnyEnvironment {

// get wallet balance
const balance = await wallet.getBalance();
console.log('this.rpc:', rpc);
console.log('this.wallet.address', wallet.address);
console.log('Balance:', balance.toString());
logger.info({ msg: 'this.rpc:', rpc });
logger.info({ msg: 'this.wallet.address', address: wallet.address });
logger.info({ msg: 'Balance:', balance: balance.toString() });

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

if (!this.contractsClient) {
console.log('❗️Contracts client not initialized');
logger.info('❗️Contracts client not initialized');
process.exit();
}

Expand All @@ -537,7 +540,7 @@ export class TinnyEnvironment {
};

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

Expand All @@ -552,9 +555,9 @@ export class TinnyEnvironment {
).capacityDelegationAuthSig;
} catch (e: any) {
if (e.message.includes(`Can't allocate capacity beyond the global max`)) {
console.log('❗️Skipping capacity delegation auth sig setup.', e);
logger.info('❗️Skipping capacity delegation auth sig setup.', e);
} else {
console.log(
logger.info(
'❗️Error while setting up capacity delegation auth sig',
e
);
Expand Down
7 changes: 2 additions & 5 deletions local-tests/setup/tinny-person.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import {
AuthSig,
generateAuthSig,
createSiweMessage,
} from '@lit-protocol/auth-helpers';
import { generateAuthSig, createSiweMessage } from '@lit-protocol/auth-helpers';
import { LitContracts } from '@lit-protocol/contracts-sdk';
import {
AuthMethod,
AuthSig,
BaseSiweMessage,
LitContractContext,
} from '@lit-protocol/types';
Expand Down
Loading