Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@solana/rpc-transformers

Package Overview
Dependencies
Maintainers
0
Versions
867
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@solana/rpc-transformers - npm Package Compare versions

Comparing version 2.0.0-canary-20240901184101 to 2.0.0-canary-20240901184654

dist/types/request-transformer-bigint-downcast.d.ts

6

dist/types/index.d.ts

@@ -1,5 +0,5 @@

export * from './params-transformer';
export * from './params-transformer-bigint-downcast';
export * from './params-transformer-integer-overflow';
export * from './request-transformer';
export * from './request-transformer-bigint-downcast';
export * from './request-transformer-default-commitment';
export * from './request-transformer-integer-overflow';
export * from './request-transformer-options-object-position-config';

@@ -6,0 +6,0 @@ export * from './response-transformer';

@@ -0,1 +1,2 @@

import { RpcRequestTransformer } from '@solana/rpc-spec';
export type KeyPathWildcard = {

@@ -11,3 +12,4 @@ readonly __brand: unique symbol;

export declare function getTreeWalker(visitors: NodeVisitor[]): <TState extends TraversalState>(node: unknown, state: TState) => unknown;
export declare function getTreeWalkerRequestTransformer<TState extends TraversalState>(visitors: NodeVisitor[], initialState: TState): RpcRequestTransformer;
export {};
//# sourceMappingURL=tree-traversal.d.ts.map
{
"name": "@solana/rpc-transformers",
"version": "2.0.0-canary-20240901184101",
"version": "2.0.0-canary-20240901184654",
"description": "Reusable transformers for patching RPC inputs and outputs",

@@ -57,7 +57,7 @@ "exports": {

"dependencies": {
"@solana/errors": "2.0.0-canary-20240901184101",
"@solana/functional": "2.0.0-canary-20240901184101",
"@solana/rpc-subscriptions-spec": "2.0.0-canary-20240901184101",
"@solana/rpc-types": "2.0.0-canary-20240901184101",
"@solana/rpc-spec": "2.0.0-canary-20240901184101"
"@solana/errors": "2.0.0-canary-20240901184654",
"@solana/functional": "2.0.0-canary-20240901184654",
"@solana/rpc-spec": "2.0.0-canary-20240901184654",
"@solana/rpc-types": "2.0.0-canary-20240901184654",
"@solana/rpc-subscriptions-spec": "2.0.0-canary-20240901184654"
},

@@ -64,0 +64,0 @@ "peerDependencies": {

@@ -17,4 +17,19 @@ [![npm][npm-image]][npm-url]

## Functions
## Request Transformers
### `getDefaultRequestTransformerForSolanaRpc(config)`
Returns the default request transformer for the Solana RPC API. Under the hood, this function composes multiple `RpcRequestTransformer` together such as the `getDefaultCommitmentTransformer`, the `getIntegerOverflowRequestTransformer` and the `getBigIntDowncastRequestTransformer`.
```ts
import { getDefaultRequestTransformerForSolanaRpc } from '@solana/rpc-transformers';
const requestTransformer = getDefaultRequestTransformerForSolanaRpc({
defaultCommitment: 'confirmed',
onIntegerOverflow: (request, keyPath, value) => {
throw new Error(`Integer overflow at ${keyPath.join('.')}: ${value}`);
},
});
```
### `getDefaultCommitmentTransformer(config)`

@@ -32,1 +47,41 @@

```
### `getIntegerOverflowRequestTransformer(handler)`
Creates a transformer that traverses the request parameters and executes the provided handler when an integer overflow is detected.
```ts
import { getIntegerOverflowRequestTransformer } from '@solana/rpc-transformers';
const requestTransformer = getIntegerOverflowRequestTransformer((request, keyPath, value) => {
throw new Error(`Integer overflow at ${keyPath.join('.')}: ${value}`);
});
```
### `getBigIntDowncastRequestTransformer()`
Creates a transformer that downcasts all `BigInt` values to `Number`.
```ts
import { getBigIntDowncastRequestTransformer } from '@solana/rpc-transformers';
const requestTransformer = getBigIntDowncastRequestTransformer();
```
### `getTreeWalkerRequestTransformer(visitors, initialState)`
Creates a transformer that traverses the request parameters and executes the provided visitors at each node. A custom initial state can be provided but must at least provide `{ keyPath: [] }`.
```ts
import { getTreeWalkerRequestTransformer } from '@solana/rpc-transformers';
const requestTransformer = getTreeWalkerRequestTransformer(
[
// Replaces foo.bar with "baz".
(node, state) => (state.keyPath === ['foo', 'bar'] ? 'baz' : node),
// Increments all numbers by 1.
node => (typeof node === number ? node + 1 : node),
],
{ keyPath: [] },
);
```

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc