@solana/rpc-transformers
Advanced tools
Comparing version 2.0.0-canary-20240901184101 to 2.0.0-canary-20240901184654
@@ -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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
229425
1810
86
+ Added@solana/addresses@2.0.0-canary-20240901184654(transitive)
+ Added@solana/assertions@2.0.0-canary-20240901184654(transitive)
+ Added@solana/codecs-core@2.0.0-canary-20240901184654(transitive)
+ Added@solana/codecs-numbers@2.0.0-canary-20240901184654(transitive)
+ Added@solana/codecs-strings@2.0.0-canary-20240901184654(transitive)
+ Added@solana/errors@2.0.0-canary-20240901184654(transitive)
+ Added@solana/functional@2.0.0-canary-20240901184654(transitive)
+ Added@solana/rpc-spec@2.0.0-canary-20240901184654(transitive)
+ Added@solana/rpc-spec-types@2.0.0-canary-20240901184654(transitive)
+ Added@solana/rpc-subscriptions-spec@2.0.0-canary-20240901184654(transitive)
+ Added@solana/rpc-types@2.0.0-canary-20240901184654(transitive)
- Removed@solana/addresses@2.0.0-canary-20240901184101(transitive)
- Removed@solana/assertions@2.0.0-canary-20240901184101(transitive)
- Removed@solana/codecs-core@2.0.0-canary-20240901184101(transitive)
- Removed@solana/codecs-numbers@2.0.0-canary-20240901184101(transitive)
- Removed@solana/codecs-strings@2.0.0-canary-20240901184101(transitive)
- Removed@solana/errors@2.0.0-canary-20240901184101(transitive)
- Removed@solana/functional@2.0.0-canary-20240901184101(transitive)
- Removed@solana/rpc-spec@2.0.0-canary-20240901184101(transitive)
- Removed@solana/rpc-spec-types@2.0.0-canary-20240901184101(transitive)
- Removed@solana/rpc-subscriptions-spec@2.0.0-canary-20240901184101(transitive)
- Removed@solana/rpc-types@2.0.0-canary-20240901184101(transitive)
Updated@solana/rpc-subscriptions-spec@2.0.0-canary-20240901184654