Skip to content

Commit

Permalink
docs: update PKP package READMEs with improved documentation
Browse files Browse the repository at this point in the history
Co-Authored-By: anson@litprotocol.com <anson@litprotocol.com>
  • Loading branch information
devin-ai-integration[bot] and anson@litprotocol.com committed Jan 2, 2025
1 parent dd4a818 commit 14b4c41
Show file tree
Hide file tree
Showing 4 changed files with 208 additions and 41 deletions.
67 changes: 50 additions & 17 deletions packages/pkp-base/README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,55 @@
# Quick Start
# PKP Base

This submodule defines a PKPBase class, providing shared wallet functionality for PKP signers, responsible for managing public key compression, initializing and connecting to the LIT node, running LIT actions, and offering debug functions for logging and error handling.
A foundational package providing shared wallet functionality for PKP (Programmable Key Pair) signers in the Lit Protocol ecosystem. This package manages public key operations, LIT node connections, and action execution.

| Method/Property | Description |
| -------------------------------------------------------------------- | ----------------------------------------------------------------------------- |
| `compressPubKey(pubKey: string)` | Compresses a provided public key |
| `setUncompressPubKeyAndBuffer(prop: PKPBaseProp)` | Sets the uncompressed public key and its buffer representation |
| `setCompressedPubKeyAndBuffer(prop: PKPBaseProp)` | Sets the compressed public key and its buffer representation |
| `setLitAction(prop: PKPBaseProp)` | Sets the Lit action to be executed by the LitNode client |
| `setLitActionJsParams<CustomType extends T = T>(params: CustomType)` | Sets the value of the `litActionJsParams` property to the given params object |
| `createAndSetSessionSigs(sessionParams: GetSessionSigsProps)` | Creates and sets the session sigs and their expiration |
| `init()` | Initializes the PKPBase instance by connecting to the LIT node |
| `runLitAction(toSign: Uint8Array, sigName: string)` | Runs the specified Lit action with the given parameters |
| `ensureLitNodeClientReady()` | Ensures that the LitNode client is ready for use |
| `log(...args: any[])` | Logs the provided arguments to the console, but only if debugging is enabled |
## Installation

### node.js / browser

```
```bash
yarn add @lit-protocol/pkp-base
```

## Quick Start

```typescript
import { PKPBase } from '@lit-protocol/pkp-base';

// Initialize PKP Base
const pkpBase = new PKPBase({
controllerAuthSig: authSig,
pkpPubKey: publicKey,
});

// Connect to LIT node
await pkpBase.init();

// Run LIT action
const signature = await pkpBase.runLitAction(dataToSign, 'sign');
```

## Key Features

- Public key compression and management
- LIT node connection handling
- Session signature management
- LIT action execution
- Debug logging capabilities

## Core Methods

| Method | Description |
| ------ | ----------- |
| `init()` | Initialize and connect to LIT node |
| `compressPubKey()` | Compress public keys |
| `runLitAction()` | Execute LIT actions |
| `createAndSetSessionSigs()` | Manage session signatures |
| `ensureLitNodeClientReady()` | Verify node connection |

## Development

### Building

Run `nx build pkp-base` to build the library.

### Testing

Run `nx test pkp-base` to execute the unit tests.
58 changes: 54 additions & 4 deletions packages/pkp-cosmos/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,59 @@
# PKPCosmos
# PKP Cosmos

The `PKPCosmosWallet` class is a specialized wallet for the Cosmos blockchain, based on the `DirectSecp256k1HdWallet` class from the `@cosmjs/proto-signing` library. This class implements the `OfflineDirectSigner` and `PKPClientHelpers` interfaces. The wallet can generate its own Bech32 address (address), manage account data (`getAccounts`), and sign transactions (`signDirect`) with the private key using a LIT node client. It can also create a SigningStargateClient instance (`getClient`), prepare transaction data (formSendTx), and sign a transaction following the SigningStargateClient.sign method (`sign`). The class supports the customization of the Cosmos RPC URL (`rpc`) and the Bech32 address prefix (`addressPrefix`).
A specialized wallet implementation for the Cosmos blockchain ecosystem using Lit Protocol's PKP (Programmable Key Pair) technology. Built on top of `@cosmjs/proto-signing`, this package enables secure transaction signing and account management through Lit nodes.

# Getting Started
## Installation

```
```bash
yarn add @lit-protocol/pkp-cosmos
```

## Quick Start

```typescript
import { PKPCosmosWallet } from '@lit-protocol/pkp-cosmos';

// Initialize wallet
const wallet = new PKPCosmosWallet({
controllerAuthSig: authSig,
pkpPubKey: publicKey,
addressPrefix: 'cosmos',
});

// Get wallet address
const address = await wallet.getAddress();

// Sign transaction
const signedTx = await wallet.signDirect(address, {
bodyBytes: tx.bodyBytes,
authInfoBytes: tx.authInfoBytes,
chainId: chainId,
});
```

## Key Features

- Bech32 address generation
- Account data management
- Transaction signing via LIT nodes
- SigningStargateClient integration
- Customizable RPC endpoints
- Flexible address prefix support

