@solana/rpc-api 2.0.0-canary-20240731173615
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -0
- package/README.md +59 -0
- package/dist/index.browser.cjs +117 -0
- package/dist/index.browser.cjs.map +1 -0
- package/dist/index.browser.mjs +115 -0
- package/dist/index.browser.mjs.map +1 -0
- package/dist/index.native.mjs +115 -0
- package/dist/index.native.mjs.map +1 -0
- package/dist/index.node.cjs +117 -0
- package/dist/index.node.cjs.map +1 -0
- package/dist/index.node.mjs +115 -0
- package/dist/index.node.mjs.map +1 -0
- package/dist/types/getAccountInfo.d.ts +31 -0
- package/dist/types/getAccountInfo.d.ts.map +1 -0
- package/dist/types/getBalance.d.ts +15 -0
- package/dist/types/getBalance.d.ts.map +1 -0
- package/dist/types/getBlock.d.ts +173 -0
- package/dist/types/getBlock.d.ts.map +1 -0
- package/dist/types/getBlockCommitment.d.ts +15 -0
- package/dist/types/getBlockCommitment.d.ts.map +1 -0
- package/dist/types/getBlockHeight.d.ts +14 -0
- package/dist/types/getBlockHeight.d.ts.map +1 -0
- package/dist/types/getBlockProduction.d.ts +40 -0
- package/dist/types/getBlockProduction.d.ts.map +1 -0
- package/dist/types/getBlockTime.d.ts +14 -0
- package/dist/types/getBlockTime.d.ts.map +1 -0
- package/dist/types/getBlocks.d.ts +13 -0
- package/dist/types/getBlocks.d.ts.map +1 -0
- package/dist/types/getBlocksWithLimit.d.ts +14 -0
- package/dist/types/getBlocksWithLimit.d.ts.map +1 -0
- package/dist/types/getClusterNodes.d.ts +34 -0
- package/dist/types/getClusterNodes.d.ts.map +1 -0
- package/dist/types/getEpochInfo.d.ts +27 -0
- package/dist/types/getEpochInfo.d.ts.map +1 -0
- package/dist/types/getEpochSchedule.d.ts +23 -0
- package/dist/types/getEpochSchedule.d.ts.map +1 -0
- package/dist/types/getFeeForMessage.d.ts +16 -0
- package/dist/types/getFeeForMessage.d.ts.map +1 -0
- package/dist/types/getFirstAvailableBlock.d.ts +12 -0
- package/dist/types/getFirstAvailableBlock.d.ts.map +1 -0
- package/dist/types/getGenesisHash.d.ts +11 -0
- package/dist/types/getGenesisHash.d.ts.map +1 -0
- package/dist/types/getHealth.d.ts +10 -0
- package/dist/types/getHealth.d.ts.map +1 -0
- package/dist/types/getHighestSnapshotSlot.d.ts +18 -0
- package/dist/types/getHighestSnapshotSlot.d.ts.map +1 -0
- package/dist/types/getIdentity.d.ts +13 -0
- package/dist/types/getIdentity.d.ts.map +1 -0
- package/dist/types/getInflationGovernor.d.ts +28 -0
- package/dist/types/getInflationGovernor.d.ts.map +1 -0
- package/dist/types/getInflationRate.d.ts +20 -0
- package/dist/types/getInflationRate.d.ts.map +1 -0
- package/dist/types/getInflationReward.d.ts +24 -0
- package/dist/types/getInflationReward.d.ts.map +1 -0
- package/dist/types/getLargestAccounts.d.ts +23 -0
- package/dist/types/getLargestAccounts.d.ts.map +1 -0
- package/dist/types/getLatestBlockhash.d.ts +19 -0
- package/dist/types/getLatestBlockhash.d.ts.map +1 -0
- package/dist/types/getLeaderSchedule.d.ts +51 -0
- package/dist/types/getLeaderSchedule.d.ts.map +1 -0
- package/dist/types/getMaxRetransmitSlot.d.ts +12 -0
- package/dist/types/getMaxRetransmitSlot.d.ts.map +1 -0
- package/dist/types/getMaxShredInsertSlot.d.ts +12 -0
- package/dist/types/getMaxShredInsertSlot.d.ts.map +1 -0
- package/dist/types/getMinimumBalanceForRentExemption.d.ts +13 -0
- package/dist/types/getMinimumBalanceForRentExemption.d.ts.map +1 -0
- package/dist/types/getMultipleAccounts.d.ts +44 -0
- package/dist/types/getMultipleAccounts.d.ts.map +1 -0
- package/dist/types/getProgramAccounts.d.ts +60 -0
- package/dist/types/getProgramAccounts.d.ts.map +1 -0
- package/dist/types/getRecentPerformanceSamples.d.ts +25 -0
- package/dist/types/getRecentPerformanceSamples.d.ts.map +1 -0
- package/dist/types/getRecentPrioritizationFees.d.ts +31 -0
- package/dist/types/getRecentPrioritizationFees.d.ts.map +1 -0
- package/dist/types/getSignatureStatuses.d.ts +57 -0
- package/dist/types/getSignatureStatuses.d.ts.map +1 -0
- package/dist/types/getSignaturesForAddress.d.ts +40 -0
- package/dist/types/getSignaturesForAddress.d.ts.map +1 -0
- package/dist/types/getSlot.d.ts +14 -0
- package/dist/types/getSlot.d.ts.map +1 -0
- package/dist/types/getSlotLeader.d.ts +15 -0
- package/dist/types/getSlotLeader.d.ts.map +1 -0
- package/dist/types/getSlotLeaders.d.ts +17 -0
- package/dist/types/getSlotLeaders.d.ts.map +1 -0
- package/dist/types/getStakeActivation.d.ts +26 -0
- package/dist/types/getStakeActivation.d.ts.map +1 -0
- package/dist/types/getStakeMinimumDelegation.d.ts +13 -0
- package/dist/types/getStakeMinimumDelegation.d.ts.map +1 -0
- package/dist/types/getSupply.d.ts +38 -0
- package/dist/types/getSupply.d.ts.map +1 -0
- package/dist/types/getTokenAccountBalance.d.ts +16 -0
- package/dist/types/getTokenAccountBalance.d.ts.map +1 -0
- package/dist/types/getTokenAccountsByDelegate.d.ts +55 -0
- package/dist/types/getTokenAccountsByDelegate.d.ts.map +1 -0
- package/dist/types/getTokenAccountsByOwner.d.ts +55 -0
- package/dist/types/getTokenAccountsByOwner.d.ts.map +1 -0
- package/dist/types/getTokenLargestAccounts.d.ts +17 -0
- package/dist/types/getTokenLargestAccounts.d.ts.map +1 -0
- package/dist/types/getTokenSupply.d.ts +16 -0
- package/dist/types/getTokenSupply.d.ts.map +1 -0
- package/dist/types/getTransaction.d.ts +167 -0
- package/dist/types/getTransaction.d.ts.map +1 -0
- package/dist/types/getTransactionCount.d.ts +14 -0
- package/dist/types/getTransactionCount.d.ts.map +1 -0
- package/dist/types/getVersion.d.ts +15 -0
- package/dist/types/getVersion.d.ts.map +1 -0
- package/dist/types/getVoteAccounts.d.ts +44 -0
- package/dist/types/getVoteAccounts.d.ts.map +1 -0
- package/dist/types/index.d.ts +65 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/isBlockhashValid.d.ts +18 -0
- package/dist/types/isBlockhashValid.d.ts.map +1 -0
- package/dist/types/minimumLedgerSlot.d.ts +12 -0
- package/dist/types/minimumLedgerSlot.d.ts.map +1 -0
- package/dist/types/requestAirdrop.d.ts +16 -0
- package/dist/types/requestAirdrop.d.ts.map +1 -0
- package/dist/types/sendTransaction.d.ts +49 -0
- package/dist/types/sendTransaction.d.ts.map +1 -0
- package/dist/types/simulateTransaction.d.ts +144 -0
- package/dist/types/simulateTransaction.d.ts.map +1 -0
- package/package.json +88 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2023 Solana Labs, Inc
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
[![npm][npm-image]][npm-url]
|
|
2
|
+
[![npm-downloads][npm-downloads-image]][npm-url]
|
|
3
|
+
[![semantic-release][semantic-release-image]][semantic-release-url]
|
|
4
|
+
<br />
|
|
5
|
+
[![code-style-prettier][code-style-prettier-image]][code-style-prettier-url]
|
|
6
|
+
|
|
7
|
+
[code-style-prettier-image]: https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square
|
|
8
|
+
[code-style-prettier-url]: https://github.com/prettier/prettier
|
|
9
|
+
[npm-downloads-image]: https://img.shields.io/npm/dm/@solana/rpc-api/experimental.svg?style=flat
|
|
10
|
+
[npm-image]: https://img.shields.io/npm/v/@solana/rpc-api/experimental.svg?style=flat
|
|
11
|
+
[npm-url]: https://www.npmjs.com/package/@solana/rpc-api/v/experimental
|
|
12
|
+
[semantic-release-image]: https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg
|
|
13
|
+
[semantic-release-url]: https://github.com/semantic-release/semantic-release
|
|
14
|
+
|
|
15
|
+
# @solana/rpc-api
|
|
16
|
+
|
|
17
|
+
This package contains types that describe the [methods](https://solana.com/docs/rpc/http) of the Solana JSON RPC API, and utilities for creating a `RpcApi` implementation with sensible defaults. It can be used standalone, but it is also exported as part of the Solana JavaScript SDK [`@solana/web3.js@experimental`](https://github.com/solana-labs/solana-web3.js/tree/master/packages/library).
|
|
18
|
+
|
|
19
|
+
Each RPC method is described in terms of a TypeScript interface of the following form:
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
interface ExampleApi extends RpcApiMethods {
|
|
23
|
+
getSomething(address: Address): Something;
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
A `RpcApi` that implements `ExampleApi` will ultimately expose its defined methods on any `Rpc` that uses it.
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
const rpc: Rpc<ExampleApi> = createExampleRpc(/* ... */);
|
|
31
|
+
const something: Something = await rpc.getSomething(address('95DpK3y3GF7U8s1k4EvZ7xqyeCkhsHeZaE97iZpHUGMN')).send();
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Types
|
|
35
|
+
|
|
36
|
+
### `SolanaRpcApi{Devnet|Testnet|Mainnet}`
|
|
37
|
+
|
|
38
|
+
These types represent the RPC methods available on a specific Solana cluster.
|
|
39
|
+
|
|
40
|
+
For instance, the test clusters support the `RequestAirdropApi` while mainnet does not.
|
|
41
|
+
|
|
42
|
+
## Functions
|
|
43
|
+
|
|
44
|
+
### `createSolanaRpcApi(config)`
|
|
45
|
+
|
|
46
|
+
Creates a `RpcApi` implementation of the Solana JSON RPC API with some default behaviours.
|
|
47
|
+
|
|
48
|
+
The default behaviours include:
|
|
49
|
+
|
|
50
|
+
- A transform that converts `bigint` inputs to `number` for compatiblity with version 1.0 of the Solana JSON RPC.
|
|
51
|
+
- A transform that calls the config's `onIntegerOverflow` handler whenever a `bigint` input would overflow a JavaScript IEEE 754 number. See [this](https://github.com/solana-labs/solana-web3.js/issues/1116) GitHub issue for more information.
|
|
52
|
+
- A transform that applies a default commitment wherever not specified
|
|
53
|
+
|
|
54
|
+
#### Arguments
|
|
55
|
+
|
|
56
|
+
A config object with the following properties:
|
|
57
|
+
|
|
58
|
+
- `defaultCommitment`: An optional default `Commitment` value. Given an RPC method that takes `commitment` as a parameter, this value will be used when the caller does not supply one.
|
|
59
|
+
- `onIntegerOverflow(methodName, keyPath, value): void`: An optional function that will be called whenever a `bigint` input exceeds that which can be expressed using JavaScript numbers. This is used in the default `SolanaRpcApi` to throw an exception rather than to allow truncated values to propagate through a program.
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var rpcSpec = require('@solana/rpc-spec');
|
|
4
|
+
var rpcTransformers = require('@solana/rpc-transformers');
|
|
5
|
+
|
|
6
|
+
// src/index.ts
|
|
7
|
+
function createSolanaRpcApi(config) {
|
|
8
|
+
return rpcSpec.createRpcApi({
|
|
9
|
+
parametersTransformer: rpcTransformers.getDefaultParamsTransformerForSolanaRpc(config),
|
|
10
|
+
responseTransformer: rpcTransformers.getDefaultResponseTransformerForSolanaRpc({
|
|
11
|
+
allowedNumericKeyPaths: getAllowedNumericKeypaths()
|
|
12
|
+
})
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
var memoizedKeypaths;
|
|
16
|
+
function getAllowedNumericKeypaths() {
|
|
17
|
+
if (!memoizedKeypaths) {
|
|
18
|
+
memoizedKeypaths = {
|
|
19
|
+
getAccountInfo: rpcTransformers.jsonParsedAccountsConfigs.map((c) => ["value", ...c]),
|
|
20
|
+
getBlock: [
|
|
21
|
+
["blockTime"],
|
|
22
|
+
["transactions", rpcTransformers.KEYPATH_WILDCARD, "meta", "preTokenBalances", rpcTransformers.KEYPATH_WILDCARD, "accountIndex"],
|
|
23
|
+
[
|
|
24
|
+
"transactions",
|
|
25
|
+
rpcTransformers.KEYPATH_WILDCARD,
|
|
26
|
+
"meta",
|
|
27
|
+
"preTokenBalances",
|
|
28
|
+
rpcTransformers.KEYPATH_WILDCARD,
|
|
29
|
+
"uiTokenAmount",
|
|
30
|
+
"decimals"
|
|
31
|
+
],
|
|
32
|
+
["transactions", rpcTransformers.KEYPATH_WILDCARD, "meta", "postTokenBalances", rpcTransformers.KEYPATH_WILDCARD, "accountIndex"],
|
|
33
|
+
[
|
|
34
|
+
"transactions",
|
|
35
|
+
rpcTransformers.KEYPATH_WILDCARD,
|
|
36
|
+
"meta",
|
|
37
|
+
"postTokenBalances",
|
|
38
|
+
rpcTransformers.KEYPATH_WILDCARD,
|
|
39
|
+
"uiTokenAmount",
|
|
40
|
+
"decimals"
|
|
41
|
+
],
|
|
42
|
+
["transactions", rpcTransformers.KEYPATH_WILDCARD, "meta", "rewards", rpcTransformers.KEYPATH_WILDCARD, "commission"],
|
|
43
|
+
...rpcTransformers.innerInstructionsConfigs.map((c) => [
|
|
44
|
+
"transactions",
|
|
45
|
+
rpcTransformers.KEYPATH_WILDCARD,
|
|
46
|
+
"meta",
|
|
47
|
+
"innerInstructions",
|
|
48
|
+
rpcTransformers.KEYPATH_WILDCARD,
|
|
49
|
+
...c
|
|
50
|
+
]),
|
|
51
|
+
...rpcTransformers.messageConfig.map((c) => ["transactions", rpcTransformers.KEYPATH_WILDCARD, "transaction", "message", ...c]),
|
|
52
|
+
["rewards", rpcTransformers.KEYPATH_WILDCARD, "commission"]
|
|
53
|
+
],
|
|
54
|
+
getBlockTime: [[]],
|
|
55
|
+
getClusterNodes: [
|
|
56
|
+
[rpcTransformers.KEYPATH_WILDCARD, "featureSet"],
|
|
57
|
+
[rpcTransformers.KEYPATH_WILDCARD, "shredVersion"]
|
|
58
|
+
],
|
|
59
|
+
getInflationGovernor: [["initial"], ["foundation"], ["foundationTerm"], ["taper"], ["terminal"]],
|
|
60
|
+
getInflationRate: [["foundation"], ["total"], ["validator"]],
|
|
61
|
+
getInflationReward: [[rpcTransformers.KEYPATH_WILDCARD, "commission"]],
|
|
62
|
+
getMultipleAccounts: rpcTransformers.jsonParsedAccountsConfigs.map((c) => ["value", rpcTransformers.KEYPATH_WILDCARD, ...c]),
|
|
63
|
+
getProgramAccounts: rpcTransformers.jsonParsedAccountsConfigs.flatMap((c) => [
|
|
64
|
+
["value", rpcTransformers.KEYPATH_WILDCARD, "account", ...c],
|
|
65
|
+
[rpcTransformers.KEYPATH_WILDCARD, "account", ...c]
|
|
66
|
+
]),
|
|
67
|
+
getRecentPerformanceSamples: [[rpcTransformers.KEYPATH_WILDCARD, "samplePeriodSecs"]],
|
|
68
|
+
getTokenAccountBalance: [
|
|
69
|
+
["value", "decimals"],
|
|
70
|
+
["value", "uiAmount"]
|
|
71
|
+
],
|
|
72
|
+
getTokenAccountsByDelegate: rpcTransformers.jsonParsedTokenAccountsConfigs.map((c) => [
|
|
73
|
+
"value",
|
|
74
|
+
rpcTransformers.KEYPATH_WILDCARD,
|
|
75
|
+
"account",
|
|
76
|
+
...c
|
|
77
|
+
]),
|
|
78
|
+
getTokenAccountsByOwner: rpcTransformers.jsonParsedTokenAccountsConfigs.map((c) => [
|
|
79
|
+
"value",
|
|
80
|
+
rpcTransformers.KEYPATH_WILDCARD,
|
|
81
|
+
"account",
|
|
82
|
+
...c
|
|
83
|
+
]),
|
|
84
|
+
getTokenLargestAccounts: [
|
|
85
|
+
["value", rpcTransformers.KEYPATH_WILDCARD, "decimals"],
|
|
86
|
+
["value", rpcTransformers.KEYPATH_WILDCARD, "uiAmount"]
|
|
87
|
+
],
|
|
88
|
+
getTokenSupply: [
|
|
89
|
+
["value", "decimals"],
|
|
90
|
+
["value", "uiAmount"]
|
|
91
|
+
],
|
|
92
|
+
getTransaction: [
|
|
93
|
+
["meta", "preTokenBalances", rpcTransformers.KEYPATH_WILDCARD, "accountIndex"],
|
|
94
|
+
["meta", "preTokenBalances", rpcTransformers.KEYPATH_WILDCARD, "uiTokenAmount", "decimals"],
|
|
95
|
+
["meta", "postTokenBalances", rpcTransformers.KEYPATH_WILDCARD, "accountIndex"],
|
|
96
|
+
["meta", "postTokenBalances", rpcTransformers.KEYPATH_WILDCARD, "uiTokenAmount", "decimals"],
|
|
97
|
+
["meta", "rewards", rpcTransformers.KEYPATH_WILDCARD, "commission"],
|
|
98
|
+
...rpcTransformers.innerInstructionsConfigs.map((c) => ["meta", "innerInstructions", rpcTransformers.KEYPATH_WILDCARD, ...c]),
|
|
99
|
+
...rpcTransformers.messageConfig.map((c) => ["transaction", "message", ...c])
|
|
100
|
+
],
|
|
101
|
+
getVersion: [["feature-set"]],
|
|
102
|
+
getVoteAccounts: [
|
|
103
|
+
["current", rpcTransformers.KEYPATH_WILDCARD, "commission"],
|
|
104
|
+
["delinquent", rpcTransformers.KEYPATH_WILDCARD, "commission"]
|
|
105
|
+
],
|
|
106
|
+
simulateTransaction: [
|
|
107
|
+
...rpcTransformers.jsonParsedAccountsConfigs.map((c) => ["value", "accounts", rpcTransformers.KEYPATH_WILDCARD, ...c]),
|
|
108
|
+
...rpcTransformers.innerInstructionsConfigs.map((c) => ["value", "innerInstructions", rpcTransformers.KEYPATH_WILDCARD, ...c])
|
|
109
|
+
]
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
return memoizedKeypaths;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
exports.createSolanaRpcApi = createSolanaRpcApi;
|
|
116
|
+
//# sourceMappingURL=index.browser.cjs.map
|
|
117
|
+
//# sourceMappingURL=index.browser.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":["createRpcApi","getDefaultParamsTransformerForSolanaRpc","getDefaultResponseTransformerForSolanaRpc","jsonParsedAccountsConfigs","KEYPATH_WILDCARD","innerInstructionsConfigs","messageConfig","jsonParsedTokenAccountsConfigs"],"mappings":";;;;;;AAuLO,SAAS,mBAEd,MAAsC,EAAA;AACpC,EAAA,OAAOA,oBAA0B,CAAA;AAAA,IAC7B,qBAAA,EAAuBC,wDAAwC,MAAM,CAAA;AAAA,IACrE,qBAAqBC,yDAA0C,CAAA;AAAA,MAC3D,wBAAwB,yBAA0B,EAAA;AAAA,KACrD,CAAA;AAAA,GACJ,CAAA,CAAA;AACL,CAAA;AAEA,IAAI,gBAAA,CAAA;AAMJ,SAAS,yBAA0E,GAAA;AAC/E,EAAA,IAAI,CAAC,gBAAkB,EAAA;AACnB,IAAmB,gBAAA,GAAA;AAAA,MACf,cAAA,EAAgBC,0CAA0B,GAAI,CAAA,CAAA,CAAA,KAAK,CAAC,OAAS,EAAA,GAAG,CAAC,CAAC,CAAA;AAAA,MAClE,QAAU,EAAA;AAAA,QACN,CAAC,WAAW,CAAA;AAAA,QACZ,CAAC,cAAgB,EAAAC,gCAAA,EAAkB,MAAQ,EAAA,kBAAA,EAAoBA,kCAAkB,cAAc,CAAA;AAAA,QAC/F;AAAA,UACI,cAAA;AAAA,UACAA,gCAAA;AAAA,UACA,MAAA;AAAA,UAC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cApi } from '@solana/rpc-spec';\nimport {\n AllowedNumericKeypaths,\n getDefaultParamsTransformerForSolanaRpc,\n getDefaultResponseTransformerForSolanaRpc,\n innerInstructionsConfigs,\n jsonParsedAccountsConfigs,\n jsonParsedTokenAccountsConfigs,\n KEYPATH_WILDCARD,\n messageConfig,\n ParamsTransformerConfig,\n} from '@solana/rpc-transformers';\n\nimport { GetAccountInfoApi } from './getAccountInfo';\nimport { GetBalanceApi } from './getBalance';\nimport { GetBlockApi } from './getBlock';\nimport { GetBlockCommitmentApi } from './getBlockCommitment';\nimport { GetBlockHeightApi } from './getBlockHeight';\nimport { GetBlockProductionApi } from './getBlockProduction';\nimport { GetBlocksApi } from './getBlocks';\nimport { GetBlocksWithLimitApi } from './getBlocksWithLimit';\nimport { GetBlockTimeApi } from './getBlockTime';\nimport { GetClusterNodesApi } from './getClusterNodes';\nimport { GetEpochInfoApi } from './getEpochInfo';\nimport { GetEpochScheduleApi } from './getEpochSchedule';\nimport { GetFeeForMessageApi } from './getFeeForMessage';\nimport { GetFirstAvailableBlockApi } from './getFirstAvailableBlock';\nimport { GetGenesisHashApi } from './getGenesisHash';\nimport { GetHealthApi } from './getHealth';\nimport { GetHighestSnapshotSlotApi } from './getHighestSnapshotSlot';\nimport { GetIdentityApi } from './getIdentity';\nimport { GetInflationGovernorApi } from './getInflationGovernor';\nimport { GetInflationRateApi } from './getInflationRate';\nimport { GetInflationRewardApi } from './getInflationReward';\nimport { GetLargestAccountsApi } from './getLargestAccounts';\nimport { GetLatestBlockhashApi } from './getLatestBlockhash';\nimport { GetLeaderScheduleApi } from './getLeaderSchedule';\nimport { GetMaxRetransmitSlotApi } from './getMaxRetransmitSlot';\nimport { GetMaxShredInsertSlotApi } from './getMaxShredInsertSlot';\nimport { GetMinimumBalanceForRentExemptionApi } from './getMinimumBalanceForRentExemption';\nimport { GetMultipleAccountsApi } from './getMultipleAccounts';\nimport { GetProgramAccountsApi } from './getProgramAccounts';\nimport { GetRecentPerformanceSamplesApi } from './getRecentPerformanceSamples';\nimport { GetRecentPrioritizationFeesApi } from './getRecentPrioritizationFees';\nimport { GetSignaturesForAddressApi } from './getSignaturesForAddress';\nimport { GetSignatureStatusesApi } from './getSignatureStatuses';\nimport { GetSlotApi } from './getSlot';\nimport { GetSlotLeaderApi } from './getSlotLeader';\nimport { GetSlotLeadersApi } from './getSlotLeaders';\nimport { GetStakeActivationApi } from './getStakeActivation';\nimport { GetStakeMinimumDelegationApi } from './getStakeMinimumDelegation';\nimport { GetSupplyApi } from './getSupply';\nimport { GetTokenAccountBalanceApi } from './getTokenAccountBalance';\nimport { GetTokenAccountsByDelegateApi } from './getTokenAccountsByDelegate';\nimport { GetTokenAccountsByOwnerApi } from './getTokenAccountsByOwner';\nimport { GetTokenLargestAccountsApi } from './getTokenLargestAccounts';\nimport { GetTokenSupplyApi } from './getTokenSupply';\nimport { GetTransactionApi } from './getTransaction';\nimport { GetTransactionCountApi } from './getTransactionCount';\nimport { GetVersionApi } from './getVersion';\nimport { GetVoteAccountsApi } from './getVoteAccounts';\nimport { IsBlockhashValidApi } from './isBlockhashValid';\nimport { MinimumLedgerSlotApi } from './minimumLedgerSlot';\nimport { RequestAirdropApi } from './requestAirdrop';\nimport { SendTransactionApi } from './sendTransaction';\nimport { SimulateTransactionApi } from './simulateTransaction';\n\ntype SolanaRpcApiForAllClusters = GetAccountInfoApi &\n GetBalanceApi &\n GetBlockApi &\n GetBlockCommitmentApi &\n GetBlockHeightApi &\n GetBlockProductionApi &\n GetBlocksApi &\n GetBlocksWithLimitApi &\n GetBlockTimeApi &\n GetClusterNodesApi &\n GetEpochInfoApi &\n GetEpochScheduleApi &\n GetFeeForMessageApi &\n GetFirstAvailableBlockApi &\n GetGenesisHashApi &\n GetHealthApi &\n GetHighestSnapshotSlotApi &\n GetIdentityApi &\n GetInflationGovernorApi &\n GetInflationRateApi &\n GetInflationRewardApi &\n GetLargestAccountsApi &\n GetLatestBlockhashApi &\n GetLeaderScheduleApi &\n GetMaxRetransmitSlotApi &\n GetMaxShredInsertSlotApi &\n GetMinimumBalanceForRentExemptionApi &\n GetMultipleAccountsApi &\n GetProgramAccountsApi &\n GetRecentPerformanceSamplesApi &\n GetRecentPrioritizationFeesApi &\n GetSignaturesForAddressApi &\n GetSignatureStatusesApi &\n GetSlotApi &\n GetSlotLeaderApi &\n GetSlotLeadersApi &\n GetStakeActivationApi &\n GetStakeMinimumDelegationApi &\n GetSupplyApi &\n GetTokenAccountBalanceApi &\n GetTokenAccountsByDelegateApi &\n GetTokenAccountsByOwnerApi &\n GetTokenLargestAccountsApi &\n GetTokenSupplyApi &\n GetTransactionApi &\n GetTransactionCountApi &\n GetVersionApi &\n GetVoteAccountsApi &\n IsBlockhashValidApi &\n MinimumLedgerSlotApi &\n SendTransactionApi &\n SimulateTransactionApi;\ntype SolanaRpcApiForTestClusters = RequestAirdropApi & SolanaRpcApiForAllClusters;\nexport type SolanaRpcApi = SolanaRpcApiForTestClusters;\nexport type SolanaRpcApiDevnet = SolanaRpcApiForTestClusters;\nexport type SolanaRpcApiTestnet = SolanaRpcApiForTestClusters;\nexport type SolanaRpcApiMainnet = SolanaRpcApiForAllClusters;\n\nexport type {\n GetAccountInfoApi,\n GetBalanceApi,\n GetBlockApi,\n GetBlockCommitmentApi,\n GetBlockHeightApi,\n GetBlockProductionApi,\n GetBlocksApi,\n GetBlocksWithLimitApi,\n GetBlockTimeApi,\n GetClusterNodesApi,\n GetEpochInfoApi,\n GetEpochScheduleApi,\n GetFeeForMessageApi,\n GetFirstAvailableBlockApi,\n GetGenesisHashApi,\n GetHealthApi,\n GetHighestSnapshotSlotApi,\n GetIdentityApi,\n GetInflationGovernorApi,\n GetInflationRateApi,\n GetInflationRewardApi,\n GetLargestAccountsApi,\n GetLatestBlockhashApi,\n GetLeaderScheduleApi,\n GetMaxRetransmitSlotApi,\n GetMaxShredInsertSlotApi,\n GetMinimumBalanceForRentExemptionApi,\n GetMultipleAccountsApi,\n GetProgramAccountsApi,\n GetRecentPerformanceSamplesApi,\n GetRecentPrioritizationFeesApi,\n GetSignaturesForAddressApi,\n GetSignatureStatusesApi,\n GetSlotApi,\n GetSlotLeaderApi,\n GetSlotLeadersApi,\n GetStakeActivationApi,\n GetStakeMinimumDelegationApi,\n GetSupplyApi,\n GetTokenAccountBalanceApi,\n GetTokenAccountsByDelegateApi,\n GetTokenAccountsByOwnerApi,\n GetTokenLargestAccountsApi,\n GetTokenSupplyApi,\n GetTransactionApi,\n GetTransactionCountApi,\n GetVersionApi,\n GetVoteAccountsApi,\n IsBlockhashValidApi,\n MinimumLedgerSlotApi,\n RequestAirdropApi,\n SendTransactionApi,\n SimulateTransactionApi,\n};\n\ntype Config = ParamsTransformerConfig;\n\nexport function createSolanaRpcApi<\n TRpcMethods extends SolanaRpcApi | SolanaRpcApiDevnet | SolanaRpcApiMainnet | SolanaRpcApiTestnet = SolanaRpcApi,\n>(config?: Config): RpcApi<TRpcMethods> {\n return createRpcApi<TRpcMethods>({\n parametersTransformer: getDefaultParamsTransformerForSolanaRpc(config) as (params: unknown[]) => unknown[],\n responseTransformer: getDefaultResponseTransformerForSolanaRpc({\n allowedNumericKeyPaths: getAllowedNumericKeypaths(),\n }),\n });\n}\n\nlet memoizedKeypaths: AllowedNumericKeypaths<RpcApi<SolanaRpcApi>>;\n\n/**\n * These are keypaths at the end of which you will find a numeric value that should *not* be upcast\n * to a `bigint`. These are values that are legitimately defined as `u8` or `usize` on the backend.\n */\nfunction getAllowedNumericKeypaths(): AllowedNumericKeypaths<RpcApi<SolanaRpcApi>> {\n if (!memoizedKeypaths) {\n memoizedKeypaths = {\n getAccountInfo: jsonParsedAccountsConfigs.map(c => ['value', ...c]),\n getBlock: [\n ['blockTime'],\n ['transactions', KEYPATH_WILDCARD, 'meta', 'preTokenBalances', KEYPATH_WILDCARD, 'accountIndex'],\n [\n 'transactions',\n KEYPATH_WILDCARD,\n 'meta',\n 'preTokenBalances',\n KEYPATH_WILDCARD,\n 'uiTokenAmount',\n 'decimals',\n ],\n ['transactions', KEYPATH_WILDCARD, 'meta', 'postTokenBalances', KEYPATH_WILDCARD, 'accountIndex'],\n [\n 'transactions',\n KEYPATH_WILDCARD,\n 'meta',\n 'postTokenBalances',\n KEYPATH_WILDCARD,\n 'uiTokenAmount',\n 'decimals',\n ],\n ['transactions', KEYPATH_WILDCARD, 'meta', 'rewards', KEYPATH_WILDCARD, 'commission'],\n ...innerInstructionsConfigs.map(c => [\n 'transactions',\n KEYPATH_WILDCARD,\n 'meta',\n 'innerInstructions',\n KEYPATH_WILDCARD,\n ...c,\n ]),\n ...messageConfig.map(c => ['transactions', KEYPATH_WILDCARD, 'transaction', 'message', ...c] as const),\n ['rewards', KEYPATH_WILDCARD, 'commission'],\n ],\n getBlockTime: [[]],\n getClusterNodes: [\n [KEYPATH_WILDCARD, 'featureSet'],\n [KEYPATH_WILDCARD, 'shredVersion'],\n ],\n getInflationGovernor: [['initial'], ['foundation'], ['foundationTerm'], ['taper'], ['terminal']],\n getInflationRate: [['foundation'], ['total'], ['validator']],\n getInflationReward: [[KEYPATH_WILDCARD, 'commission']],\n getMultipleAccounts: jsonParsedAccountsConfigs.map(c => ['value', KEYPATH_WILDCARD, ...c]),\n getProgramAccounts: jsonParsedAccountsConfigs.flatMap(c => [\n ['value', KEYPATH_WILDCARD, 'account', ...c],\n [KEYPATH_WILDCARD, 'account', ...c],\n ]),\n getRecentPerformanceSamples: [[KEYPATH_WILDCARD, 'samplePeriodSecs']],\n getTokenAccountBalance: [\n ['value', 'decimals'],\n ['value', 'uiAmount'],\n ],\n getTokenAccountsByDelegate: jsonParsedTokenAccountsConfigs.map(c => [\n 'value',\n KEYPATH_WILDCARD,\n 'account',\n ...c,\n ]),\n getTokenAccountsByOwner: jsonParsedTokenAccountsConfigs.map(c => [\n 'value',\n KEYPATH_WILDCARD,\n 'account',\n ...c,\n ]),\n getTokenLargestAccounts: [\n ['value', KEYPATH_WILDCARD, 'decimals'],\n ['value', KEYPATH_WILDCARD, 'uiAmount'],\n ],\n getTokenSupply: [\n ['value', 'decimals'],\n ['value', 'uiAmount'],\n ],\n getTransaction: [\n ['meta', 'preTokenBalances', KEYPATH_WILDCARD, 'accountIndex'],\n ['meta', 'preTokenBalances', KEYPATH_WILDCARD, 'uiTokenAmount', 'decimals'],\n ['meta', 'postTokenBalances', KEYPATH_WILDCARD, 'accountIndex'],\n ['meta', 'postTokenBalances', KEYPATH_WILDCARD, 'uiTokenAmount', 'decimals'],\n ['meta', 'rewards', KEYPATH_WILDCARD, 'commission'],\n ...innerInstructionsConfigs.map(c => ['meta', 'innerInstructions', KEYPATH_WILDCARD, ...c]),\n ...messageConfig.map(c => ['transaction', 'message', ...c] as const),\n ],\n getVersion: [['feature-set']],\n getVoteAccounts: [\n ['current', KEYPATH_WILDCARD, 'commission'],\n ['delinquent', KEYPATH_WILDCARD, 'commission'],\n ],\n simulateTransaction: [\n ...jsonParsedAccountsConfigs.map(c => ['value', 'accounts', KEYPATH_WILDCARD, ...c]),\n ...innerInstructionsConfigs.map(c => ['value', 'innerInstructions', KEYPATH_WILDCARD, ...c]),\n ],\n };\n }\n return memoizedKeypaths;\n}\n"]}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { createRpcApi } from '@solana/rpc-spec';
|
|
2
|
+
import { getDefaultParamsTransformerForSolanaRpc, getDefaultResponseTransformerForSolanaRpc, jsonParsedAccountsConfigs, KEYPATH_WILDCARD, innerInstructionsConfigs, messageConfig, jsonParsedTokenAccountsConfigs } from '@solana/rpc-transformers';
|
|
3
|
+
|
|
4
|
+
// src/index.ts
|
|
5
|
+
function createSolanaRpcApi(config) {
|
|
6
|
+
return createRpcApi({
|
|
7
|
+
parametersTransformer: getDefaultParamsTransformerForSolanaRpc(config),
|
|
8
|
+
responseTransformer: getDefaultResponseTransformerForSolanaRpc({
|
|
9
|
+
allowedNumericKeyPaths: getAllowedNumericKeypaths()
|
|
10
|
+
})
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
var memoizedKeypaths;
|
|
14
|
+
function getAllowedNumericKeypaths() {
|
|
15
|
+
if (!memoizedKeypaths) {
|
|
16
|
+
memoizedKeypaths = {
|
|
17
|
+
getAccountInfo: jsonParsedAccountsConfigs.map((c) => ["value", ...c]),
|
|
18
|
+
getBlock: [
|
|
19
|
+
["blockTime"],
|
|
20
|
+
["transactions", KEYPATH_WILDCARD, "meta", "preTokenBalances", KEYPATH_WILDCARD, "accountIndex"],
|
|
21
|
+
[
|
|
22
|
+
"transactions",
|
|
23
|
+
KEYPATH_WILDCARD,
|
|
24
|
+
"meta",
|
|
25
|
+
"preTokenBalances",
|
|
26
|
+
KEYPATH_WILDCARD,
|
|
27
|
+
"uiTokenAmount",
|
|
28
|
+
"decimals"
|
|
29
|
+
],
|
|
30
|
+
["transactions", KEYPATH_WILDCARD, "meta", "postTokenBalances", KEYPATH_WILDCARD, "accountIndex"],
|
|
31
|
+
[
|
|
32
|
+
"transactions",
|
|
33
|
+
KEYPATH_WILDCARD,
|
|
34
|
+
"meta",
|
|
35
|
+
"postTokenBalances",
|
|
36
|
+
KEYPATH_WILDCARD,
|
|
37
|
+
"uiTokenAmount",
|
|
38
|
+
"decimals"
|
|
39
|
+
],
|
|
40
|
+
["transactions", KEYPATH_WILDCARD, "meta", "rewards", KEYPATH_WILDCARD, "commission"],
|
|
41
|
+
...innerInstructionsConfigs.map((c) => [
|
|
42
|
+
"transactions",
|
|
43
|
+
KEYPATH_WILDCARD,
|
|
44
|
+
"meta",
|
|
45
|
+
"innerInstructions",
|
|
46
|
+
KEYPATH_WILDCARD,
|
|
47
|
+
...c
|
|
48
|
+
]),
|
|
49
|
+
...messageConfig.map((c) => ["transactions", KEYPATH_WILDCARD, "transaction", "message", ...c]),
|
|
50
|
+
["rewards", KEYPATH_WILDCARD, "commission"]
|
|
51
|
+
],
|
|
52
|
+
getBlockTime: [[]],
|
|
53
|
+
getClusterNodes: [
|
|
54
|
+
[KEYPATH_WILDCARD, "featureSet"],
|
|
55
|
+
[KEYPATH_WILDCARD, "shredVersion"]
|
|
56
|
+
],
|
|
57
|
+
getInflationGovernor: [["initial"], ["foundation"], ["foundationTerm"], ["taper"], ["terminal"]],
|
|
58
|
+
getInflationRate: [["foundation"], ["total"], ["validator"]],
|
|
59
|
+
getInflationReward: [[KEYPATH_WILDCARD, "commission"]],
|
|
60
|
+
getMultipleAccounts: jsonParsedAccountsConfigs.map((c) => ["value", KEYPATH_WILDCARD, ...c]),
|
|
61
|
+
getProgramAccounts: jsonParsedAccountsConfigs.flatMap((c) => [
|
|
62
|
+
["value", KEYPATH_WILDCARD, "account", ...c],
|
|
63
|
+
[KEYPATH_WILDCARD, "account", ...c]
|
|
64
|
+
]),
|
|
65
|
+
getRecentPerformanceSamples: [[KEYPATH_WILDCARD, "samplePeriodSecs"]],
|
|
66
|
+
getTokenAccountBalance: [
|
|
67
|
+
["value", "decimals"],
|
|
68
|
+
["value", "uiAmount"]
|
|
69
|
+
],
|
|
70
|
+
getTokenAccountsByDelegate: jsonParsedTokenAccountsConfigs.map((c) => [
|
|
71
|
+
"value",
|
|
72
|
+
KEYPATH_WILDCARD,
|
|
73
|
+
"account",
|
|
74
|
+
...c
|
|
75
|
+
]),
|
|
76
|
+
getTokenAccountsByOwner: jsonParsedTokenAccountsConfigs.map((c) => [
|
|
77
|
+
"value",
|
|
78
|
+
KEYPATH_WILDCARD,
|
|
79
|
+
"account",
|
|
80
|
+
...c
|
|
81
|
+
]),
|
|
82
|
+
getTokenLargestAccounts: [
|
|
83
|
+
["value", KEYPATH_WILDCARD, "decimals"],
|
|
84
|
+
["value", KEYPATH_WILDCARD, "uiAmount"]
|
|
85
|
+
],
|
|
86
|
+
getTokenSupply: [
|
|
87
|
+
["value", "decimals"],
|
|
88
|
+
["value", "uiAmount"]
|
|
89
|
+
],
|
|
90
|
+
getTransaction: [
|
|
91
|
+
["meta", "preTokenBalances", KEYPATH_WILDCARD, "accountIndex"],
|
|
92
|
+
["meta", "preTokenBalances", KEYPATH_WILDCARD, "uiTokenAmount", "decimals"],
|
|
93
|
+
["meta", "postTokenBalances", KEYPATH_WILDCARD, "accountIndex"],
|
|
94
|
+
["meta", "postTokenBalances", KEYPATH_WILDCARD, "uiTokenAmount", "decimals"],
|
|
95
|
+
["meta", "rewards", KEYPATH_WILDCARD, "commission"],
|
|
96
|
+
...innerInstructionsConfigs.map((c) => ["meta", "innerInstructions", KEYPATH_WILDCARD, ...c]),
|
|
97
|
+
...messageConfig.map((c) => ["transaction", "message", ...c])
|
|
98
|
+
],
|
|
99
|
+
getVersion: [["feature-set"]],
|
|
100
|
+
getVoteAccounts: [
|
|
101
|
+
["current", KEYPATH_WILDCARD, "commission"],
|
|
102
|
+
["delinquent", KEYPATH_WILDCARD, "commission"]
|
|
103
|
+
],
|
|
104
|
+
simulateTransaction: [
|
|
105
|
+
...jsonParsedAccountsConfigs.map((c) => ["value", "accounts", KEYPATH_WILDCARD, ...c]),
|
|
106
|
+
...innerInstructionsConfigs.map((c) => ["value", "innerInstructions", KEYPATH_WILDCARD, ...c])
|
|
107
|
+
]
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
return memoizedKeypaths;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export { createSolanaRpcApi };
|
|
114
|
+
//# sourceMappingURL=index.browser.mjs.map
|
|
115
|
+
//# sourceMappingURL=index.browser.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;AAuLO,SAAS,mBAEd,MAAsC,EAAA;AACpC,EAAA,OAAO,YAA0B,CAAA;AAAA,IAC7B,qBAAA,EAAuB,wCAAwC,MAAM,CAAA;AAAA,IACrE,qBAAqB,yCAA0C,CAAA;AAAA,MAC3D,wBAAwB,yBAA0B,EAAA;AAAA,KACrD,CAAA;AAAA,GACJ,CAAA,CAAA;AACL,CAAA;AAEA,IAAI,gBAAA,CAAA;AAMJ,SAAS,yBAA0E,GAAA;AAC/E,EAAA,IAAI,CAAC,gBAAkB,EAAA;AACn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C,SAAS,UAAY,EAAA,gBAAA,EAAkB,GAAG,CAAC,CAAC,CAAA;AAAA,QACnF,GAAG,wBAAyB,CAAA,GAAA,CAAI,CAAK,CAAA,KAAA,CAAC,SAAS,mBAAqB,EAAA,gBAAA,EAAkB,GAAG,CAAC,CAAC,CAAA;AAAA,OAC/F;AAAA,KACJ,CAAA;AAAA,GACJ;AACA,EAAO,OAAA,gBAAA,CAAA;AACX","file":"index.browser.mjs","sourcesContent":["import { createRpcApi, RpcApi } from '@solana/rpc-spec';\nimport {\n AllowedNumericKeypaths,\n getDefaultParamsTransformerForSolanaRpc,\n getDefaultResponseTransformerForSolanaRpc,\n innerInstructionsConfigs,\n jsonParsedAccountsConfigs,\n jsonParsedTokenAccountsConfigs,\n KEYPATH_WILDCARD,\n messageConfig,\n ParamsTransformerConfig,\n} from '@solana/rpc-transformers';\n\nimport { GetAccountInfoApi } from './getAccountInfo';\nimport { GetBalanceApi } from './getBalance';\nimport { GetBlockApi } from './getBlock';\nimport { GetBlockCommitmentApi } from './getBlockCommitment';\nimport { GetBlockHeightApi } from './getBlockHeight';\nimport { GetBlockProductionApi } from './getBlockProduction';\nimport { GetBlocksApi } from './getBlocks';\nimport { GetBlocksWithLimitApi } from './getBlocksWithLimit';\nimport { GetBlockTimeApi } from './getBlockTime';\nimport { GetClusterNodesApi } from './getClusterNodes';\nimport { GetEpochInfoApi } from './getEpochInfo';\nimport { GetEpochScheduleApi } from './getEpochSchedule';\nimport { GetFeeForMessageApi } from './getFeeForMessage';\nimport { GetFirstAvailableBlockApi } from './getFirstAvailableBlock';\nimport { GetGenesisHashApi } from './getGenesisHash';\nimport { GetHealthApi } from './getHealth';\nimport { GetHighestSnapshotSlotApi } from './getHighestSnapshotSlot';\nimport { GetIdentityApi } from './getIdentity';\nimport { GetInflationGovernorApi } from './getInflationGovernor';\nimport { GetInflationRateApi } from './getInflationRate';\nimport { GetInflationRewardApi } from './getInflationReward';\nimport { GetLargestAccountsApi } from './getLargestAccounts';\nimport { GetLatestBlockhashApi } from './getLatestBlockhash';\nimport { GetLeaderScheduleApi } from './getLeaderSchedule';\nimport { GetMaxRetransmitSlotApi } from './getMaxRetransmitSlot';\nimport { GetMaxShredInsertSlotApi } from './getMaxShredInsertSlot';\nimport { GetMinimumBalanceForRentExemptionApi } from './getMinimumBalanceForRentExemption';\nimport { GetMultipleAccountsApi } from './getMultipleAccounts';\nimport { GetProgramAccountsApi } from './getProgramAccounts';\nimport { GetRecentPerformanceSamplesApi } from './getRecentPerformanceSamples';\nimport { GetRecentPrioritizationFeesApi } from './getRecentPrioritizationFees';\nimport { GetSignaturesForAddressApi } from './getSignaturesForAddress';\nimport { GetSignatureStatusesApi } from './getSignatureStatuses';\nimport { GetSlotApi } from './getSlot';\nimport { GetSlotLeaderApi } from './getSlotLeader';\nimport { GetSlotLeadersApi } from './getSlotLeaders';\nimport { GetStakeActivationApi } from './getStakeActivation';\nimport { GetStakeMinimumDelegationApi } from './getStakeMinimumDelegation';\nimport { GetSupplyApi } from './getSupply';\nimport { GetTokenAccountBalanceApi } from './getTokenAccountBalance';\nimport { GetTokenAccountsByDelegateApi } from './getTokenAccountsByDelegate';\nimport { GetTokenAccountsByOwnerApi } from './getTokenAccountsByOwner';\nimport { GetTokenLargestAccountsApi } from './getTokenLargestAccounts';\nimport { GetTokenSupplyApi } from './getTokenSupply';\nimport { GetTransactionApi } from './getTransaction';\nimport { GetTransactionCountApi } from './getTransactionCount';\nimport { GetVersionApi } from './getVersion';\nimport { GetVoteAccountsApi } from './getVoteAccounts';\nimport { IsBlockhashValidApi } from './isBlockhashValid';\nimport { MinimumLedgerSlotApi } from './minimumLedgerSlot';\nimport { RequestAirdropApi } from './requestAirdrop';\nimport { SendTransactionApi } from './sendTransaction';\nimport { SimulateTransactionApi } from './simulateTransaction';\n\ntype SolanaRpcApiForAllClusters = GetAccountInfoApi &\n GetBalanceApi &\n GetBlockApi &\n GetBlockCommitmentApi &\n GetBlockHeightApi &\n GetBlockProductionApi &\n GetBlocksApi &\n GetBlocksWithLimitApi &\n GetBlockTimeApi &\n GetClusterNodesApi &\n GetEpochInfoApi &\n GetEpochScheduleApi &\n GetFeeForMessageApi &\n GetFirstAvailableBlockApi &\n GetGenesisHashApi &\n GetHealthApi &\n GetHighestSnapshotSlotApi &\n GetIdentityApi &\n GetInflationGovernorApi &\n GetInflationRateApi &\n GetInflationRewardApi &\n GetLargestAccountsApi &\n GetLatestBlockhashApi &\n GetLeaderScheduleApi &\n GetMaxRetransmitSlotApi &\n GetMaxShredInsertSlotApi &\n GetMinimumBalanceForRentExemptionApi &\n GetMultipleAccountsApi &\n GetProgramAccountsApi &\n GetRecentPerformanceSamplesApi &\n GetRecentPrioritizationFeesApi &\n GetSignaturesForAddressApi &\n GetSignatureStatusesApi &\n GetSlotApi &\n GetSlotLeaderApi &\n GetSlotLeadersApi &\n GetStakeActivationApi &\n GetStakeMinimumDelegationApi &\n GetSupplyApi &\n GetTokenAccountBalanceApi &\n GetTokenAccountsByDelegateApi &\n GetTokenAccountsByOwnerApi &\n GetTokenLargestAccountsApi &\n GetTokenSupplyApi &\n GetTransactionApi &\n GetTransactionCountApi &\n GetVersionApi &\n GetVoteAccountsApi &\n IsBlockhashValidApi &\n MinimumLedgerSlotApi &\n SendTransactionApi &\n SimulateTransactionApi;\ntype SolanaRpcApiForTestClusters = RequestAirdropApi & SolanaRpcApiForAllClusters;\nexport type SolanaRpcApi = SolanaRpcApiForTestClusters;\nexport type SolanaRpcApiDevnet = SolanaRpcApiForTestClusters;\nexport type SolanaRpcApiTestnet = SolanaRpcApiForTestClusters;\nexport type SolanaRpcApiMainnet = SolanaRpcApiForAllClusters;\n\nexport type {\n GetAccountInfoApi,\n GetBalanceApi,\n GetBlockApi,\n GetBlockCommitmentApi,\n GetBlockHeightApi,\n GetBlockProductionApi,\n GetBlocksApi,\n GetBlocksWithLimitApi,\n GetBlockTimeApi,\n GetClusterNodesApi,\n GetEpochInfoApi,\n GetEpochScheduleApi,\n GetFeeForMessageApi,\n GetFirstAvailableBlockApi,\n GetGenesisHashApi,\n GetHealthApi,\n GetHighestSnapshotSlotApi,\n GetIdentityApi,\n GetInflationGovernorApi,\n GetInflationRateApi,\n GetInflationRewardApi,\n GetLargestAccountsApi,\n GetLatestBlockhashApi,\n GetLeaderScheduleApi,\n GetMaxRetransmitSlotApi,\n GetMaxShredInsertSlotApi,\n GetMinimumBalanceForRentExemptionApi,\n GetMultipleAccountsApi,\n GetProgramAccountsApi,\n GetRecentPerformanceSamplesApi,\n GetRecentPrioritizationFeesApi,\n GetSignaturesForAddressApi,\n GetSignatureStatusesApi,\n GetSlotApi,\n GetSlotLeaderApi,\n GetSlotLeadersApi,\n GetStakeActivationApi,\n GetStakeMinimumDelegationApi,\n GetSupplyApi,\n GetTokenAccountBalanceApi,\n GetTokenAccountsByDelegateApi,\n GetTokenAccountsByOwnerApi,\n GetTokenLargestAccountsApi,\n GetTokenSupplyApi,\n GetTransactionApi,\n GetTransactionCountApi,\n GetVersionApi,\n GetVoteAccountsApi,\n IsBlockhashValidApi,\n MinimumLedgerSlotApi,\n RequestAirdropApi,\n SendTransactionApi,\n SimulateTransactionApi,\n};\n\ntype Config = ParamsTransformerConfig;\n\nexport function createSolanaRpcApi<\n TRpcMethods extends SolanaRpcApi | SolanaRpcApiDevnet | SolanaRpcApiMainnet | SolanaRpcApiTestnet = SolanaRpcApi,\n>(config?: Config): RpcApi<TRpcMethods> {\n return createRpcApi<TRpcMethods>({\n parametersTransformer: getDefaultParamsTransformerForSolanaRpc(config) as (params: unknown[]) => unknown[],\n responseTransformer: getDefaultResponseTransformerForSolanaRpc({\n allowedNumericKeyPaths: getAllowedNumericKeypaths(),\n }),\n });\n}\n\nlet memoizedKeypaths: AllowedNumericKeypaths<RpcApi<SolanaRpcApi>>;\n\n/**\n * These are keypaths at the end of which you will find a numeric value that should *not* be upcast\n * to a `bigint`. These are values that are legitimately defined as `u8` or `usize` on the backend.\n */\nfunction getAllowedNumericKeypaths(): AllowedNumericKeypaths<RpcApi<SolanaRpcApi>> {\n if (!memoizedKeypaths) {\n memoizedKeypaths = {\n getAccountInfo: jsonParsedAccountsConfigs.map(c => ['value', ...c]),\n getBlock: [\n ['blockTime'],\n ['transactions', KEYPATH_WILDCARD, 'meta', 'preTokenBalances', KEYPATH_WILDCARD, 'accountIndex'],\n [\n 'transactions',\n KEYPATH_WILDCARD,\n 'meta',\n 'preTokenBalances',\n KEYPATH_WILDCARD,\n 'uiTokenAmount',\n 'decimals',\n ],\n ['transactions', KEYPATH_WILDCARD, 'meta', 'postTokenBalances', KEYPATH_WILDCARD, 'accountIndex'],\n [\n 'transactions',\n KEYPATH_WILDCARD,\n 'meta',\n 'postTokenBalances',\n KEYPATH_WILDCARD,\n 'uiTokenAmount',\n 'decimals',\n ],\n ['transactions', KEYPATH_WILDCARD, 'meta', 'rewards', KEYPATH_WILDCARD, 'commission'],\n ...innerInstructionsConfigs.map(c => [\n 'transactions',\n KEYPATH_WILDCARD,\n 'meta',\n 'innerInstructions',\n KEYPATH_WILDCARD,\n ...c,\n ]),\n ...messageConfig.map(c => ['transactions', KEYPATH_WILDCARD, 'transaction', 'message', ...c] as const),\n ['rewards', KEYPATH_WILDCARD, 'commission'],\n ],\n getBlockTime: [[]],\n getClusterNodes: [\n [KEYPATH_WILDCARD, 'featureSet'],\n [KEYPATH_WILDCARD, 'shredVersion'],\n ],\n getInflationGovernor: [['initial'], ['foundation'], ['foundationTerm'], ['taper'], ['terminal']],\n getInflationRate: [['foundation'], ['total'], ['validator']],\n getInflationReward: [[KEYPATH_WILDCARD, 'commission']],\n getMultipleAccounts: jsonParsedAccountsConfigs.map(c => ['value', KEYPATH_WILDCARD, ...c]),\n getProgramAccounts: jsonParsedAccountsConfigs.flatMap(c => [\n ['value', KEYPATH_WILDCARD, 'account', ...c],\n [KEYPATH_WILDCARD, 'account', ...c],\n ]),\n getRecentPerformanceSamples: [[KEYPATH_WILDCARD, 'samplePeriodSecs']],\n getTokenAccountBalance: [\n ['value', 'decimals'],\n ['value', 'uiAmount'],\n ],\n getTokenAccountsByDelegate: jsonParsedTokenAccountsConfigs.map(c => [\n 'value',\n KEYPATH_WILDCARD,\n 'account',\n ...c,\n ]),\n getTokenAccountsByOwner: jsonParsedTokenAccountsConfigs.map(c => [\n 'value',\n KEYPATH_WILDCARD,\n 'account',\n ...c,\n ]),\n getTokenLargestAccounts: [\n ['value', KEYPATH_WILDCARD, 'decimals'],\n ['value', KEYPATH_WILDCARD, 'uiAmount'],\n ],\n getTokenSupply: [\n ['value', 'decimals'],\n ['value', 'uiAmount'],\n ],\n getTransaction: [\n ['meta', 'preTokenBalances', KEYPATH_WILDCARD, 'accountIndex'],\n ['meta', 'preTokenBalances', KEYPATH_WILDCARD, 'uiTokenAmount', 'decimals'],\n ['meta', 'postTokenBalances', KEYPATH_WILDCARD, 'accountIndex'],\n ['meta', 'postTokenBalances', KEYPATH_WILDCARD, 'uiTokenAmount', 'decimals'],\n ['meta', 'rewards', KEYPATH_WILDCARD, 'commission'],\n ...innerInstructionsConfigs.map(c => ['meta', 'innerInstructions', KEYPATH_WILDCARD, ...c]),\n ...messageConfig.map(c => ['transaction', 'message', ...c] as const),\n ],\n getVersion: [['feature-set']],\n getVoteAccounts: [\n ['current', KEYPATH_WILDCARD, 'commission'],\n ['delinquent', KEYPATH_WILDCARD, 'commission'],\n ],\n simulateTransaction: [\n ...jsonParsedAccountsConfigs.map(c => ['value', 'accounts', KEYPATH_WILDCARD, ...c]),\n ...innerInstructionsConfigs.map(c => ['value', 'innerInstructions', KEYPATH_WILDCARD, ...c]),\n ],\n };\n }\n return memoizedKeypaths;\n}\n"]}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { createRpcApi } from '@solana/rpc-spec';
|
|
2
|
+
import { getDefaultParamsTransformerForSolanaRpc, getDefaultResponseTransformerForSolanaRpc, jsonParsedAccountsConfigs, KEYPATH_WILDCARD, innerInstructionsConfigs, messageConfig, jsonParsedTokenAccountsConfigs } from '@solana/rpc-transformers';
|
|
3
|
+
|
|
4
|
+
// src/index.ts
|
|
5
|
+
function createSolanaRpcApi(config) {
|
|
6
|
+
return createRpcApi({
|
|
7
|
+
parametersTransformer: getDefaultParamsTransformerForSolanaRpc(config),
|
|
8
|
+
responseTransformer: getDefaultResponseTransformerForSolanaRpc({
|
|
9
|
+
allowedNumericKeyPaths: getAllowedNumericKeypaths()
|
|
10
|
+
})
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
var memoizedKeypaths;
|
|
14
|
+
function getAllowedNumericKeypaths() {
|
|
15
|
+
if (!memoizedKeypaths) {
|
|
16
|
+
memoizedKeypaths = {
|
|
17
|
+
getAccountInfo: jsonParsedAccountsConfigs.map((c) => ["value", ...c]),
|
|
18
|
+
getBlock: [
|
|
19
|
+
["blockTime"],
|
|
20
|
+
["transactions", KEYPATH_WILDCARD, "meta", "preTokenBalances", KEYPATH_WILDCARD, "accountIndex"],
|
|
21
|
+
[
|
|
22
|
+
"transactions",
|
|
23
|
+
KEYPATH_WILDCARD,
|
|
24
|
+
"meta",
|
|
25
|
+
"preTokenBalances",
|
|
26
|
+
KEYPATH_WILDCARD,
|
|
27
|
+
"uiTokenAmount",
|
|
28
|
+
"decimals"
|
|
29
|
+
],
|
|
30
|
+
["transactions", KEYPATH_WILDCARD, "meta", "postTokenBalances", KEYPATH_WILDCARD, "accountIndex"],
|
|
31
|
+
[
|
|
32
|
+
"transactions",
|
|
33
|
+
KEYPATH_WILDCARD,
|
|
34
|
+
"meta",
|
|
35
|
+
"postTokenBalances",
|
|
36
|
+
KEYPATH_WILDCARD,
|
|
37
|
+
"uiTokenAmount",
|
|
38
|
+
"decimals"
|
|
39
|
+
],
|
|
40
|
+
["transactions", KEYPATH_WILDCARD, "meta", "rewards", KEYPATH_WILDCARD, "commission"],
|
|
41
|
+
...innerInstructionsConfigs.map((c) => [
|
|
42
|
+
"transactions",
|
|
43
|
+
KEYPATH_WILDCARD,
|
|
44
|
+
"meta",
|
|
45
|
+
"innerInstructions",
|
|
46
|
+
KEYPATH_WILDCARD,
|
|
47
|
+
...c
|
|
48
|
+
]),
|
|
49
|
+
...messageConfig.map((c) => ["transactions", KEYPATH_WILDCARD, "transaction", "message", ...c]),
|
|
50
|
+
["rewards", KEYPATH_WILDCARD, "commission"]
|
|
51
|
+
],
|
|
52
|
+
getBlockTime: [[]],
|
|
53
|
+
getClusterNodes: [
|
|
54
|
+
[KEYPATH_WILDCARD, "featureSet"],
|
|
55
|
+
[KEYPATH_WILDCARD, "shredVersion"]
|
|
56
|
+
],
|
|
57
|
+
getInflationGovernor: [["initial"], ["foundation"], ["foundationTerm"], ["taper"], ["terminal"]],
|
|
58
|
+
getInflationRate: [["foundation"], ["total"], ["validator"]],
|
|
59
|
+
getInflationReward: [[KEYPATH_WILDCARD, "commission"]],
|
|
60
|
+
getMultipleAccounts: jsonParsedAccountsConfigs.map((c) => ["value", KEYPATH_WILDCARD, ...c]),
|
|
61
|
+
getProgramAccounts: jsonParsedAccountsConfigs.flatMap((c) => [
|
|
62
|
+
["value", KEYPATH_WILDCARD, "account", ...c],
|
|
63
|
+
[KEYPATH_WILDCARD, "account", ...c]
|
|
64
|
+
]),
|
|
65
|
+
getRecentPerformanceSamples: [[KEYPATH_WILDCARD, "samplePeriodSecs"]],
|
|
66
|
+
getTokenAccountBalance: [
|
|
67
|
+
["value", "decimals"],
|
|
68
|
+
["value", "uiAmount"]
|
|
69
|
+
],
|
|
70
|
+
getTokenAccountsByDelegate: jsonParsedTokenAccountsConfigs.map((c) => [
|
|
71
|
+
"value",
|
|
72
|
+
KEYPATH_WILDCARD,
|
|
73
|
+
"account",
|
|
74
|
+
...c
|
|
75
|
+
]),
|
|
76
|
+
getTokenAccountsByOwner: jsonParsedTokenAccountsConfigs.map((c) => [
|
|
77
|
+
"value",
|
|
78
|
+
KEYPATH_WILDCARD,
|
|
79
|
+
"account",
|
|
80
|
+
...c
|
|
81
|
+
]),
|
|
82
|
+
getTokenLargestAccounts: [
|
|
83
|
+
["value", KEYPATH_WILDCARD, "decimals"],
|
|
84
|
+
["value", KEYPATH_WILDCARD, "uiAmount"]
|
|
85
|
+
],
|
|
86
|
+
getTokenSupply: [
|
|
87
|
+
["value", "decimals"],
|
|
88
|
+
["value", "uiAmount"]
|
|
89
|
+
],
|
|
90
|
+
getTransaction: [
|
|
91
|
+
["meta", "preTokenBalances", KEYPATH_WILDCARD, "accountIndex"],
|
|
92
|
+
["meta", "preTokenBalances", KEYPATH_WILDCARD, "uiTokenAmount", "decimals"],
|
|
93
|
+
["meta", "postTokenBalances", KEYPATH_WILDCARD, "accountIndex"],
|
|
94
|
+
["meta", "postTokenBalances", KEYPATH_WILDCARD, "uiTokenAmount", "decimals"],
|
|
95
|
+
["meta", "rewards", KEYPATH_WILDCARD, "commission"],
|
|
96
|
+
...innerInstructionsConfigs.map((c) => ["meta", "innerInstructions", KEYPATH_WILDCARD, ...c]),
|
|
97
|
+
...messageConfig.map((c) => ["transaction", "message", ...c])
|
|
98
|
+
],
|
|
99
|
+
getVersion: [["feature-set"]],
|
|
100
|
+
getVoteAccounts: [
|
|
101
|
+
["current", KEYPATH_WILDCARD, "commission"],
|
|
102
|
+
["delinquent", KEYPATH_WILDCARD, "commission"]
|
|
103
|
+
],
|
|
104
|
+
simulateTransaction: [
|
|
105
|
+
...jsonParsedAccountsConfigs.map((c) => ["value", "accounts", KEYPATH_WILDCARD, ...c]),
|
|
106
|
+
...innerInstructionsConfigs.map((c) => ["value", "innerInstructions", KEYPATH_WILDCARD, ...c])
|
|
107
|
+
]
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
return memoizedKeypaths;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export { createSolanaRpcApi };
|
|
114
|
+
//# sourceMappingURL=index.native.mjs.map
|
|
115
|
+
//# sourceMappingURL=index.native.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;AAuLO,SAAS,mBAEd,MAAsC,EAAA;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vE;AAAA,MACA,UAAY,EAAA,CAAC,CAAC,aAAa,CAAC,CAAA;AAAA,MAC5B,eAAiB,EAAA;AAAA,QACb,CAAC,SAAW,EAAA,gBAAA,EAAkB,YAAY,CAAA;AAAA,QAC1C,CAAC,YAAc,EAAA,gBAAA,EAAkB,YAAY,CAAA;AAAA,OACjD;AAAA,MACA,mBAAqB,EAAA;AAAA,QACjB,GAAG,yBAA0B,CAAA,GAAA,CAAI,CAAK,CAAA,KAAA,CAAC,SAAS,UAAY,EAAA,gBAAA,EAAkB,GAAG,CAAC,CAAC,CAAA;AAAA,QACnF,GAAG,wBAAyB,CAAA,GAAA,CAAI,CAAK,CAAA,KAAA,CAAC,SAAS,mBAAqB,EAAA,gBAAA,EAAkB,GAAG,CAAC,CAAC,CAAA;AAAA,OAC/F;AAAA,KACJ,CAAA;AAAA,GACJ;AACA,EAAO,OAAA,gBAAA,CAAA;AACX","file":"index.native.mjs","sourcesContent":["import { createRpcApi, RpcApi } from '@solana/rpc-spec';\nimport {\n AllowedNumericKeypaths,\n getDefaultParamsTransformerForSolanaRpc,\n getDefaultResponseTransformerForSolanaRpc,\n innerInstructionsConfigs,\n jsonParsedAccountsConfigs,\n jsonParsedTokenAccountsConfigs,\n KEYPATH_WILDCARD,\n messageConfig,\n ParamsTransformerConfig,\n} from '@solana/rpc-transformers';\n\nimport { GetAccountInfoApi } from './getAccountInfo';\nimport { GetBalanceApi } from './getBalance';\nimport { GetBlockApi } from './getBlock';\nimport { GetBlockCommitmentApi } from './getBlockCommitment';\nimport { GetBlockHeightApi } from './getBlockHeight';\nimport { GetBlockProductionApi } from './getBlockProduction';\nimport { GetBlocksApi } from './getBlocks';\nimport { GetBlocksWithLimitApi } from './getBlocksWithLimit';\nimport { GetBlockTimeApi } from './getBlockTime';\nimport { GetClusterNodesApi } from './getClusterNodes';\nimport { GetEpochInfoApi } from './getEpochInfo';\nimport { GetEpochScheduleApi } from './getEpochSchedule';\nimport { GetFeeForMessageApi } from './getFeeForMessage';\nimport { GetFirstAvailableBlockApi } from './getFirstAvailableBlock';\nimport { GetGenesisHashApi } from './getGenesisHash';\nimport { GetHealthApi } from './getHealth';\nimport { GetHighestSnapshotSlotApi } from './getHighestSnapshotSlot';\nimport { GetIdentityApi } from './getIdentity';\nimport { GetInflationGovernorApi } from './getInflationGovernor';\nimport { GetInflationRateApi } from './getInflationRate';\nimport { GetInflationRewardApi } from './getInflationReward';\nimport { GetLargestAccountsApi } from './getLargestAccounts';\nimport { GetLatestBlockhashApi } from './getLatestBlockhash';\nimport { GetLeaderScheduleApi } from './getLeaderSchedule';\nimport { GetMaxRetransmitSlotApi } from './getMaxRetransmitSlot';\nimport { GetMaxShredInsertSlotApi } from './getMaxShredInsertSlot';\nimport { GetMinimumBalanceForRentExemptionApi } from './getMinimumBalanceForRentExemption';\nimport { GetMultipleAccountsApi } from './getMultipleAccounts';\nimport { GetProgramAccountsApi } from './getProgramAccounts';\nimport { GetRecentPerformanceSamplesApi } from './getRecentPerformanceSamples';\nimport { GetRecentPrioritizationFeesApi } from './getRecentPrioritizationFees';\nimport { GetSignaturesForAddressApi } from './getSignaturesForAddress';\nimport { GetSignatureStatusesApi } from './getSignatureStatuses';\nimport { GetSlotApi } from './getSlot';\nimport { GetSlotLeaderApi } from './getSlotLeader';\nimport { GetSlotLeadersApi } from './getSlotLeaders';\nimport { GetStakeActivationApi } from './getStakeActivation';\nimport { GetStakeMinimumDelegationApi } from './getStakeMinimumDelegation';\nimport { GetSupplyApi } from './getSupply';\nimport { GetTokenAccountBalanceApi } from './getTokenAccountBalance';\nimport { GetTokenAccountsByDelegateApi } from './getTokenAccountsByDelegate';\nimport { GetTokenAccountsByOwnerApi } from './getTokenAccountsByOwner';\nimport { GetTokenLargestAccountsApi } from './getTokenLargestAccounts';\nimport { GetTokenSupplyApi } from './getTokenSupply';\nimport { GetTransactionApi } from './getTransaction';\nimport { GetTransactionCountApi } from './getTransactionCount';\nimport { GetVersionApi } from './getVersion';\nimport { GetVoteAccountsApi } from './getVoteAccounts';\nimport { IsBlockhashValidApi } from './isBlockhashValid';\nimport { MinimumLedgerSlotApi } from './minimumLedgerSlot';\nimport { RequestAirdropApi } from './requestAirdrop';\nimport { SendTransactionApi } from './sendTransaction';\nimport { SimulateTransactionApi } from './simulateTransaction';\n\ntype SolanaRpcApiForAllClusters = GetAccountInfoApi &\n GetBalanceApi &\n GetBlockApi &\n GetBlockCommitmentApi &\n GetBlockHeightApi &\n GetBlockProductionApi &\n GetBlocksApi &\n GetBlocksWithLimitApi &\n GetBlockTimeApi &\n GetClusterNodesApi &\n GetEpochInfoApi &\n GetEpochScheduleApi &\n GetFeeForMessageApi &\n GetFirstAvailableBlockApi &\n GetGenesisHashApi &\n GetHealthApi &\n GetHighestSnapshotSlotApi &\n GetIdentityApi &\n GetInflationGovernorApi &\n GetInflationRateApi &\n GetInflationRewardApi &\n GetLargestAccountsApi &\n GetLatestBlockhashApi &\n GetLeaderScheduleApi &\n GetMaxRetransmitSlotApi &\n GetMaxShredInsertSlotApi &\n GetMinimumBalanceForRentExemptionApi &\n GetMultipleAccountsApi &\n GetProgramAccountsApi &\n GetRecentPerformanceSamplesApi &\n GetRecentPrioritizationFeesApi &\n GetSignaturesForAddressApi &\n GetSignatureStatusesApi &\n GetSlotApi &\n GetSlotLeaderApi &\n GetSlotLeadersApi &\n GetStakeActivationApi &\n GetStakeMinimumDelegationApi &\n GetSupplyApi &\n GetTokenAccountBalanceApi &\n GetTokenAccountsByDelegateApi &\n GetTokenAccountsByOwnerApi &\n GetTokenLargestAccountsApi &\n GetTokenSupplyApi &\n GetTransactionApi &\n GetTransactionCountApi &\n GetVersionApi &\n GetVoteAccountsApi &\n IsBlockhashValidApi &\n MinimumLedgerSlotApi &\n SendTransactionApi &\n SimulateTransactionApi;\ntype SolanaRpcApiForTestClusters = RequestAirdropApi & SolanaRpcApiForAllClusters;\nexport type SolanaRpcApi = SolanaRpcApiForTestClusters;\nexport type SolanaRpcApiDevnet = SolanaRpcApiForTestClusters;\nexport type SolanaRpcApiTestnet = SolanaRpcApiForTestClusters;\nexport type SolanaRpcApiMainnet = SolanaRpcApiForAllClusters;\n\nexport type {\n GetAccountInfoApi,\n GetBalanceApi,\n GetBlockApi,\n GetBlockCommitmentApi,\n GetBlockHeightApi,\n GetBlockProductionApi,\n GetBlocksApi,\n GetBlocksWithLimitApi,\n GetBlockTimeApi,\n GetClusterNodesApi,\n GetEpochInfoApi,\n GetEpochScheduleApi,\n GetFeeForMessageApi,\n GetFirstAvailableBlockApi,\n GetGenesisHashApi,\n GetHealthApi,\n GetHighestSnapshotSlotApi,\n GetIdentityApi,\n GetInflationGovernorApi,\n GetInflationRateApi,\n GetInflationRewardApi,\n GetLargestAccountsApi,\n GetLatestBlockhashApi,\n GetLeaderScheduleApi,\n GetMaxRetransmitSlotApi,\n GetMaxShredInsertSlotApi,\n GetMinimumBalanceForRentExemptionApi,\n GetMultipleAccountsApi,\n GetProgramAccountsApi,\n GetRecentPerformanceSamplesApi,\n GetRecentPrioritizationFeesApi,\n GetSignaturesForAddressApi,\n GetSignatureStatusesApi,\n GetSlotApi,\n GetSlotLeaderApi,\n GetSlotLeadersApi,\n GetStakeActivationApi,\n GetStakeMinimumDelegationApi,\n GetSupplyApi,\n GetTokenAccountBalanceApi,\n GetTokenAccountsByDelegateApi,\n GetTokenAccountsByOwnerApi,\n GetTokenLargestAccountsApi,\n GetTokenSupplyApi,\n GetTransactionApi,\n GetTransactionCountApi,\n GetVersionApi,\n GetVoteAccountsApi,\n IsBlockhashValidApi,\n MinimumLedgerSlotApi,\n RequestAirdropApi,\n SendTransactionApi,\n SimulateTransactionApi,\n};\n\ntype Config = ParamsTransformerConfig;\n\nexport function createSolanaRpcApi<\n TRpcMethods extends SolanaRpcApi | SolanaRpcApiDevnet | SolanaRpcApiMainnet | SolanaRpcApiTestnet = SolanaRpcApi,\n>(config?: Config): RpcApi<TRpcMethods> {\n return createRpcApi<TRpcMethods>({\n parametersTransformer: getDefaultParamsTransformerForSolanaRpc(config) as (params: unknown[]) => unknown[],\n responseTransformer: getDefaultResponseTransformerForSolanaRpc({\n allowedNumericKeyPaths: getAllowedNumericKeypaths(),\n }),\n });\n}\n\nlet memoizedKeypaths: AllowedNumericKeypaths<RpcApi<SolanaRpcApi>>;\n\n/**\n * These are keypaths at the end of which you will find a numeric value that should *not* be upcast\n * to a `bigint`. These are values that are legitimately defined as `u8` or `usize` on the backend.\n */\nfunction getAllowedNumericKeypaths(): AllowedNumericKeypaths<RpcApi<SolanaRpcApi>> {\n if (!memoizedKeypaths) {\n memoizedKeypaths = {\n getAccountInfo: jsonParsedAccountsConfigs.map(c => ['value', ...c]),\n getBlock: [\n ['blockTime'],\n ['transactions', KEYPATH_WILDCARD, 'meta', 'preTokenBalances', KEYPATH_WILDCARD, 'accountIndex'],\n [\n 'transactions',\n KEYPATH_WILDCARD,\n 'meta',\n 'preTokenBalances',\n KEYPATH_WILDCARD,\n 'uiTokenAmount',\n 'decimals',\n ],\n ['transactions', KEYPATH_WILDCARD, 'meta', 'postTokenBalances', KEYPATH_WILDCARD, 'accountIndex'],\n [\n 'transactions',\n KEYPATH_WILDCARD,\n 'meta',\n 'postTokenBalances',\n KEYPATH_WILDCARD,\n 'uiTokenAmount',\n 'decimals',\n ],\n ['transactions', KEYPATH_WILDCARD, 'meta', 'rewards', KEYPATH_WILDCARD, 'commission'],\n ...innerInstructionsConfigs.map(c => [\n 'transactions',\n KEYPATH_WILDCARD,\n 'meta',\n 'innerInstructions',\n KEYPATH_WILDCARD,\n ...c,\n ]),\n ...messageConfig.map(c => ['transactions', KEYPATH_WILDCARD, 'transaction', 'message', ...c] as const),\n ['rewards', KEYPATH_WILDCARD, 'commission'],\n ],\n getBlockTime: [[]],\n getClusterNodes: [\n [KEYPATH_WILDCARD, 'featureSet'],\n [KEYPATH_WILDCARD, 'shredVersion'],\n ],\n getInflationGovernor: [['initial'], ['foundation'], ['foundationTerm'], ['taper'], ['terminal']],\n getInflationRate: [['foundation'], ['total'], ['validator']],\n getInflationReward: [[KEYPATH_WILDCARD, 'commission']],\n getMultipleAccounts: jsonParsedAccountsConfigs.map(c => ['value', KEYPATH_WILDCARD, ...c]),\n getProgramAccounts: jsonParsedAccountsConfigs.flatMap(c => [\n ['value', KEYPATH_WILDCARD, 'account', ...c],\n [KEYPATH_WILDCARD, 'account', ...c],\n ]),\n getRecentPerformanceSamples: [[KEYPATH_WILDCARD, 'samplePeriodSecs']],\n getTokenAccountBalance: [\n ['value', 'decimals'],\n ['value', 'uiAmount'],\n ],\n getTokenAccountsByDelegate: jsonParsedTokenAccountsConfigs.map(c => [\n 'value',\n KEYPATH_WILDCARD,\n 'account',\n ...c,\n ]),\n getTokenAccountsByOwner: jsonParsedTokenAccountsConfigs.map(c => [\n 'value',\n KEYPATH_WILDCARD,\n 'account',\n ...c,\n ]),\n getTokenLargestAccounts: [\n ['value', KEYPATH_WILDCARD, 'decimals'],\n ['value', KEYPATH_WILDCARD, 'uiAmount'],\n ],\n getTokenSupply: [\n ['value', 'decimals'],\n ['value', 'uiAmount'],\n ],\n getTransaction: [\n ['meta', 'preTokenBalances', KEYPATH_WILDCARD, 'accountIndex'],\n ['meta', 'preTokenBalances', KEYPATH_WILDCARD, 'uiTokenAmount', 'decimals'],\n ['meta', 'postTokenBalances', KEYPATH_WILDCARD, 'accountIndex'],\n ['meta', 'postTokenBalances', KEYPATH_WILDCARD, 'uiTokenAmount', 'decimals'],\n ['meta', 'rewards', KEYPATH_WILDCARD, 'commission'],\n ...innerInstructionsConfigs.map(c => ['meta', 'innerInstructions', KEYPATH_WILDCARD, ...c]),\n ...messageConfig.map(c => ['transaction', 'message', ...c] as const),\n ],\n getVersion: [['feature-set']],\n getVoteAccounts: [\n ['current', KEYPATH_WILDCARD, 'commission'],\n ['delinquent', KEYPATH_WILDCARD, 'commission'],\n ],\n simulateTransaction: [\n ...jsonParsedAccountsConfigs.map(c => ['value', 'accounts', KEYPATH_WILDCARD, ...c]),\n ...innerInstructionsConfigs.map(c => ['value', 'innerInstructions', KEYPATH_WILDCARD, ...c]),\n ],\n };\n }\n return memoizedKeypaths;\n}\n"]}
|