@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.
- package/package.json +14 -13
- package/src/getAccountInfo.ts +145 -0
- package/src/getBalance.ts +31 -0
- package/src/getBlock.ts +552 -0
- package/src/getBlockCommitment.ts +20 -0
- package/src/getBlockHeight.ts +29 -0
- package/src/getBlockProduction.ts +83 -0
- package/src/getBlockTime.ts +21 -0
- package/src/getBlocks.ts +34 -0
- package/src/getBlocksWithLimit.ts +33 -0
- package/src/getClusterNodes.ts +49 -0
- package/src/getEpochInfo.ts +43 -0
- package/src/getEpochSchedule.ts +29 -0
- package/src/getFeeForMessage.ts +35 -0
- package/src/getFirstAvailableBlock.ts +17 -0
- package/src/getGenesisHash.ts +13 -0
- package/src/getHealth.ts +17 -0
- package/src/getHighestSnapshotSlot.ts +23 -0
- package/src/getIdentity.ts +14 -0
- package/src/getInflationGovernor.ts +39 -0
- package/src/getInflationRate.ts +21 -0
- package/src/getInflationReward.ts +53 -0
- package/src/getLargestAccounts.ts +42 -0
- package/src/getLatestBlockhash.ts +40 -0
- package/src/getLeaderSchedule.ts +103 -0
- package/src/getMaxRetransmitSlot.ts +12 -0
- package/src/getMaxShredInsertSlot.ts +12 -0
- package/src/getMinimumBalanceForRentExemption.ts +32 -0
- package/src/getMultipleAccounts.ts +156 -0
- package/src/getProgramAccounts.ts +264 -0
- package/src/getRecentPerformanceSamples.ts +29 -0
- package/src/getRecentPrioritizationFees.ts +28 -0
- package/src/getSignatureStatuses.ts +62 -0
- package/src/getSignaturesForAddress.ts +88 -0
- package/src/getSlot.ts +29 -0
- package/src/getSlotLeader.ts +32 -0
- package/src/getSlotLeaders.ts +21 -0
- package/src/getStakeMinimumDelegation.ts +26 -0
- package/src/getSupply.ts +66 -0
- package/src/getTokenAccountBalance.ts +26 -0
- package/src/getTokenAccountsByDelegate.ts +196 -0
- package/src/getTokenAccountsByOwner.ts +190 -0
- package/src/getTokenLargestAccounts.ts +29 -0
- package/src/getTokenSupply.ts +26 -0
- package/src/getTransaction.ts +437 -0
- package/src/getTransactionCount.ts +30 -0
- package/src/getVersion.ts +21 -0
- package/src/getVoteAccounts.ts +80 -0
- package/src/index.ts +353 -0
- package/src/isBlockhashValid.ts +35 -0
- package/src/minimumLedgerSlot.ts +16 -0
- package/src/requestAirdrop.ts +34 -0
- package/src/sendTransaction.ts +80 -0
- package/src/simulateTransaction.ts +727 -0
package/src/getSlot.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Commitment, Slot } from '@solana/rpc-types';
|
|
2
|
+
|
|
3
|
+
type GetSlotApiResponse = Slot;
|
|
4
|
+
|
|
5
|
+
export type GetSlotApi = {
|
|
6
|
+
/**
|
|
7
|
+
* Returns the slot that has reached the given or default commitment level.
|
|
8
|
+
*
|
|
9
|
+
* @see https://solana.com/docs/rpc/http/getslot
|
|
10
|
+
*/
|
|
11
|
+
getSlot(
|
|
12
|
+
config?: Readonly<{
|
|
13
|
+
/**
|
|
14
|
+
* Fetch the highest slot that has reached this level of commitment.
|
|
15
|
+
*
|
|
16
|
+
* @defaultValue Whichever default is applied by the underlying {@link RpcApi} in use.
|
|
17
|
+
* For example, when using an API created by a `createSolanaRpc*()` helper, the default
|
|
18
|
+
* commitment is `"confirmed"` unless configured otherwise. Unmitigated by an API layer
|
|
19
|
+
* on the client, the default commitment applied by the server is `"finalized"`.
|
|
20
|
+
*/
|
|
21
|
+
commitment?: Commitment;
|
|
22
|
+
/**
|
|
23
|
+
* Prevents accessing stale data by enforcing that the RPC node has processed
|
|
24
|
+
* transactions up to this slot
|
|
25
|
+
*/
|
|
26
|
+
minContextSlot?: Slot;
|
|
27
|
+
}>,
|
|
28
|
+
): GetSlotApiResponse;
|
|
29
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Address } from '@solana/addresses';
|
|
2
|
+
import type { Commitment, Slot } from '@solana/rpc-types';
|
|
3
|
+
|
|
4
|
+
type GetSlotLeaderApiResponse = Address;
|
|
5
|
+
|
|
6
|
+
export type GetSlotLeaderApi = {
|
|
7
|
+
/**
|
|
8
|
+
* Returns the current slot leader.
|
|
9
|
+
*
|
|
10
|
+
* @returns The address of the validator that has been granted the opportunity to create the
|
|
11
|
+
* block for the current slot.
|
|
12
|
+
* @see https://solana.com/docs/rpc/http/getslotleader
|
|
13
|
+
*/
|
|
14
|
+
getSlotLeader(
|
|
15
|
+
config?: Readonly<{
|
|
16
|
+
/**
|
|
17
|
+
* Fetch the leader as of the highest slot that has reached this level of commitment.
|
|
18
|
+
*
|
|
19
|
+
* @defaultValue Whichever default is applied by the underlying {@link RpcApi} in use.
|
|
20
|
+
* For example, when using an API created by a `createSolanaRpc*()` helper, the default
|
|
21
|
+
* commitment is `"confirmed"` unless configured otherwise. Unmitigated by an API layer
|
|
22
|
+
* on the client, the default commitment applied by the server is `"finalized"`.
|
|
23
|
+
*/
|
|
24
|
+
commitment?: Commitment;
|
|
25
|
+
/**
|
|
26
|
+
* Prevents accessing stale data by enforcing that the RPC node has processed
|
|
27
|
+
* transactions up to this slot
|
|
28
|
+
*/
|
|
29
|
+
minContextSlot?: Slot;
|
|
30
|
+
}>,
|
|
31
|
+
): GetSlotLeaderApiResponse;
|
|
32
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Address } from '@solana/addresses';
|
|
2
|
+
import type { Slot } from '@solana/rpc-types';
|
|
3
|
+
|
|
4
|
+
/** array of Node identity public keys as base-58 encoded strings */
|
|
5
|
+
type GetSlotLeadersApiResponse = Address[];
|
|
6
|
+
|
|
7
|
+
export type GetSlotLeadersApi = {
|
|
8
|
+
/**
|
|
9
|
+
* Returns the slot leaders for a given slot range.
|
|
10
|
+
*
|
|
11
|
+
* @returns The addresses of the validators that have been granted the opportunity to create the
|
|
12
|
+
* blocks for each slot in the range provided
|
|
13
|
+
* @see https://solana.com/docs/rpc/http/getslotleaders
|
|
14
|
+
*/
|
|
15
|
+
getSlotLeaders(
|
|
16
|
+
/** Start slot, as u64 integer */
|
|
17
|
+
startSlotInclusive: Slot,
|
|
18
|
+
/** Limit (between 1 and 5000) */
|
|
19
|
+
limit: number,
|
|
20
|
+
): GetSlotLeadersApiResponse;
|
|
21
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Commitment, Lamports, SolanaRpcResponse } from '@solana/rpc-types';
|
|
2
|
+
|
|
3
|
+
type GetStakeMinimumDelegationApiResponse = Lamports;
|
|
4
|
+
|
|
5
|
+
export type GetStakeMinimumDelegationApi = {
|
|
6
|
+
/**
|
|
7
|
+
* Returns the minimum amount of stake that can be delegated to a validator, in
|
|
8
|
+
* {@link Lamports}.
|
|
9
|
+
*
|
|
10
|
+
* @see https://solana.com/docs/rpc/http/getstakeminimumdelegation
|
|
11
|
+
*/
|
|
12
|
+
getStakeMinimumDelegation(
|
|
13
|
+
config?: Readonly<{
|
|
14
|
+
/**
|
|
15
|
+
* Fetch the minimum delegation as of the highest slot that has reached this level of
|
|
16
|
+
* commitment.
|
|
17
|
+
*
|
|
18
|
+
* @defaultValue Whichever default is applied by the underlying {@link RpcApi} in use.
|
|
19
|
+
* For example, when using an API created by a `createSolanaRpc*()` helper, the default
|
|
20
|
+
* commitment is `"confirmed"` unless configured otherwise. Unmitigated by an API layer
|
|
21
|
+
* on the client, the default commitment applied by the server is `"finalized"`.
|
|
22
|
+
*/
|
|
23
|
+
commitment?: Commitment;
|
|
24
|
+
}>,
|
|
25
|
+
): SolanaRpcResponse<GetStakeMinimumDelegationApiResponse>;
|
|
26
|
+
};
|
package/src/getSupply.ts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { Address } from '@solana/addresses';
|
|
2
|
+
import type { Commitment, Lamports, SolanaRpcResponse } from '@solana/rpc-types';
|
|
3
|
+
|
|
4
|
+
type GetSupplyConfig = Readonly<{
|
|
5
|
+
/**
|
|
6
|
+
* Fetch the supply as of the highest slot that has reached this level of commitment.
|
|
7
|
+
*
|
|
8
|
+
* @defaultValue Whichever default is applied by the underlying {@link RpcApi} in use. For
|
|
9
|
+
* example, when using an API created by a `createSolanaRpc*()` helper, the default commitment
|
|
10
|
+
* is `"confirmed"` unless configured otherwise. Unmitigated by an API layer on the client, the
|
|
11
|
+
* default commitment applied by the server is `"finalized"`.
|
|
12
|
+
*/
|
|
13
|
+
commitment?: Commitment;
|
|
14
|
+
excludeNonCirculatingAccountsList?: boolean;
|
|
15
|
+
}>;
|
|
16
|
+
|
|
17
|
+
type GetSupplyApiResponseBase = Readonly<{
|
|
18
|
+
/** Circulating supply in {@link Lamports} */
|
|
19
|
+
circulating: Lamports;
|
|
20
|
+
/** Non-circulating supply in {@link Lamports} */
|
|
21
|
+
nonCirculating: Lamports;
|
|
22
|
+
/** Total supply in {@link Lamports} */
|
|
23
|
+
total: Lamports;
|
|
24
|
+
}>;
|
|
25
|
+
|
|
26
|
+
type GetSupplyApiResponseWithNonCirculatingAccounts = GetSupplyApiResponseBase &
|
|
27
|
+
Readonly<{
|
|
28
|
+
/** Addresses of non-circulating accounts */
|
|
29
|
+
nonCirculatingAccounts: Address[];
|
|
30
|
+
}>;
|
|
31
|
+
|
|
32
|
+
type GetSupplyApiResponseWithoutNonCirculatingAccounts = GetSupplyApiResponseBase &
|
|
33
|
+
Readonly<{
|
|
34
|
+
/**
|
|
35
|
+
* An empty array, since the `excludeNonCirculatingAccountsList` argument was not set to
|
|
36
|
+
* `true`.
|
|
37
|
+
*/
|
|
38
|
+
nonCirculatingAccounts: never[];
|
|
39
|
+
}>;
|
|
40
|
+
|
|
41
|
+
export type GetSupplyApi = {
|
|
42
|
+
/**
|
|
43
|
+
* Returns information about the current supply, excluding the list of non-circulating accounts.
|
|
44
|
+
*
|
|
45
|
+
* {@label exclude-non-circulating-accounts}
|
|
46
|
+
* @see https://solana.com/docs/rpc/http/getsupply
|
|
47
|
+
*/
|
|
48
|
+
getSupply(
|
|
49
|
+
config: GetSupplyConfig &
|
|
50
|
+
Readonly<{
|
|
51
|
+
excludeNonCirculatingAccountsList: true;
|
|
52
|
+
}>,
|
|
53
|
+
): SolanaRpcResponse<GetSupplyApiResponseWithoutNonCirculatingAccounts>;
|
|
54
|
+
/**
|
|
55
|
+
* Returns information about the current supply.
|
|
56
|
+
*
|
|
57
|
+
* {@label default}
|
|
58
|
+
* @see https://solana.com/docs/rpc/http/getsupply
|
|
59
|
+
*/
|
|
60
|
+
getSupply(
|
|
61
|
+
config?: GetSupplyConfig &
|
|
62
|
+
Readonly<{
|
|
63
|
+
excludeNonCirculatingAccountsList?: false;
|
|
64
|
+
}>,
|
|
65
|
+
): SolanaRpcResponse<GetSupplyApiResponseWithNonCirculatingAccounts>;
|
|
66
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Address } from '@solana/addresses';
|
|
2
|
+
import type { Commitment, SolanaRpcResponse, TokenAmount } from '@solana/rpc-types';
|
|
3
|
+
|
|
4
|
+
type GetTokenAccountBalanceApiResponse = TokenAmount;
|
|
5
|
+
|
|
6
|
+
export type GetTokenAccountBalanceApi = {
|
|
7
|
+
/**
|
|
8
|
+
* Returns the balance of an SPL Token account.
|
|
9
|
+
*
|
|
10
|
+
* @see https://solana.com/docs/rpc/http/gettokenaccountbalance
|
|
11
|
+
*/
|
|
12
|
+
getTokenAccountBalance(
|
|
13
|
+
address: Address,
|
|
14
|
+
config?: Readonly<{
|
|
15
|
+
/**
|
|
16
|
+
* Fetch the balance as of the highest slot that has reached this level of commitment.
|
|
17
|
+
*
|
|
18
|
+
* @defaultValue Whichever default is applied by the underlying {@link RpcApi} in use.
|
|
19
|
+
* For example, when using an API created by a `createSolanaRpc*()` helper, the default
|
|
20
|
+
* commitment is `"confirmed"` unless configured otherwise. Unmitigated by an API layer
|
|
21
|
+
* on the client, the default commitment applied by the server is `"finalized"`.
|
|
22
|
+
*/
|
|
23
|
+
commitment?: Commitment;
|
|
24
|
+
}>,
|
|
25
|
+
): SolanaRpcResponse<GetTokenAccountBalanceApiResponse>;
|
|
26
|
+
};
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import type { Address } from '@solana/addresses';
|
|
2
|
+
import type { JsonParsedTokenAccount } from '@solana/rpc-parsed-types';
|
|
3
|
+
import type {
|
|
4
|
+
AccountInfoBase,
|
|
5
|
+
AccountInfoWithBase58Bytes,
|
|
6
|
+
AccountInfoWithBase58EncodedData,
|
|
7
|
+
AccountInfoWithBase64EncodedData,
|
|
8
|
+
AccountInfoWithBase64EncodedZStdCompressedData,
|
|
9
|
+
AccountInfoWithPubkey,
|
|
10
|
+
Commitment,
|
|
11
|
+
DataSlice,
|
|
12
|
+
Slot,
|
|
13
|
+
SolanaRpcResponse,
|
|
14
|
+
} from '@solana/rpc-types';
|
|
15
|
+
|
|
16
|
+
type TokenAccountInfoWithJsonData = Readonly<{
|
|
17
|
+
data: Readonly<{
|
|
18
|
+
parsed: {
|
|
19
|
+
info: JsonParsedTokenAccount;
|
|
20
|
+
type: 'account';
|
|
21
|
+
};
|
|
22
|
+
/** Name of the program that owns this account. */
|
|
23
|
+
program: Address;
|
|
24
|
+
space: bigint;
|
|
25
|
+
}>;
|
|
26
|
+
}>;
|
|
27
|
+
|
|
28
|
+
type GetTokenAccountsByDelegateResponse<T> = readonly AccountInfoWithPubkey<AccountInfoBase & T>[];
|
|
29
|
+
|
|
30
|
+
type MintFilter = Readonly<{
|
|
31
|
+
/** This filter matches when the token account's mint is equal to the address supplied. */
|
|
32
|
+
mint: Address;
|
|
33
|
+
}>;
|
|
34
|
+
|
|
35
|
+
type ProgramIdFilter = Readonly<{
|
|
36
|
+
/**
|
|
37
|
+
* This filter matches when the token account's token program address is equal to the address
|
|
38
|
+
* supplied.
|
|
39
|
+
*/
|
|
40
|
+
programId: Address;
|
|
41
|
+
}>;
|
|
42
|
+
|
|
43
|
+
type AccountsFilter = MintFilter | ProgramIdFilter;
|
|
44
|
+
|
|
45
|
+
type GetTokenAccountsByDelegateApiCommonConfig = Readonly<{
|
|
46
|
+
/**
|
|
47
|
+
* Fetch the details of the accounts as of the highest slot that has reached this level of
|
|
48
|
+
* commitment.
|
|
49
|
+
*
|
|
50
|
+
* @defaultValue Whichever default is applied by the underlying {@link RpcApi} in use. For
|
|
51
|
+
* example, when using an API created by a `createSolanaRpc*()` helper, the default commitment
|
|
52
|
+
* is `"confirmed"` unless configured otherwise. Unmitigated by an API layer on the client, the
|
|
53
|
+
* default commitment applied by the server is `"finalized"`.
|
|
54
|
+
*/
|
|
55
|
+
commitment?: Commitment;
|
|
56
|
+
/**
|
|
57
|
+
* Determines how the accounts' data should be encoded in the response.
|
|
58
|
+
*
|
|
59
|
+
* - `'base58'` returns a tuple whose first element is the data as a base58-encoded string. If
|
|
60
|
+
* the account contains more than 129 bytes of data, an error will be raised.
|
|
61
|
+
* - `'base64'` returns a tuple whose first element is the data as a base64-encoded string.
|
|
62
|
+
* - `'base64+zstd'` returns a tuple whose first element is the
|
|
63
|
+
* [ZStandard](https://facebook.github.io/zstd/)-compressed data as a base64-encoded string.
|
|
64
|
+
* - `'jsonParsed'` will cause the server to attempt to process the data using a parser specific
|
|
65
|
+
* to each account's owning program. If successful, the parsed data will be returned in the
|
|
66
|
+
* response as JSON. Otherwise, the raw account data will be returned in the response as a
|
|
67
|
+
* tuple whose first element is a base64-encoded string.
|
|
68
|
+
*/
|
|
69
|
+
encoding?: 'base58' | 'base64' | 'base64+zstd' | 'jsonParsed';
|
|
70
|
+
/**
|
|
71
|
+
* Prevents accessing stale data by enforcing that the RPC node has processed transactions up to
|
|
72
|
+
* this slot
|
|
73
|
+
*/
|
|
74
|
+
minContextSlot?: Slot;
|
|
75
|
+
}>;
|
|
76
|
+
|
|
77
|
+
type GetTokenAccountsByDelegateApiSliceableCommonConfig = Readonly<{
|
|
78
|
+
/**
|
|
79
|
+
* Define which slice of the accounts' data you want the RPC to return.
|
|
80
|
+
*
|
|
81
|
+
* Use this to save network bandwidth and encoding time when you do not need the entire buffer.
|
|
82
|
+
*
|
|
83
|
+
* Data slicing is only available for `"base58"`, `"base64"`, and `"base64+zstd"` encodings.
|
|
84
|
+
*/
|
|
85
|
+
dataSlice?: DataSlice;
|
|
86
|
+
}>;
|
|
87
|
+
|
|
88
|
+
export type GetTokenAccountsByDelegateApi = {
|
|
89
|
+
/**
|
|
90
|
+
* Returns all SPL Token accounts for which transfer authority over some quantity of tokens has
|
|
91
|
+
* been delegated to the supplied address.
|
|
92
|
+
*
|
|
93
|
+
* The accounts' data will be returned in the response as a tuple whose first element is a
|
|
94
|
+
* base64-encoded string.
|
|
95
|
+
*
|
|
96
|
+
* @param filter Limits the results to either token accounts associated with a particular mint,
|
|
97
|
+
* or token accounts owned by a certain token program.
|
|
98
|
+
*
|
|
99
|
+
* {@label base64}
|
|
100
|
+
* @see https://solana.com/docs/rpc/http/gettokenaccountsbydelegate
|
|
101
|
+
*/
|
|
102
|
+
getTokenAccountsByDelegate(
|
|
103
|
+
delegate: Address,
|
|
104
|
+
filter: AccountsFilter,
|
|
105
|
+
config: GetTokenAccountsByDelegateApiCommonConfig &
|
|
106
|
+
GetTokenAccountsByDelegateApiSliceableCommonConfig &
|
|
107
|
+
Readonly<{
|
|
108
|
+
encoding: 'base64';
|
|
109
|
+
}>,
|
|
110
|
+
): SolanaRpcResponse<GetTokenAccountsByDelegateResponse<AccountInfoWithBase64EncodedData>>;
|
|
111
|
+
/**
|
|
112
|
+
* Returns all SPL Token accounts for which transfer authority over some quantity of tokens has
|
|
113
|
+
* been delegated to the supplied address.
|
|
114
|
+
*
|
|
115
|
+
* The accounts' data will first be compressed using
|
|
116
|
+
* [ZStandard](https://facebook.github.io/zstd/) and the result will be returned in the response
|
|
117
|
+
* as a tuple whose first element is a base64-encoded string.
|
|
118
|
+
*
|
|
119
|
+
* @param filter Limits the results to either token accounts associated with a particular mint,
|
|
120
|
+
* or token accounts owned by a certain token program.
|
|
121
|
+
*
|
|
122
|
+
* {@label base64-zstd-compressed}
|
|
123
|
+
* @see https://solana.com/docs/rpc/http/gettokenaccountsbydelegate
|
|
124
|
+
*/
|
|
125
|
+
getTokenAccountsByDelegate(
|
|
126
|
+
delegate: Address,
|
|
127
|
+
filter: AccountsFilter,
|
|
128
|
+
config: GetTokenAccountsByDelegateApiCommonConfig &
|
|
129
|
+
GetTokenAccountsByDelegateApiSliceableCommonConfig &
|
|
130
|
+
Readonly<{
|
|
131
|
+
encoding: 'base64+zstd';
|
|
132
|
+
}>,
|
|
133
|
+
): SolanaRpcResponse<GetTokenAccountsByDelegateResponse<AccountInfoWithBase64EncodedZStdCompressedData>>;
|
|
134
|
+
/**
|
|
135
|
+
* Returns all SPL Token accounts for which transfer authority over some quantity of tokens has
|
|
136
|
+
* been delegated to the supplied address.
|
|
137
|
+
*
|
|
138
|
+
* The server will attempt to process the accounts' data using a parser specific to each
|
|
139
|
+
* account's owning token program.
|
|
140
|
+
*
|
|
141
|
+
* @param filter Limits the results to either token accounts associated with a particular mint,
|
|
142
|
+
* or token accounts owned by a certain token program.
|
|
143
|
+
*
|
|
144
|
+
* {@label parsed}
|
|
145
|
+
* @see https://solana.com/docs/rpc/http/gettokenaccountsbydelegate
|
|
146
|
+
*/
|
|
147
|
+
getTokenAccountsByDelegate(
|
|
148
|
+
delegate: Address,
|
|
149
|
+
filter: AccountsFilter,
|
|
150
|
+
config: GetTokenAccountsByDelegateApiCommonConfig &
|
|
151
|
+
Readonly<{
|
|
152
|
+
encoding: 'jsonParsed';
|
|
153
|
+
}>,
|
|
154
|
+
): SolanaRpcResponse<GetTokenAccountsByDelegateResponse<TokenAccountInfoWithJsonData>>;
|
|
155
|
+
/**
|
|
156
|
+
* Returns all SPL Token accounts for which transfer authority over some quantity of tokens has
|
|
157
|
+
* been delegated to the supplied address.
|
|
158
|
+
*
|
|
159
|
+
* The accounts' data will be returned in the response as a tuple whose first element is a
|
|
160
|
+
* base58-encoded string. If any account contains more than 129 bytes of data, this method will
|
|
161
|
+
* raise an error.
|
|
162
|
+
*
|
|
163
|
+
* @param filter Limits the results to either token accounts associated with a particular mint,
|
|
164
|
+
* or token accounts owned by a certain token program.
|
|
165
|
+
*
|
|
166
|
+
* {@label base58}
|
|
167
|
+
* @see https://solana.com/docs/rpc/http/gettokenaccountsbydelegate
|
|
168
|
+
*/
|
|
169
|
+
getTokenAccountsByDelegate(
|
|
170
|
+
delegate: Address,
|
|
171
|
+
filter: AccountsFilter,
|
|
172
|
+
config: GetTokenAccountsByDelegateApiCommonConfig &
|
|
173
|
+
GetTokenAccountsByDelegateApiSliceableCommonConfig &
|
|
174
|
+
Readonly<{
|
|
175
|
+
encoding: 'base58';
|
|
176
|
+
}>,
|
|
177
|
+
): SolanaRpcResponse<GetTokenAccountsByDelegateResponse<AccountInfoWithBase58EncodedData>>;
|
|
178
|
+
/**
|
|
179
|
+
* Returns all SPL Token accounts for which transfer authority over some quantity of tokens has
|
|
180
|
+
* been delegated to the supplied address.
|
|
181
|
+
*
|
|
182
|
+
* The accounts' data will be returned in the response as a base58-encoded string. If any
|
|
183
|
+
* account contains more than 129 bytes of data, this method will raise an error.
|
|
184
|
+
*
|
|
185
|
+
* @param filter Limits the results to either token accounts associated with a particular mint,
|
|
186
|
+
* or token accounts owned by a certain token program.
|
|
187
|
+
*
|
|
188
|
+
* {@label base58-legacy}
|
|
189
|
+
* @see https://solana.com/docs/rpc/http/gettokenaccountsbydelegate
|
|
190
|
+
*/
|
|
191
|
+
getTokenAccountsByDelegate(
|
|
192
|
+
delegate: Address,
|
|
193
|
+
filter: AccountsFilter,
|
|
194
|
+
config?: GetTokenAccountsByDelegateApiCommonConfig & GetTokenAccountsByDelegateApiSliceableCommonConfig,
|
|
195
|
+
): SolanaRpcResponse<GetTokenAccountsByDelegateResponse<AccountInfoWithBase58Bytes>>;
|
|
196
|
+
};
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import type { Address } from '@solana/addresses';
|
|
2
|
+
import type { JsonParsedTokenAccount } from '@solana/rpc-parsed-types';
|
|
3
|
+
import type {
|
|
4
|
+
AccountInfoBase,
|
|
5
|
+
AccountInfoWithBase58Bytes,
|
|
6
|
+
AccountInfoWithBase58EncodedData,
|
|
7
|
+
AccountInfoWithBase64EncodedData,
|
|
8
|
+
AccountInfoWithBase64EncodedZStdCompressedData,
|
|
9
|
+
AccountInfoWithPubkey,
|
|
10
|
+
Commitment,
|
|
11
|
+
DataSlice,
|
|
12
|
+
Slot,
|
|
13
|
+
SolanaRpcResponse,
|
|
14
|
+
} from '@solana/rpc-types';
|
|
15
|
+
|
|
16
|
+
type TokenAccountInfoWithJsonData = Readonly<{
|
|
17
|
+
data: Readonly<{
|
|
18
|
+
parsed: {
|
|
19
|
+
info: JsonParsedTokenAccount;
|
|
20
|
+
type: 'account';
|
|
21
|
+
};
|
|
22
|
+
/** Name of the program that owns this account. */
|
|
23
|
+
program: Address;
|
|
24
|
+
space: bigint;
|
|
25
|
+
}>;
|
|
26
|
+
}>;
|
|
27
|
+
|
|
28
|
+
type GetTokenAccountsByOwnerResponse<T> = readonly AccountInfoWithPubkey<AccountInfoBase & T>[];
|
|
29
|
+
|
|
30
|
+
type MintFilter = Readonly<{
|
|
31
|
+
/** This filter matches when the token account's mint is equal to the address supplied. */
|
|
32
|
+
mint: Address;
|
|
33
|
+
}>;
|
|
34
|
+
|
|
35
|
+
type ProgramIdFilter = Readonly<{
|
|
36
|
+
/**
|
|
37
|
+
* This filter matches when the token account's token program address is equal to the address
|
|
38
|
+
* supplied.
|
|
39
|
+
*/
|
|
40
|
+
programId: Address;
|
|
41
|
+
}>;
|
|
42
|
+
|
|
43
|
+
type AccountsFilter = MintFilter | ProgramIdFilter;
|
|
44
|
+
|
|
45
|
+
type GetTokenAccountsByOwnerApiCommonConfig = Readonly<{
|
|
46
|
+
/**
|
|
47
|
+
* Fetch the details of the accounts as of the highest slot that has reached this level of
|
|
48
|
+
* commitment.
|
|
49
|
+
*
|
|
50
|
+
* @defaultValue Whichever default is applied by the underlying {@link RpcApi} in use. For
|
|
51
|
+
* example, when using an API created by a `createSolanaRpc*()` helper, the default commitment
|
|
52
|
+
* is `"confirmed"` unless configured otherwise. Unmitigated by an API layer on the client, the
|
|
53
|
+
* default commitment applied by the server is `"finalized"`.
|
|
54
|
+
*/
|
|
55
|
+
commitment?: Commitment;
|
|
56
|
+
/**
|
|
57
|
+
* Determines how the accounts' data should be encoded in the response.
|
|
58
|
+
*
|
|
59
|
+
* - `'base58'` returns a tuple whose first element is the data as a base58-encoded string. If
|
|
60
|
+
* the account contains more than 129 bytes of data, an error will be raised.
|
|
61
|
+
* - `'base64'` returns a tuple whose first element is the data as a base64-encoded string.
|
|
62
|
+
* - `'base64+zstd'` returns a tuple whose first element is the
|
|
63
|
+
* [ZStandard](https://facebook.github.io/zstd/)-compressed data as a base64-encoded string.
|
|
64
|
+
* - `'jsonParsed'` will cause the server to attempt to process the data using a parser specific
|
|
65
|
+
* to each account's owning program. If successful, the parsed data will be returned in the
|
|
66
|
+
* response as JSON. Otherwise, the raw account data will be returned in the response as a
|
|
67
|
+
* tuple whose first element is a base64-encoded string.
|
|
68
|
+
*/
|
|
69
|
+
encoding?: 'base58' | 'base64' | 'base64+zstd' | 'jsonParsed';
|
|
70
|
+
/**
|
|
71
|
+
* Prevents accessing stale data by enforcing that the RPC node has processed transactions up to
|
|
72
|
+
* this slot
|
|
73
|
+
*/
|
|
74
|
+
minContextSlot?: Slot;
|
|
75
|
+
}>;
|
|
76
|
+
|
|
77
|
+
type GetTokenAccountsByOwnerApiSliceableCommonConfig = Readonly<{
|
|
78
|
+
/**
|
|
79
|
+
* Define which slice of the accounts' data you want the RPC to return.
|
|
80
|
+
*
|
|
81
|
+
* Use this to save network bandwidth and encoding time when you do not need the entire buffer.
|
|
82
|
+
*
|
|
83
|
+
* Data slicing is only available for `"base58"`, `"base64"`, and `"base64+zstd"` encodings.
|
|
84
|
+
*/
|
|
85
|
+
dataSlice?: DataSlice;
|
|
86
|
+
}>;
|
|
87
|
+
export type GetTokenAccountsByOwnerApi = {
|
|
88
|
+
/**
|
|
89
|
+
* Returns all SPL Token accounts owned by the supplied address.
|
|
90
|
+
*
|
|
91
|
+
* The accounts' data will be returned in the response as a tuple whose first element is a
|
|
92
|
+
* base64-encoded string.
|
|
93
|
+
*
|
|
94
|
+
* @param filter Limits the results to either token accounts associated with a particular mint,
|
|
95
|
+
* or token accounts owned by a certain token program.
|
|
96
|
+
*
|
|
97
|
+
* {@label base64}
|
|
98
|
+
* @see https://solana.com/docs/rpc/http/gettokenaccountsbyowner
|
|
99
|
+
*/
|
|
100
|
+
getTokenAccountsByOwner(
|
|
101
|
+
owner: Address,
|
|
102
|
+
filter: AccountsFilter,
|
|
103
|
+
config: GetTokenAccountsByOwnerApiCommonConfig &
|
|
104
|
+
GetTokenAccountsByOwnerApiSliceableCommonConfig &
|
|
105
|
+
Readonly<{
|
|
106
|
+
encoding: 'base64';
|
|
107
|
+
}>,
|
|
108
|
+
): SolanaRpcResponse<GetTokenAccountsByOwnerResponse<AccountInfoWithBase64EncodedData>>;
|
|
109
|
+
/**
|
|
110
|
+
* Returns all SPL Token accounts owned by the supplied address.
|
|
111
|
+
*
|
|
112
|
+
* The accounts' data will first be compressed using
|
|
113
|
+
* [ZStandard](https://facebook.github.io/zstd/) and the result will be returned in the response
|
|
114
|
+
* as a tuple whose first element is a base64-encoded string.
|
|
115
|
+
*
|
|
116
|
+
* @param filter Limits the results to either token accounts associated with a particular mint,
|
|
117
|
+
* or token accounts owned by a certain token program.
|
|
118
|
+
*
|
|
119
|
+
* {@label base64-zstd-compressed}
|
|
120
|
+
* @see https://solana.com/docs/rpc/http/gettokenaccountsbyowner
|
|
121
|
+
*/
|
|
122
|
+
getTokenAccountsByOwner(
|
|
123
|
+
owner: Address,
|
|
124
|
+
filter: AccountsFilter,
|
|
125
|
+
config: GetTokenAccountsByOwnerApiCommonConfig &
|
|
126
|
+
GetTokenAccountsByOwnerApiSliceableCommonConfig &
|
|
127
|
+
Readonly<{
|
|
128
|
+
encoding: 'base64+zstd';
|
|
129
|
+
}>,
|
|
130
|
+
): SolanaRpcResponse<GetTokenAccountsByOwnerResponse<AccountInfoWithBase64EncodedZStdCompressedData>>;
|
|
131
|
+
/**
|
|
132
|
+
* Returns all SPL Token accounts owned by the supplied address.
|
|
133
|
+
*
|
|
134
|
+
* The server will attempt to process the accounts' data using a parser specific to each
|
|
135
|
+
* account's owning token program.
|
|
136
|
+
*
|
|
137
|
+
* @param filter Limits the results to either token accounts associated with a particular mint,
|
|
138
|
+
* or token accounts owned by a certain token program.
|
|
139
|
+
*
|
|
140
|
+
* {@label parsed}
|
|
141
|
+
* @see https://solana.com/docs/rpc/http/gettokenaccountsbyowner
|
|
142
|
+
*/
|
|
143
|
+
getTokenAccountsByOwner(
|
|
144
|
+
owner: Address,
|
|
145
|
+
filter: AccountsFilter,
|
|
146
|
+
config: GetTokenAccountsByOwnerApiCommonConfig &
|
|
147
|
+
Readonly<{
|
|
148
|
+
encoding: 'jsonParsed';
|
|
149
|
+
}>,
|
|
150
|
+
): SolanaRpcResponse<GetTokenAccountsByOwnerResponse<TokenAccountInfoWithJsonData>>;
|
|
151
|
+
/**
|
|
152
|
+
* Returns all SPL Token accounts owned by the supplied address.
|
|
153
|
+
*
|
|
154
|
+
* The accounts' data will be returned in the response as a tuple whose first element is a
|
|
155
|
+
* base58-encoded string. If any account contains more than 129 bytes of data, this method will
|
|
156
|
+
* raise an error.
|
|
157
|
+
*
|
|
158
|
+
* @param filter Limits the results to either token accounts associated with a particular mint,
|
|
159
|
+
* or token accounts owned by a certain token program.
|
|
160
|
+
*
|
|
161
|
+
* {@label base58}
|
|
162
|
+
* @see https://solana.com/docs/rpc/http/gettokenaccountsbyowner
|
|
163
|
+
*/
|
|
164
|
+
getTokenAccountsByOwner(
|
|
165
|
+
owner: Address,
|
|
166
|
+
filter: AccountsFilter,
|
|
167
|
+
config: GetTokenAccountsByOwnerApiCommonConfig &
|
|
168
|
+
GetTokenAccountsByOwnerApiSliceableCommonConfig &
|
|
169
|
+
Readonly<{
|
|
170
|
+
encoding: 'base58';
|
|
171
|
+
}>,
|
|
172
|
+
): SolanaRpcResponse<GetTokenAccountsByOwnerResponse<AccountInfoWithBase58EncodedData>>;
|
|
173
|
+
/**
|
|
174
|
+
* Returns all SPL Token accounts owned by the supplied address.
|
|
175
|
+
*
|
|
176
|
+
* The accounts' data will be returned in the response as a base58-encoded string. If any
|
|
177
|
+
* account contains more than 129 bytes of data, this method will raise an error.
|
|
178
|
+
*
|
|
179
|
+
* @param filter Limits the results to either token accounts associated with a particular mint,
|
|
180
|
+
* or token accounts owned by a certain token program.
|
|
181
|
+
*
|
|
182
|
+
* {@label base58-legacy}
|
|
183
|
+
* @see https://solana.com/docs/rpc/http/gettokenaccountsbyowner
|
|
184
|
+
*/
|
|
185
|
+
getTokenAccountsByOwner(
|
|
186
|
+
owner: Address,
|
|
187
|
+
filter: AccountsFilter,
|
|
188
|
+
config?: GetTokenAccountsByOwnerApiCommonConfig & GetTokenAccountsByOwnerApiSliceableCommonConfig,
|
|
189
|
+
): SolanaRpcResponse<GetTokenAccountsByOwnerResponse<AccountInfoWithBase58Bytes>>;
|
|
190
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Address } from '@solana/addresses';
|
|
2
|
+
import type { Commitment, SolanaRpcResponse, TokenAmount } from '@solana/rpc-types';
|
|
3
|
+
|
|
4
|
+
type TokenLargestAccount = Readonly<{ address: Address }> & TokenAmount;
|
|
5
|
+
|
|
6
|
+
type GetTokenLargestAccountsApiResponse = readonly TokenLargestAccount[];
|
|
7
|
+
|
|
8
|
+
export type GetTokenLargestAccountsApi = {
|
|
9
|
+
/**
|
|
10
|
+
* Returns the 20 largest token accounts whose mint is equal to the address supplied.
|
|
11
|
+
*
|
|
12
|
+
* @see https://solana.com/docs/rpc/http/gettokenlargestaccounts
|
|
13
|
+
*/
|
|
14
|
+
getTokenLargestAccounts(
|
|
15
|
+
tokenMint: Address,
|
|
16
|
+
config?: Readonly<{
|
|
17
|
+
/**
|
|
18
|
+
* Fetch the largest accounts as of the highest slot that has reached this level of
|
|
19
|
+
* commitment.
|
|
20
|
+
*
|
|
21
|
+
* @defaultValue Whichever default is applied by the underlying {@link RpcApi} in use.
|
|
22
|
+
* For example, when using an API created by a `createSolanaRpc*()` helper, the default
|
|
23
|
+
* commitment is `"confirmed"` unless configured otherwise. Unmitigated by an API layer
|
|
24
|
+
* on the client, the default commitment applied by the server is `"finalized"`.
|
|
25
|
+
*/
|
|
26
|
+
commitment?: Commitment;
|
|
27
|
+
}>,
|
|
28
|
+
): SolanaRpcResponse<GetTokenLargestAccountsApiResponse>;
|
|
29
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Address } from '@solana/addresses';
|
|
2
|
+
import type { Commitment, SolanaRpcResponse, TokenAmount } from '@solana/rpc-types';
|
|
3
|
+
|
|
4
|
+
type GetTokenSupplyApiResponse = TokenAmount;
|
|
5
|
+
|
|
6
|
+
export type GetTokenSupplyApi = {
|
|
7
|
+
/**
|
|
8
|
+
* Returns the total supply of the token mint supplied.
|
|
9
|
+
*
|
|
10
|
+
* @see https://solana.com/docs/rpc/http/gettokensupply
|
|
11
|
+
*/
|
|
12
|
+
getTokenSupply(
|
|
13
|
+
tokenMint: Address,
|
|
14
|
+
config?: Readonly<{
|
|
15
|
+
/**
|
|
16
|
+
* Fetch the supply as of the highest slot that has reached this level of commitment.
|
|
17
|
+
*
|
|
18
|
+
* @defaultValue Whichever default is applied by the underlying {@link RpcApi} in use.
|
|
19
|
+
* For example, when using an API created by a `createSolanaRpc*()` helper, the default
|
|
20
|
+
* commitment is `"confirmed"` unless configured otherwise. Unmitigated by an API layer
|
|
21
|
+
* on the client, the default commitment applied by the server is `"finalized"`.
|
|
22
|
+
*/
|
|
23
|
+
commitment?: Commitment;
|
|
24
|
+
}>,
|
|
25
|
+
): SolanaRpcResponse<GetTokenSupplyApiResponse>;
|
|
26
|
+
};
|