Package Exports
- @gvnrdao/dh-lit-ops
- @gvnrdao/dh-lit-ops/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@gvnrdao/dh-lit-ops) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
LIT-OPS Package
Diamond Hands Protocol - LIT Protocol Operations
Decoupled LIT Protocol operations supporting both standalone and service modes.
๐ฏ Purpose
This package provides a clean separation of LIT Protocol operations from the main SDK, enabling:
- Standalone Mode: Users pay LIT tokens directly with their private keys
- Service Mode: Backend service handles LIT token costs centrally
๐๏ธ Architecture
lit-ops/
โโโ src/
โ โโโ client/ # LIT client management
โ โโโ auth/ # SessionSigs & authentication
โ โโโ pkp/ # PKP operations (mint, validate, burn)
โ โโโ actions/ # LIT Action execution
โ โโโ interfaces/ # Type definitions
โ โโโ index.ts # Main exports
โโโ package.json
โโโ README.md๐ Usage
Basic Setup
import { LitOps } from "@diamond-hands/lit-ops";
// Standalone mode (user pays)
const wallet = ethers.Wallet.createRandom();
const litOps = new LitOps({
mode: "standalone",
network: "datil-test",
signer: wallet,
debug: true,
});
// Service mode (backend pays) - Future
const litOps = new LitOps({
mode: "service",
signer: wallet,
network: "datil-test",
serviceEndpoint: "https://api.diamond-hands.com",
debug: false,
});PKP Operations
// Create PKP
const pkpResult = await litOps.createPKP(signer, litActionCid);
// Validate PKP
const validation = await litOps.validatePKP(pkpId, signer);
// Burn PKP
const burnResult = await litOps.burnPKP(pkpId, signer, "liquidation");LIT Action Execution
// Execute from CID (deployed LIT Action)
const result = await litOps.executeActionFromCID(
"bafkreidxcjah2ogybxm5do5yvvy6z6klr4zca6vwvcyni4qmmtj6loef4q",
pkpPublicKey,
{ message: "test" },
signer
);
// Execute from code
const result = await litOps.executeActionFromCode(
litActionCode,
pkpPublicKey,
{ message: "test" },
signer
);๐ง Configuration
interface LitOpsConfig {
mode: "standalone" | "service";
network: "datil-test" | "datil";
debug?: boolean;
serviceEndpoint?: string;
domain?: string;
sessionExpirationMinutes?: number;
}๐ฆ Integration
In SDK
// sdk/src/modules/PKPManager.ts
import { LitOps } from "../../lit-ops";
export class PKPManager {
private litOps: LitOps;
constructor(config: SDKConfig) {
this.litOps = new LitOps({
mode: config.litMode || "standalone",
network: config.litNetwork,
signer: config.signer, // Add signer to SDK config
debug: config.debug,
});
}
}In Backend Service
// backend-service/routes/lit.ts
import { LitOps } from "../lit-ops";
const serviceSigner = ethers.Wallet.fromMnemonic(process.env.SERVICE_MNEMONIC);
const litOps = new LitOps({
mode: "service",
network: "datil-test",
signer: serviceSigner,
});
app.post("/api/lit/create-pkp", async (req, res) => {
const result = await litOps.createPKP();
res.json(result);
});๐ Operation Modes
Standalone Mode
- User provides their own signer
- User pays LIT token costs
- Direct LIT Protocol interaction
- Full decentralization
Service Mode (Future)
- Backend service handles LIT operations
- Centralized LIT token payment
- API-based interaction
- Simplified user experience
๐งช Development
# Install dependencies
npm install
# Build package
npm run build
# Run tests
npm test
# Watch mode
npm run dev๐ Status
- โ Standalone Mode: Implemented
- โ PKP Operations: Mock implementation ready
- โ LIT Action Execution: Real execution from CID
- โ SessionSigs Authentication: Working
- โณ Service Mode: Future implementation
- โณ Real PKP Minting: Will replace mock implementation
๐ Dependencies
@lit-protocol/lit-node-client@lit-protocol/auth-helpers@lit-protocol/constantsethersaxios
๐ฏ Benefits
- Separation of Concerns: LIT operations isolated from business logic
- Reusability: Same code in SDK and backend service
- Cost Flexibility: Support both payment models
- Maintainability: Single place for LIT Protocol interactions
- Testing: Isolated testing of LIT operations