@solana/rpc-api 6.3.1 → 6.3.2-canary-20260313112147

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.
Files changed (54) hide show
  1. package/package.json +14 -13
  2. package/src/getAccountInfo.ts +145 -0
  3. package/src/getBalance.ts +31 -0
  4. package/src/getBlock.ts +552 -0
  5. package/src/getBlockCommitment.ts +20 -0
  6. package/src/getBlockHeight.ts +29 -0
  7. package/src/getBlockProduction.ts +83 -0
  8. package/src/getBlockTime.ts +21 -0
  9. package/src/getBlocks.ts +34 -0
  10. package/src/getBlocksWithLimit.ts +33 -0
  11. package/src/getClusterNodes.ts +49 -0
  12. package/src/getEpochInfo.ts +43 -0
  13. package/src/getEpochSchedule.ts +29 -0
  14. package/src/getFeeForMessage.ts +35 -0
  15. package/src/getFirstAvailableBlock.ts +17 -0
  16. package/src/getGenesisHash.ts +13 -0
  17. package/src/getHealth.ts +17 -0
  18. package/src/getHighestSnapshotSlot.ts +23 -0
  19. package/src/getIdentity.ts +14 -0
  20. package/src/getInflationGovernor.ts +39 -0
  21. package/src/getInflationRate.ts +21 -0
  22. package/src/getInflationReward.ts +53 -0
  23. package/src/getLargestAccounts.ts +42 -0
  24. package/src/getLatestBlockhash.ts +40 -0
  25. package/src/getLeaderSchedule.ts +103 -0
  26. package/src/getMaxRetransmitSlot.ts +12 -0
  27. package/src/getMaxShredInsertSlot.ts +12 -0
  28. package/src/getMinimumBalanceForRentExemption.ts +32 -0
  29. package/src/getMultipleAccounts.ts +156 -0
  30. package/src/getProgramAccounts.ts +264 -0
  31. package/src/getRecentPerformanceSamples.ts +29 -0
  32. package/src/getRecentPrioritizationFees.ts +28 -0
  33. package/src/getSignatureStatuses.ts +62 -0
  34. package/src/getSignaturesForAddress.ts +88 -0
  35. package/src/getSlot.ts +29 -0
  36. package/src/getSlotLeader.ts +32 -0
  37. package/src/getSlotLeaders.ts +21 -0
  38. package/src/getStakeMinimumDelegation.ts +26 -0
  39. package/src/getSupply.ts +66 -0
  40. package/src/getTokenAccountBalance.ts +26 -0
  41. package/src/getTokenAccountsByDelegate.ts +196 -0
  42. package/src/getTokenAccountsByOwner.ts +190 -0
  43. package/src/getTokenLargestAccounts.ts +29 -0
  44. package/src/getTokenSupply.ts +26 -0
  45. package/src/getTransaction.ts +437 -0
  46. package/src/getTransactionCount.ts +30 -0
  47. package/src/getVersion.ts +21 -0
  48. package/src/getVoteAccounts.ts +80 -0
  49. package/src/index.ts +353 -0
  50. package/src/isBlockhashValid.ts +35 -0
  51. package/src/minimumLedgerSlot.ts +16 -0
  52. package/src/requestAirdrop.ts +34 -0
  53. package/src/sendTransaction.ts +80 -0
  54. package/src/simulateTransaction.ts +727 -0
