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-9/

WalletConnect Link Mode Session Manager

Build a session manager utility that handles WalletConnect sessions using alternative transport methods, specifically focusing on link mode support for direct peer-to-peer connections.

Requirements

Create a TypeScript utility that manages WalletConnect session metadata and transport configurations. The utility should:

  1. Session Transport Configuration: Accept session data and determine the appropriate transport mechanism based on peer metadata
  2. Deep Link Generation: Generate platform-specific deep links for initiating direct connections with wallets
  3. Transport Type Tracking: Maintain and query information about which transport type each session is using
  4. Session Filtering: Filter sessions by their transport type to identify which are using link mode versus relay mode

Implementation Details

Your solution should include:

  • A SessionManager class that stores and manages multiple sessions
  • A method to add sessions with their metadata and automatically detect link mode capability
  • A method to generate deep link URLs for a given session when link mode is available
  • Methods to query sessions by transport type
  • Proper TypeScript typing using types from @walletconnect/types

API

import { SessionTypes, RelayerTypes } from '@walletconnect/types';

/**
 * Manages WalletConnect sessions with link mode support
 */
export class SessionManager {
  /**
   * Adds a session to the manager
   * @param session - The WalletConnect session structure
   */
  addSession(session: SessionTypes.Struct): void;

  /**
   * Generates a deep link URL for the given session topic if link mode is supported
   * @param topic - The session topic
   * @returns The deep link URL or null if link mode is not available
   */
  generateDeepLink(topic: string): string | null;

  /**
   * Returns all sessions using the specified transport type
   * @param transportType - The transport type to filter by ('relay' or 'link_mode')
   * @returns Array of matching sessions
   */
  getSessionsByTransport(transportType: RelayerTypes.TransportTypes): SessionTypes.Struct[];

  /**
   * Checks if a session has link mode capability
   * @param topic - The session topic
   * @returns true if the session peer supports link mode
   */
  hasLinkModeSupport(topic: string): boolean;
}

Test Cases

  • A session with relay transport is added, and getSessionsByTransport('relay') returns it @test
  • A session with link_mode transport and peer metadata containing link mode is added, hasLinkModeSupport returns true, and generateDeepLink produces a valid deep link URL @test
  • Multiple sessions with different transport types are added, and filtering by each transport type returns only matching sessions @test
  • A session without link mode redirect is queried, and generateDeepLink returns null @test

@generates

Dependencies { .dependencies }

@walletconnect/types { .dependency }

Provides TypeScript type definitions for WalletConnect Protocol v2, including session structures, transport types, and core metadata types.

Version

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