CtrlK
CommunityDocumentationLog inGet started
Tessl Logo

tessl/npm-walletconnect--types

tessl install tessl/npm-walletconnect--types@2.21.0

TypeScript type definitions and interfaces for the WalletConnect Protocol v2, enabling type-safe development across the WalletConnect ecosystem

Agent Success

Agent success rate when using this tile

70%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.19x

Baseline

Agent success rate without this tile

59%

task.mdevals/scenario-6/

WalletConnect Message Handler

A utility module for managing JSON-RPC messages in a WalletConnect-based application, with support for tracking message history and preventing duplicate processing.

Capabilities

Message History Tracking

  • Records an incoming JSON-RPC request with ID 123, method "eth_signTransaction", topic "abc", chainId "eip155:1", and expiry timestamp 1735689600, then successfully retrieves it by ID @test
  • Records multiple requests with IDs 1, 2, and 3, then returns all pending requests as an array @test
  • Records a request with ID 456 and matching response with ID 456, then verifies the request is no longer pending @test

Message Deduplication

  • Tracks message hash "msg_abc123" as received, then returns true when checking if it exists @test
  • Checks for a message hash "msg_xyz789" that was never tracked and returns false @test
  • Tracks message hash "msg_def456" and confirms it exists, then deletes it and confirms it no longer exists @test

Implementation

@generates

API

/**
 * Manages JSON-RPC message history and correlation
 */
export interface MessageHistory {
  /**
   * Records a JSON-RPC request
   * @param topic - The topic associated with the request
   * @param request - The JSON-RPC request object with id, method, and params
   * @param chainId - Optional chain identifier (e.g., "eip155:1")
   * @param expiry - Optional expiration timestamp
   */
  set(topic: string, request: any, chainId?: string, expiry?: number): Promise<void>;

  /**
   * Retrieves a record by request ID
   * @param id - The request ID
   * @returns The stored record or undefined if not found
   */
  get(id: number): Promise<any | undefined>;

  /**
   * Retrieves all pending requests (requests without responses)
   * @returns Array of pending request records
   */
  getPending(): Promise<any[]>;

  /**
   * Records a JSON-RPC response and matches it to the request
   * @param topic - The topic associated with the response
   * @param response - The JSON-RPC response object with id and result or error
   */
  resolve(topic: string, response: any): Promise<void>;
}

/**
 * Manages message deduplication through hash tracking
 */
export interface MessageTracker {
  /**
   * Records a message hash to track it
   * @param hash - The unique message hash
   */
  set(hash: string): Promise<void>;

  /**
   * Checks if a message hash has been tracked
   * @param hash - The message hash to check
   * @returns true if the hash exists, false otherwise
   */
  get(hash: string): Promise<boolean>;

  /**
   * Removes a tracked message hash
   * @param hash - The message hash to remove
   */
  delete(hash: string): Promise<void>;
}

/**
 * Creates a new MessageHistory instance
 */
export function createMessageHistory(): MessageHistory;

/**
 * Creates a new MessageTracker instance
 */
export function createMessageTracker(): MessageTracker;

Dependencies { .dependencies }

@walletconnect/types { .dependency }

Provides TypeScript type definitions for WalletConnect Protocol v2, including interfaces for message history tracking and deduplication.

@satisfied-by

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/@walletconnect/types@2.21.x
tile.json