Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
@walletconnect/jsonrpc-utils
Advanced tools
@walletconnect/jsonrpc-utils is a utility library for working with JSON-RPC in the context of WalletConnect. It provides tools for creating, validating, and managing JSON-RPC requests and responses, which are essential for communication between clients and servers in a decentralized environment.
Creating JSON-RPC Requests
This feature allows you to create a JSON-RPC request. The `formatJsonRpcRequest` function takes a method name and parameters, and returns a properly formatted JSON-RPC request object.
const { formatJsonRpcRequest } = require('@walletconnect/jsonrpc-utils');
const request = formatJsonRpcRequest('eth_sendTransaction', [{ from: '0x...', to: '0x...', value: '0x...' }]);
console.log(request);
Validating JSON-RPC Responses
This feature allows you to validate JSON-RPC responses. The `isJsonRpcResponseSuccess` function checks if a response is successful, while `isJsonRpcResponseError` checks if it contains an error.
const { isJsonRpcResponseSuccess, isJsonRpcResponseError } = require('@walletconnect/jsonrpc-utils');
const response = { jsonrpc: '2.0', result: '0x1', id: 1 };
console.log(isJsonRpcResponseSuccess(response)); // true
console.log(isJsonRpcResponseError(response)); // false
Handling JSON-RPC Errors
This feature allows you to create a JSON-RPC error response. The `formatJsonRpcError` function takes an id and an error message, and returns a properly formatted JSON-RPC error object.
const { formatJsonRpcError } = require('@walletconnect/jsonrpc-utils');
const error = formatJsonRpcError(1, 'Something went wrong');
console.log(error);
json-rpc-engine is a modular JSON-RPC middleware engine for building JSON-RPC servers and clients. It provides a flexible way to handle JSON-RPC requests and responses, similar to @walletconnect/jsonrpc-utils, but with a focus on middleware composition.
jayson is a full-featured JSON-RPC 2.0/1.0 client and server for Node.js. It offers a comprehensive set of tools for creating and managing JSON-RPC requests and responses, similar to @walletconnect/jsonrpc-utils, but with additional support for server-side operations.
jsonrpc-lite is a lightweight JSON-RPC 2.0 library for Node.js and the browser. It provides basic utilities for creating and parsing JSON-RPC requests and responses, similar to @walletconnect/jsonrpc-utils, but with a focus on minimalism and simplicity.
FAQs
Utilities for JSON-RPC
The npm package @walletconnect/jsonrpc-utils receives a total of 311,010 weekly downloads. As such, @walletconnect/jsonrpc-utils popularity was classified as popular.
We found that @walletconnect/jsonrpc-utils demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 8 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.