-
Notifications
You must be signed in to change notification settings - Fork 88
docs: improve package descriptions and standardize README formatting #754
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
Changes from 10 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
39af557
docs: improve package descriptions in READMEs
devin-ai-integration[bot] b3f6537
docs: update core package READMEs with improved descriptions and exam…
devin-ai-integration[bot] dd4a818
docs: update auth package READMEs with improved descriptions
devin-ai-integration[bot] 14b4c41
docs: update PKP package READMEs with improved documentation
devin-ai-integration[bot] 873aacf
docs: improve package descriptions and standardize README formatting
devin-ai-integration[bot] 19054af
docs: improve root README.md organization and clarity
devin-ai-integration[bot] 5884685
docs: fix formatting issues in README.md
devin-ai-integration[bot] 7893a7c
doc: clean up devin's work
Ansonhkg 763bd14
fmt
Ansonhkg fee3b14
doc: cleanup Devin's work
Ansonhkg 9f0bcde
docs: address reviewer feedback on README
devin-ai-integration[bot] 45efa33
chore: fix formatting
devin-ai-integration[bot] 6cd6f07
Update packages/pkp-base/README.md
Ansonhkg 90ee710
chore: apply prettier formatting
devin-ai-integration[bot] 35137ce
feat: fix feedback devin missed
FedericoAmura 0801de0
feat: fix feedback devin missed
FedericoAmura File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -98,35 +98,39 @@ If you're a tech-savvy user and wish to utilize only specific submodules that ou | |||||
|
|
||||||
| # Contributing and developing to this SDK | ||||||
|
|
||||||
| ## Prerequisite | ||||||
| ## Prerequisites | ||||||
|
|
||||||
| - node (v19.x or above) | ||||||
| - rust (v1.70.00 or above) | ||||||
| - [wasm-pack](https://github.com/rustwasm/wasm-pack) | ||||||
| Before you begin, ensure you have the following installed: | ||||||
|
|
||||||
| ## Recommended | ||||||
| - Node.js v19.0.0 or later | ||||||
| - Rust v1.70.0 or later | ||||||
| - [wasm-pack](https://github.com/rustwasm/wasm-pack) for WebAssembly compilation | ||||||
|
|
||||||
| - NX Console: https://nx.dev/core-features/integrate-with-editors | ||||||
| ## Development Tools | ||||||
|
|
||||||
| Recommended for better development experience: | ||||||
|
|
||||||
| - [NX Console](https://nx.dev/core-features/integrate-with-editors) - Visual Studio Code extension for NX workspace management | ||||||
|
|
||||||
| # Quick Start | ||||||
|
|
||||||
| The following commands will help you start developing with this repository. | ||||||
| To start developing with this repository: | ||||||
|
|
||||||
| First, install the dependencies via yarn: | ||||||
| 1. Install dependencies: | ||||||
|
|
||||||
| ``` | ||||||
| yarn | ||||||
| ``` | ||||||
|
|
||||||
| ## Building | ||||||
|
|
||||||
| You can build the project with the following commands: | ||||||
| Build the project using one of these commands: | ||||||
|
|
||||||
| ``` | ||||||
| // for local development - It stripped away operations that don't matter for local dev | ||||||
| // For local development (optimized, excludes production-only operations) | ||||||
| yarn build:dev | ||||||
|
|
||||||
| // you should never need to use yarn build unless you want to test or publish it | ||||||
| // For testing and publishing (full build with all operations) | ||||||
| yarn build | ||||||
| ``` | ||||||
|
|
||||||
|
|
@@ -148,22 +152,6 @@ yarn test:local | |||||
|
|
||||||
| `nx generate @nx/js:library` | ||||||
|
|
||||||
| ## Create a new react demo app using the Lit JS SDK | ||||||
|
|
||||||
| ```sh | ||||||
| yarn tools --create --react contracts-sdk --demo | ||||||
| ``` | ||||||
|
|
||||||
| ## Deleting a package or app | ||||||
|
|
||||||
| ``` | ||||||
| // delete an app from ./app/<app-name> | ||||||
| yarn delete:app <app-name> | ||||||
|
|
||||||
| // delete a package from ./packages/<package-name> | ||||||
| yarn delete:package <package-name> | ||||||
| ``` | ||||||
|
|
||||||
| ## Building | ||||||
|
|
||||||
| ```sh | ||||||
|
|
@@ -210,170 +198,208 @@ Having done this setup, this is what the development cycle looks like moving for | |||||
| 2. Rebuild specific package | ||||||
| 3. Rebuild client application. | ||||||
|
|
||||||
| ### Building changes to Rust source | ||||||
| ### Building Rust Components | ||||||
|
|
||||||
| If changes are made to `packages/wasm` see [here](./packages/wasm/README.md) for info on building from source. | ||||||
| For changes to WebAssembly components in `packages/wasm`, refer to the [WebAssembly build guide](./packages/wasm/README.md). | ||||||
|
|
||||||
| ## Publishing | ||||||
| ## Publishing New Versions | ||||||
|
|
||||||
| You must have at least nodejs v18 to do this. | ||||||
| Prerequisites: | ||||||
|
|
||||||
| 1. Install the latest packages with `yarn install` | ||||||
| - Node.js v18.0.0 or later | ||||||
|
|
||||||
| 2. Run `yarn bump` to bump the version | ||||||
| Publishing steps: | ||||||
|
|
||||||
| 3. Build all the packages with `yarn build` | ||||||
| 1. Update dependencies: `yarn install` | ||||||
| 2. Increment version: `yarn bump` | ||||||
| 3. Build packages: `yarn build` | ||||||
| 4. Run tests: | ||||||
| - Unit tests: `yarn test:unit` | ||||||
| - E2E tests: `yarn test:local` | ||||||
| 5. Generate documentation: `yarn gen:docs --push` | ||||||
| 6. Publish packages: `yarn publish:packages` | ||||||
| 7. Commit with message: "Published version X.X.X" | ||||||
FedericoAmura marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
|
|
||||||
| 4. Run the unit tests with `yarn test:unit` & e2e node tests `yarn test:local` locally & ensure that they pass | ||||||
| ## Testing Guide | ||||||
|
|
||||||
| 5. Update the docs with `yarn gen:docs --push` | ||||||
| ### Available Test Commands | ||||||
|
|
||||||
| 6. Finally, publish with `yarn publish:packages` | ||||||
| | Command | Description | | ||||||
| | ----------------- | ------------------------------------ | | ||||||
| | `yarn test:unit` | Run unit tests for all packages | | ||||||
| | `yarn test:local` | Run E2E tests in Node.js environment | | ||||||
|
|
||||||
| 7. Commit these changes "Published version X.X.X" | ||||||
| ### Running Tests | ||||||
|
|
||||||
| ## Testing | ||||||
| 1. Unit Tests: | ||||||
|
|
||||||
| ### Quick Start on E2E Testing | ||||||
| ```sh | ||||||
| yarn test:unit | ||||||
| ``` | ||||||
|
|
||||||
| The following will serve the react testing app and launch the cypress e2e testing after | ||||||
| 2. End-to-End Tests: | ||||||
|
|
||||||
| ```sh | ||||||
| yarn test:local | ||||||
| ``` | ||||||
| ```sh | ||||||
| yarn test:local | ||||||
| ``` | ||||||
|
|
||||||
| ### Unit Tests | ||||||
| Optional Environment Variables: | ||||||
|
|
||||||
| ```sh | ||||||
| yarn test:unit | ||||||
| ``` | ||||||
| - NETWORK=<network_name> (datil, datil-test, datil-dev, etc.) | ||||||
| - DEBUG=true/false | ||||||
|
|
||||||
| ## Testing with a Local Lit Node | ||||||
| Optional Flags: | ||||||
|
|
||||||
| First, deploy your Lit Node Contracts, since the correct addresses will be pulled from the `../lit-assets/blockchain/contracts/deployed-lit-node-contracts-temp.json` file. | ||||||
| - --filter=<test-name> | ||||||
|
|
||||||
| Set these two env vars: | ||||||
| See more in `local-tests/README.md` | ||||||
|
|
||||||
| ```sh | ||||||
| export LIT_JS_SDK_LOCAL_NODE_DEV="true" | ||||||
| export LIT_JS_SDK_FUNDED_WALLET_PRIVATE_KEY="putAFundedPrivateKeyOnChronicleHere" | ||||||
| ``` | ||||||
| ## Local Development with Lit Node | ||||||
|
|
||||||
| Run: | ||||||
| ### Setup Local Environment | ||||||
|
|
||||||
| ```sh | ||||||
| yarn update:contracts-sdk --fetch | ||||||
| yarn update:contracts-sdk --gen | ||||||
| yarn build:packages | ||||||
| ``` | ||||||
| 1. Deploy Lit Node Contracts (addresses will be read from `../lit-assets/blockchain/contracts/deployed-lit-node-contracts-temp.json`) | ||||||
|
|
||||||
| To run manual tests: | ||||||
| 2. Configure environment variables: | ||||||
|
|
||||||
| ```sh | ||||||
| yarn nx run nodejs:serve | ||||||
| # Enable local node development | ||||||
| export LIT_JS_SDK_LOCAL_NODE_DEV="true" | ||||||
|
|
||||||
| # Set funded wallet for Chronicle testnet | ||||||
| export LIT_JS_SDK_FUNDED_WALLET_PRIVATE_KEY="your-funded-private-key" | ||||||
| ``` | ||||||
|
|
||||||
| ## ENV Vars | ||||||
| ## Environment Variables | ||||||
|
|
||||||
| | Variable | Description | Usage | | ||||||
| | -------------------------------------- | --------------------------- | ------------------------------------------------------------ | | ||||||
| | `LIT_JS_SDK_GITHUB_ACCESS_TOKEN` | GitHub access token | Required for accessing contract ABIs from private repository | | ||||||
| | `LIT_JS_SDK_LOCAL_NODE_DEV` | Local node development flag | Set to `true` to use a local Lit node | | ||||||
| | `LIT_JS_SDK_FUNDED_WALLET_PRIVATE_KEY` | Funded wallet private key | Required for Chronicle Testnet transactions | | ||||||
|
|
||||||
| - LIT_JS_SDK_GITHUB_ACCESS_TOKEN - a github access token to get the contract ABIs from a private repo | ||||||
| - LIT_JS_SDK_LOCAL_NODE_DEV - set to true to use a local node | ||||||
| - LIT_JS_SDK_FUNDED_WALLET_PRIVATE_KEY - set to a funded wallet on Chronicle Testnet | ||||||
| # Error Handling Guide | ||||||
|
|
||||||
| # Error Handling | ||||||
| ## Overview | ||||||
|
|
||||||
| This SDK uses custom error classes derived from [@openagenda/verror](https://github.com/OpenAgenda/verror) to handle errors between packages and to the SDK consumers. | ||||||
| Normal error handling is also supported as VError extends the native Error class, but using VError allows for better error composition and information propagation. | ||||||
| You can check their documentation for the extra fields that are added to the error object and methods on how to handle them in a safe way. | ||||||
| The SDK implements a robust error handling system using [@openagenda/verror](https://github.com/OpenAgenda/verror). This system provides: | ||||||
|
|
||||||
| ## Example | ||||||
| - Detailed error information with cause tracking | ||||||
| - Error composition and chaining | ||||||
| - Additional context through metadata | ||||||
| - Compatibility with native JavaScript Error handling | ||||||
|
|
||||||
| ## Using Error Handling | ||||||
|
|
||||||
| ### Basic Example | ||||||
|
|
||||||
| ```ts | ||||||
| import { VError } from '@openagenda/verror'; | ||||||
| import { LitNodeClientBadConfigError } from '@lit-protocol/constants'; | ||||||
|
|
||||||
| try { | ||||||
| // Simulate an error condition | ||||||
| const someNativeError = new Error('some native error'); | ||||||
|
|
||||||
| // Throw a Lit-specific error with context | ||||||
| throw new LitNodeClientBadConfigError( | ||||||
| { | ||||||
| cause: someNativeError, | ||||||
| info: { | ||||||
| foo: 'bar', | ||||||
| }, | ||||||
| meta: { | ||||||
| baz: 'qux', | ||||||
| }, | ||||||
| info: { foo: 'bar' }, | ||||||
| meta: { baz: 'qux' }, | ||||||
| }, | ||||||
| 'some useful message' | ||||||
| ); | ||||||
| } catch (e) { | ||||||
| // Access error details | ||||||
| console.log(e.name); // LitNodeClientBadConfigError | ||||||
| console.log(e.message); // some useful message: some native error | ||||||
| console.log(e.info); // { foo: 'bar' } | ||||||
| console.log(e.baz); // qux | ||||||
| // VError.cause(e) is someNativeError | ||||||
| // VError.info(e) is { foo: 'bar' } | ||||||
| // VError.meta(e) is { baz: 'qux', code: 'lit_node_client_bad_config_error', kind: 'Config' } | ||||||
| // Verror.fullStack(e) is the full stack trace composed of the error chain including the causes | ||||||
|
|
||||||
| // Additional error information | ||||||
| // - VError.cause(e): Original error (someNativeError) | ||||||
| // - VError.info(e): Additional context ({ foo: 'bar' }) | ||||||
| // - VError.meta(e): Metadata ({ baz: 'qux', code: 'lit_node_client_bad_config_error', kind: 'Config' }) | ||||||
| // - VError.fullStack(e): Complete error chain stack trace | ||||||
| } | ||||||
| ``` | ||||||
|
|
||||||
| ## Creating a new error | ||||||
|
|
||||||
| In file `packages/constants/src/lib/errors.ts` you can find the list of errors that are currently supported and add new ones if needed. | ||||||
|
|
||||||
| To create and use a new error, you need to: | ||||||
|
|
||||||
| 1. Add the error information to the `LIT_ERROR` object in `packages/constants/src/lib/errors.ts` | ||||||
| 2. Export the error from the `errors.ts` file at the end of the file | ||||||
| 3. Import the error where you need it | ||||||
| 4. Throw the error in your code adding all the information a user might need to know about the error such as the cause, the info, etc. | ||||||
| ## Creating Custom Errors | ||||||
|
|
||||||
| To add new error types: | ||||||
|
|
||||||
| 1. Locate `packages/constants/src/lib/errors.ts` | ||||||
| 2. Add your error definition to the `LIT_ERROR` object | ||||||
| 3. Export the new error class | ||||||
| 4. Import and use in your code with relevant context: | ||||||
| ```ts | ||||||
| throw new YourCustomError( | ||||||
| { | ||||||
| cause: originalError, | ||||||
| info: { | ||||||
| /* context */ | ||||||
| }, | ||||||
| meta: { | ||||||
| /* metadata */ | ||||||
| }, | ||||||
| }, | ||||||
| 'Error message' | ||||||
| ); | ||||||
| ``` | ||||||
|
|
||||||
| # Dockerfile | ||||||
|
|
||||||
| ...coming soon | ||||||
|
|
||||||
| ## Other Commands | ||||||
|
|
||||||
| ### Interactive graph dependencies using NX | ||||||
| # Core Systems and Services | ||||||
|
|
||||||
| ``` | ||||||
| yarn graph | ||||||
| ``` | ||||||
| The Lit Protocol SDK provides the following core systems: | ||||||
|
|
||||||
|  | ||||||
| - Cryptographic key management (PKP - Public Key Protocol) | ||||||
|
||||||
| - Cryptographic key management (PKP - Public Key Protocol) | |
| - Cryptographic key management (PKP - Programable Key Pair) |
FedericoAmura marked this conversation as resolved.
Show resolved
Hide resolved
FedericoAmura marked this conversation as resolved.
Show resolved
Hide resolved
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.