@solana/plugin-interfaces 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 CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@solana/plugin-interfaces",
3
- "version": "6.3.1",
3
+ "version": "6.3.2-canary-20260313112147",
4
4
  "description": "TypeScript interfaces for building pluggable Solana clients",
5
5
  "homepage": "https://www.solanakit.com/api#solanaplugin-interfaces",
6
6
  "types": "./dist/types/index.d.ts",
7
7
  "type": "commonjs",
8
8
  "files": [
9
- "./dist/"
9
+ "./dist/",
10
+ "./src/"
10
11
  ],
11
12
  "sideEffects": false,
12
13
  "keywords": [
@@ -28,13 +29,13 @@
28
29
  "maintained node versions"
29
30
  ],
30
31
  "dependencies": {
31
- "@solana/instruction-plans": "6.3.1",
32
- "@solana/keys": "6.3.1",
33
- "@solana/addresses": "6.3.1",
34
- "@solana/rpc-spec": "6.3.1",
35
- "@solana/rpc-subscriptions-spec": "6.3.1",
36
- "@solana/rpc-types": "6.3.1",
37
- "@solana/signers": "6.3.1"
32
+ "@solana/addresses": "6.3.2-canary-20260313112147",
33
+ "@solana/keys": "6.3.2-canary-20260313112147",
34
+ "@solana/rpc-spec": "6.3.2-canary-20260313112147",
35
+ "@solana/instruction-plans": "6.3.2-canary-20260313112147",
36
+ "@solana/rpc-subscriptions-spec": "6.3.2-canary-20260313112147",
37
+ "@solana/rpc-types": "6.3.2-canary-20260313112147",
38
+ "@solana/signers": "6.3.2-canary-20260313112147"
38
39
  },
