@solana/program-client-core 0.0.0 → 6.1.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.
@@ -0,0 +1,85 @@
1
+ import type { InstructionPlan } from '@solana/instruction-plans';
2
+ import type { Instruction } from '@solana/instructions';
3
+ import type { ClientWithTransactionPlanning, ClientWithTransactionSending } from '@solana/plugin-interfaces';
4
+ type PlanTransaction = ClientWithTransactionPlanning['planTransaction'];
5
+ type PlanTransactions = ClientWithTransactionPlanning['planTransactions'];
6
+ type SendTransaction = ClientWithTransactionSending['sendTransaction'];
7
+ type SendTransactions = ClientWithTransactionSending['sendTransactions'];
8
+ /**
9
+ * Methods that allow an instruction or instruction plan to plan and send itself.
10
+ *
11
+ * These methods are added to instruction or instruction plan objects via
12
+ * {@link addSelfPlanAndSendFunctions}, enabling a fluent API where you can call
13
+ * `.sendTransaction()` directly on an instruction without passing it to a separate function.
14
+ *
15
+ * @example
16
+ * Sending a transfer instruction directly.
17
+ * ```ts
18
+ * const result = await getTransferInstruction({ source, destination, amount }).sendTransaction();
19
+ * ```
20
+ *
21
+ * @example
22
+ * Planning multiple transactions from an instruction plan.
23
+ * ```ts
24
+ * const plan = await getComplexInstructionPlan(/* ... *\/).planTransactions();
25
+ * ```
26
+ *
27
+ * @see {@link addSelfPlanAndSendFunctions}
28
+ */
29
+ export type SelfPlanAndSendFunctions = {
30
+ /** Plans a single transaction. */
31
+ planTransaction: (config?: Parameters<PlanTransaction>[1]) => ReturnType<PlanTransaction>;
32
+ /** Plans one or more transactions. */
33
+ planTransactions: (config?: Parameters<PlanTransactions>[1]) => ReturnType<PlanTransactions>;
34
+ /** Sends a single transaction. */
35
+ sendTransaction: (config?: Parameters<SendTransaction>[1]) => ReturnType<SendTransaction>;
36
+ /** Sends one or more transactions. */
37
+ sendTransactions: (config?: Parameters<SendTransactions>[1]) => ReturnType<SendTransactions>;
38
+ };
39
+ /**
40
+ * Adds self-planning and self-sending methods to an instruction or instruction plan.
41
+ *
42
+ * This function augments the provided instruction or instruction plan with methods
43
+ * that allow it to plan and send itself using the provided client. It enables a fluent API
44
+ * where you can call methods like `.sendTransaction()` directly on the instruction.
45
+ *
46
+ * The function supports both synchronous inputs (instructions, instruction plans) and
47
+ * promise-like inputs, making it suitable for use with async instruction builders.
48
+ *
49
+ * @typeParam TItem - The type of the instruction, instruction plan, or a promise resolving to one.
50
+ *
51
+ * @param client - A client that provides transaction planning and sending capabilities.
52
+ * @param input - The instruction, instruction plan, or promise to augment with self-plan/send methods.
53
+ * @returns The input augmented with {@link SelfPlanAndSendFunctions} methods.
54
+ *
55
+ * @example
56
+ * Adding self-plan and send to a transfer instruction.
57
+ * ```ts
58
+ * import { addSelfPlanAndSendFunctions } from '@solana/program-client-core';
59
+ *
60
+ * const transferInstruction = addSelfPlanAndSendFunctions(
61
+ * client,
62
+ * getTransferInstruction({ payer, source, destination, amount })
63
+ * );
64
+ *
65
+ * // Now you can send directly from the instruction.
66
+ * const result = await transferInstruction.sendTransaction();
67
+ * ```
68
+ *
69
+ * @example
70
+ * Using with an async instruction builder.
71
+ * ```ts
72
+ * const asyncInstruction = addSelfPlanAndSendFunctions(
73
+ * client,
74
+ * fetchAndBuildInstruction(/* ... *\/)
75
+ * );
76
+ *
77
+ * // The promise is augmented with self-plan/send methods.
78
+ * const result = await asyncInstruction.sendTransaction();
79
+ * ```
80
+ *
81
+ * @see {@link SelfPlanAndSendFunctions}
82
+ */
83
+ export declare function addSelfPlanAndSendFunctions<TItem extends Instruction | InstructionPlan | PromiseLike<Instruction> | PromiseLike<InstructionPlan>>(client: ClientWithTransactionPlanning & ClientWithTransactionSending, input: TItem): SelfPlanAndSendFunctions & TItem;
84
+ export {};
85
+ //# sourceMappingURL=self-plan-and-send-functions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"self-plan-and-send-functions.d.ts","sourceRoot":"","sources":["../../src/self-plan-and-send-functions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,E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ErG,MAAM,EAAE,6BAA6B,GAAG,4BAA4B,EACpE,KAAK,EAAE,KAAK,GACb,wBAAwB,GAAG,KAAK,CAiBlC"}
package/package.json CHANGED
@@ -1,12 +1,96 @@
1
1
  {
2
2
  "name": "@solana/program-client-core",
3
- "version": "0.0.0",
4
- "description": "",
5
- "license": "ISC",
6
- "author": "",
3
+ "version": "6.1.0",
4
+ "description": "Core utilities for building Solana program clients",
5
+ "homepage": "https://www.solanakit.com/api#solanaprogram-client-core",
6
+ "exports": {
7
+ "edge-light": {
8
+ "import": "./dist/index.node.mjs",
9
+ "require": "./dist/index.node.cjs"
10
+ },
11
+ "workerd": {
12
+ "import": "./dist/index.node.mjs",
13
+ "require": "./dist/index.node.cjs"
14
+ },
15
+ "browser": {
16
+ "import": "./dist/index.browser.mjs",
17
+ "require": "./dist/index.browser.cjs"
18
+ },
19
+ "node": {
20
+ "import": "./dist/index.node.mjs",
21
+ "require": "./dist/index.node.cjs"
22
+ },
23
+ "react-native": "./dist/index.native.mjs",
24
+ "types": "./dist/types/index.d.ts"
25
+ },
26
+ "browser": {
27
+ "./dist/index.node.cjs": "./dist/index.browser.cjs",
28
+ "./dist/index.node.mjs": "./dist/index.browser.mjs"
29
+ },
30
+ "main": "./dist/index.node.cjs",
31
+ "module": "./dist/index.node.mjs",
32
+ "react-native": "./dist/index.native.mjs",
33
+ "types": "./dist/types/index.d.ts",
7
34
  "type": "commonjs",
8
- "main": "index.js",
35
+ "files": [
36
+ "./dist/"
37
+ ],
38
+ "sideEffects": false,
39
+ "keywords": [
40
+ "blockchain",
41
+ "solana",
42
+ "web3"
43
+ ],
44
+ "author": "Solana Labs Maintainers <maintainers@solanalabs.com>",
45
+ "license": "MIT",
46
+ "repository": {
47
+ "type": "git",
48
+ "url": "https://github.com/anza-xyz/kit"
49
+ },
50
+ "bugs": {
51
+ "url": "https://github.com/anza-xyz/kit/issues"
52
+ },
53
+ "browserslist": [
54
+ "supports bigint and not dead",
55
+ "maintained node versions"
56
+ ],
57
+ "dependencies": {
58
+ "@solana/accounts": "6.1.0",
59
+ "@solana/addresses": "6.1.0",
60
+ "@solana/errors": "6.1.0",
61
+ "@solana/codecs-core": "6.1.0",
62
+ "@solana/instruction-plans": "6.1.0",
63
+ "@solana/plugin-interfaces": "6.1.0",
64
+ "@solana/instructions": "6.1.0",
65
+ "@solana/rpc-api": "6.1.0",
66
+ "@solana/signers": "6.1.0"
67
+ },
68
+ "peerDependencies": {
69
+ "typescript": "^5.0.0"
70
+ },
71
+ "peerDependenciesMeta": {
72
+ "typescript": {
73
+ "optional": true
74
+ }
75
+ },
76
+ "engines": {
77
+ "node": ">=20.18.0"
78
+ },
9
79
  "scripts": {
10
- "test": "echo \"Error: no test specified\" && exit 1"
80
+ "compile:docs": "typedoc",
81
+ "compile:js": "tsup --config build-scripts/tsup.config.package.ts",
82
+ "compile:typedefs": "tsc -p ./tsconfig.declarations.json",
83
+ "dev": "NODE_OPTIONS=\"--no-experimental-webstorage\" jest -c ../../node_modules/@solana/test-config/jest-dev.config.js --rootDir . --watch",
84
+ "publish-impl": "npm view $npm_package_name@$npm_package_version > /dev/null 2>&1 || (pnpm publish --tag ${PUBLISH_TAG:-canary} --access public --no-git-checks && (([ -n \"${GITHUB_OUTPUT:-}\" ] && echo 'published=true' >> \"$GITHUB_OUTPUT\") || true) && (([ \"$PUBLISH_TAG\" != \"canary\" ] && ../build-scripts/maybe-tag-latest.ts --token \"$GITHUB_TOKEN\" $npm_package_name@$npm_package_version) || true))",
85
+ "publish-packages": "pnpm prepublishOnly && pnpm publish-impl",
86
+ "style:fix": "pnpm eslint --fix src && pnpm prettier --log-level warn --ignore-unknown --write ./*",
87
+ "test:lint": "TERM_OVERRIDE=\"${TURBO_HASH:+dumb}\" TERM=${TERM_OVERRIDE:-$TERM} jest -c ../../node_modules/@solana/test-config/jest-lint.config.js --rootDir . --silent",
88
+ "test:prettier": "TERM_OVERRIDE=\"${TURBO_HASH:+dumb}\" TERM=${TERM_OVERRIDE:-$TERM} jest -c ../../node_modules/@solana/test-config/jest-prettier.config.js --rootDir . --silent",
89
+ "test:treeshakability:browser": "agadoo dist/index.browser.mjs",
90
+ "test:treeshakability:native": "agadoo dist/index.native.mjs",
91
+ "test:treeshakability:node": "agadoo dist/index.node.mjs",
92
+ "test:typecheck": "tsc --noEmit",
93
+ "test:unit:browser": "NODE_OPTIONS=\"--no-experimental-webstorage\" TERM_OVERRIDE=\"${TURBO_HASH:+dumb}\" TERM=${TERM_OVERRIDE:-$TERM} jest -c ../../node_modules/@solana/test-config/jest-unit.config.browser.js --rootDir . --silent",
94
+ "test:unit:node": "NODE_OPTIONS=\"--no-experimental-webstorage\" TERM_OVERRIDE=\"${TURBO_HASH:+dumb}\" TERM=${TERM_OVERRIDE:-$TERM} jest -c ../../node_modules/@solana/test-config/jest-unit.config.node.js --rootDir . --silent"
11
95
  }
12
- }
96
+ }