@solana/kit-plugins 0.0.0 → 0.2.0
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 +22 -0
- package/README.md +133 -0
- package/dist/index.browser.cjs +63 -0
- package/dist/index.browser.cjs.map +1 -0
- package/dist/index.browser.mjs +34 -0
- package/dist/index.browser.mjs.map +1 -0
- package/dist/index.node.cjs +63 -0
- package/dist/index.node.cjs.map +1 -0
- package/dist/index.node.mjs +34 -0
- package/dist/index.node.mjs.map +1 -0
- package/dist/index.react-native.mjs +34 -0
- package/dist/index.react-native.mjs.map +1 -0
- package/dist/types/defaults.d.ts +153 -0
- package/dist/types/defaults.d.ts.map +1 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.d.ts.map +1 -0
- package/package.json +68 -11
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Anza
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# Kit Plugins ➤ Main Library
|
|
2
|
+
|
|
3
|
+
[![npm][npm-image]][npm-url]
|
|
4
|
+
[![npm-downloads][npm-downloads-image]][npm-url]
|
|
5
|
+
|
|
6
|
+
[npm-downloads-image]: https://img.shields.io/npm/dm/@solana/kit-plugins.svg?style=flat
|
|
7
|
+
[npm-image]: https://img.shields.io/npm/v/@solana/kit-plugins.svg?style=flat&label=%40solana%2Fkit-plugins
|
|
8
|
+
[npm-url]: https://www.npmjs.com/package/@solana/kit-plugins
|
|
9
|
+
|
|
10
|
+
Essential plugins and plugin presets for Solana Kit that provide RPC connectivity, payer management, transaction execution, test environments and more. Choose from three ready-to-use client configurations or build your own.
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```sh
|
|
15
|
+
pnpm install @solana/kit-plugins
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Default Clients
|
|
19
|
+
|
|
20
|
+
This package provides three plugin presets that create ready-to-use Kit clients for different use cases: production, localhost development, and local blockchain simulation.
|
|
21
|
+
|
|
22
|
+
### `createDefaultRpcClient`
|
|
23
|
+
|
|
24
|
+
Pre-configured client for production use with real Solana clusters.
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
import { createDefaultRpcClient } from '@solana/kit-plugins';
|
|
28
|
+
import { generateKeyPairSigner } from '@solana/kit';
|
|
29
|
+
|
|
30
|
+
const payer = await generateKeyPairSigner();
|
|
31
|
+
const client = createDefaultRpcClient({
|
|
32
|
+
url: 'https://api.devnet.solana.com',
|
|
33
|
+
payer,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
await client.send([myInstruction]);
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
#### Features
|
|
40
|
+
|
|
41
|
+
- `client.rpc`: RPC methods for interacting with the Solana cluster.
|
|
42
|
+
- `client.rpcSubscriptions`: Subscription methods for real-time updates.
|
|
43
|
+
- `client.payer`: The main payer signer for transactions.
|
|
44
|
+
- `client.transactionPlanner`: Plans instructions into transaction messages.
|
|
45
|
+
- `client.transactionPlanExecutor`: Executes planned transaction messages.
|
|
46
|
+
- `client.send`: Sends instructions or instruction plans to the cluster by using the client's transaction planner and executor.
|
|
47
|
+
|
|
48
|
+
#### Configuration
|
|
49
|
+
|
|
50
|
+
| Option | Type | Description |
|
|
51
|
+
| ------------------------ | ------------------------ | ---------------------------------------------------------------------------------------------- |
|
|
52
|
+
| `url` (required) | `string` | URL of the Solana RPC endpoint. |
|
|
53
|
+
| `payer` (required) | `TransactionSigner` | Signer used to pay for transaction fees and on-chain account storage. |
|
|
54
|
+
| `rpcSubscriptionsConfig` | `RpcSubscriptionsConfig` | Configuration for RPC subscriptions. Use `rpcSubscriptionsConfig.url` to specify its endpoint. |
|
|
55
|
+
|
|
56
|
+
### `createDefaultLocalhostRpcClient`
|
|
57
|
+
|
|
58
|
+
Pre-configured client for localhost development with automatic payer funding.
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
import { createDefaultLocalhostRpcClient } from '@solana/kit-plugins';
|
|
62
|
+
import { lamports } from '@solana/kit';
|
|
63
|
+
|
|
64
|
+
const client = await createDefaultLocalhostRpcClient();
|
|
65
|
+
|
|
66
|
+
// Payer is automatically generated and funded
|
|
67
|
+
console.log('Payer address:', client.payer.address);
|
|
68
|
+
await client.send([myInstruction]);
|
|
69
|
+
|
|
70
|
+
// Request additional funding
|
|
71
|
+
await client.airdrop(client.payer.address, lamports(5_000_000_000n));
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
#### Features
|
|
75
|
+
|
|
76
|
+
- `client.rpc`: RPC methods for interacting with the local validator (i.e. `http://127.0.0.1:8899`).
|
|
77
|
+
- `client.rpcSubscriptions`: Subscription methods for real-time updates from the local validator (i.e. `ws://127.0.0.1:8900`).
|
|
78
|
+
- `client.payer`: The main payer signer for transactions.
|
|
79
|
+
- `client.airdrop`: Function to request SOL from the local faucet.
|
|
80
|
+
- `client.transactionPlanner`: Plans instructions into transaction messages.
|
|
81
|
+
- `client.transactionPlanExecutor`: Executes planned transaction messages.
|
|
82
|
+
- `client.send`: Sends instructions or instruction plans to the cluster by using the client's transaction planner and executor.
|
|
83
|
+
|
|
84
|
+
#### Configuration
|
|
85
|
+
|
|
86
|
+
| Option | Type | Description |
|
|
87
|
+
| ------- | ------------------- | --------------------------------------------------------------------------------------------------------------- |
|
|
88
|
+
| `payer` | `TransactionSigner` | Signer used to pay for transaction fees and on-chain account storage. Defaults to a generated and funded payer. |
|
|
89
|
+
|
|
90
|
+
### `createDefaultLiteSVMClient`
|
|
91
|
+
|
|
92
|
+
Pre-configured client using LiteSVM for testing without an RPC connection.
|
|
93
|
+
|
|
94
|
+
```ts
|
|
95
|
+
import { createDefaultLiteSVMClient } from '@solana/kit-plugins';
|
|
96
|
+
|
|
97
|
+
const client = await createDefaultLiteSVMClient();
|
|
98
|
+
|
|
99
|
+
// Set up test environment
|
|
100
|
+
client.svm.setAccount(myTestAccount);
|
|
101
|
+
client.svm.addProgramFromFile(myProgramAddress, 'program.so');
|
|
102
|
+
|
|
103
|
+
// Execute transactions locally
|
|
104
|
+
await client.send([myInstruction]);
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
#### Features
|
|
108
|
+
|
|
109
|
+
- `client.svm`: Embedded LiteSVM instance for local blockchain simulation.
|
|
110
|
+
- `client.rpc`: Subset of RPC methods that delegate to the LiteSVM instance.
|
|
111
|
+
- `client.payer`: The main payer signer for transactions.
|
|
112
|
+
- `client.airdrop`: Function to request SOL from the LiteSVM instance.
|
|
113
|
+
- `client.transactionPlanner`: Plans instructions into transaction messages.
|
|
114
|
+
- `client.transactionPlanExecutor`: Executes planned transaction messages.
|
|
115
|
+
- `client.send`: Sends instructions or instruction plans to the cluster by using the client's transaction planner and executor.
|
|
116
|
+
|
|
117
|
+
#### Configuration
|
|
118
|
+
|
|
119
|
+
| Option | Type | Description |
|
|
120
|
+
| ------- | ------------------- | --------------------------------------------------------------------------------------------------------------- |
|
|
121
|
+
| `payer` | `TransactionSigner` | Signer used to pay for transaction fees and on-chain account storage. Defaults to a generated and funded payer. |
|
|
122
|
+
|
|
123
|
+
## Individual Plugins
|
|
124
|
+
|
|
125
|
+
This package includes and re-exports all the individual plugin packages in this monorepo. You can also install and use them separately:
|
|
126
|
+
|
|
127
|
+
| Plugin | Purpose | Package |
|
|
128
|
+
| -------------------- | ---------------------------------- | ----------------------------------------------------------------------- |
|
|
129
|
+
| **RPC** | Connect to Solana clusters | [`@solana/kit-plugin-rpc`](../kit-plugin-rpc) |
|
|
130
|
+
| **Payer** | Manage transaction fee payers | [`@solana/kit-plugin-payer`](../kit-plugin-payer) |
|
|
131
|
+
| **Airdrop** | Request SOL from faucets | [`@solana/kit-plugin-airdrop`](../kit-plugin-airdrop) |
|
|
132
|
+
| **LiteSVM** | Local blockchain simulation | [`@solana/kit-plugin-litesvm`](../kit-plugin-litesvm) |
|
|
133
|
+
| **Instruction Plan** | Transaction planning and execution | [`@solana/kit-plugin-instruction-plan`](../kit-plugin-instruction-plan) |
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var kitPluginAirdrop = require('@solana/kit-plugin-airdrop');
|
|
4
|
+
var kitPluginInstructionPlan = require('@solana/kit-plugin-instruction-plan');
|
|
5
|
+
var kitPluginLitesvm = require('@solana/kit-plugin-litesvm');
|
|
6
|
+
var kitPluginPayer = require('@solana/kit-plugin-payer');
|
|
7
|
+
var kitPluginRpc = require('@solana/kit-plugin-rpc');
|
|
8
|
+
var kit = require('@solana/kit');
|
|
9
|
+
|
|
10
|
+
// src/index.ts
|
|
11
|
+
function createDefaultRpcClient(config) {
|
|
12
|
+
return kit.createEmptyClient().use(kitPluginRpc.rpc(config.url, config.rpcSubscriptionsConfig)).use(kitPluginPayer.payer(config.payer)).use(kitPluginInstructionPlan.defaultTransactionPlannerAndExecutorFromRpc()).use(kitPluginInstructionPlan.sendInstructionPlans());
|
|
13
|
+
}
|
|
14
|
+
function createDefaultLocalhostRpcClient(config = {}) {
|
|
15
|
+
return kit.createEmptyClient().use(kitPluginRpc.localhostRpc()).use(kitPluginAirdrop.airdrop()).use(payerOrGeneratedPayer(config.payer)).use(kitPluginInstructionPlan.defaultTransactionPlannerAndExecutorFromRpc()).use(kitPluginInstructionPlan.sendInstructionPlans());
|
|
16
|
+
}
|
|
17
|
+
function createDefaultLiteSVMClient(config = {}) {
|
|
18
|
+
return kit.createEmptyClient().use(kitPluginLitesvm.litesvm()).use(kitPluginAirdrop.airdrop()).use(payerOrGeneratedPayer(config.payer)).use(kitPluginInstructionPlan.defaultTransactionPlannerAndExecutorFromLitesvm()).use(kitPluginInstructionPlan.sendInstructionPlans());
|
|
19
|
+
}
|
|
20
|
+
function payerOrGeneratedPayer(explicitPayer) {
|
|
21
|
+
return (client) => {
|
|
22
|
+
if (explicitPayer) {
|
|
23
|
+
return Promise.resolve(kitPluginPayer.payer(explicitPayer)(client));
|
|
24
|
+
}
|
|
25
|
+
return kitPluginPayer.generatedPayerWithSol(kit.lamports(100000000000n))(client);
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
exports.createDefaultLiteSVMClient = createDefaultLiteSVMClient;
|
|
30
|
+
exports.createDefaultLocalhostRpcClient = createDefaultLocalhostRpcClient;
|
|
31
|
+
exports.createDefaultRpcClient = createDefaultRpcClient;
|
|
32
|
+
Object.keys(kitPluginAirdrop).forEach(function (k) {
|
|
33
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
34
|
+
enumerable: true,
|
|
35
|
+
get: function () { return kitPluginAirdrop[k]; }
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
Object.keys(kitPluginInstructionPlan).forEach(function (k) {
|
|
39
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
40
|
+
enumerable: true,
|
|
41
|
+
get: function () { return kitPluginInstructionPlan[k]; }
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
Object.keys(kitPluginLitesvm).forEach(function (k) {
|
|
45
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
46
|
+
enumerable: true,
|
|
47
|
+
get: function () { return kitPluginLitesvm[k]; }
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
Object.keys(kitPluginPayer).forEach(function (k) {
|
|
51
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
52
|
+
enumerable: true,
|
|
53
|
+
get: function () { return kitPluginPayer[k]; }
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
Object.keys(kitPluginRpc).forEach(function (k) {
|
|
57
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
58
|
+
enumerable: true,
|
|
59
|
+
get: function () { return kitPluginRpc[k]; }
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
//# sourceMappingURL=index.browser.cjs.map
|
|
63
|
+
//# sourceMappingURL=index.browser.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/defaults.ts"],"names":["createEmptyClient","rpc","payer","defaultTransactionPlannerAndExecutorFromRpc","sendInstructionPlans","localhostRpc","airdrop","litesvm","defaultTransactionPlannerAndExecutorFromLitesvm","generatedPayerWithSol","lamports"],"mappings":";;;;;;;;;;AA0CO,SAAS,uBAAuD,MAAA,EAIpE;AACC,EAAA,OAAOA,qBAAA,GACF,GAAA,CAAIC,gBAAA,CAAiB,OAAO,GAAA,EAAK,MAAA,CAAO,sBAAsB,CAAC,CAAA,CAC/D,GAAA,CAAIC,qBAAM,MAAA,CAAO,KAAK,CAAC,CAAA,CACvB,GAAA,CAAIC,sEAA6C,CAAA,CACjD,GAAA,CAAIC,6CAAA,EAAsB,CAAA;AACnC;AAkCO,SAAS,+BAAA,CAAgC,MAAA,GAAwC,EAAC,EAAG;AACxF,EAAA,OAAOJ,qBAAA,GACF,GAAA,CAAIK,yBAAA,EAAc,CAAA,CAClB,GAAA,CAAIC,wBAAA,EAAS,CAAA,CACb,GAAA,CAAI,sBAAsB,MAAA,CAAO,KAAK,CAAC,CAAA,CACvC,GAAA,CAAIH,sEAA6C,CAAA,CACjD,GAAA,CAAIC,6CAAA,EAAsB,CAAA;AACnC;AAsCO,SAAS,0BAAA,CAA2B,MAAA,GAAwC,EAAC,EAAG;AACnF,EAAA,OAAOJ,qBAAA,GACF,GAAA,CAAIO,wBAAA,EAAS,CAAA,CACb,GAAA,CAAID,wBAAA,EAAS,CAAA,CACb,GAAA,CAAI,sBAAsB,MAAA,CAAO,KAAK,CAAC,CAAA,CACvC,GAAA,CAAIE,0EAAiD,CAAA,CACrD,GAAA,CAAIJ,6CAAA,EAAsB,CAAA;AACnC;AAMA,SAAS,sBAAsB,aAAA,EAA8C;AACzE,EAAA,OAAO,CAAyC,MAAA,KAAyD;AACrG,IAAA,IAAI,aAAA,EAAe;AACf,MAAA,OAAO,QAAQ,OAAA,CAAQF,oBAAA,CAAM,aAAa,CAAA,CAAE,MAAM,CAAC,CAAA;AAAA,IACvD;AACA,IAAA,OAAOO,oCAAA,CAAsBC,YAAA,CAAS,aAAgB,CAAC,EAAE,MAAM,CAAA;AAAA,EACnE,CAAA;AACJ","file":"index.browser.cjs","sourcesContent":["import {\n ClusterUrl,\n createEmptyClient,\n DefaultRpcSubscriptionsChannelConfig,\n lamports,\n TransactionSigner,\n} from '@solana/kit';\nimport { airdrop, AirdropFunction } from '@solana/kit-plugin-airdrop';\nimport {\n defaultTransactionPlannerAndExecutorFromLitesvm,\n defaultTransactionPlannerAndExecutorFromRpc,\n sendInstructionPlans,\n} from '@solana/kit-plugin-instruction-plan';\nimport { litesvm } from '@solana/kit-plugin-litesvm';\nimport { generatedPayerWithSol, payer } from '@solana/kit-plugin-payer';\nimport { localhostRpc, rpc } from '@solana/kit-plugin-rpc';\n\n/**\n * Creates a default RPC client with all essential plugins configured.\n *\n * This function sets up a client with RPC capabilities, payer configuration,\n * transaction planning and execution, and instruction plan sending functionality.\n * It's designed for production use with real Solana clusters.\n *\n * @param config - Configuration object containing the payer, URL, and optional RPC subscriptions config.\n * @returns A fully configured default client ready for transaction operations.\n *\n * @example\n * ```ts\n * import { createDefaultRpcClient } from '@solana/kit-plugins';\n * import { generateKeyPairSigner } from '@solana/kit';\n *\n * const payer = await generateKeyPairSigner();\n * const client = createDefaultRpcClient({\n * url: 'https://api.mainnet-beta.solana.com',\n * payer,\n * });\n *\n * // Use the client\n * const result = await client.send([myInstruction]);\n * ```\n */\nexport function createDefaultRpcClient<TClusterUrl extends ClusterUrl>(config: {\n payer: TransactionSigner;\n rpcSubscriptionsConfig?: DefaultRpcSubscriptionsChannelConfig<TClusterUrl>;\n url: TClusterUrl;\n}) {\n return createEmptyClient()\n .use(rpc<TClusterUrl>(config.url, config.rpcSubscriptionsConfig))\n .use(payer(config.payer))\n .use(defaultTransactionPlannerAndExecutorFromRpc())\n .use(sendInstructionPlans());\n}\n\n/**\n * Creates a default RPC client configured for localhost development.\n *\n * This function sets up a client connected to a local validator with airdrop\n * functionality, automatic payer generation (if not provided), and all essential\n * transaction capabilities. Perfect for local development and testing.\n *\n * @param config - Optional configuration object with an optional payer.\n * @returns A fully configured client ready for localhost development.\n *\n * @example\n * ```ts\n * import { createDefaultLocalhostRpcClient } from '@solana/kit-plugins';\n *\n * // Creates a client with auto-generated and funded payer\n * const client = await createDefaultLocalhostRpcClient();\n *\n * // Use the client\n * const result = await client.send([myInstruction]);\n * console.log('Payer address:', client.payer.address);\n * ```\n *\n * @example\n * Using a custom payer.\n * ```ts\n * import { createDefaultLocalhostRpcClient } from '@solana/kit-plugins';\n * import { generateKeyPairSigner } from '@solana/kit';\n *\n * const customPayer = await generateKeyPairSigner();\n * const client = await createDefaultLocalhostRpcClient({ payer: customPayer });\n * ```\n */\nexport function createDefaultLocalhostRpcClient(config: { payer?: TransactionSigner } = {}) {\n return createEmptyClient()\n .use(localhostRpc())\n .use(airdrop())\n .use(payerOrGeneratedPayer(config.payer))\n .use(defaultTransactionPlannerAndExecutorFromRpc())\n .use(sendInstructionPlans());\n}\n\n/**\n * Creates a default LiteSVM client for local blockchain simulation.\n *\n * This function sets up a client with an embedded LiteSVM instance for fast\n * local blockchain simulation, airdrop functionality, automatic payer generation\n * (if not provided), and all essential transaction capabilities. Ideal for testing\n * and development without requiring a live network connection.\n *\n * @param config - Optional configuration object with an optional payer.\n * @returns A fully configured client ready for local blockchain simulation.\n *\n * @example\n * ```ts\n * import { createDefaultLiteSVMClient } from '@solana/kit-plugins';\n *\n * // Creates a client with auto-generated and funded payer\n * const client = await createDefaultLiteSVMClient();\n *\n * // Set up accounts and programs\n * client.svm.setAccount(myAccount);\n * client.svm.addProgramFromFile(myProgramAddress, 'program.so');\n *\n * // Use the client\n * const result = await client.send([myInstruction]);\n * ```\n *\n * @example\n * Using a custom payer.\n * ```ts\n * import { createDefaultLiteSVMClient } from '@solana/kit-plugins';\n * import { generateKeyPairSigner } from '@solana/kit';\n *\n * const customPayer = await generateKeyPairSigner();\n * const client = await createDefaultLiteSVMClient({ payer: customPayer });\n * ```\n */\nexport function createDefaultLiteSVMClient(config: { payer?: TransactionSigner } = {}) {\n return createEmptyClient()\n .use(litesvm())\n .use(airdrop())\n .use(payerOrGeneratedPayer(config.payer))\n .use(defaultTransactionPlannerAndExecutorFromLitesvm())\n .use(sendInstructionPlans());\n}\n\n/**\n * Helper function that uses the provided payer if any,\n * otherwise generates a new payer and funds it with 100 SOL.\n */\nfunction payerOrGeneratedPayer(explicitPayer: TransactionSigner | undefined) {\n return <T extends { airdrop: AirdropFunction }>(client: T): Promise<T & { payer: TransactionSigner }> => {\n if (explicitPayer) {\n return Promise.resolve(payer(explicitPayer)(client));\n }\n return generatedPayerWithSol(lamports(100_000_000_000n))(client);\n };\n}\n"]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { airdrop } from '@solana/kit-plugin-airdrop';
|
|
2
|
+
export * from '@solana/kit-plugin-airdrop';
|
|
3
|
+
import { defaultTransactionPlannerAndExecutorFromRpc, sendInstructionPlans, defaultTransactionPlannerAndExecutorFromLitesvm } from '@solana/kit-plugin-instruction-plan';
|
|
4
|
+
export * from '@solana/kit-plugin-instruction-plan';
|
|
5
|
+
import { litesvm } from '@solana/kit-plugin-litesvm';
|
|
6
|
+
export * from '@solana/kit-plugin-litesvm';
|
|
7
|
+
import { payer, generatedPayerWithSol } from '@solana/kit-plugin-payer';
|
|
8
|
+
export * from '@solana/kit-plugin-payer';
|
|
9
|
+
import { rpc, localhostRpc } from '@solana/kit-plugin-rpc';
|
|
10
|
+
export * from '@solana/kit-plugin-rpc';
|
|
11
|
+
import { createEmptyClient, lamports } from '@solana/kit';
|
|
12
|
+
|
|
13
|
+
// src/index.ts
|
|
14
|
+
function createDefaultRpcClient(config) {
|
|
15
|
+
return createEmptyClient().use(rpc(config.url, config.rpcSubscriptionsConfig)).use(payer(config.payer)).use(defaultTransactionPlannerAndExecutorFromRpc()).use(sendInstructionPlans());
|
|
16
|
+
}
|
|
17
|
+
function createDefaultLocalhostRpcClient(config = {}) {
|
|
18
|
+
return createEmptyClient().use(localhostRpc()).use(airdrop()).use(payerOrGeneratedPayer(config.payer)).use(defaultTransactionPlannerAndExecutorFromRpc()).use(sendInstructionPlans());
|
|
19
|
+
}
|
|
20
|
+
function createDefaultLiteSVMClient(config = {}) {
|
|
21
|
+
return createEmptyClient().use(litesvm()).use(airdrop()).use(payerOrGeneratedPayer(config.payer)).use(defaultTransactionPlannerAndExecutorFromLitesvm()).use(sendInstructionPlans());
|
|
22
|
+
}
|
|
23
|
+
function payerOrGeneratedPayer(explicitPayer) {
|
|
24
|
+
return (client) => {
|
|
25
|
+
if (explicitPayer) {
|
|
26
|
+
return Promise.resolve(payer(explicitPayer)(client));
|
|
27
|
+
}
|
|
28
|
+
return generatedPayerWithSol(lamports(100000000000n))(client);
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { createDefaultLiteSVMClient, createDefaultLocalhostRpcClient, createDefaultRpcClient };
|
|
33
|
+
//# sourceMappingURL=index.browser.mjs.map
|
|
34
|
+
//# sourceMappingURL=index.browser.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/defaults.ts"],"names":[],"mappings":";;;;;;;;;;;;;AA0CO,SAAS,uBAAuD,MAAA,EAIpE;AACC,EAAA,OAAO,iBAAA,GACF,GAAA,CAAI,GAAA,CAAiB,OAAO,GAAA,EAAK,MAAA,CAAO,sBAAsB,CAAC,CAAA,CAC/D,GAAA,CAAI,MAAM,MAAA,CAAO,KAAK,CAAC,CAAA,CACvB,GAAA,CAAI,6CAA6C,CAAA,CACjD,GAAA,CAAI,oBAAA,EAAsB,CAAA;AACnC;AAkCO,SAAS,+BAAA,CAAgC,MAAA,GAAwC,EAAC,EAAG;AACxF,EAAA,OAAO,iBAAA,GACF,GAAA,CAAI,YAAA,EAAc,CAAA,CAClB,GAAA,CAAI,OAAA,EAAS,CAAA,CACb,GAAA,CAAI,sBAAsB,MAAA,CAAO,KAAK,CAAC,CAAA,CACvC,GAAA,CAAI,6CAA6C,CAAA,CACjD,GAAA,CAAI,oBAAA,EAAsB,CAAA;AACnC;AAsCO,SAAS,0BAAA,CAA2B,MAAA,GAAwC,EAAC,EAAG;AACnF,EAAA,OAAO,iBAAA,GACF,GAAA,CAAI,OAAA,EAAS,CAAA,CACb,GAAA,CAAI,OAAA,EAAS,CAAA,CACb,GAAA,CAAI,sBAAsB,MAAA,CAAO,KAAK,CAAC,CAAA,CACvC,GAAA,CAAI,iDAAiD,CAAA,CACrD,GAAA,CAAI,oBAAA,EAAsB,CAAA;AACnC;AAMA,SAAS,sBAAsB,aAAA,EAA8C;AACzE,EAAA,OAAO,CAAyC,MAAA,KAAyD;AACrG,IAAA,IAAI,aAAA,EAAe;AACf,MAAA,OAAO,QAAQ,OAAA,CAAQ,KAAA,CAAM,aAAa,CAAA,CAAE,MAAM,CAAC,CAAA;AAAA,IACvD;AACA,IAAA,OAAO,qBAAA,CAAsB,QAAA,CAAS,aAAgB,CAAC,EAAE,MAAM,CAAA;AAAA,EACnE,CAAA;AACJ","file":"index.browser.mjs","sourcesContent":["import {\n ClusterUrl,\n createEmptyClient,\n DefaultRpcSubscriptionsChannelConfig,\n lamports,\n TransactionSigner,\n} from '@solana/kit';\nimport { airdrop, AirdropFunction } from '@solana/kit-plugin-airdrop';\nimport {\n defaultTransactionPlannerAndExecutorFromLitesvm,\n defaultTransactionPlannerAndExecutorFromRpc,\n sendInstructionPlans,\n} from '@solana/kit-plugin-instruction-plan';\nimport { litesvm } from '@solana/kit-plugin-litesvm';\nimport { generatedPayerWithSol, payer } from '@solana/kit-plugin-payer';\nimport { localhostRpc, rpc } from '@solana/kit-plugin-rpc';\n\n/**\n * Creates a default RPC client with all essential plugins configured.\n *\n * This function sets up a client with RPC capabilities, payer configuration,\n * transaction planning and execution, and instruction plan sending functionality.\n * It's designed for production use with real Solana clusters.\n *\n * @param config - Configuration object containing the payer, URL, and optional RPC subscriptions config.\n * @returns A fully configured default client ready for transaction operations.\n *\n * @example\n * ```ts\n * import { createDefaultRpcClient } from '@solana/kit-plugins';\n * import { generateKeyPairSigner } from '@solana/kit';\n *\n * const payer = await generateKeyPairSigner();\n * const client = createDefaultRpcClient({\n * url: 'https://api.mainnet-beta.solana.com',\n * payer,\n * });\n *\n * // Use the client\n * const result = await client.send([myInstruction]);\n * ```\n */\nexport function createDefaultRpcClient<TClusterUrl extends ClusterUrl>(config: {\n payer: TransactionSigner;\n rpcSubscriptionsConfig?: DefaultRpcSubscriptionsChannelConfig<TClusterUrl>;\n url: TClusterUrl;\n}) {\n return createEmptyClient()\n .use(rpc<TClusterUrl>(config.url, config.rpcSubscriptionsConfig))\n .use(payer(config.payer))\n .use(defaultTransactionPlannerAndExecutorFromRpc())\n .use(sendInstructionPlans());\n}\n\n/**\n * Creates a default RPC client configured for localhost development.\n *\n * This function sets up a client connected to a local validator with airdrop\n * functionality, automatic payer generation (if not provided), and all essential\n * transaction capabilities. Perfect for local development and testing.\n *\n * @param config - Optional configuration object with an optional payer.\n * @returns A fully configured client ready for localhost development.\n *\n * @example\n * ```ts\n * import { createDefaultLocalhostRpcClient } from '@solana/kit-plugins';\n *\n * // Creates a client with auto-generated and funded payer\n * const client = await createDefaultLocalhostRpcClient();\n *\n * // Use the client\n * const result = await client.send([myInstruction]);\n * console.log('Payer address:', client.payer.address);\n * ```\n *\n * @example\n * Using a custom payer.\n * ```ts\n * import { createDefaultLocalhostRpcClient } from '@solana/kit-plugins';\n * import { generateKeyPairSigner } from '@solana/kit';\n *\n * const customPayer = await generateKeyPairSigner();\n * const client = await createDefaultLocalhostRpcClient({ payer: customPayer });\n * ```\n */\nexport function createDefaultLocalhostRpcClient(config: { payer?: TransactionSigner } = {}) {\n return createEmptyClient()\n .use(localhostRpc())\n .use(airdrop())\n .use(payerOrGeneratedPayer(config.payer))\n .use(defaultTransactionPlannerAndExecutorFromRpc())\n .use(sendInstructionPlans());\n}\n\n/**\n * Creates a default LiteSVM client for local blockchain simulation.\n *\n * This function sets up a client with an embedded LiteSVM instance for fast\n * local blockchain simulation, airdrop functionality, automatic payer generation\n * (if not provided), and all essential transaction capabilities. Ideal for testing\n * and development without requiring a live network connection.\n *\n * @param config - Optional configuration object with an optional payer.\n * @returns A fully configured client ready for local blockchain simulation.\n *\n * @example\n * ```ts\n * import { createDefaultLiteSVMClient } from '@solana/kit-plugins';\n *\n * // Creates a client with auto-generated and funded payer\n * const client = await createDefaultLiteSVMClient();\n *\n * // Set up accounts and programs\n * client.svm.setAccount(myAccount);\n * client.svm.addProgramFromFile(myProgramAddress, 'program.so');\n *\n * // Use the client\n * const result = await client.send([myInstruction]);\n * ```\n *\n * @example\n * Using a custom payer.\n * ```ts\n * import { createDefaultLiteSVMClient } from '@solana/kit-plugins';\n * import { generateKeyPairSigner } from '@solana/kit';\n *\n * const customPayer = await generateKeyPairSigner();\n * const client = await createDefaultLiteSVMClient({ payer: customPayer });\n * ```\n */\nexport function createDefaultLiteSVMClient(config: { payer?: TransactionSigner } = {}) {\n return createEmptyClient()\n .use(litesvm())\n .use(airdrop())\n .use(payerOrGeneratedPayer(config.payer))\n .use(defaultTransactionPlannerAndExecutorFromLitesvm())\n .use(sendInstructionPlans());\n}\n\n/**\n * Helper function that uses the provided payer if any,\n * otherwise generates a new payer and funds it with 100 SOL.\n */\nfunction payerOrGeneratedPayer(explicitPayer: TransactionSigner | undefined) {\n return <T extends { airdrop: AirdropFunction }>(client: T): Promise<T & { payer: TransactionSigner }> => {\n if (explicitPayer) {\n return Promise.resolve(payer(explicitPayer)(client));\n }\n return generatedPayerWithSol(lamports(100_000_000_000n))(client);\n };\n}\n"]}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var kitPluginAirdrop = require('@solana/kit-plugin-airdrop');
|
|
4
|
+
var kitPluginInstructionPlan = require('@solana/kit-plugin-instruction-plan');
|
|
5
|
+
var kitPluginLitesvm = require('@solana/kit-plugin-litesvm');
|
|
6
|
+
var kitPluginPayer = require('@solana/kit-plugin-payer');
|
|
7
|
+
var kitPluginRpc = require('@solana/kit-plugin-rpc');
|
|
8
|
+
var kit = require('@solana/kit');
|
|
9
|
+
|
|
10
|
+
// src/index.ts
|
|
11
|
+
function createDefaultRpcClient(config) {
|
|
12
|
+
return kit.createEmptyClient().use(kitPluginRpc.rpc(config.url, config.rpcSubscriptionsConfig)).use(kitPluginPayer.payer(config.payer)).use(kitPluginInstructionPlan.defaultTransactionPlannerAndExecutorFromRpc()).use(kitPluginInstructionPlan.sendInstructionPlans());
|
|
13
|
+
}
|
|
14
|
+
function createDefaultLocalhostRpcClient(config = {}) {
|
|
15
|
+
return kit.createEmptyClient().use(kitPluginRpc.localhostRpc()).use(kitPluginAirdrop.airdrop()).use(payerOrGeneratedPayer(config.payer)).use(kitPluginInstructionPlan.defaultTransactionPlannerAndExecutorFromRpc()).use(kitPluginInstructionPlan.sendInstructionPlans());
|
|
16
|
+
}
|
|
17
|
+
function createDefaultLiteSVMClient(config = {}) {
|
|
18
|
+
return kit.createEmptyClient().use(kitPluginLitesvm.litesvm()).use(kitPluginAirdrop.airdrop()).use(payerOrGeneratedPayer(config.payer)).use(kitPluginInstructionPlan.defaultTransactionPlannerAndExecutorFromLitesvm()).use(kitPluginInstructionPlan.sendInstructionPlans());
|
|
19
|
+
}
|
|
20
|
+
function payerOrGeneratedPayer(explicitPayer) {
|
|
21
|
+
return (client) => {
|
|
22
|
+
if (explicitPayer) {
|
|
23
|
+
return Promise.resolve(kitPluginPayer.payer(explicitPayer)(client));
|
|
24
|
+
}
|
|
25
|
+
return kitPluginPayer.generatedPayerWithSol(kit.lamports(100000000000n))(client);
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
exports.createDefaultLiteSVMClient = createDefaultLiteSVMClient;
|
|
30
|
+
exports.createDefaultLocalhostRpcClient = createDefaultLocalhostRpcClient;
|
|
31
|
+
exports.createDefaultRpcClient = createDefaultRpcClient;
|
|
32
|
+
Object.keys(kitPluginAirdrop).forEach(function (k) {
|
|
33
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
34
|
+
enumerable: true,
|
|
35
|
+
get: function () { return kitPluginAirdrop[k]; }
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
Object.keys(kitPluginInstructionPlan).forEach(function (k) {
|
|
39
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
40
|
+
enumerable: true,
|
|
41
|
+
get: function () { return kitPluginInstructionPlan[k]; }
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
Object.keys(kitPluginLitesvm).forEach(function (k) {
|
|
45
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
46
|
+
enumerable: true,
|
|
47
|
+
get: function () { return kitPluginLitesvm[k]; }
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
Object.keys(kitPluginPayer).forEach(function (k) {
|
|
51
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
52
|
+
enumerable: true,
|
|
53
|
+
get: function () { return kitPluginPayer[k]; }
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
Object.keys(kitPluginRpc).forEach(function (k) {
|
|
57
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
58
|
+
enumerable: true,
|
|
59
|
+
get: function () { return kitPluginRpc[k]; }
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
//# sourceMappingURL=index.node.cjs.map
|
|
63
|
+
//# sourceMappingURL=index.node.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/defaults.ts"],"names":["createEmptyClient","rpc","payer","defaultTransactionPlannerAndExecutorFromRpc","sendInstructionPlans","localhostRpc","airdrop","litesvm","defaultTransactionPlannerAndExecutorFromLitesvm","generatedPayerWithSol","lamports"],"mappings":";;;;;;;;;;AA0CO,SAAS,uBAAuD,MAAA,EAIpE;AACC,EAAA,OAAOA,qBAAA,GACF,GAAA,CAAIC,gBAAA,CAAiB,OAAO,GAAA,EAAK,MAAA,CAAO,sBAAsB,CAAC,CAAA,CAC/D,GAAA,CAAIC,qBAAM,MAAA,CAAO,KAAK,CAAC,CAAA,CACvB,GAAA,CAAIC,sEAA6C,CAAA,CACjD,GAAA,CAAIC,6CAAA,EAAsB,CAAA;AACnC;AAkCO,SAAS,+BAAA,CAAgC,MAAA,GAAwC,EAAC,EAAG;AACxF,EAAA,OAAOJ,qBAAA,GACF,GAAA,CAAIK,yBAAA,EAAc,CAAA,CAClB,GAAA,CAAIC,wBAAA,EAAS,CAAA,CACb,GAAA,CAAI,sBAAsB,MAAA,CAAO,KAAK,CAAC,CAAA,CACvC,GAAA,CAAIH,sEAA6C,CAAA,CACjD,GAAA,CAAIC,6CAAA,EAAsB,CAAA;AACnC;AAsCO,SAAS,0BAAA,CAA2B,MAAA,GAAwC,EAAC,EAAG;AACnF,EAAA,OAAOJ,qBAAA,GACF,GAAA,CAAIO,wBAAA,EAAS,CAAA,CACb,GAAA,CAAID,wBAAA,EAAS,CAAA,CACb,GAAA,CAAI,sBAAsB,MAAA,CAAO,KAAK,CAAC,CAAA,CACvC,GAAA,CAAIE,0EAAiD,CAAA,CACrD,GAAA,CAAIJ,6CAAA,EAAsB,CAAA;AACnC;AAMA,SAAS,sBAAsB,aAAA,EAA8C;AACzE,EAAA,OAAO,CAAyC,MAAA,KAAyD;AACrG,IAAA,IAAI,aAAA,EAAe;AACf,MAAA,OAAO,QAAQ,OAAA,CAAQF,oBAAA,CAAM,aAAa,CAAA,CAAE,MAAM,CAAC,CAAA;AAAA,IACvD;AACA,IAAA,OAAOO,oCAAA,CAAsBC,YAAA,CAAS,aAAgB,CAAC,EAAE,MAAM,CAAA;AAAA,EACnE,CAAA;AACJ","file":"index.node.cjs","sourcesContent":["import {\n ClusterUrl,\n createEmptyClient,\n DefaultRpcSubscriptionsChannelConfig,\n lamports,\n TransactionSigner,\n} from '@solana/kit';\nimport { airdrop, AirdropFunction } from '@solana/kit-plugin-airdrop';\nimport {\n defaultTransactionPlannerAndExecutorFromLitesvm,\n defaultTransactionPlannerAndExecutorFromRpc,\n sendInstructionPlans,\n} from '@solana/kit-plugin-instruction-plan';\nimport { litesvm } from '@solana/kit-plugin-litesvm';\nimport { generatedPayerWithSol, payer } from '@solana/kit-plugin-payer';\nimport { localhostRpc, rpc } from '@solana/kit-plugin-rpc';\n\n/**\n * Creates a default RPC client with all essential plugins configured.\n *\n * This function sets up a client with RPC capabilities, payer configuration,\n * transaction planning and execution, and instruction plan sending functionality.\n * It's designed for production use with real Solana clusters.\n *\n * @param config - Configuration object containing the payer, URL, and optional RPC subscriptions config.\n * @returns A fully configured default client ready for transaction operations.\n *\n * @example\n * ```ts\n * import { createDefaultRpcClient } from '@solana/kit-plugins';\n * import { generateKeyPairSigner } from '@solana/kit';\n *\n * const payer = await generateKeyPairSigner();\n * const client = createDefaultRpcClient({\n * url: 'https://api.mainnet-beta.solana.com',\n * payer,\n * });\n *\n * // Use the client\n * const result = await client.send([myInstruction]);\n * ```\n */\nexport function createDefaultRpcClient<TClusterUrl extends ClusterUrl>(config: {\n payer: TransactionSigner;\n rpcSubscriptionsConfig?: DefaultRpcSubscriptionsChannelConfig<TClusterUrl>;\n url: TClusterUrl;\n}) {\n return createEmptyClient()\n .use(rpc<TClusterUrl>(config.url, config.rpcSubscriptionsConfig))\n .use(payer(config.payer))\n .use(defaultTransactionPlannerAndExecutorFromRpc())\n .use(sendInstructionPlans());\n}\n\n/**\n * Creates a default RPC client configured for localhost development.\n *\n * This function sets up a client connected to a local validator with airdrop\n * functionality, automatic payer generation (if not provided), and all essential\n * transaction capabilities. Perfect for local development and testing.\n *\n * @param config - Optional configuration object with an optional payer.\n * @returns A fully configured client ready for localhost development.\n *\n * @example\n * ```ts\n * import { createDefaultLocalhostRpcClient } from '@solana/kit-plugins';\n *\n * // Creates a client with auto-generated and funded payer\n * const client = await createDefaultLocalhostRpcClient();\n *\n * // Use the client\n * const result = await client.send([myInstruction]);\n * console.log('Payer address:', client.payer.address);\n * ```\n *\n * @example\n * Using a custom payer.\n * ```ts\n * import { createDefaultLocalhostRpcClient } from '@solana/kit-plugins';\n * import { generateKeyPairSigner } from '@solana/kit';\n *\n * const customPayer = await generateKeyPairSigner();\n * const client = await createDefaultLocalhostRpcClient({ payer: customPayer });\n * ```\n */\nexport function createDefaultLocalhostRpcClient(config: { payer?: TransactionSigner } = {}) {\n return createEmptyClient()\n .use(localhostRpc())\n .use(airdrop())\n .use(payerOrGeneratedPayer(config.payer))\n .use(defaultTransactionPlannerAndExecutorFromRpc())\n .use(sendInstructionPlans());\n}\n\n/**\n * Creates a default LiteSVM client for local blockchain simulation.\n *\n * This function sets up a client with an embedded LiteSVM instance for fast\n * local blockchain simulation, airdrop functionality, automatic payer generation\n * (if not provided), and all essential transaction capabilities. Ideal for testing\n * and development without requiring a live network connection.\n *\n * @param config - Optional configuration object with an optional payer.\n * @returns A fully configured client ready for local blockchain simulation.\n *\n * @example\n * ```ts\n * import { createDefaultLiteSVMClient } from '@solana/kit-plugins';\n *\n * // Creates a client with auto-generated and funded payer\n * const client = await createDefaultLiteSVMClient();\n *\n * // Set up accounts and programs\n * client.svm.setAccount(myAccount);\n * client.svm.addProgramFromFile(myProgramAddress, 'program.so');\n *\n * // Use the client\n * const result = await client.send([myInstruction]);\n * ```\n *\n * @example\n * Using a custom payer.\n * ```ts\n * import { createDefaultLiteSVMClient } from '@solana/kit-plugins';\n * import { generateKeyPairSigner } from '@solana/kit';\n *\n * const customPayer = await generateKeyPairSigner();\n * const client = await createDefaultLiteSVMClient({ payer: customPayer });\n * ```\n */\nexport function createDefaultLiteSVMClient(config: { payer?: TransactionSigner } = {}) {\n return createEmptyClient()\n .use(litesvm())\n .use(airdrop())\n .use(payerOrGeneratedPayer(config.payer))\n .use(defaultTransactionPlannerAndExecutorFromLitesvm())\n .use(sendInstructionPlans());\n}\n\n/**\n * Helper function that uses the provided payer if any,\n * otherwise generates a new payer and funds it with 100 SOL.\n */\nfunction payerOrGeneratedPayer(explicitPayer: TransactionSigner | undefined) {\n return <T extends { airdrop: AirdropFunction }>(client: T): Promise<T & { payer: TransactionSigner }> => {\n if (explicitPayer) {\n return Promise.resolve(payer(explicitPayer)(client));\n }\n return generatedPayerWithSol(lamports(100_000_000_000n))(client);\n };\n}\n"]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { airdrop } from '@solana/kit-plugin-airdrop';
|
|
2
|
+
export * from '@solana/kit-plugin-airdrop';
|
|
3
|
+
import { defaultTransactionPlannerAndExecutorFromRpc, sendInstructionPlans, defaultTransactionPlannerAndExecutorFromLitesvm } from '@solana/kit-plugin-instruction-plan';
|
|
4
|
+
export * from '@solana/kit-plugin-instruction-plan';
|
|
5
|
+
import { litesvm } from '@solana/kit-plugin-litesvm';
|
|
6
|
+
export * from '@solana/kit-plugin-litesvm';
|
|
7
|
+
import { payer, generatedPayerWithSol } from '@solana/kit-plugin-payer';
|
|
8
|
+
export * from '@solana/kit-plugin-payer';
|
|
9
|
+
import { rpc, localhostRpc } from '@solana/kit-plugin-rpc';
|
|
10
|
+
export * from '@solana/kit-plugin-rpc';
|
|
11
|
+
import { createEmptyClient, lamports } from '@solana/kit';
|
|
12
|
+
|
|
13
|
+
// src/index.ts
|
|
14
|
+
function createDefaultRpcClient(config) {
|
|
15
|
+
return createEmptyClient().use(rpc(config.url, config.rpcSubscriptionsConfig)).use(payer(config.payer)).use(defaultTransactionPlannerAndExecutorFromRpc()).use(sendInstructionPlans());
|
|
16
|
+
}
|
|
17
|
+
function createDefaultLocalhostRpcClient(config = {}) {
|
|
18
|
+
return createEmptyClient().use(localhostRpc()).use(airdrop()).use(payerOrGeneratedPayer(config.payer)).use(defaultTransactionPlannerAndExecutorFromRpc()).use(sendInstructionPlans());
|
|
19
|
+
}
|
|
20
|
+
function createDefaultLiteSVMClient(config = {}) {
|
|
21
|
+
return createEmptyClient().use(litesvm()).use(airdrop()).use(payerOrGeneratedPayer(config.payer)).use(defaultTransactionPlannerAndExecutorFromLitesvm()).use(sendInstructionPlans());
|
|
22
|
+
}
|
|
23
|
+
function payerOrGeneratedPayer(explicitPayer) {
|
|
24
|
+
return (client) => {
|
|
25
|
+
if (explicitPayer) {
|
|
26
|
+
return Promise.resolve(payer(explicitPayer)(client));
|
|
27
|
+
}
|
|
28
|
+
return generatedPayerWithSol(lamports(100000000000n))(client);
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { createDefaultLiteSVMClient, createDefaultLocalhostRpcClient, createDefaultRpcClient };
|
|
33
|
+
//# sourceMappingURL=index.node.mjs.map
|
|
34
|
+
//# sourceMappingURL=index.node.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/defaults.ts"],"names":[],"mappings":";;;;;;;;;;;;;AA0CO,SAAS,uBAAuD,MAAA,EAIpE;AACC,EAAA,OAAO,iBAAA,GACF,GAAA,CAAI,GAAA,CAAiB,OAAO,GAAA,EAAK,MAAA,CAAO,sBAAsB,CAAC,CAAA,CAC/D,GAAA,CAAI,MAAM,MAAA,CAAO,KAAK,CAAC,CAAA,CACvB,GAAA,CAAI,6CAA6C,CAAA,CACjD,GAAA,CAAI,oBAAA,EAAsB,CAAA;AACnC;AAkCO,SAAS,+BAAA,CAAgC,MAAA,GAAwC,EAAC,EAAG;AACxF,EAAA,OAAO,iBAAA,GACF,GAAA,CAAI,YAAA,EAAc,CAAA,CAClB,GAAA,CAAI,OAAA,EAAS,CAAA,CACb,GAAA,CAAI,sBAAsB,MAAA,CAAO,KAAK,CAAC,CAAA,CACvC,GAAA,CAAI,6CAA6C,CAAA,CACjD,GAAA,CAAI,oBAAA,EAAsB,CAAA;AACnC;AAsCO,SAAS,0BAAA,CAA2B,MAAA,GAAwC,EAAC,EAAG;AACnF,EAAA,OAAO,iBAAA,GACF,GAAA,CAAI,OAAA,EAAS,CAAA,CACb,GAAA,CAAI,OAAA,EAAS,CAAA,CACb,GAAA,CAAI,sBAAsB,MAAA,CAAO,KAAK,CAAC,CAAA,CACvC,GAAA,CAAI,iDAAiD,CAAA,CACrD,GAAA,CAAI,oBAAA,EAAsB,CAAA;AACnC;AAMA,SAAS,sBAAsB,aAAA,EAA8C;AACzE,EAAA,OAAO,CAAyC,MAAA,KAAyD;AACrG,IAAA,IAAI,aAAA,EAAe;AACf,MAAA,OAAO,QAAQ,OAAA,CAAQ,KAAA,CAAM,aAAa,CAAA,CAAE,MAAM,CAAC,CAAA;AAAA,IACvD;AACA,IAAA,OAAO,qBAAA,CAAsB,QAAA,CAAS,aAAgB,CAAC,EAAE,MAAM,CAAA;AAAA,EACnE,CAAA;AACJ","file":"index.node.mjs","sourcesContent":["import {\n ClusterUrl,\n createEmptyClient,\n DefaultRpcSubscriptionsChannelConfig,\n lamports,\n TransactionSigner,\n} from '@solana/kit';\nimport { airdrop, AirdropFunction } from '@solana/kit-plugin-airdrop';\nimport {\n defaultTransactionPlannerAndExecutorFromLitesvm,\n defaultTransactionPlannerAndExecutorFromRpc,\n sendInstructionPlans,\n} from '@solana/kit-plugin-instruction-plan';\nimport { litesvm } from '@solana/kit-plugin-litesvm';\nimport { generatedPayerWithSol, payer } from '@solana/kit-plugin-payer';\nimport { localhostRpc, rpc } from '@solana/kit-plugin-rpc';\n\n/**\n * Creates a default RPC client with all essential plugins configured.\n *\n * This function sets up a client with RPC capabilities, payer configuration,\n * transaction planning and execution, and instruction plan sending functionality.\n * It's designed for production use with real Solana clusters.\n *\n * @param config - Configuration object containing the payer, URL, and optional RPC subscriptions config.\n * @returns A fully configured default client ready for transaction operations.\n *\n * @example\n * ```ts\n * import { createDefaultRpcClient } from '@solana/kit-plugins';\n * import { generateKeyPairSigner } from '@solana/kit';\n *\n * const payer = await generateKeyPairSigner();\n * const client = createDefaultRpcClient({\n * url: 'https://api.mainnet-beta.solana.com',\n * payer,\n * });\n *\n * // Use the client\n * const result = await client.send([myInstruction]);\n * ```\n */\nexport function createDefaultRpcClient<TClusterUrl extends ClusterUrl>(config: {\n payer: TransactionSigner;\n rpcSubscriptionsConfig?: DefaultRpcSubscriptionsChannelConfig<TClusterUrl>;\n url: TClusterUrl;\n}) {\n return createEmptyClient()\n .use(rpc<TClusterUrl>(config.url, config.rpcSubscriptionsConfig))\n .use(payer(config.payer))\n .use(defaultTransactionPlannerAndExecutorFromRpc())\n .use(sendInstructionPlans());\n}\n\n/**\n * Creates a default RPC client configured for localhost development.\n *\n * This function sets up a client connected to a local validator with airdrop\n * functionality, automatic payer generation (if not provided), and all essential\n * transaction capabilities. Perfect for local development and testing.\n *\n * @param config - Optional configuration object with an optional payer.\n * @returns A fully configured client ready for localhost development.\n *\n * @example\n * ```ts\n * import { createDefaultLocalhostRpcClient } from '@solana/kit-plugins';\n *\n * // Creates a client with auto-generated and funded payer\n * const client = await createDefaultLocalhostRpcClient();\n *\n * // Use the client\n * const result = await client.send([myInstruction]);\n * console.log('Payer address:', client.payer.address);\n * ```\n *\n * @example\n * Using a custom payer.\n * ```ts\n * import { createDefaultLocalhostRpcClient } from '@solana/kit-plugins';\n * import { generateKeyPairSigner } from '@solana/kit';\n *\n * const customPayer = await generateKeyPairSigner();\n * const client = await createDefaultLocalhostRpcClient({ payer: customPayer });\n * ```\n */\nexport function createDefaultLocalhostRpcClient(config: { payer?: TransactionSigner } = {}) {\n return createEmptyClient()\n .use(localhostRpc())\n .use(airdrop())\n .use(payerOrGeneratedPayer(config.payer))\n .use(defaultTransactionPlannerAndExecutorFromRpc())\n .use(sendInstructionPlans());\n}\n\n/**\n * Creates a default LiteSVM client for local blockchain simulation.\n *\n * This function sets up a client with an embedded LiteSVM instance for fast\n * local blockchain simulation, airdrop functionality, automatic payer generation\n * (if not provided), and all essential transaction capabilities. Ideal for testing\n * and development without requiring a live network connection.\n *\n * @param config - Optional configuration object with an optional payer.\n * @returns A fully configured client ready for local blockchain simulation.\n *\n * @example\n * ```ts\n * import { createDefaultLiteSVMClient } from '@solana/kit-plugins';\n *\n * // Creates a client with auto-generated and funded payer\n * const client = await createDefaultLiteSVMClient();\n *\n * // Set up accounts and programs\n * client.svm.setAccount(myAccount);\n * client.svm.addProgramFromFile(myProgramAddress, 'program.so');\n *\n * // Use the client\n * const result = await client.send([myInstruction]);\n * ```\n *\n * @example\n * Using a custom payer.\n * ```ts\n * import { createDefaultLiteSVMClient } from '@solana/kit-plugins';\n * import { generateKeyPairSigner } from '@solana/kit';\n *\n * const customPayer = await generateKeyPairSigner();\n * const client = await createDefaultLiteSVMClient({ payer: customPayer });\n * ```\n */\nexport function createDefaultLiteSVMClient(config: { payer?: TransactionSigner } = {}) {\n return createEmptyClient()\n .use(litesvm())\n .use(airdrop())\n .use(payerOrGeneratedPayer(config.payer))\n .use(defaultTransactionPlannerAndExecutorFromLitesvm())\n .use(sendInstructionPlans());\n}\n\n/**\n * Helper function that uses the provided payer if any,\n * otherwise generates a new payer and funds it with 100 SOL.\n */\nfunction payerOrGeneratedPayer(explicitPayer: TransactionSigner | undefined) {\n return <T extends { airdrop: AirdropFunction }>(client: T): Promise<T & { payer: TransactionSigner }> => {\n if (explicitPayer) {\n return Promise.resolve(payer(explicitPayer)(client));\n }\n return generatedPayerWithSol(lamports(100_000_000_000n))(client);\n };\n}\n"]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { airdrop } from '@solana/kit-plugin-airdrop';
|
|
2
|
+
export * from '@solana/kit-plugin-airdrop';
|
|
3
|
+
import { defaultTransactionPlannerAndExecutorFromRpc, sendInstructionPlans, defaultTransactionPlannerAndExecutorFromLitesvm } from '@solana/kit-plugin-instruction-plan';
|
|
4
|
+
export * from '@solana/kit-plugin-instruction-plan';
|
|
5
|
+
import { litesvm } from '@solana/kit-plugin-litesvm';
|
|
6
|
+
export * from '@solana/kit-plugin-litesvm';
|
|
7
|
+
import { payer, generatedPayerWithSol } from '@solana/kit-plugin-payer';
|
|
8
|
+
export * from '@solana/kit-plugin-payer';
|
|
9
|
+
import { rpc, localhostRpc } from '@solana/kit-plugin-rpc';
|
|
10
|
+
export * from '@solana/kit-plugin-rpc';
|
|
11
|
+
import { createEmptyClient, lamports } from '@solana/kit';
|
|
12
|
+
|
|
13
|
+
// src/index.ts
|
|
14
|
+
function createDefaultRpcClient(config) {
|
|
15
|
+
return createEmptyClient().use(rpc(config.url, config.rpcSubscriptionsConfig)).use(payer(config.payer)).use(defaultTransactionPlannerAndExecutorFromRpc()).use(sendInstructionPlans());
|
|
16
|
+
}
|
|
17
|
+
function createDefaultLocalhostRpcClient(config = {}) {
|
|
18
|
+
return createEmptyClient().use(localhostRpc()).use(airdrop()).use(payerOrGeneratedPayer(config.payer)).use(defaultTransactionPlannerAndExecutorFromRpc()).use(sendInstructionPlans());
|
|
19
|
+
}
|
|
20
|
+
function createDefaultLiteSVMClient(config = {}) {
|
|
21
|
+
return createEmptyClient().use(litesvm()).use(airdrop()).use(payerOrGeneratedPayer(config.payer)).use(defaultTransactionPlannerAndExecutorFromLitesvm()).use(sendInstructionPlans());
|
|
22
|
+
}
|
|
23
|
+
function payerOrGeneratedPayer(explicitPayer) {
|
|
24
|
+
return (client) => {
|
|
25
|
+
if (explicitPayer) {
|
|
26
|
+
return Promise.resolve(payer(explicitPayer)(client));
|
|
27
|
+
}
|
|
28
|
+
return generatedPayerWithSol(lamports(100000000000n))(client);
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { createDefaultLiteSVMClient, createDefaultLocalhostRpcClient, createDefaultRpcClient };
|
|
33
|
+
//# sourceMappingURL=index.react-native.mjs.map
|
|
34
|
+
//# sourceMappingURL=index.react-native.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/defaults.ts"],"names":[],"mappings":";;;;;;;;;;;;;AA0CO,SAAS,uBAAuD,MAAA,EAIpE;AACC,EAAA,OAAO,iBAAA,GACF,GAAA,CAAI,GAAA,CAAiB,OAAO,GAAA,EAAK,MAAA,CAAO,sBAAsB,CAAC,CAAA,CAC/D,GAAA,CAAI,MAAM,MAAA,CAAO,KAAK,CAAC,CAAA,CACvB,GAAA,CAAI,6CAA6C,CAAA,CACjD,GAAA,CAAI,oBAAA,EAAsB,CAAA;AACnC;AAkCO,SAAS,+BAAA,CAAgC,MAAA,GAAwC,EAAC,EAAG;AACxF,EAAA,OAAO,iBAAA,GACF,GAAA,CAAI,YAAA,EAAc,CAAA,CAClB,GAAA,CAAI,OAAA,EAAS,CAAA,CACb,GAAA,CAAI,sBAAsB,MAAA,CAAO,KAAK,CAAC,CAAA,CACvC,GAAA,CAAI,6CAA6C,CAAA,CACjD,GAAA,CAAI,oBAAA,EAAsB,CAAA;AACnC;AAsCO,SAAS,0BAAA,CAA2B,MAAA,GAAwC,EAAC,EAAG;AACnF,EAAA,OAAO,iBAAA,GACF,GAAA,CAAI,OAAA,EAAS,CAAA,CACb,GAAA,CAAI,OAAA,EAAS,CAAA,CACb,GAAA,CAAI,sBAAsB,MAAA,CAAO,KAAK,CAAC,CAAA,CACvC,GAAA,CAAI,iDAAiD,CAAA,CACrD,GAAA,CAAI,oBAAA,EAAsB,CAAA;AACnC;AAMA,SAAS,sBAAsB,aAAA,EAA8C;AACzE,EAAA,OAAO,CAAyC,MAAA,KAAyD;AACrG,IAAA,IAAI,aAAA,EAAe;AACf,MAAA,OAAO,QAAQ,OAAA,CAAQ,KAAA,CAAM,aAAa,CAAA,CAAE,MAAM,CAAC,CAAA;AAAA,IACvD;AACA,IAAA,OAAO,qBAAA,CAAsB,QAAA,CAAS,aAAgB,CAAC,EAAE,MAAM,CAAA;AAAA,EACnE,CAAA;AACJ","file":"index.react-native.mjs","sourcesContent":["import {\n ClusterUrl,\n createEmptyClient,\n DefaultRpcSubscriptionsChannelConfig,\n lamports,\n TransactionSigner,\n} from '@solana/kit';\nimport { airdrop, AirdropFunction } from '@solana/kit-plugin-airdrop';\nimport {\n defaultTransactionPlannerAndExecutorFromLitesvm,\n defaultTransactionPlannerAndExecutorFromRpc,\n sendInstructionPlans,\n} from '@solana/kit-plugin-instruction-plan';\nimport { litesvm } from '@solana/kit-plugin-litesvm';\nimport { generatedPayerWithSol, payer } from '@solana/kit-plugin-payer';\nimport { localhostRpc, rpc } from '@solana/kit-plugin-rpc';\n\n/**\n * Creates a default RPC client with all essential plugins configured.\n *\n * This function sets up a client with RPC capabilities, payer configuration,\n * transaction planning and execution, and instruction plan sending functionality.\n * It's designed for production use with real Solana clusters.\n *\n * @param config - Configuration object containing the payer, URL, and optional RPC subscriptions config.\n * @returns A fully configured default client ready for transaction operations.\n *\n * @example\n * ```ts\n * import { createDefaultRpcClient } from '@solana/kit-plugins';\n * import { generateKeyPairSigner } from '@solana/kit';\n *\n * const payer = await generateKeyPairSigner();\n * const client = createDefaultRpcClient({\n * url: 'https://api.mainnet-beta.solana.com',\n * payer,\n * });\n *\n * // Use the client\n * const result = await client.send([myInstruction]);\n * ```\n */\nexport function createDefaultRpcClient<TClusterUrl extends ClusterUrl>(config: {\n payer: TransactionSigner;\n rpcSubscriptionsConfig?: DefaultRpcSubscriptionsChannelConfig<TClusterUrl>;\n url: TClusterUrl;\n}) {\n return createEmptyClient()\n .use(rpc<TClusterUrl>(config.url, config.rpcSubscriptionsConfig))\n .use(payer(config.payer))\n .use(defaultTransactionPlannerAndExecutorFromRpc())\n .use(sendInstructionPlans());\n}\n\n/**\n * Creates a default RPC client configured for localhost development.\n *\n * This function sets up a client connected to a local validator with airdrop\n * functionality, automatic payer generation (if not provided), and all essential\n * transaction capabilities. Perfect for local development and testing.\n *\n * @param config - Optional configuration object with an optional payer.\n * @returns A fully configured client ready for localhost development.\n *\n * @example\n * ```ts\n * import { createDefaultLocalhostRpcClient } from '@solana/kit-plugins';\n *\n * // Creates a client with auto-generated and funded payer\n * const client = await createDefaultLocalhostRpcClient();\n *\n * // Use the client\n * const result = await client.send([myInstruction]);\n * console.log('Payer address:', client.payer.address);\n * ```\n *\n * @example\n * Using a custom payer.\n * ```ts\n * import { createDefaultLocalhostRpcClient } from '@solana/kit-plugins';\n * import { generateKeyPairSigner } from '@solana/kit';\n *\n * const customPayer = await generateKeyPairSigner();\n * const client = await createDefaultLocalhostRpcClient({ payer: customPayer });\n * ```\n */\nexport function createDefaultLocalhostRpcClient(config: { payer?: TransactionSigner } = {}) {\n return createEmptyClient()\n .use(localhostRpc())\n .use(airdrop())\n .use(payerOrGeneratedPayer(config.payer))\n .use(defaultTransactionPlannerAndExecutorFromRpc())\n .use(sendInstructionPlans());\n}\n\n/**\n * Creates a default LiteSVM client for local blockchain simulation.\n *\n * This function sets up a client with an embedded LiteSVM instance for fast\n * local blockchain simulation, airdrop functionality, automatic payer generation\n * (if not provided), and all essential transaction capabilities. Ideal for testing\n * and development without requiring a live network connection.\n *\n * @param config - Optional configuration object with an optional payer.\n * @returns A fully configured client ready for local blockchain simulation.\n *\n * @example\n * ```ts\n * import { createDefaultLiteSVMClient } from '@solana/kit-plugins';\n *\n * // Creates a client with auto-generated and funded payer\n * const client = await createDefaultLiteSVMClient();\n *\n * // Set up accounts and programs\n * client.svm.setAccount(myAccount);\n * client.svm.addProgramFromFile(myProgramAddress, 'program.so');\n *\n * // Use the client\n * const result = await client.send([myInstruction]);\n * ```\n *\n * @example\n * Using a custom payer.\n * ```ts\n * import { createDefaultLiteSVMClient } from '@solana/kit-plugins';\n * import { generateKeyPairSigner } from '@solana/kit';\n *\n * const customPayer = await generateKeyPairSigner();\n * const client = await createDefaultLiteSVMClient({ payer: customPayer });\n * ```\n */\nexport function createDefaultLiteSVMClient(config: { payer?: TransactionSigner } = {}) {\n return createEmptyClient()\n .use(litesvm())\n .use(airdrop())\n .use(payerOrGeneratedPayer(config.payer))\n .use(defaultTransactionPlannerAndExecutorFromLitesvm())\n .use(sendInstructionPlans());\n}\n\n/**\n * Helper function that uses the provided payer if any,\n * otherwise generates a new payer and funds it with 100 SOL.\n */\nfunction payerOrGeneratedPayer(explicitPayer: TransactionSigner | undefined) {\n return <T extends { airdrop: AirdropFunction }>(client: T): Promise<T & { payer: TransactionSigner }> => {\n if (explicitPayer) {\n return Promise.resolve(payer(explicitPayer)(client));\n }\n return generatedPayerWithSol(lamports(100_000_000_000n))(client);\n };\n}\n"]}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { ClusterUrl, DefaultRpcSubscriptionsChannelConfig, TransactionSigner } from '@solana/kit';
|
|
2
|
+
import { AirdropFunction } from '@solana/kit-plugin-airdrop';
|
|
3
|
+
/**
|
|
4
|
+
* Creates a default RPC client with all essential plugins configured.
|
|
5
|
+
*
|
|
6
|
+
* This function sets up a client with RPC capabilities, payer configuration,
|
|
7
|
+
* transaction planning and execution, and instruction plan sending functionality.
|
|
8
|
+
* It's designed for production use with real Solana clusters.
|
|
9
|
+
*
|
|
10
|
+
* @param config - Configuration object containing the payer, URL, and optional RPC subscriptions config.
|
|
11
|
+
* @returns A fully configured default client ready for transaction operations.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { createDefaultRpcClient } from '@solana/kit-plugins';
|
|
16
|
+
* import { generateKeyPairSigner } from '@solana/kit';
|
|
17
|
+
*
|
|
18
|
+
* const payer = await generateKeyPairSigner();
|
|
19
|
+
* const client = createDefaultRpcClient({
|
|
20
|
+
* url: 'https://api.mainnet-beta.solana.com',
|
|
21
|
+
* payer,
|
|
22
|
+
* });
|
|
23
|
+
*
|
|
24
|
+
* // Use the client
|
|
25
|
+
* const result = await client.send([myInstruction]);
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare function createDefaultRpcClient<TClusterUrl extends ClusterUrl>(config: {
|
|
29
|
+
payer: TransactionSigner;
|
|
30
|
+
rpcSubscriptionsConfig?: DefaultRpcSubscriptionsChannelConfig<TClusterUrl>;
|
|
31
|
+
url: TClusterUrl;
|
|
32
|
+
}): import("@solana/kit").Client<object & {
|
|
33
|
+
rpc: import("@solana/kit").RpcFromTransport<import("@solana/kit").SolanaRpcApiFromTransport<import("@solana/kit").RpcTransportFromClusterUrl<TClusterUrl>>, import("@solana/kit").RpcTransportFromClusterUrl<TClusterUrl>>;
|
|
34
|
+
rpcSubscriptions: import("@solana/kit").RpcSubscriptions<import("@solana/kit").SolanaRpcSubscriptionsApi>;
|
|
35
|
+
} & {
|
|
36
|
+
payer: TransactionSigner;
|
|
37
|
+
} & {
|
|
38
|
+
transactionPlanExecutor: import("@solana/kit").TransactionPlanExecutor<import("@solana/kit").TransactionPlanResultContext>;
|
|
39
|
+
transactionPlanner: import("@solana/kit").TransactionPlanner;
|
|
40
|
+
} & {
|
|
41
|
+
send: (instructions: import("@solana/kit").Instruction | import("@solana/kit").Instruction[] | import("@solana/kit").InstructionPlan, config?: {
|
|
42
|
+
abortSignal?: AbortSignal;
|
|
43
|
+
transactionPlanExecutor?: import("@solana/kit").TransactionPlanExecutor;
|
|
44
|
+
transactionPlanner?: import("@solana/kit").TransactionPlanner;
|
|
45
|
+
}) => Promise<import("@solana/kit").TransactionPlanResult<import("@solana/kit").TransactionPlanResultContext>>;
|
|
46
|
+
}>;
|
|
47
|
+
/**
|
|
48
|
+
* Creates a default RPC client configured for localhost development.
|
|
49
|
+
*
|
|
50
|
+
* This function sets up a client connected to a local validator with airdrop
|
|
51
|
+
* functionality, automatic payer generation (if not provided), and all essential
|
|
52
|
+
* transaction capabilities. Perfect for local development and testing.
|
|
53
|
+
*
|
|
54
|
+
* @param config - Optional configuration object with an optional payer.
|
|
55
|
+
* @returns A fully configured client ready for localhost development.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* import { createDefaultLocalhostRpcClient } from '@solana/kit-plugins';
|
|
60
|
+
*
|
|
61
|
+
* // Creates a client with auto-generated and funded payer
|
|
62
|
+
* const client = await createDefaultLocalhostRpcClient();
|
|
63
|
+
*
|
|
64
|
+
* // Use the client
|
|
65
|
+
* const result = await client.send([myInstruction]);
|
|
66
|
+
* console.log('Payer address:', client.payer.address);
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* Using a custom payer.
|
|
71
|
+
* ```ts
|
|
72
|
+
* import { createDefaultLocalhostRpcClient } from '@solana/kit-plugins';
|
|
73
|
+
* import { generateKeyPairSigner } from '@solana/kit';
|
|
74
|
+
*
|
|
75
|
+
* const customPayer = await generateKeyPairSigner();
|
|
76
|
+
* const client = await createDefaultLocalhostRpcClient({ payer: customPayer });
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
export declare function createDefaultLocalhostRpcClient(config?: {
|
|
80
|
+
payer?: TransactionSigner;
|
|
81
|
+
}): import("@solana/kit").AsyncClient<object & {
|
|
82
|
+
rpc: import("@solana/kit").Rpc<import("@solana/kit").RequestAirdropApi & import("@solana/kit").GetAccountInfoApi & import("@solana/kit").GetBalanceApi & import("@solana/kit").GetBlockApi & import("@solana/kit").GetBlockCommitmentApi & import("@solana/kit").GetBlockHeightApi & import("@solana/kit").GetBlockProductionApi & import("@solana/kit").GetBlocksApi & import("@solana/kit").GetBlocksWithLimitApi & import("@solana/kit").GetBlockTimeApi & import("@solana/kit").GetClusterNodesApi & import("@solana/kit").GetEpochInfoApi & import("@solana/kit").GetEpochScheduleApi & import("@solana/kit").GetFeeForMessageApi & import("@solana/kit").GetFirstAvailableBlockApi & import("@solana/kit").GetGenesisHashApi & import("@solana/kit").GetHealthApi & import("@solana/kit").GetHighestSnapshotSlotApi & import("@solana/kit").GetIdentityApi & import("@solana/kit").GetInflationGovernorApi & import("@solana/kit").GetInflationRateApi & import("@solana/kit").GetInflationRewardApi & import("@solana/kit").GetLargestAccountsApi & import("@solana/kit").GetLatestBlockhashApi & import("@solana/kit").GetLeaderScheduleApi & import("@solana/kit").GetMaxRetransmitSlotApi & import("@solana/kit").GetMaxShredInsertSlotApi & import("@solana/kit").GetMinimumBalanceForRentExemptionApi & import("@solana/kit").GetMultipleAccountsApi & import("@solana/kit").GetProgramAccountsApi & import("@solana/kit").GetRecentPerformanceSamplesApi & import("@solana/kit").GetRecentPrioritizationFeesApi & import("@solana/kit").GetSignaturesForAddressApi & import("@solana/kit").GetSignatureStatusesApi & import("@solana/kit").GetSlotApi & import("@solana/kit").GetSlotLeaderApi & import("@solana/kit").GetSlotLeadersApi & import("@solana/kit").GetStakeMinimumDelegationApi & import("@solana/kit").GetSupplyApi & import("@solana/kit").GetTokenAccountBalanceApi & import("@solana/kit").GetTokenAccountsByDelegateApi & import("@solana/kit").GetTokenAccountsByOwnerApi & import("@solana/kit").GetTokenLargestAccountsApi & import("@solana/kit").GetTokenSupplyApi & import("@solana/kit").GetTransactionApi & import("@solana/kit").GetTransactionCountApi & import("@solana/kit").GetVersionApi & import("@solana/kit").GetVoteAccountsApi & import("@solana/kit").IsBlockhashValidApi & import("@solana/kit").MinimumLedgerSlotApi & import("@solana/kit").SendTransactionApi & import("@solana/kit").SimulateTransactionApi>;
|
|
83
|
+
rpcSubscriptions: import("@solana/kit").RpcSubscriptions<import("@solana/kit").SolanaRpcSubscriptionsApi>;
|
|
84
|
+
} & {
|
|
85
|
+
airdrop: AirdropFunction;
|
|
86
|
+
} & {
|
|
87
|
+
payer: TransactionSigner;
|
|
88
|
+
} & {
|
|
89
|
+
transactionPlanExecutor: import("@solana/kit").TransactionPlanExecutor<import("@solana/kit").TransactionPlanResultContext>;
|
|
90
|
+
transactionPlanner: import("@solana/kit").TransactionPlanner;
|
|
91
|
+
} & {
|
|
92
|
+
send: (instructions: import("@solana/kit").Instruction | import("@solana/kit").Instruction[] | import("@solana/kit").InstructionPlan, config?: {
|
|
93
|
+
abortSignal?: AbortSignal;
|
|
94
|
+
transactionPlanExecutor?: import("@solana/kit").TransactionPlanExecutor;
|
|
95
|
+
transactionPlanner?: import("@solana/kit").TransactionPlanner;
|
|
96
|
+
}) => Promise<import("@solana/kit").TransactionPlanResult<import("@solana/kit").TransactionPlanResultContext>>;
|
|
97
|
+
}>;
|
|
98
|
+
/**
|
|
99
|
+
* Creates a default LiteSVM client for local blockchain simulation.
|
|
100
|
+
*
|
|
101
|
+
* This function sets up a client with an embedded LiteSVM instance for fast
|
|
102
|
+
* local blockchain simulation, airdrop functionality, automatic payer generation
|
|
103
|
+
* (if not provided), and all essential transaction capabilities. Ideal for testing
|
|
104
|
+
* and development without requiring a live network connection.
|
|
105
|
+
*
|
|
106
|
+
* @param config - Optional configuration object with an optional payer.
|
|
107
|
+
* @returns A fully configured client ready for local blockchain simulation.
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* ```ts
|
|
111
|
+
* import { createDefaultLiteSVMClient } from '@solana/kit-plugins';
|
|
112
|
+
*
|
|
113
|
+
* // Creates a client with auto-generated and funded payer
|
|
114
|
+
* const client = await createDefaultLiteSVMClient();
|
|
115
|
+
*
|
|
116
|
+
* // Set up accounts and programs
|
|
117
|
+
* client.svm.setAccount(myAccount);
|
|
118
|
+
* client.svm.addProgramFromFile(myProgramAddress, 'program.so');
|
|
119
|
+
*
|
|
120
|
+
* // Use the client
|
|
121
|
+
* const result = await client.send([myInstruction]);
|
|
122
|
+
* ```
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* Using a custom payer.
|
|
126
|
+
* ```ts
|
|
127
|
+
* import { createDefaultLiteSVMClient } from '@solana/kit-plugins';
|
|
128
|
+
* import { generateKeyPairSigner } from '@solana/kit';
|
|
129
|
+
*
|
|
130
|
+
* const customPayer = await generateKeyPairSigner();
|
|
131
|
+
* const client = await createDefaultLiteSVMClient({ payer: customPayer });
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
export declare function createDefaultLiteSVMClient(config?: {
|
|
135
|
+
payer?: TransactionSigner;
|
|
136
|
+
}): import("@solana/kit").AsyncClient<object & {
|
|
137
|
+
rpc: import("@solana/kit").Rpc<import("@solana/kit").GetAccountInfoApi & import("@solana/kit").GetLatestBlockhashApi & import("@solana/kit").GetMultipleAccountsApi>;
|
|
138
|
+
svm: import("@solana/kit-plugin-litesvm").LiteSVM;
|
|
139
|
+
} & {
|
|
140
|
+
airdrop: AirdropFunction;
|
|
141
|
+
} & {
|
|
142
|
+
payer: TransactionSigner;
|
|
143
|
+
} & {
|
|
144
|
+
transactionPlanExecutor: import("@solana/kit").TransactionPlanExecutor<import("@solana/kit").TransactionPlanResultContext>;
|
|
145
|
+
transactionPlanner: import("@solana/kit").TransactionPlanner;
|
|
146
|
+
} & {
|
|
147
|
+
send: (instructions: import("@solana/kit").Instruction | import("@solana/kit").Instruction[] | import("@solana/kit").InstructionPlan, config?: {
|
|
148
|
+
abortSignal?: AbortSignal;
|
|
149
|
+
transactionPlanExecutor?: import("@solana/kit").TransactionPlanExecutor;
|
|
150
|
+
transactionPlanner?: import("@solana/kit").TransactionPlanner;
|
|
151
|
+
}) => Promise<import("@solana/kit").TransactionPlanResult<import("@solana/kit").TransactionPlanResultContext>>;
|
|
152
|
+
}>;
|
|
153
|
+
//# sourceMappingURL=defaults.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/defaults.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,UAAU,EAEV,oCAAoC,EAEpC,iBAAiB,EACpB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAW,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAUtE;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,sBAAsB,CAAC,WAAW,SAAS,UAAU,EAAE,MAAM,EAAE;IAC3E,KAAK,EAAE,iBAAiB,CAAC;IACzB,sBAAsB,CAAC,EAAE,oCAAoC,CAAC,WAAW,CAAC,CAAC;IAC3E,GAAG,EAAE,WAAW,CAAC;CACpB;;;;;;;;;gJAuBwC,CAAC;mBAGzC,CADG;+BACyB,CAAC;0BACD,CAAC;;GArB7B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,+BAA+B,CAAC,MAAM,GAAE;IAAE,KAAK,CAAC,EAAE,iBAAiB,CAAA;CAAO;;;;;;WA2DL,iBAAiB;;;;;gJA5E7D,CAAC;mBAGzC,CADG;+BACyB,CAAC;0BACD,CAAC;;GAoB7B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,GAAE;IAAE,KAAK,CAAC,EAAE,iBAAiB,CAAA;CAAO;;;;;;WAcA,iBAAiB;;;;;gJA5E7D,CAAC;mBAGzC,CADG;+BACyB,CAAC;0BACD,CAAC;;GAiE7B"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from '@solana/kit-plugin-airdrop';
|
|
2
|
+
export * from '@solana/kit-plugin-instruction-plan';
|
|
3
|
+
export * from '@solana/kit-plugin-litesvm';
|
|
4
|
+
export * from '@solana/kit-plugin-payer';
|
|
5
|
+
export * from '@solana/kit-plugin-rpc';
|
|
6
|
+
export * from './defaults';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qCAAqC,CAAC;AACpD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AAEvC,cAAc,YAAY,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,14 +1,71 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solana/kit-plugins",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "",
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
"
|
|
9
|
-
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Essential plugins and plugin presets for Solana Kit.",
|
|
5
|
+
"exports": {
|
|
6
|
+
"types": "./dist/types/index.d.ts",
|
|
7
|
+
"react-native": "./dist/index.react-native.mjs",
|
|
8
|
+
"browser": {
|
|
9
|
+
"import": "./dist/index.browser.mjs",
|
|
10
|
+
"require": "./dist/index.browser.cjs"
|
|
11
|
+
},
|
|
12
|
+
"node": {
|
|
13
|
+
"import": "./dist/index.node.mjs",
|
|
14
|
+
"require": "./dist/index.node.cjs"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"browser": {
|
|
18
|
+
"./dist/index.node.cjs": "./dist/index.browser.cjs",
|
|
19
|
+
"./dist/index.node.mjs": "./dist/index.browser.mjs"
|
|
20
|
+
},
|
|
21
|
+
"jsdelivr": "./dist/index.production.min.js",
|
|
22
|
+
"umd": "./dist/index.production.min.js",
|
|
23
|
+
"unpkg": "./dist/index.production.min.js",
|
|
24
|
+
"main": "./dist/index.node.cjs",
|
|
25
|
+
"module": "./dist/index.node.mjs",
|
|
26
|
+
"react-native": "./dist/index.react-native.mjs",
|
|
27
|
+
"types": "./dist/types/index.d.ts",
|
|
28
|
+
"type": "commonjs",
|
|
29
|
+
"files": [
|
|
30
|
+
"./dist/types",
|
|
31
|
+
"./dist/index.*"
|
|
32
|
+
],
|
|
33
|
+
"sideEffects": false,
|
|
34
|
+
"keywords": [
|
|
35
|
+
"solana",
|
|
36
|
+
"kit",
|
|
37
|
+
"plugins"
|
|
38
|
+
],
|
|
39
|
+
"peerDependencies": {
|
|
40
|
+
"@solana/kit": "^5.2.0"
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@solana/kit-plugin-airdrop": "0.2.0",
|
|
44
|
+
"@solana/kit-plugin-instruction-plan": "0.2.0",
|
|
45
|
+
"@solana/kit-plugin-litesvm": "0.2.0",
|
|
46
|
+
"@solana/kit-plugin-payer": "0.2.0",
|
|
47
|
+
"@solana/kit-plugin-rpc": "0.2.0"
|
|
10
48
|
},
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
|
|
49
|
+
"license": "MIT",
|
|
50
|
+
"repository": {
|
|
51
|
+
"type": "git",
|
|
52
|
+
"url": "https://github.com/anza-xyz/kit-plugins"
|
|
53
|
+
},
|
|
54
|
+
"bugs": {
|
|
55
|
+
"url": "http://github.com/anza-xyz/kit-plugins/issues"
|
|
56
|
+
},
|
|
57
|
+
"browserslist": [
|
|
58
|
+
"supports bigint and not dead",
|
|
59
|
+
"maintained node versions"
|
|
60
|
+
],
|
|
61
|
+
"scripts": {
|
|
62
|
+
"build": "rimraf dist && tsup && tsc -p ./tsconfig.declarations.json",
|
|
63
|
+
"dev": "vitest --project node",
|
|
64
|
+
"lint": "eslint . && prettier --check .",
|
|
65
|
+
"lint:fix": "eslint --fix . && prettier --write .",
|
|
66
|
+
"test": "pnpm test:types && pnpm test:treeshakability && pnpm test:unit",
|
|
67
|
+
"test:treeshakability": "for file in dist/index.*.mjs; do agadoo $file; done",
|
|
68
|
+
"test:types": "tsc --noEmit",
|
|
69
|
+
"test:unit": "vitest run"
|
|
70
|
+
}
|
|
71
|
+
}
|