package/src/index.ts ADDED
@@ -0,0 +1,353 @@
1
+ /**
2
+ * This package contains types that describe the [methods](https://solana.com/docs/rpc/http) of the
3
+ * Solana JSON RPC API, and utilities for creating a {@link RpcApi} implementation with sensible
4
+ * defaults. It can be used standalone, but it is also exported as part of Kit
5
+ * [`@solana/kit`](https://github.com/anza-xyz/kit/tree/main/packages/kit).
6
+ *
7
+ * @example
8
+ * Each RPC method is described in terms of a TypeScript type of the following form:
9
+ *
10
+ * ```ts
11
+ * type ExampleApi = {
12
+ * getSomething(address: Address): Something;
13
+ * };
14
+ * ```
15
+ *
16
+ * A {@link RpcApi} that implements `ExampleApi` will ultimately expose its defined methods on any
17
+ * {@link Rpc} that uses it.
18
+ *
19
+ * ```ts
20
+ * const rpc: Rpc<ExampleApi> = createExampleRpc(/* ... *\/);
21
+ * const something: Something = await rpc.getSomething(address('95DpK3y3GF7U8s1k4EvZ7xqyeCkhsHeZaE97iZpHUGMN')).send();
22
+ * ```
23
+ *
24
+ * @packageDocumentation
25
+ */
26
+ import { createJsonRpcApi, RpcApi } from '@solana/rpc-spec';
27
+ import {
28
+ AllowedNumericKeypaths,
29
+ getDefaultRequestTransformerForSolanaRpc,
30
+ getDefaultResponseTransformerForSolanaRpc,
31
+ innerInstructionsConfigs,
32
+ jsonParsedAccountsConfigs,
33
+ jsonParsedTokenAccountsConfigs,
34
+ KEYPATH_WILDCARD,
35
+ messageConfig,
36
+ RequestTransformerConfig,
37
+ } from '@solana/rpc-transformers';
38
+
39
+ import { GetAccountInfoApi } from './getAccountInfo';
40
+ import { GetBalanceApi } from './getBalance';
41
+ import { GetBlockApi } from './getBlock';
42
+ import { GetBlockCommitmentApi } from './getBlockCommitment';
43
+ import { GetBlockHeightApi } from './getBlockHeight';
44
+ import { GetBlockProductionApi } from './getBlockProduction';
45
+ import { GetBlocksApi } from './getBlocks';
46
+ import { GetBlocksWithLimitApi } from './getBlocksWithLimit';
47
+ import { GetBlockTimeApi } from './getBlockTime';
48
+ import { GetClusterNodesApi } from './getClusterNodes';
49
+ import { GetEpochInfoApi } from './getEpochInfo';
50
+ import { GetEpochScheduleApi } from './getEpochSchedule';
51
+ import { GetFeeForMessageApi } from './getFeeForMessage';
52
+ import { GetFirstAvailableBlockApi } from './getFirstAvailableBlock';
53
+ import { GetGenesisHashApi } from './getGenesisHash';
54
+ import { GetHealthApi } from './getHealth';
55
+ import { GetHighestSnapshotSlotApi } from './getHighestSnapshotSlot';
56
+ import { GetIdentityApi } from './getIdentity';
57
+ import { GetInflationGovernorApi } from './getInflationGovernor';
58
+ import { GetInflationRateApi } from './getInflationRate';
59
+ import { GetInflationRewardApi } from './getInflationReward';
60
+ import { GetLargestAccountsApi } from './getLargestAccounts';
61
+ import { GetLatestBlockhashApi } from './getLatestBlockhash';
62
+ import { GetLeaderScheduleApi } from './getLeaderSchedule';
63
+ import { GetMaxRetransmitSlotApi } from './getMaxRetransmitSlot';
64
+ import { GetMaxShredInsertSlotApi } from './getMaxShredInsertSlot';
65
+ import { GetMinimumBalanceForRentExemptionApi } from './getMinimumBalanceForRentExemption';
66
+ import { GetMultipleAccountsApi } from './getMultipleAccounts';
67
+ import { GetProgramAccountsApi } from './getProgramAccounts';
68
+ import { GetRecentPerformanceSamplesApi } from './getRecentPerformanceSamples';
69
+ import { GetRecentPrioritizationFeesApi } from './getRecentPrioritizationFees';
70
+ import { GetSignaturesForAddressApi } from './getSignaturesForAddress';
71
+ import { GetSignatureStatusesApi } from './getSignatureStatuses';
72
+ import { GetSlotApi } from './getSlot';
73
+ import { GetSlotLeaderApi } from './getSlotLeader';
74
+ import { GetSlotLeadersApi } from './getSlotLeaders';
75
+ import { GetStakeMinimumDelegationApi } from './getStakeMinimumDelegation';
76
+ import { GetSupplyApi } from './getSupply';
77
+ import { GetTokenAccountBalanceApi } from './getTokenAccountBalance';
78
+ import { GetTokenAccountsByDelegateApi } from './getTokenAccountsByDelegate';
79
+ import { GetTokenAccountsByOwnerApi } from './getTokenAccountsByOwner';
80
+ import { GetTokenLargestAccountsApi } from './getTokenLargestAccounts';
81
+ import { GetTokenSupplyApi } from './getTokenSupply';
82
+ import { GetTransactionApi } from './getTransaction';
83
+ import { GetTransactionCountApi } from './getTransactionCount';
84
+ import { GetVersionApi } from './getVersion';
85
+ import { GetVoteAccountsApi } from './getVoteAccounts';
86
+ import { IsBlockhashValidApi } from './isBlockhashValid';
87
+ import { MinimumLedgerSlotApi } from './minimumLedgerSlot';
88
+ import { RequestAirdropApi } from './requestAirdrop';
89
+ import { SendTransactionApi } from './sendTransaction';
90
+ import { SimulateTransactionApi } from './simulateTransaction';
91
+
92
+ type SolanaRpcApiForAllClusters = GetAccountInfoApi &
93
+ GetBalanceApi &
94
+ GetBlockApi &
95
+ GetBlockCommitmentApi &
96
+ GetBlockHeightApi &
97
+ GetBlockProductionApi &
98
+ GetBlocksApi &
99
+ GetBlocksWithLimitApi &
100
+ GetBlockTimeApi &
101
+ GetClusterNodesApi &
102
+ GetEpochInfoApi &
103
+ GetEpochScheduleApi &
104
+ GetFeeForMessageApi &
105
+ GetFirstAvailableBlockApi &
106
+ GetGenesisHashApi &
107
+ GetHealthApi &
108
+ GetHighestSnapshotSlotApi &
109
+ GetIdentityApi &
110
+ GetInflationGovernorApi &
111
+ GetInflationRateApi &
112
+ GetInflationRewardApi &
113
+ GetLargestAccountsApi &
114
+ GetLatestBlockhashApi &
115
+ GetLeaderScheduleApi &
116
+ GetMaxRetransmitSlotApi &
117
+ GetMaxShredInsertSlotApi &
118
+ GetMinimumBalanceForRentExemptionApi &
119
+ GetMultipleAccountsApi &
120
+ GetProgramAccountsApi &
121
+ GetRecentPerformanceSamplesApi &
122
+ GetRecentPrioritizationFeesApi &
123
+ GetSignaturesForAddressApi &
124
+ GetSignatureStatusesApi &
125
+ GetSlotApi &
126
+ GetSlotLeaderApi &
127
+ GetSlotLeadersApi &
128
+ GetStakeMinimumDelegationApi &
129
+ GetSupplyApi &
130
+ GetTokenAccountBalanceApi &
131
+ GetTokenAccountsByDelegateApi &
132
+ GetTokenAccountsByOwnerApi &
133
+ GetTokenLargestAccountsApi &
134
+ GetTokenSupplyApi &
135
+ GetTransactionApi &
136
+ GetTransactionCountApi &
137
+ GetVersionApi &
138
+ GetVoteAccountsApi &
139
+ IsBlockhashValidApi &
140
+ MinimumLedgerSlotApi &
141
+ SendTransactionApi &
142
+ SimulateTransactionApi;
143
+ type SolanaRpcApiForTestClusters = RequestAirdropApi & SolanaRpcApiForAllClusters;
144
+ /**
145
+ * Represents the RPC methods available on test clusters.
146
+ *
147
+ * For instance, the test clusters support the {@link RequestAirdropApi} while mainnet does not.
148
+ */
149
+ export type SolanaRpcApi = SolanaRpcApiForTestClusters;
150
+ /**
151
+ * Represents the RPC methods available on the devnet cluster.
152
+ *
153
+ * For instance, the devnet cluster supports the {@link RequestAirdropApi} while mainnet does not.
154
+ */
155
+ export type SolanaRpcApiDevnet = SolanaRpcApiForTestClusters;
156
+ /**
157
+ * Represents the RPC methods available on the testnet cluster.
158
+ *
159
+ * For instance, the testnet cluster supports the {@link RequestAirdropApi} while mainnet does not.
160
+ */
161
+ export type SolanaRpcApiTestnet = SolanaRpcApiForTestClusters;
162
+ /**
163
+ * Represents the RPC methods available on the mainnet cluster.
164
+ *
165
+ * For instance, the mainnet cluster does not support the {@link RequestAirdropApi} whereas test
166
+ * clusters do.
167
+ */
168
+ export type SolanaRpcApiMainnet = SolanaRpcApiForAllClusters;
169
+
170
+ export type {
171
+ GetAccountInfoApi,
172
+ GetBalanceApi,
173
+ GetBlockApi,
174
+ GetBlockCommitmentApi,
175
+ GetBlockHeightApi,
176
+ GetBlockProductionApi,
177
+ GetBlocksApi,
178
+ GetBlocksWithLimitApi,
179
+ GetBlockTimeApi,
180
+ GetClusterNodesApi,
181
+ GetEpochInfoApi,
182
+ GetEpochScheduleApi,
183
+ GetFeeForMessageApi,
184
+ GetFirstAvailableBlockApi,
185
+ GetGenesisHashApi,
186
+ GetHealthApi,
187
+ GetHighestSnapshotSlotApi,
188
+ GetIdentityApi,
189
+ GetInflationGovernorApi,
190
+ GetInflationRateApi,
191
+ GetInflationRewardApi,
192
+ GetLargestAccountsApi,
193
+ GetLatestBlockhashApi,
194
+ GetLeaderScheduleApi,
195
+ GetMaxRetransmitSlotApi,
196
+ GetMaxShredInsertSlotApi,
197
+ GetMinimumBalanceForRentExemptionApi,
198
+ GetMultipleAccountsApi,
199
+ GetProgramAccountsApi,
200
+ GetRecentPerformanceSamplesApi,
201
+ GetRecentPrioritizationFeesApi,
202
+ GetSignaturesForAddressApi,
203
+ GetSignatureStatusesApi,
204
+ GetSlotApi,
205
+ GetSlotLeaderApi,
206
+ GetSlotLeadersApi,
207
+ GetStakeMinimumDelegationApi,
208
+ GetSupplyApi,
209
+ GetTokenAccountBalanceApi,
210
+ GetTokenAccountsByDelegateApi,
211
+ GetTokenAccountsByOwnerApi,
212
+ GetTokenLargestAccountsApi,
213
+ GetTokenSupplyApi,
214
+ GetTransactionApi,
215
+ GetTransactionCountApi,
216
+ GetVersionApi,
217
+ GetVoteAccountsApi,
218
+ IsBlockhashValidApi,
219
+ MinimumLedgerSlotApi,
220
+ RequestAirdropApi,
221
+ SendTransactionApi,
222
+ SimulateTransactionApi,
223
+ };
224
+
225
+ type Config = RequestTransformerConfig;
226
+
227
+ /**
228
+ * Creates a {@link RpcApi} implementation of the Solana JSON RPC API with some default behaviours.
229
+ *
230
+ * The default behaviours include:
231
+ * - A transform that converts `bigint` inputs to `number` for compatibility with version 1.0 of the
232
+ * Solana JSON RPC.
233
+ * - A transform that calls the config's {@link Config.onIntegerOverflow | onIntegerOverflow}
234
+ * handler whenever a `bigint` input would overflow a JavaScript IEEE 754 number. See
235
+ * [this](https://github.com/solana-labs/solana-web3.js/issues/1116) GitHub issue for more
236
+ * information.
237
+ * - A transform that applies a default commitment wherever not specified
238
+ */
239
+ export function createSolanaRpcApi<
240
+ // eslint-disable-next-line @typescript-eslint/no-duplicate-type-constituents
241
+ TRpcMethods extends SolanaRpcApi | SolanaRpcApiDevnet | SolanaRpcApiMainnet | SolanaRpcApiTestnet = SolanaRpcApi,
242
+ >(config?: Config): RpcApi<TRpcMethods> {
243
+ return createJsonRpcApi<TRpcMethods>({
244
+ requestTransformer: getDefaultRequestTransformerForSolanaRpc(config),
245
+ responseTransformer: getDefaultResponseTransformerForSolanaRpc({
246
+ allowedNumericKeyPaths: getAllowedNumericKeypaths(),
247
+ }),
248
+ });
249
+ }
250
+
251
+ let memoizedKeypaths: AllowedNumericKeypaths<RpcApi<SolanaRpcApi>>;
252
+
253
+ /**
254
+ * These are keypaths at the end of which you will find a numeric value that should *not* be upcast
255
+ * to a `bigint`. These are values that are legitimately defined as `u8` or `usize` on the backend.
256
+ */
257
+ function getAllowedNumericKeypaths(): AllowedNumericKeypaths<RpcApi<SolanaRpcApi>> {
258
+ if (!memoizedKeypaths) {
259
+ memoizedKeypaths = {
260
+ getAccountInfo: jsonParsedAccountsConfigs.map(c => ['value', ...c]),
261
+ getBlock: [
262
+ ['transactions', KEYPATH_WILDCARD, 'meta', 'preTokenBalances', KEYPATH_WILDCARD, 'accountIndex'],
263
+ [
264
+ 'transactions',
265
+ KEYPATH_WILDCARD,
266
+ 'meta',
267
+ 'preTokenBalances',
268
+ KEYPATH_WILDCARD,
269
+ 'uiTokenAmount',
270
+ 'decimals',
271
+ ],
272
+ ['transactions', KEYPATH_WILDCARD, 'meta', 'postTokenBalances', KEYPATH_WILDCARD, 'accountIndex'],
273
+ [
274
+ 'transactions',
275
+ KEYPATH_WILDCARD,
276
+ 'meta',
277
+ 'postTokenBalances',
278
+ KEYPATH_WILDCARD,
279
+ 'uiTokenAmount',
280
+ 'decimals',
281
+ ],
282
+ ['transactions', KEYPATH_WILDCARD, 'meta', 'rewards', KEYPATH_WILDCARD, 'commission'],
283
+ ...innerInstructionsConfigs.map(c => [
284
+ 'transactions',
285
+ KEYPATH_WILDCARD,
286
+ 'meta',
287
+ 'innerInstructions',
288
+ KEYPATH_WILDCARD,
289
+ ...c,
290
+ ]),
291
+ ...messageConfig.map(c => ['transactions', KEYPATH_WILDCARD, 'transaction', 'message', ...c] as const),
292
+ ['rewards', KEYPATH_WILDCARD, 'commission'],
293
+ ],
294
+ getClusterNodes: [
295
+ [KEYPATH_WILDCARD, 'featureSet'],
296
+ [KEYPATH_WILDCARD, 'shredVersion'],
297
+ ],
298
+ getInflationGovernor: [['initial'], ['foundation'], ['foundationTerm'], ['taper'], ['terminal']],
299
+ getInflationRate: [['foundation'], ['total'], ['validator']],
300
+ getInflationReward: [[KEYPATH_WILDCARD, 'commission']],
301
+ getMultipleAccounts: jsonParsedAccountsConfigs.map(c => ['value', KEYPATH_WILDCARD, ...c]),
302
+ getProgramAccounts: jsonParsedAccountsConfigs.flatMap(c => [
303
+ ['value', KEYPATH_WILDCARD, 'account', ...c],
304
+ [KEYPATH_WILDCARD, 'account', ...c],
305
+ ]),
306
+ getRecentPerformanceSamples: [[KEYPATH_WILDCARD, 'samplePeriodSecs']],
307
+ getTokenAccountBalance: [
308
+ ['value', 'decimals'],
309
+ ['value', 'uiAmount'],
310
+ ],
311
+ getTokenAccountsByDelegate: jsonParsedTokenAccountsConfigs.map(c => [
312
+ 'value',
313
+ KEYPATH_WILDCARD,
314
+ 'account',
315
+ ...c,
316
+ ]),
317
+ getTokenAccountsByOwner: jsonParsedTokenAccountsConfigs.map(c => [
318
+ 'value',
319
+ KEYPATH_WILDCARD,
320
+ 'account',
321
+ ...c,
322
+ ]),
323
+ getTokenLargestAccounts: [
324
+ ['value', KEYPATH_WILDCARD, 'decimals'],
325
+ ['value', KEYPATH_WILDCARD, 'uiAmount'],
326
+ ],
327
+ getTokenSupply: [
328
+ ['value', 'decimals'],
329
+ ['value', 'uiAmount'],
330
+ ],
331
+ getTransaction: [
332
+ ['meta', 'preTokenBalances', KEYPATH_WILDCARD, 'accountIndex'],
333
+ ['meta', 'preTokenBalances', KEYPATH_WILDCARD, 'uiTokenAmount', 'decimals'],
334
+ ['meta', 'postTokenBalances', KEYPATH_WILDCARD, 'accountIndex'],
335
+ ['meta', 'postTokenBalances', KEYPATH_WILDCARD, 'uiTokenAmount', 'decimals'],
336
+ ['meta', 'rewards', KEYPATH_WILDCARD, 'commission'],
337
+ ...innerInstructionsConfigs.map(c => ['meta', 'innerInstructions', KEYPATH_WILDCARD, ...c]),
338
+ ...messageConfig.map(c => ['transaction', 'message', ...c] as const),
339
+ ],
340
+ getVersion: [['feature-set']],
341
+ getVoteAccounts: [
342
+ ['current', KEYPATH_WILDCARD, 'commission'],
343
+ ['delinquent', KEYPATH_WILDCARD, 'commission'],
344
+ ],
345
+ simulateTransaction: [
346
+ ['value', 'loadedAccountsDataSize'],
347
+ ...jsonParsedAccountsConfigs.map(c => ['value', 'accounts', KEYPATH_WILDCARD, ...c]),
348
+ ...innerInstructionsConfigs.map(c => ['value', 'innerInstructions', KEYPATH_WILDCARD, ...c]),
349
+ ],
350
+ };
351
+ }
352
+ return memoizedKeypaths;
353
+ }
@@ -0,0 +1,35 @@
1
+ import type { Blockhash, Commitment, Slot, SolanaRpcResponse } from '@solana/rpc-types';
2
+
3
+ type IsBlockhashValidApiResponse = boolean;
4
+
5
+ export type IsBlockhashValidApi = {
6
+ /**
7
+ * Returns whether a blockhash is still valid or not.
8
+ *
9
+ * The last 300 blockhashes produced are considered valid. This equates to an age of ~2 minutes.
10
+ *
11
+ * @param blockhash A SHA-256 hash as base-58 encoded string
12
+ *
13
+ * @see https://solana.com/docs/rpc/http/isblockhashvalid
14
+ */
15
+ isBlockhashValid(
16
+ blockhash: Blockhash,
17
+ config?: Readonly<{
18
+ /**
19
+ * Evaluate whether the blockhash is valid as of the highest slot that has reached this
20
+ * level of commitment.
21
+ *
22
+ * @defaultValue Whichever default is applied by the underlying {@link RpcApi} in use.
23
+ * For example, when using an API created by a `createSolanaRpc*()` helper, the default
24
+ * commitment is `"confirmed"` unless configured otherwise. Unmitigated by an API layer
25
+ * on the client, the default commitment applied by the server is `"finalized"`.
26
+ */
27
+ commitment?: Commitment;
28
+ /**
29
+ * Prevents accessing stale data by enforcing that the RPC node has processed
30
+ * transactions up to this slot
31
+ */
32
+ minContextSlot?: Slot;
33
+ }>,
34
+ ): SolanaRpcResponse<IsBlockhashValidApiResponse>;
35
+ };
@@ -0,0 +1,16 @@
1
+ import type { Slot } from '@solana/rpc-types';
2
+
3
+ type MinimumLedgerSlotApiResponse = Slot;
4
+
5
+ export type MinimumLedgerSlotApi = {
6
+ /**
7
+ * Returns the lowest slot about which the node has information.
8
+ *
9
+ * Different nodes may offer more or less historical slot data, depending on their
10
+ * configuration. An appropriately configured node should be able to access all slots, from
11
+ * genesis onward. When it is not, this method will tell you the lowest slot available.
12
+ *
13
+ * @see https://solana.com/docs/rpc/http/minimumledgerslot
14
+ */
15
+ minimumLedgerSlot(): MinimumLedgerSlotApiResponse;
16
+ };
@@ -0,0 +1,34 @@
1
+ import type { Address } from '@solana/addresses';
2
+ import type { Signature } from '@solana/keys';
3
+ import type { Commitment, Lamports } from '@solana/rpc-types';
4
+
5
+ type RequestAirdropConfig = Readonly<{
6
+ /**
7
+ * Evaluate the request as of the highest slot that has reached this level of commitment.
8
+ *
9
+ * @defaultValue Whichever default is applied by the underlying {@link RpcApi} in use. For
10
+ * example, when using an API created by a `createSolanaRpc*()` helper, the default commitment
11
+ * is `"confirmed"` unless configured otherwise. Unmitigated by an API layer on the client, the
12
+ * default commitment applied by the server is `"finalized"`.
13
+ */
14
+ commitment?: Commitment;
15
+ }>;
16
+
17
+ type RequestAirdropResponse = Signature;
18
+
19
+ export type RequestAirdropApi = {
20
+ /**
21
+ * Requests an airdrop of {@link Lamports} to the specified address.
22
+ *
23
+ * This method is offered by test clusters as a way to obtain SOL tokens to pay transaction
24
+ * fees.
25
+ *
26
+ * @returns The signature of the airdrop transaction, as a base-58 encoded string.
27
+ * @see https://solana.com/docs/rpc/http/requestairdrop
28
+ */
29
+ requestAirdrop(
30
+ recipientAccount: Address,
31
+ lamports: Lamports,
32
+ config?: RequestAirdropConfig,
33
+ ): RequestAirdropResponse;
34
+ };
@@ -0,0 +1,80 @@
1
+ import type { Signature } from '@solana/keys';
2
+ import type { Commitment, Slot } from '@solana/rpc-types';
3
+ import type { Base64EncodedWireTransaction } from '@solana/transactions';
4
+
5
+ type SendTransactionConfig = Readonly<{
6
+ /**
7
+ * Maximum number of times for the RPC node to retry sending the transaction to the leader.
8
+ *
9
+ * @defaultValue When omitted, the RPC node will retry the transaction until it is finalized or
10
+ * until its lifetime specifier (ie. its recent blockhash or nonce) expires.
11
+ */
12
+ maxRetries?: bigint;
13
+ /**
14
+ * Prevents accessing stale data by enforcing that the RPC node has processed transactions up to
15
+ * this slot
16
+ */
17
+ minContextSlot?: Slot;
18
+ /**
19
+ * Simulate the transaction as of the highest slot that has reached this level of commitment.
20
+ *
21
+ * Has no effect when `skipPreflight` is set to `true`.
22
+ *
23
+ * @defaultValue Whichever default is applied by the underlying {@link RpcApi} in use. For
24
+ * example, when using an API created by a `createSolanaRpc*()` helper, the default commitment
25
+ * is `"confirmed"` unless configured otherwise. Unmitigated by an API layer on the client, the
26
+ * default commitment applied by the server is `"finalized"`.
27
+ */
28
+ preflightCommitment?: Commitment;
29
+ /** @defaultValue `false` */
30
+ skipPreflight?: boolean;
31
+ }>;
32
+
33
+ type SendTransactionResponse = Signature;
34
+
35
+ export type SendTransactionApi = {
36
+ /** @deprecated Set `encoding` to `'base64'` when calling this method */
37
+ sendTransaction(
38
+ base64EncodedWireTransaction: Base64EncodedWireTransaction,
39
+ config?: SendTransactionConfig & { encoding?: 'base58' },
40
+ ): SendTransactionResponse;
41
+ /**
42
+ * Submits a signed transaction to the cluster for processing.
43
+ *
44
+ * This method does not alter the transaction in any way; it relays the transaction created by
45
+ * clients to the node as-is.
46
+ *
47
+ * If the node's RPC service receives the transaction, this method immediately succeeds, without
48
+ * waiting for any confirmations. A successful response from this method does not guarantee the
49
+ * transaction will be processed or confirmed by the cluster.
50
+ *
51
+ * While the RPC service will reasonably retry to submit it, the transaction could fail to be
52
+ * committed if the transaction's lifetime specifier (ie. its recent blockhash or nonce) expires
53
+ * before it lands.
54
+ *
55
+ * Use {@link GetSignatureStatusesApi.getSignatureStatuses} to ensure that a transaction has
56
+ * been processed and confirmed.
57
+ *
58
+ * Before submitting, the following preflight checks are performed:
59
+ *
60
+ * 1. The transaction signatures are verified
61
+ * 2. The transaction is simulated against the bank slot specified by the preflight
62
+ * commitment. On failure, an error will be returned. It is recommended to specify the
63
+ * same commitment and preflight commitment to avoid confusing behavior. You can disable
64
+ * preflight checks if desired.
65
+ *
66
+ * @param base64EncodedWireTransaction A fully signed transaction in wire format, as a base-64
67
+ * encoded string. Use {@link getBase64EncodedWireTransaction} to obtain this.
68
+ *
69
+ * @returns The signature of the transaction, as a base-58 encoded string. This is the first
70
+ * signature in the transaction, which is used to uniquely identify it. You do not have to wait
71
+ * for this method to return to obtain the signature; you can extract it from the transaction
72
+ * before sending it.
73
+ *
74
+ * @see https://solana.com/docs/rpc/http/sendtransaction
75
+ */
76
+ sendTransaction(
77
+ base64EncodedWireTransaction: Base64EncodedWireTransaction,
78
+ config?: SendTransactionConfig & { encoding: 'base64' },
79
+ ): SendTransactionResponse;
80
+ };