39
40
  "peerDependencies": {
40
41
  "typescript": "^5.0.0"
package/src/airdrop.ts ADDED
@@ -0,0 +1,34 @@
1
+ import { Address } from '@solana/addresses';
2
+ import { Signature } from '@solana/keys';
3
+ import { Lamports } from '@solana/rpc-types';
4
+
5
+ /**
6
+ * Represents a client that can request airdrops of SOL to a specified address.
7
+ *
8
+ * The airdrop capability is typically available on test networks (devnet, testnet)
9
+ * and local validators. It allows funding accounts with SOL for testing purposes.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * async function fundAccount(client: ClientWithAirdrop, address: Address) {
14
+ * const signature = await client.airdrop(address, lamports(1_000_000_000n));
15
+ * console.log(`Airdrop confirmed: ${signature ?? '[no signature]'}`);
16
+ * }
17
+ * ```
18
+ */
19
+ export type ClientWithAirdrop = {
20
+ /**
21
+ * Requests an airdrop of SOL to the specified address.
22
+ *
23
+ * The returned promise resolves when the airdrop succeeds and rejects on failure.
24
+ * Some implementations (e.g., LiteSVM) update account balances directly without
25
+ * sending a transaction, in which case no signature is returned.
26
+ *
27
+ * @param address - The address to receive the airdrop.
28
+ * @param amount - The amount of lamports to airdrop.
29
+ * @param abortSignal - An optional signal to abort the airdrop request.
30
+ * @returns A promise resolving to the transaction signature if the airdrop was
31
+ * performed via a transaction, or `undefined` if no transaction was used.
32
+ */
33
+ airdrop: (address: Address, amount: Lamports, abortSignal?: AbortSignal) => Promise<Signature | undefined>;
34
+ };
package/src/index.ts ADDED
@@ -0,0 +1,11 @@
1
+ /**
2
+ * This package defines common TypeScript interfaces for features that Kit plugins
3
+ * can provide or require. It can be used standalone, but it is also exported as part
4
+ * of Kit [`@solana/kit`](https://github.com/anza-xyz/kit/tree/main/packages/kit).
5
+ *
6
+ * @packageDocumentation
7
+ */
8
+ export * from './airdrop';
9
+ export * from './instruction-plans';
10
+ export * from './payer';
11
+ export * from './rpc';
@@ -0,0 +1,118 @@
1
+ import type {
2
+ InstructionPlanInput,
3
+ SingleTransactionPlan,
4
+ SuccessfulSingleTransactionPlanResult,
5
+ TransactionPlan,
6
+ TransactionPlanInput,
7
+ TransactionPlanResult,
8
+ } from '@solana/instruction-plans';
9
+
10
+ type Config = { abortSignal?: AbortSignal };
11
+
12
+ /**
13
+ * Represents a client that can plan transactions from instruction inputs.
14
+ *
15
+ * Transaction planning converts high-level instruction plans into concrete
16
+ * transaction messages, handling concerns like blockhash fetching, transaction
17
+ * splitting for size limits, and instruction ordering.
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * async function prepareTransfer(client: ClientWithTransactionPlanning) {
22
+ * const instructions = [createTransferInstruction(...)];
23
+ *
24
+ * // Plan a single transaction
25
+ * const message = await client.planTransaction(instructions);
26
+ *
27
+ * // Or plan potentially multiple transactions if needed
28
+ * const plan = await client.planTransactions(instructions);
29
+ * }
30
+ * ```
31
+ */
32
+ export type ClientWithTransactionPlanning = {
33
+ /**
34
+ * Plans a single transaction from the given instruction input.
35
+ *
36
+ * Use this when you expect all instructions to fit in a single transaction.
37
+ *
38
+ * @param input - The instruction plan input (instructions or instruction plans).
39
+ * @param config - Optional configuration including an abort signal.
40
+ * @returns A promise resolving to the planned transaction message.
41
+ *
42
+ * @see {@link InstructionPlanInput}
43
+ */
44
+ planTransaction: (input: InstructionPlanInput, config?: Config) => Promise<SingleTransactionPlan['message']>;
45
+
46
+ /**
47
+ * Plans one or more transactions from the given instruction input.
48
+ *
49
+ * Use this when instructions might need to be split across multiple
50
+ * transactions due to size limits.
51
+ *
52
+ * @param input - The instruction plan input (instructions or instruction plans).
53
+ * @param config - Optional configuration including an abort signal.
54
+ * @returns A promise resolving to the full transaction plan.
55
+ *
56
+ * @see {@link InstructionPlanInput}
57
+ */
58
+ planTransactions: (input: InstructionPlanInput, config?: Config) => Promise<TransactionPlan>;
59
+ };
60
+
61
+ /**
62
+ * Represents a client that can send transactions to the Solana network.
63
+ *
64
+ * Transaction sending handles signing, submission, and confirmation of
65
+ * transactions. It supports flexible input formats including instructions,
66
+ * instruction plans, transaction messages or transaction plans.
67
+ *
68
+ * @example
69
+ * ```ts
70
+ * async function executeTransfer(client: ClientWithTransactionSending) {
71
+ * const instructions = [createTransferInstruction(...)];
72
+ *
73
+ * // Send a single transaction
74
+ * const result = await client.sendTransaction(instructions);
75
+ * console.log(`Transaction confirmed: ${result.context.signature}`);
76
+ *
77
+ * // Or send potentially multiple transactions
78
+ * const results = await client.sendTransactions(instructions);
79
+ * }
80
+ * ```
81
+ */
82
+ export type ClientWithTransactionSending = {
83
+ /**
84
+ * Sends a single transaction to the network.
85
+ *
86
+ * Accepts flexible input: instructions, instruction plans, a single
87
+ * transaction message or a single transaction plan.
88
+ *
89
+ * @param input - Instructions, a transaction plan, or a transaction message.
90
+ * @param config - Optional configuration including an abort signal.
91
+ * @returns A promise resolving to the successful transaction result.
92
+ *
93
+ * @see {@link InstructionPlanInput}
94
+ * @see {@link SingleTransactionPlan}
95
+ */
96
+ sendTransaction: (
97
+ input: InstructionPlanInput | SingleTransactionPlan | SingleTransactionPlan['message'],
98
+ config?: Config,
99
+ ) => Promise<SuccessfulSingleTransactionPlanResult>;
100
+
101
+ /**
102
+ * Sends one or more transactions to the network.
103
+ *
104
+ * Accepts flexible input: instructions, instruction plans, transaction messages
105
+ * or transaction plans.
106
+ *
107
+ * @param input - Any instruction or a transaction plan input.
108
+ * @param config - Optional configuration including an abort signal.
109
+ * @returns A promise resolving to the results for all transactions.
110
+ *
111
+ * @see {@link InstructionPlanInput}
112
+ * @see {@link TransactionPlanInput}
113
+ */
114
+ sendTransactions: (
115
+ input: InstructionPlanInput | TransactionPlanInput,
116
+ config?: Config,
117
+ ) => Promise<TransactionPlanResult>;
118
+ };
package/src/payer.ts ADDED
@@ -0,0 +1,18 @@
1
+ import { TransactionSigner } from '@solana/signers';
2
+
3
+ /**
4
+ * Represents a client that provides a default transaction payer.
5
+ *
6
+ * The payer is a {@link TransactionSigner} used to sign and pay for transactions.
7
+ * Clients implementing this interface can automatically fund transactions
8
+ * without requiring callers to specify a fee payer explicitly.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * function createTransfer(client: ClientWithPayer, recipient: Address, amount: Lamports) {
13
+ * const feePayer = client.payer;
14
+ * // Use feePayer.address as the transaction fee payer
15
+ * }
16
+ * ```
17
+ */
18
+ export type ClientWithPayer = { payer: TransactionSigner };
package/src/rpc.ts ADDED
@@ -0,0 +1,52 @@
1
+ import type { Rpc } from '@solana/rpc-spec';
2
+ import type { RpcSubscriptions } from '@solana/rpc-subscriptions-spec';
3
+
4
+ /**
5
+ * Represents a client that provides access to a Solana RPC endpoint.
6
+ *
7
+ * The RPC interface allows making JSON-RPC calls to a Solana validator,
8
+ * such as fetching account data, sending transactions, and querying blockchain state.
9
+ *
10
+ * @typeParam TRpcMethods - The RPC methods available on this client. Use specific
11
+ * method types from `@solana/rpc-api` for the Solana JSON-RPC API.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * import { SolanaRpcApi } from '@solana/rpc-api';
16
+ *
17
+ * async function getBalance(client: ClientWithRpc<SolanaRpcApi>, address: Address) {
18
+ * const { value: balance } = await client.rpc.getBalance(address).send();
19
+ * return balance;
20
+ * }
21
+ * ```
22
+ */
23
+ export type ClientWithRpc<TRpcMethods> = { rpc: Rpc<TRpcMethods> };
24
+
25
+ /**
26
+ * Represents a client that provides access to Solana RPC subscriptions.
27
+ *
28
+ * RPC subscriptions enable real-time notifications from the Solana validator,
29
+ * such as account changes, slot updates, and transaction confirmations.
30
+ *
31
+ * @typeParam TRpcSubscriptionsMethods - The subscription methods available on this client.
32
+ * Use specific method types from `@solana/rpc-subscriptions-api` for the Solana
33
+ * subscription API.
34
+ *
35
+ * @example
36
+ * ```ts
37
+ * import { SolanaRpcSubscriptionsApi } from '@solana/rpc-subscriptions-api';
38
+ *
39
+ * async function subscribeToAccount(
40
+ * client: ClientWithRpcSubscriptions<SolanaRpcSubscriptionsApi>,
41
+ * address: Address,
42
+ * ) {
43
+ * const subscription = await client.rpcSubscriptions.accountNotifications(address).subscribe();
44
+ * for await (const notification of subscription) {
45
+ * console.log('Account changed:', notification);
46
+ * }
47
+ * }
48
+ * ```
49
+ */
50
+ export type ClientWithRpcSubscriptions<TRpcSubscriptionsMethods> = {
51
+ rpcSubscriptions: RpcSubscriptions<TRpcSubscriptionsMethods>;
52
+ };