tessl install tessl/npm-walletconnect--types@2.21.0TypeScript 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%
Build a request tracking system that manages JSON-RPC requests and responses, handling request correlation, timeout management, and pending request queries.
Your system should:
Store requests with metadata: When a JSON-RPC request is created, store it with a unique ID, topic, chain ID, and expiry timestamp.
Update with responses: When a response arrives for a request, update the stored record to include the response data.
Query pending requests: Provide the ability to query all pending requests (requests without responses) for a specific topic.
Query by chain ID: Support querying all requests associated with a specific chain ID.
Handle expiry: Automatically remove expired requests based on their expiry timestamps.
Check request existence: Allow checking if a specific request ID exists in the history.
Create a TypeScript module with the following:
@generates
/**
* Represents a stored JSON-RPC request/response record
*/
export interface RequestRecord {
id: number;
topic: string;
chainId: string;
request: {
method: string;
params: any;
};
response?: {
result?: any;
error?: any;
};
expiry: number;
}
/**
* Manages JSON-RPC request/response history
*/
export class RequestTracker {
/**
* Add a new request to the tracker
*/
set(topic: string, request: { id: number; chainId: string; request: { method: string; params: any }; expiry: number }): void;
/**
* Update a request with its response
*/
resolve(id: number, response: { result?: any; error?: any }): void;
/**
* Get all pending requests for a topic (requests without responses)
*/
getPending(topic: string): RequestRecord[];
/**
* Get all requests for a specific chain ID
*/
getByChainId(chainId: string): RequestRecord[];
/**
* Remove all expired requests
*/
removeExpired(currentTimestamp: number): void;
/**
* Check if a request exists
*/
exists(id: number): boolean;
}Provides type definitions for WalletConnect Protocol v2, including JSON-RPC history interfaces.