JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1973
  • Score
    100M100P100Q99291F
  • License MIT

Diamond Hands Protocol - LIT Protocol Operations Package

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:

  1. Standalone Mode: Users pay LIT tokens directly with their private keys
  2. 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/constants
  • ethers
  • axios

๐ŸŽฏ Benefits

  1. Separation of Concerns: LIT operations isolated from business logic
  2. Reusability: Same code in SDK and backend service
  3. Cost Flexibility: Support both payment models
  4. Maintainability: Single place for LIT Protocol interactions
  5. Testing: Isolated testing of LIT operations