## Core Functionality

- Address Generation: Create Cosmos blockchain addresses
- Transaction Management: Sign and prepare transactions
- Client Integration: Create SigningStargateClient instances
- Account Operations: Manage account data and balances
- Network Configuration: Customize RPC URLs and prefixes

## Development

### Building

Run `nx build pkp-cosmos` to build the library.

### Testing

Run `nx test pkp-cosmos` to execute the unit tests.
62 changes: 54 additions & 8 deletions packages/pkp-ethers/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,60 @@
# Getting started
# PKP Ethers

This module presents a modified version of `new ethers.Wallet()`, known as `PKPEthersWallet`. Unlike its counterpart, `PKPEthersWallet` does not store private keys nor does it support the creation of random wallets.
A specialized Ethereum wallet implementation using Lit Protocol's PKP (Programmable Key Pair) technology, built as an extension of ethers.js Wallet. This package provides secure transaction signing and account management through Lit nodes without storing private keys locally.

Despite these differences, it retains the ability to sign and send transactions, process JSON requests, retrieve balance and transaction count, among other functionalities, just like a standard ethers.js Wallet instance.
## Installation

API: https://docs.ethers.org/v4/api-wallet.html

```
```bash
yarn add @lit-protocol/pkp-ethers ethers
```

More info here:
https://github.com/LIT-Protocol/pkp-ethers/tree/master/packages/wallet
## Quick Start

```typescript
import { PKPEthersWallet } from '@lit-protocol/pkp-ethers';

// Initialize wallet
const wallet = new PKPEthersWallet({
controllerAuthSig: authSig,
pkpPubKey: publicKey,
});

// Get wallet address
const address = await wallet.getAddress();

// Sign transaction
const signedTx = await wallet.signTransaction({
to: recipient,
value: ethers.utils.parseEther("0.1"),
});
```

## Key Features

- Secure transaction signing via LIT nodes
- Full ethers.js Wallet compatibility
- JSON-RPC request handling
- Balance and nonce management
- Gas estimation support
- Message signing capabilities

## Core Functionality

- Transaction Management: Sign and send transactions
- Account Operations: Get balances and transaction counts
- Message Signing: Sign messages and typed data
- Network Integration: Connect to any EVM network
- Gas Handling: Estimate and manage gas costs

For detailed API documentation, visit:
https://docs.ethers.org/v4/api-wallet.html

## Development

### Building

Run `nx build pkp-ethers` to build the library.

### Testing

Run `nx test pkp-ethers` to execute the unit tests.
62 changes: 50 additions & 12 deletions packages/pkp-walletconnect/README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,65 @@
# pkp-walletconnect
# PKP WalletConnect

`pkp-walletconnect` wraps [`@walletconnect/web3wallet`](https://docs.walletconnect.com/2.0/web/web3wallet/wallet-usage) to provide base functionality needed to pair PKPs to dApps, approve and reject session proposals, and respond to session requests. This library is intended to be used with `pkp-client`.
A WalletConnect integration for Lit Protocol's PKP (Programmable Key Pair) system, enabling secure dApp connections and session management. This package wraps WalletConnect's Web3Wallet to provide seamless PKP integration with decentralized applications.

## 📜 API Reference
## Installation

Check out the [API reference](https://docs.lit-js-sdk-v2.litprotocol.com/modules/pkp_walletconnect_src.html).
```bash
yarn add @lit-protocol/pkp-walletconnect
```

## 📦 Installation
## Quick Start

Get started by installing the package:
```typescript
import { PKPWalletConnect } from '@lit-protocol/pkp-walletconnect';

```bash
yarn add @lit-protocol/pkp-walletconnect
// Initialize WalletConnect client
const client = new PKPWalletConnect({
projectId: 'your-project-id',
metadata: {
name: 'Your App',
description: 'Your app description',
url: 'https://your-app.com',
icons: ['https://your-app.com/icon.png']
}
});

// Handle session proposals
client.on('session_proposal', async (proposal) => {
const approved = await client.approveSession(proposal);
});

// Handle session requests
client.on('session_request', async (request) => {
const response = await client.respondToRequest(request);
});
```

## 🙌 Contributing
## Key Features

- WalletConnect v2.0 integration
- dApp pairing management
- Session proposal handling
- Request/response management
- Multi-chain support
- Event handling system

## Core Functionality

- Session Management: Handle dApp connections
- Request Processing: Respond to session requests
- Pairing: Manage PKP-dApp pairings
- Event Handling: Subscribe to WalletConnect events
- Chain Configuration: Support multiple blockchains

For detailed API documentation, visit the [API reference](https://docs.lit-js-sdk-v2.litprotocol.com/modules/pkp_walletconnect_src.html).

This library was generated with [Nx](https://nx.dev).
## Development

### Building

Run `nx build pkp-walletconnect` to build the library.

### Running unit tests
### Testing

Run `nx test pkp-walletconnect` to execute the unit tests via [Jest](https://jestjs.io).
Run `nx test pkp-walletconnect` to execute the unit tests.

0 comments on commit 14b4c41

Please sign in to comment.