@solana/instruction-plans 3.0.0-canary-20250726063714 → 3.0.0-canary-20250808140800
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/dist/index.browser.cjs +382 -0
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.mjs +372 -3
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.native.mjs +372 -3
- package/dist/index.native.mjs.map +1 -1
- package/dist/index.node.cjs +382 -0
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.mjs +372 -3
- package/dist/index.node.mjs.map +1 -1
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/transaction-plan-executor.d.ts +53 -0
- package/dist/types/transaction-plan-executor.d.ts.map +1 -0
- package/dist/types/transaction-plan-result.d.ts +303 -0
- package/dist/types/transaction-plan-result.d.ts.map +1 -0
- package/dist/types/transaction-plan.d.ts +243 -0
- package/dist/types/transaction-plan.d.ts.map +1 -0
- package/dist/types/transaction-planner.d.ts +62 -0
- package/dist/types/transaction-planner.d.ts.map +1 -0
- package/package.json +6 -6
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction-plan-result.d.ts","sourceRoot":"","sources":["../../src/transaction-plan-result.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,sBAAsB,EAAE,8BAA8B,EAAE,MAAM,8BAA8B,CAAC;AACtG,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,MAAM,qBAAqB,CAAC,QAAQ,SAAS,4BAA4B,GAAG,4BAA4B,IACxG,6BAA6B,CAAC,QAAQ,CAAC,GACvC,+BAA+B,CAAC,QAAQ,CAAC,GACzC,2BAA2B,CAAC,QAAQ,CAAC,CAAC;AAE5C,yEAAyE;AACzE,MAAM,MA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GACxG,8BAA8B,EAElC,kBAAkB,EAAE,mBAAmB,EACvC,KAAK,EAAE,WAAW,GACnB,2BAA2B,CAAC,QAAQ,EAAE,mBAAmB,CAAC,CAM5D;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,mCAAmC,CAC/C,QAAQ,SAAS,4BAA4B,GAAG,4BAA4B,EAC5E,mBAAmB,SAAS,sBAAsB,GAAG,8BAA8B,GAAG,sBAAsB,GACxG,8BAA8B,EACpC,kBAAkB,EAAE,mBAAmB,GAAG,2BAA2B,CAAC,QAAQ,EAAE,mBAAmB,CAAC,CAMrG"}
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import { BaseTransactionMessage, TransactionMessageWithFeePayer } from '@solana/transaction-messages';
|
|
2
|
+
/**
|
|
3
|
+
* A set of transaction messages with constraints on how they can be executed.
|
|
4
|
+
*
|
|
5
|
+
* This is structured as a recursive tree of plans to allow for
|
|
6
|
+
* parallel execution, sequential execution and combinations of both.
|
|
7
|
+
*
|
|
8
|
+
* Namely, the following plans are supported:
|
|
9
|
+
* - {@link SingleTransactionPlan} - A plan that contains a single transaction message.
|
|
10
|
+
* This is the simplest leaf in this tree.
|
|
11
|
+
* - {@link ParallelTransactionPlan} - A plan that contains other plans that
|
|
12
|
+
* can be executed in parallel.
|
|
13
|
+
* - {@link SequentialTransactionPlan} - A plan that contains other plans that
|
|
14
|
+
* must be executed sequentially. It also defines whether the plan is divisible
|
|
15
|
+
* meaning that transaction messages inside it can be split into separate batches.
|
|
16
|
+
*
|
|
17
|
+
* Helpers are provided for each of these plans to make it easier to create them.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* const myTransactionPlan: TransactionPlan = parallelTransactionPlan([
|
|
22
|
+
* sequentialTransactionPlan([messageA, messageB]),
|
|
23
|
+
* messageC,
|
|
24
|
+
* ]);
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @see {@link SingleTransactionPlan}
|
|
28
|
+
* @see {@link ParallelTransactionPlan}
|
|
29
|
+
* @see {@link SequentialTransactionPlan}
|
|
30
|
+
*/
|
|
31
|
+
export type TransactionPlan = ParallelTransactionPlan | SequentialTransactionPlan | SingleTransactionPlan;
|
|
32
|
+
/**
|
|
33
|
+
* A plan wrapping other plans that must be executed sequentially.
|
|
34
|
+
*
|
|
35
|
+
* It also defines whether nested plans are divisible — meaning that
|
|
36
|
+
* the transaction messages inside them can be split into separate batches.
|
|
37
|
+
* When `divisible` is `false`, the transaction messages inside the plan should
|
|
38
|
+
* all be executed atomically — usually in a transaction bundle.
|
|
39
|
+
*
|
|
40
|
+
* You may use the {@link sequentialTransactionPlan} and {@link nonDivisibleSequentialTransactionPlan}
|
|
41
|
+
* helpers to create objects of this type.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* Simple sequential plan with two transaction messages.
|
|
45
|
+
* ```ts
|
|
46
|
+
* const plan = sequentialTransactionPlan([messageA, messageB]);
|
|
47
|
+
* plan satisfies SequentialTransactionPlan;
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* Non-divisible sequential plan with two transaction messages.
|
|
52
|
+
* ```ts
|
|
53
|
+
* const plan = nonDivisibleSequentialTransactionPlan([messageA, messageB]);
|
|
54
|
+
* plan satisfies SequentialTransactionPlan & { divisible: false };
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* Sequential plan with nested parallel plans.
|
|
59
|
+
* Here, messages A and B can be executed in parallel, but they must both be finalized
|
|
60
|
+
* before messages C and D can be sent — which can also be executed in parallel.
|
|
61
|
+
* ```ts
|
|
62
|
+
* const plan = sequentialTransactionPlan([
|
|
63
|
+
* parallelTransactionPlan([messageA, messageB]),
|
|
64
|
+
* parallelTransactionPlan([messageC, messageD]),
|
|
65
|
+
* ]);
|
|
66
|
+
* ```
|
|
67
|
+
*
|
|
68
|
+
* @see {@link sequentialTransactionPlan}
|
|
69
|
+
* @see {@link nonDivisibleSequentialTransactionPlan}
|
|
70
|
+
*/
|
|
71
|
+
export type SequentialTransactionPlan = Readonly<{
|
|
72
|
+
divisible: boolean;
|
|
73
|
+
kind: 'sequential';
|
|
74
|
+
plans: TransactionPlan[];
|
|
75
|
+
}>;
|
|
76
|
+
/**
|
|
77
|
+
* A plan wrapping other plans that can be executed in parallel.
|
|
78
|
+
*
|
|
79
|
+
* This means direct children of this plan can be executed in separate
|
|
80
|
+
* parallel transactions without causing any side effects.
|
|
81
|
+
* However, the children themselves can define additional constraints
|
|
82
|
+
* for that specific branch of the tree — such as the {@link SequentialTransactionPlan}.
|
|
83
|
+
*
|
|
84
|
+
* You may use the {@link parallelTransactionPlan} helper to create objects of this type.
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* Simple parallel plan with two transaction messages.
|
|
88
|
+
* ```ts
|
|
89
|
+
* const plan = parallelTransactionPlan([messageA, messageB]);
|
|
90
|
+
* plan satisfies ParallelTransactionPlan;
|
|
91
|
+
* ```
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* Parallel plan with nested sequential plans.
|
|
95
|
+
* Here, messages A and B must be executed sequentially and so must messages C and D,
|
|
96
|
+
* but both pairs can be executed in parallel.
|
|
97
|
+
* ```ts
|
|
98
|
+
* const plan = parallelTransactionPlan([
|
|
99
|
+
* sequentialTransactionPlan([messageA, messageB]),
|
|
100
|
+
* sequentialTransactionPlan([messageC, messageD]),
|
|
101
|
+
* ]);
|
|
102
|
+
* plan satisfies ParallelTransactionPlan;
|
|
103
|
+
* ```
|
|
104
|
+
*
|
|
105
|
+
* @see {@link parallelTransactionPlan}
|
|
106
|
+
*/
|
|
107
|
+
export type ParallelTransactionPlan = Readonly<{
|
|
108
|
+
kind: 'parallel';
|
|
109
|
+
plans: TransactionPlan[];
|
|
110
|
+
}>;
|
|
111
|
+
/**
|
|
112
|
+
* A plan that contains a single transaction message.
|
|
113
|
+
*
|
|
114
|
+
* This is a simple transaction message wrapper that transforms a message into a plan.
|
|
115
|
+
*
|
|
116
|
+
* You may use the {@link singleTransactionPlan} helper to create objects of this type.
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```ts
|
|
120
|
+
* const plan = singleTransactionPlan(transactionMessage);
|
|
121
|
+
* plan satisfies SingleTransactionPlan;
|
|
122
|
+
* ```
|
|
123
|
+
*
|
|
124
|
+
* @see {@link singleTransactionPlan}
|
|
125
|
+
*/
|
|
126
|
+
export type SingleTransactionPlan<TTransactionMessage extends BaseTransactionMessage & TransactionMessageWithFeePayer = BaseTransactionMessage & TransactionMessageWithFeePayer> = Readonly<{
|
|
127
|
+
kind: 'single';
|
|
128
|
+
message: TTransactionMessage;
|
|
129
|
+
}>;
|
|
130
|
+
/**
|
|
131
|
+
* Creates a {@link ParallelTransactionPlan} from an array of nested plans.
|
|
132
|
+
*
|
|
133
|
+
* It can accept {@link TransactionMessage} objects directly, which will be wrapped
|
|
134
|
+
* in {@link SingleTransactionPlan | SingleTransactionPlans} automatically.
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* Using explicit {@link SingleTransactionPlan | SingleTransactionPlans}.
|
|
138
|
+
* ```ts
|
|
139
|
+
* const plan = parallelTransactionPlan([
|
|
140
|
+
* singleTransactionPlan(messageA),
|
|
141
|
+
* singleTransactionPlan(messageB),
|
|
142
|
+
* ]);
|
|
143
|
+
* ```
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* Using {@link TransactionMessage | TransactionMessages} directly.
|
|
147
|
+
* ```ts
|
|
148
|
+
* const plan = parallelTransactionPlan([messageA, messageB]);
|
|
149
|
+
* ```
|
|
150
|
+
*
|
|
151
|
+
* @see {@link ParallelTransactionPlan}
|
|
152
|
+
*/
|
|
153
|
+
export declare function parallelTransactionPlan(plans: (TransactionPlan | (BaseTransactionMessage & TransactionMessageWithFeePayer))[]): ParallelTransactionPlan;
|
|
154
|
+
/**
|
|
155
|
+
* Creates a divisible {@link SequentialTransactionPlan} from an array of nested plans.
|
|
156
|
+
*
|
|
157
|
+
* It can accept {@link TransactionMessage} objects directly, which will be wrapped
|
|
158
|
+
* in {@link SingleTransactionPlan | SingleTransactionPlans} automatically.
|
|
159
|
+
*
|
|
160
|
+
* @example
|
|
161
|
+
* Using explicit {@link SingleTransactionPlan | SingleTransactionPlans}.
|
|
162
|
+
* ```ts
|
|
163
|
+
* const plan = sequentialTransactionPlan([
|
|
164
|
+
* singleTransactionPlan(messageA),
|
|
165
|
+
* singleTransactionPlan(messageB),
|
|
166
|
+
* ]);
|
|
167
|
+
* ```
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* Using {@link TransactionMessage | TransactionMessages} directly.
|
|
171
|
+
* ```ts
|
|
172
|
+
* const plan = sequentialTransactionPlan([messageA, messageB]);
|
|
173
|
+
* ```
|
|
174
|
+
*
|
|
175
|
+
* @see {@link SequentialTransactionPlan}
|
|
176
|
+
*/
|
|
177
|
+
export declare function sequentialTransactionPlan(plans: (TransactionPlan | (BaseTransactionMessage & TransactionMessageWithFeePayer))[]): SequentialTransactionPlan & {
|
|
178
|
+
divisible: true;
|
|
179
|
+
};
|
|
180
|
+
/**
|
|
181
|
+
* Creates a non-divisible {@link SequentialTransactionPlan} from an array of nested plans.
|
|
182
|
+
*
|
|
183
|
+
* It can accept {@link TransactionMessage} objects directly, which will be wrapped
|
|
184
|
+
* in {@link SingleTransactionPlan | SingleTransactionPlans} automatically.
|
|
185
|
+
*
|
|
186
|
+
* @example
|
|
187
|
+
* Using explicit {@link SingleTransactionPlan | SingleTransactionPlans}.
|
|
188
|
+
* ```ts
|
|
189
|
+
* const plan = nonDivisibleSequentialTransactionPlan([
|
|
190
|
+
* singleTransactionPlan(messageA),
|
|
191
|
+
* singleTransactionPlan(messageB),
|
|
192
|
+
* ]);
|
|
193
|
+
* ```
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* Using {@link TransactionMessage | TransactionMessages} directly.
|
|
197
|
+
* ```ts
|
|
198
|
+
* const plan = nonDivisibleSequentialTransactionPlan([messageA, messageB]);
|
|
199
|
+
* ```
|
|
200
|
+
*
|
|
201
|
+
* @see {@link SequentialTransactionPlan}
|
|
202
|
+
*/
|
|
203
|
+
export declare function nonDivisibleSequentialTransactionPlan(plans: (TransactionPlan | (BaseTransactionMessage & TransactionMessageWithFeePayer))[]): SequentialTransactionPlan & {
|
|
204
|
+
divisible: false;
|
|
205
|
+
};
|
|
206
|
+
/**
|
|
207
|
+
* Creates a {@link SingleTransactionPlan} from a {@link TransactionMessage} object.
|
|
208
|
+
*
|
|
209
|
+
* @example
|
|
210
|
+
* ```ts
|
|
211
|
+
* const plan = singleTransactionPlan(transactionMessage);
|
|
212
|
+
* plan satisfies SingleTransactionPlan;
|
|
213
|
+
* ```
|
|
214
|
+
*
|
|
215
|
+
* @see {@link SingleTransactionPlan}
|
|
216
|
+
*/
|
|
217
|
+
export declare function singleTransactionPlan<TTransactionMessage extends BaseTransactionMessage & TransactionMessageWithFeePayer = BaseTransactionMessage & TransactionMessageWithFeePayer>(transactionMessage: TTransactionMessage): SingleTransactionPlan<TTransactionMessage>;
|
|
218
|
+
/**
|
|
219
|
+
* Retrieves all individual {@link SingleTransactionPlan} instances from a transaction plan tree.
|
|
220
|
+
*
|
|
221
|
+
* This function recursively traverses any nested structure of transaction plans and extracts
|
|
222
|
+
* all the single transaction plans they contain. It's useful when you need to access all
|
|
223
|
+
* the actual transaction messages that will be executed, regardless of their organization
|
|
224
|
+
* in the plan tree (parallel or sequential).
|
|
225
|
+
*
|
|
226
|
+
* @param transactionPlan - The transaction plan to extract single plans from
|
|
227
|
+
* @returns An array of all single transaction plans contained in the tree
|
|
228
|
+
*
|
|
229
|
+
* @example
|
|
230
|
+
* ```ts
|
|
231
|
+
* const plan = parallelTransactionPlan([
|
|
232
|
+
* sequentialTransactionPlan([messageA, messageB]),
|
|
233
|
+
* nonDivisibleSequentialTransactionPlan([messageC, messageD]),
|
|
234
|
+
* messageE,
|
|
235
|
+
* ]);
|
|
236
|
+
*
|
|
237
|
+
* const singlePlans = getAllSingleTransactionPlans(plan);
|
|
238
|
+
* // Array of `SingleTransactionPlan` containing:
|
|
239
|
+
* // messageA, messageB, messageC and messageD.
|
|
240
|
+
* ```
|
|
241
|
+
*/
|
|
242
|
+
export declare function getAllSingleTransactionPlans(transactionPlan: TransactionPlan): SingleTransactionPlan[];
|
|
243
|
+
//# sourceMappingURL=transaction-plan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction-plan.d.ts","sourceRoot":"","sources":["../../src/transaction-plan.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,8BAA8B,EAAE,MAAM,8BAA8B,CAAC;AAEtG;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,MAAM,eAAe,GAAG,uBAAuB,GAAG,yBAAyB,GAAG,qBAAqB,CAAC;AAE1G;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,MAAM,MAAM,yBAAyB,GAAG,QAAQ,CAAC;IAC7C,SAAS,EAAE,OAAO,CAAC;IACnB,IAAI,EAAE,YAAY,CAAC;IACnB,KAAK,EAAE,eAAe,EAAE,CAAC;CAC5B,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,MAAM,uBAAuB,GAAG,QAAQ,CAAC;IAC3C,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,EAAE,eAAe,EAAE,CAAC;CAC5B,CAAC,CAAC;AAEH;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,qBAAqB,CAC7B,mBAAmB,SAAS,sBAAsB,GAAG,8BAA8B,GAAG,sBAAsB,GACxG,8BAA8B,IAClC,QAAQ,CAAC;IACT,IAAI,EAAE,QAAQ,CAAC;IACf,OAAO,EAAE,mBAAmB,CAAC;CAChC,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,uBAAuB,CACnC,KAAK,EAAE,CAAC,eAAe,GAAG,CAAC,sBAAsB,GAAG,8BAA8B,CAAC,CAAC,EAAE,GACvF,uBAAuB,CAEzB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,yBAAyB,CACrC,KAAK,EAAE,CAAC,eAAe,GAAG,CAAC,sBAAsB,GAAG,8BAA8B,CAAC,CAAC,EAAE,GACvF,yBAAyB,GAAG;IAAE,SAAS,EAAE,IAAI,CAAA;CAAE,CAEjD;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,qCAAqC,CACjD,KAAK,EAAE,CAAC,eAAe,GAAG,CAAC,sBAAsB,GAAG,8BAA8B,CAAC,CAAC,EAAE,GACvF,yBAAyB,GAAG;IAAE,SAAS,EAAE,KAAK,CAAA;CAAE,CAElD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CACjC,mBAAmB,SAAS,sBAAsB,GAAG,8BAA8B,GAAG,sBAAsB,GACxG,8BAA8B,EACpC,kBAAkB,EAAE,mBAAmB,GAAG,qBAAqB,CAAC,mBAAmB,CAAC,CAErF;AAQD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,4BAA4B,CAAC,eAAe,EAAE,eAAe,GAAG,qBAAqB,EAAE,CAKtG"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { BaseTransactionMessage, TransactionMessageWithFeePayer } from '@solana/transaction-messages';
|
|
2
|
+
import { InstructionPlan } from './instruction-plan';
|
|
3
|
+
import { TransactionPlan } from './transaction-plan';
|
|
4
|
+
/**
|
|
5
|
+
* Plans one or more transactions according to the provided instruction plan.
|
|
6
|
+
*
|
|
7
|
+
* @param instructionPlan - The instruction plan to be planned and executed.
|
|
8
|
+
* @param config - Optional configuration object that can include an `AbortSignal` to cancel the planning process.
|
|
9
|
+
*
|
|
10
|
+
* @see {@link InstructionPlan}
|
|
11
|
+
* @see {@link TransactionPlan}
|
|
12
|
+
*/
|
|
13
|
+
export type TransactionPlanner = (instructionPlan: InstructionPlan, config?: {
|
|
14
|
+
abortSignal?: AbortSignal;
|
|
15
|
+
}) => Promise<TransactionPlan>;
|
|
16
|
+
type CreateTransactionMessage = (config?: {
|
|
17
|
+
abortSignal?: AbortSignal;
|
|
18
|
+
}) => Promise<BaseTransactionMessage & TransactionMessageWithFeePayer> | (BaseTransactionMessage & TransactionMessageWithFeePayer);
|
|
19
|
+
type OnTransactionMessageUpdated = <TTransactionMessage extends BaseTransactionMessage & TransactionMessageWithFeePayer>(transactionMessage: TTransactionMessage, config?: {
|
|
20
|
+
abortSignal?: AbortSignal;
|
|
21
|
+
}) => Promise<TTransactionMessage> | TTransactionMessage;
|
|
22
|
+
/**
|
|
23
|
+
* Configuration object for creating a new transaction planner.
|
|
24
|
+
*
|
|
25
|
+
* @see {@link createTransactionPlanner}
|
|
26
|
+
*/
|
|
27
|
+
export type TransactionPlannerConfig = {
|
|
28
|
+
/** Called whenever a new transaction message is needed. */
|
|
29
|
+
createTransactionMessage: CreateTransactionMessage;
|
|
30
|
+
/**
|
|
31
|
+
* Called whenever a transaction message is updated — e.g. new instructions were added.
|
|
32
|
+
* This function must return the updated transaction message back — even if no changes were made.
|
|
33
|
+
*/
|
|
34
|
+
onTransactionMessageUpdated?: OnTransactionMessageUpdated;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Creates a new transaction planner based on the provided configuration.
|
|
38
|
+
*
|
|
39
|
+
* At the very least, the `createTransactionMessage` function must be provided.
|
|
40
|
+
* This function is used to create new transaction messages whenever needed.
|
|
41
|
+
*
|
|
42
|
+
* Additionally, the `onTransactionMessageUpdated` function can be provided
|
|
43
|
+
* to update transaction messages during the planning process. This function will
|
|
44
|
+
* be called whenever a transaction message is updated, e.g. when new instructions
|
|
45
|
+
* are added to a transaction message. It accepts the updated transaction message
|
|
46
|
+
* and must return a transaction message back, even if no changes were made.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```ts
|
|
50
|
+
* const transactionPlanner = createTransactionPlanner({
|
|
51
|
+
* createTransactionMessage: () => pipe(
|
|
52
|
+
* createTransactionMessage({ version: 0 }),
|
|
53
|
+
* message => setTransactionMessageFeePayerSigner(mySigner, message),
|
|
54
|
+
* )
|
|
55
|
+
* });
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* @see {@link TransactionPlannerConfig}
|
|
59
|
+
*/
|
|
60
|
+
export declare function createTransactionPlanner(config: TransactionPlannerConfig): TransactionPlanner;
|
|
61
|
+
export {};
|
|
62
|
+
//# sourceMappingURL=transaction-planner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction-planner.d.ts","sourceRoot":"","sources":["../../src/transaction-planner.ts"],"names":[],"mappings":"AASA,OAAO,EAEH,sBAAsB,EACtB,8BAA8B,EACjC,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EACH,eAAe,EAKlB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAOH,eAAe,EAClB,MAAM,oBAAoB,CAAC;AAE5B;;;;;;;;GAQG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAC7B,eAAe,EAAE,eAAe,EAChC,MAAM,CAAC,EAAE;IAAE,WAAW,CAAC,EAAE,WAAW,CAAA;CAAE,KACrC,OAAO,CAAC,eAAe,CAAC,CAAC;AAI9B,KAAK,wBAAwB,GAAG,CAAC,MAAM,CAAC,EAAE;IACtC,WAAW,CAAC,EAAE,WAAW,CAAC;CAC7B,KACK,OAAO,CAAC,sBAAsB,GAAG,8BAA8B,CAAC,GAChE,CAAC,sBAAsB,GAAG,8BAA8B,CAAC,CAAC;AAEhE,KAAK,2BAA2B,GAAG,CAC/B,mBAAmB,SAAS,sBAAsB,GAAG,8BAA8B,EAEnF,kBAAkB,EAAE,mBAAmB,EACvC,MAAM,CAAC,EAAE;IAAE,WAAW,CAAC,EAAE,WAAW,CAAA;CAAE,KACrC,OAAO,CAAC,mBAAmB,CAAC,GAAG,mBAAmB,CAAC;AAExD;;;;GAIG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACnC,2DAA2D;IAC3D,wBAAwB,EAAE,wBAAwB,CAAC;IACnD;;;OAGG;IACH,2BAA2B,CAAC,EAAE,2BAA2B,CAAC;CAC7D,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,wBAAwB,GAAG,kBAAkB,CAgB7F"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solana/instruction-plans",
|
|
3
|
-
"version": "3.0.0-canary-
|
|
3
|
+
"version": "3.0.0-canary-20250808140800",
|
|
4
4
|
"description": "Construct, plan and execute transactions from multiple instructions.",
|
|
5
5
|
"exports": {
|
|
6
6
|
"edge-light": {
|
|
@@ -54,11 +54,11 @@
|
|
|
54
54
|
"maintained node versions"
|
|
55
55
|
],
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@solana/errors": "3.0.0-canary-
|
|
58
|
-
"@solana/instructions": "3.0.0-canary-
|
|
59
|
-
"@solana/
|
|
60
|
-
"@solana/promises": "3.0.0-canary-
|
|
61
|
-
"@solana/
|
|
57
|
+
"@solana/errors": "3.0.0-canary-20250808140800",
|
|
58
|
+
"@solana/instructions": "3.0.0-canary-20250808140800",
|
|
59
|
+
"@solana/transactions": "3.0.0-canary-20250808140800",
|
|
60
|
+
"@solana/promises": "3.0.0-canary-20250808140800",
|
|
61
|
+
"@solana/transaction-messages": "3.0.0-canary-20250808140800"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
64
|
"typescript": ">=5.3.3"
|