@solana/instruction-plans 0.0.0 → 3.0.0-canary-20250718212840
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 +20 -0
- package/README.md +16 -0
- package/dist/index.browser.cjs +126 -0
- package/dist/index.browser.cjs.map +1 -0
- package/dist/index.browser.mjs +118 -0
- package/dist/index.browser.mjs.map +1 -0
- package/dist/index.native.mjs +118 -0
- package/dist/index.native.mjs.map +1 -0
- package/dist/index.node.cjs +126 -0
- package/dist/index.node.cjs.map +1 -0
- package/dist/index.node.mjs +118 -0
- package/dist/index.node.mjs.map +1 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/instruction-plan.d.ts +394 -0
- package/dist/types/instruction-plan.d.ts.map +1 -0
- package/package.json +83 -8
- package/.bash_logout +0 -7
- package/.bashrc +0 -113
- package/.npm/_cacache/content-v2/sha512/0a/b2/1e3ee5df0f0ccadee46eda1eb4c6136ae97aef14c939de8b5587c1eb4184a7c4abcd7fa2e591ce848be56a879a605042c84093030ae19ec85bdbd6263609 +0 -0
- package/.npm/_cacache/content-v2/sha512/90/55/fd43ac13e9a04d1e752f2bab216c6e7e51f69ed34d4072903ee65f2a1d2fb3437ad06a02ce93f441e2c91d8acd00e0cfe1d0c3ac6f6f0d0ac143a89b271f +0 -0
- package/.npm/_cacache/index-v5/a6/aa/29e44d5a310c9b93c5aa5fba31edf53f53cfa917687cfe0458292b3a2017 +0 -3
- package/.npm/_logs/2025-07-17T21_52_29_821Z-debug-0.log +0 -33
- package/.npm/_logs/2025-07-17T22_01_15_651Z-debug-0.log +0 -62
- package/.npm/_logs/2025-07-17T22_02_14_226Z-debug-0.log +0 -45
- package/.npm/_logs/2025-07-17T22_02_53_059Z-debug-0.log +0 -86
- package/.npm/_logs/2025-07-17T22_03_31_452Z-debug-0.log +0 -48
- package/.npm/_logs/2025-07-17T22_04_15_893Z-debug-0.log +0 -89
- package/.npm/_logs/2025-07-17T22_05_07_641Z-debug-0.log +0 -34
- package/.npm/_update-notifier-last-checked +0 -0
- package/.profile +0 -27
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
import { Instruction } from '@solana/instructions';
|
|
2
|
+
import { BaseTransactionMessage, TransactionMessageWithFeePayer } from '@solana/transaction-messages';
|
|
3
|
+
/**
|
|
4
|
+
* A set of instructions with constraints on how they can be executed.
|
|
5
|
+
*
|
|
6
|
+
* This is structured as a recursive tree of plans in order to allow for
|
|
7
|
+
* parallel execution, sequential execution and combinations of both.
|
|
8
|
+
*
|
|
9
|
+
* Namely the following plans are supported:
|
|
10
|
+
* - {@link SingleInstructionPlan} - A plan that contains a single instruction.
|
|
11
|
+
* This is a simple instruction wrapper and the simplest leaf in this tree.
|
|
12
|
+
* - {@link ParallelInstructionPlan} - A plan that contains other plans that
|
|
13
|
+
* can be executed in parallel.
|
|
14
|
+
* - {@link SequentialInstructionPlan} - A plan that contains other plans that
|
|
15
|
+
* must be executed sequentially. It also defines whether the plan is divisible
|
|
16
|
+
* meaning that instructions inside it can be split into separate transactions.
|
|
17
|
+
* - {@link MessagePackerInstructionPlan} - A plan that can dynamically pack
|
|
18
|
+
* instructions into transaction messages.
|
|
19
|
+
*
|
|
20
|
+
* Helpers are provided for each of these plans to make it easier to create them.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* const myInstructionPlan: InstructionPlan = parallelInstructionPlan([
|
|
25
|
+
* sequentialInstructionPlan([instructionA, instructionB]),
|
|
26
|
+
* instructionC,
|
|
27
|
+
* instructionD,
|
|
28
|
+
* ]);
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @see {@link SingleInstructionPlan}
|
|
32
|
+
* @see {@link ParallelInstructionPlan}
|
|
33
|
+
* @see {@link SequentialInstructionPlan}
|
|
34
|
+
* @see {@link MessagePackerInstructionPlan}
|
|
35
|
+
*/
|
|
36
|
+
export type InstructionPlan = MessagePackerInstructionPlan | ParallelInstructionPlan | SequentialInstructionPlan | SingleInstructionPlan;
|
|
37
|
+
/**
|
|
38
|
+
* A plan wrapping other plans that must be executed sequentially.
|
|
39
|
+
*
|
|
40
|
+
* It also defines whether nested plans are divisible — meaning that
|
|
41
|
+
* the instructions inside them can be split into separate transactions.
|
|
42
|
+
* When `divisible` is `false`, the instructions inside the plan should
|
|
43
|
+
* all be executed atomicly — either in a single transaction or in a
|
|
44
|
+
* transaction bundle.
|
|
45
|
+
*
|
|
46
|
+
* You may use the {@link sequentialInstructionPlan} and {@link nonDivisibleSequentialInstructionPlan}
|
|
47
|
+
* helpers to create objects of this type.
|
|
48
|
+
*
|
|
49
|
+
* @example Simple sequential plan with two instructions.
|
|
50
|
+
* ```ts
|
|
51
|
+
* const plan = sequentialInstructionPlan([instructionA, instructionB]);
|
|
52
|
+
* plan satisfies SequentialInstructionPlan;
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
55
|
+
* @example Non-divisible sequential plan with two instructions.
|
|
56
|
+
* ```ts
|
|
57
|
+
* const plan = nonDivisibleSequentialInstructionPlan([instructionA, instructionB]);
|
|
58
|
+
* plan satisfies SequentialInstructionPlan & { divisible: false };
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* @example Sequential plan with nested parallel plans.
|
|
62
|
+
* Here, instructions A and B can be executed in parallel, but they must both be finalized
|
|
63
|
+
* before instructions C and D can be sent — which can also be executed in parallel.
|
|
64
|
+
* ```ts
|
|
65
|
+
* const plan = sequentialInstructionPlan([
|
|
66
|
+
* parallelInstructionPlan([instructionA, instructionB]),
|
|
67
|
+
* parallelInstructionPlan([instructionC, instructionD]),
|
|
68
|
+
* ]);
|
|
69
|
+
* plan satisfies SequentialInstructionPlan & { divisible: false };
|
|
70
|
+
* ```
|
|
71
|
+
*
|
|
72
|
+
* @see {@link sequentialInstructionPlan}
|
|
73
|
+
* @see {@link nonDivisibleSequentialInstructionPlan}
|
|
74
|
+
*/
|
|
75
|
+
export type SequentialInstructionPlan = Readonly<{
|
|
76
|
+
divisible: boolean;
|
|
77
|
+
kind: 'sequential';
|
|
78
|
+
plans: InstructionPlan[];
|
|
79
|
+
}>;
|
|
80
|
+
/**
|
|
81
|
+
* A plan wrapping other plans that can be executed in parallel.
|
|
82
|
+
*
|
|
83
|
+
* This means direct children of this plan can be executed in separate
|
|
84
|
+
* parallel transactions without consequence.
|
|
85
|
+
* However, the children themselves can define additional constraints
|
|
86
|
+
* for that specific branch of the tree — such as the {@link SequentialInstructionPlan}.
|
|
87
|
+
*
|
|
88
|
+
* You may use the {@link parallelInstructionPlan} helper to create objects of this type.
|
|
89
|
+
*
|
|
90
|
+
* @example Simple parallel plan with two instructions.
|
|
91
|
+
* ```ts
|
|
92
|
+
* const plan = parallelInstructionPlan([instructionA, instructionB]);
|
|
93
|
+
* plan satisfies ParallelInstructionPlan;
|
|
94
|
+
* ```
|
|
95
|
+
*
|
|
96
|
+
* @example Parallel plan with nested sequential plans.
|
|
97
|
+
* Here, instructions A and B must be executed sequentially and so must instructions C and D,
|
|
98
|
+
* but both pairs can be executed in parallel.
|
|
99
|
+
* ```ts
|
|
100
|
+
* const plan = parallelInstructionPlan([
|
|
101
|
+
* sequentialInstructionPlan([instructionA, instructionB]),
|
|
102
|
+
* sequentialInstructionPlan([instructionC, instructionD]),
|
|
103
|
+
* ]);
|
|
104
|
+
* plan satisfies ParallelInstructionPlan;
|
|
105
|
+
* ```
|
|
106
|
+
*
|
|
107
|
+
* @see {@link parallelInstructionPlan}
|
|
108
|
+
*/
|
|
109
|
+
export type ParallelInstructionPlan = Readonly<{
|
|
110
|
+
kind: 'parallel';
|
|
111
|
+
plans: InstructionPlan[];
|
|
112
|
+
}>;
|
|
113
|
+
/**
|
|
114
|
+
* A plan that contains a single instruction.
|
|
115
|
+
*
|
|
116
|
+
* This is a simple instruction wrapper that transforms an instruction into a plan.
|
|
117
|
+
*
|
|
118
|
+
* You may use the {@link singleInstructionPlan} helper to create objects of this type.
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* ```ts
|
|
122
|
+
* const plan = singleInstructionPlan(instructionA);
|
|
123
|
+
* plan satisfies SingleInstructionPlan;
|
|
124
|
+
* ```
|
|
125
|
+
*
|
|
126
|
+
* @see {@link singleInstructionPlan}
|
|
127
|
+
*/
|
|
128
|
+
export type SingleInstructionPlan<TInstruction extends Instruction = Instruction> = Readonly<{
|
|
129
|
+
instruction: TInstruction;
|
|
130
|
+
kind: 'single';
|
|
131
|
+
}>;
|
|
132
|
+
/**
|
|
133
|
+
* A plan that can dynamically pack instructions into transaction messages.
|
|
134
|
+
*
|
|
135
|
+
* This plan provides a {@link MessagePacker} via the `getMessagePacker`
|
|
136
|
+
* method, which enables instructions to be dynamically packed into the
|
|
137
|
+
* provided transaction message until there are no more instructions to pack.
|
|
138
|
+
* The returned {@link MessagePacker} offers a `packMessageToCapacity(message)`
|
|
139
|
+
* method that packs the provided message — when possible — and a `done()` method
|
|
140
|
+
* that checks whether there are more instructions to pack.
|
|
141
|
+
*
|
|
142
|
+
* Several helper functions are provided to create objects of this type such as
|
|
143
|
+
* {@link getLinearMessagePackerInstructionPlan} or {@link getMessagePackerInstructionPlanFromInstructions}.
|
|
144
|
+
*
|
|
145
|
+
* @example An message packer plan for a write instruction that uses as many bytes as possible.
|
|
146
|
+
* ```ts
|
|
147
|
+
* const plan = getLinearMessagePackerInstructionPlan({
|
|
148
|
+
* totalLength: dataToWrite.length,
|
|
149
|
+
* getInstruction: (offset, length) =>
|
|
150
|
+
* getWriteInstruction({
|
|
151
|
+
* offset,
|
|
152
|
+
* data: dataToWrite.slice(offset, offset + length),
|
|
153
|
+
* }),
|
|
154
|
+
* });
|
|
155
|
+
* plan satisfies MessagePackerInstructionPlan;
|
|
156
|
+
* ```
|
|
157
|
+
*
|
|
158
|
+
* @example A message packer plan for multiple realloc instructions.
|
|
159
|
+
* ```ts
|
|
160
|
+
* const plan = getReallocMessagePackerInstructionPlan({
|
|
161
|
+
* totalSize: additionalDataSize,
|
|
162
|
+
* getInstruction: (size) => getExtendInstruction({ length: size }),
|
|
163
|
+
* });
|
|
164
|
+
* plan satisfies MessagePackerInstructionPlan;
|
|
165
|
+
* ```
|
|
166
|
+
*
|
|
167
|
+
* @example Using a message packer plan.
|
|
168
|
+
* ```ts
|
|
169
|
+
* let plan: MessagePackerInstructionPlan;
|
|
170
|
+
* const messagePacker = plan.getMessagePacker();
|
|
171
|
+
*
|
|
172
|
+
* while (!messagePacker.done()) {
|
|
173
|
+
* try {
|
|
174
|
+
* transactionMessage = messagePacker.packMessageToCapacity(transactionMessage);
|
|
175
|
+
* } catch (error) {
|
|
176
|
+
* // The current transaction message cannot be used to pack this plan.
|
|
177
|
+
* // We should create a new one and try again.
|
|
178
|
+
* }
|
|
179
|
+
* }
|
|
180
|
+
* ```
|
|
181
|
+
*
|
|
182
|
+
* @see {@link getLinearMessagePackerInstructionPlan}
|
|
183
|
+
* @see {@link getMessagePackerInstructionPlanFromInstructions}
|
|
184
|
+
* @see {@link getReallocMessagePackerInstructionPlan}
|
|
185
|
+
*/
|
|
186
|
+
export type MessagePackerInstructionPlan = Readonly<{
|
|
187
|
+
getMessagePacker: () => MessagePacker;
|
|
188
|
+
kind: 'messagePacker';
|
|
189
|
+
}>;
|
|
190
|
+
/**
|
|
191
|
+
* The message packer returned by the {@link MessagePackerInstructionPlan}.
|
|
192
|
+
*
|
|
193
|
+
* It offers a `packMessageToCapacity(transactionMessage)` method that packs as many instructions
|
|
194
|
+
* as possible into the provided transaction message, while still being able to fit into the
|
|
195
|
+
* transaction size limit. It returns the updated transaction message with the packed instructions
|
|
196
|
+
* or throws an error if the current transaction message cannot accommodate this plan.
|
|
197
|
+
*
|
|
198
|
+
* The `done()` method checks whether there are more instructions to pack into
|
|
199
|
+
* transaction messages.
|
|
200
|
+
*
|
|
201
|
+
* @example
|
|
202
|
+
* ```ts
|
|
203
|
+
* let plan: MessagePackerInstructionPlan;
|
|
204
|
+
* const messagePacker = plan.getMessagePacker();
|
|
205
|
+
*
|
|
206
|
+
* while (!messagePacker.done()) {
|
|
207
|
+
* try {
|
|
208
|
+
* transactionMessage = messagePacker.packMessageToCapacity(transactionMessage);
|
|
209
|
+
* } catch (error) {
|
|
210
|
+
* // The current transaction message cannot be used to pack this plan.
|
|
211
|
+
* // We should create a new one and try again.
|
|
212
|
+
* }
|
|
213
|
+
* }
|
|
214
|
+
* ```
|
|
215
|
+
*
|
|
216
|
+
* @see {@link MessagePackerInstructionPlan}
|
|
217
|
+
*/
|
|
218
|
+
export type MessagePacker = Readonly<{
|
|
219
|
+
/** Checks whether the message packer has more instructions to pack into transaction messages. */
|
|
220
|
+
done: () => boolean;
|
|
221
|
+
/**
|
|
222
|
+
* Packs the provided transaction message with instructions or throws if not possible.
|
|
223
|
+
*
|
|
224
|
+
* @throws {@link SOLANA_ERROR__INSTRUCTION_PLANS__MESSAGE_CANNOT_ACCOMMODATE_PLAN}
|
|
225
|
+
* if the provided transaction message cannot be used to fill the next instructions.
|
|
226
|
+
* @throws {@link SOLANA_ERROR__INSTRUCTION_PLANS__MESSAGE_PACKER_ALREADY_COMPLETE}
|
|
227
|
+
* if the message packer is already done and no more instructions can be packed.
|
|
228
|
+
*/
|
|
229
|
+
packMessageToCapacity: (transactionMessage: BaseTransactionMessage & TransactionMessageWithFeePayer) => BaseTransactionMessage & TransactionMessageWithFeePayer;
|
|
230
|
+
}>;
|
|
231
|
+
/**
|
|
232
|
+
* Creates a {@link ParallelInstructionPlan} from an array of nested plans.
|
|
233
|
+
*
|
|
234
|
+
* It can accept {@link Instruction} objects directly, which will be wrapped
|
|
235
|
+
* in {@link SingleInstructionPlan | SingleInstructionPlans} automatically.
|
|
236
|
+
*
|
|
237
|
+
* @example Using explicit {@link SingleInstructionPlan | SingleInstructionPlans}.
|
|
238
|
+
* ```ts
|
|
239
|
+
* const plan = parallelInstructionPlan([
|
|
240
|
+
* singleInstructionPlan(instructionA),
|
|
241
|
+
* singleInstructionPlan(instructionB),
|
|
242
|
+
* ]);
|
|
243
|
+
* ```
|
|
244
|
+
*
|
|
245
|
+
* @example Using {@link Instruction | Instructions} directly.
|
|
246
|
+
* ```ts
|
|
247
|
+
* const plan = parallelInstructionPlan([instructionA, instructionB]);
|
|
248
|
+
* ```
|
|
249
|
+
*
|
|
250
|
+
* @see {@link ParallelInstructionPlan}
|
|
251
|
+
*/
|
|
252
|
+
export declare function parallelInstructionPlan(plans: (Instruction | InstructionPlan)[]): ParallelInstructionPlan;
|
|
253
|
+
/**
|
|
254
|
+
* Creates a divisible {@link SequentialInstructionPlan} from an array of nested plans.
|
|
255
|
+
*
|
|
256
|
+
* It can accept {@link Instruction} objects directly, which will be wrapped
|
|
257
|
+
* in {@link SingleInstructionPlan | SingleInstructionPlans} automatically.
|
|
258
|
+
*
|
|
259
|
+
* @example Using explicit {@link SingleInstructionPlan | SingleInstructionPlans}.
|
|
260
|
+
* ```ts
|
|
261
|
+
* const plan = sequentialInstructionPlan([
|
|
262
|
+
* singleInstructionPlan(instructionA),
|
|
263
|
+
* singleInstructionPlan(instructionB),
|
|
264
|
+
* ]);
|
|
265
|
+
* ```
|
|
266
|
+
*
|
|
267
|
+
* @example Using {@link Instruction | Instructions} directly.
|
|
268
|
+
* ```ts
|
|
269
|
+
* const plan = sequentialInstructionPlan([instructionA, instructionB]);
|
|
270
|
+
* ```
|
|
271
|
+
*
|
|
272
|
+
* @see {@link SequentialInstructionPlan}
|
|
273
|
+
*/
|
|
274
|
+
export declare function sequentialInstructionPlan(plans: (Instruction | InstructionPlan)[]): SequentialInstructionPlan & {
|
|
275
|
+
divisible: true;
|
|
276
|
+
};
|
|
277
|
+
/**
|
|
278
|
+
* Creates a non-divisible {@link SequentialInstructionPlan} from an array of nested plans.
|
|
279
|
+
*
|
|
280
|
+
* It can accept {@link Instruction} objects directly, which will be wrapped
|
|
281
|
+
* in {@link SingleInstructionPlan | SingleInstructionPlans} automatically.
|
|
282
|
+
*
|
|
283
|
+
* @example Using explicit {@link SingleInstructionPlan | SingleInstructionPlans}.
|
|
284
|
+
* ```ts
|
|
285
|
+
* const plan = nonDivisibleSequentialInstructionPlan([
|
|
286
|
+
* singleInstructionPlan(instructionA),
|
|
287
|
+
* singleInstructionPlan(instructionB),
|
|
288
|
+
* ]);
|
|
289
|
+
* ```
|
|
290
|
+
*
|
|
291
|
+
* @example Using {@link Instruction | Instructions} directly.
|
|
292
|
+
* ```ts
|
|
293
|
+
* const plan = nonDivisibleSequentialInstructionPlan([instructionA, instructionB]);
|
|
294
|
+
* ```
|
|
295
|
+
*
|
|
296
|
+
* @see {@link SequentialInstructionPlan}
|
|
297
|
+
*/
|
|
298
|
+
export declare function nonDivisibleSequentialInstructionPlan(plans: (Instruction | InstructionPlan)[]): SequentialInstructionPlan & {
|
|
299
|
+
divisible: false;
|
|
300
|
+
};
|
|
301
|
+
/**
|
|
302
|
+
* Creates a {@link SingleInstructionPlan} from an {@link Instruction} object.
|
|
303
|
+
*
|
|
304
|
+
* @example
|
|
305
|
+
* ```ts
|
|
306
|
+
* const plan = singleInstructionPlan(instructionA);
|
|
307
|
+
* ```
|
|
308
|
+
*
|
|
309
|
+
* @see {@link SingleInstructionPlan}
|
|
310
|
+
*/
|
|
311
|
+
export declare function singleInstructionPlan(instruction: Instruction): SingleInstructionPlan;
|
|
312
|
+
/**
|
|
313
|
+
* Creates a {@link MessagePackerInstructionPlan} that packs instructions
|
|
314
|
+
* such that each instruction consumes as many bytes as possible from the given
|
|
315
|
+
* `totalLength` while still being able to fit into the given transaction messages.
|
|
316
|
+
*
|
|
317
|
+
* This is particularly useful for instructions that write data to accounts and must
|
|
318
|
+
* span multiple transactions due to their size limit.
|
|
319
|
+
*
|
|
320
|
+
* This message packer will first call `getInstruction` with a length of zero to
|
|
321
|
+
* determine the base size of the instruction before figuring out how many
|
|
322
|
+
* additional bytes can be packed into the transaction message. That remaining space
|
|
323
|
+
* will then be used to call `getInstruction` again with the appropriate length.
|
|
324
|
+
*
|
|
325
|
+
* @param getInstruction - A function that returns an instruction for a given offset and length.
|
|
326
|
+
* @param totalLength - The total length of the data to write, in bytes.
|
|
327
|
+
*
|
|
328
|
+
* @example
|
|
329
|
+
* ```ts
|
|
330
|
+
* const plan = getLinearMessagePackerInstructionPlan({
|
|
331
|
+
* totalLength: dataToWrite.length,
|
|
332
|
+
* getInstruction: (offset, length) =>
|
|
333
|
+
* getWriteInstruction({
|
|
334
|
+
* offset,
|
|
335
|
+
* data: dataToWrite.slice(offset, offset + length),
|
|
336
|
+
* }),
|
|
337
|
+
* });
|
|
338
|
+
* plan satisfies MessagePackerInstructionPlan;
|
|
339
|
+
* ```
|
|
340
|
+
*
|
|
341
|
+
* @see {@link MessagePackerInstructionPlan}
|
|
342
|
+
*/
|
|
343
|
+
export declare function getLinearMessagePackerInstructionPlan({ getInstruction, totalLength: totalBytes, }: {
|
|
344
|
+
getInstruction: (offset: number, length: number) => Instruction;
|
|
345
|
+
totalLength: number;
|
|
346
|
+
}): MessagePackerInstructionPlan;
|
|
347
|
+
/**
|
|
348
|
+
* Creates a {@link MessagePackerInstructionPlan} from a list of instructions.
|
|
349
|
+
*
|
|
350
|
+
* This can be useful to prepare a set of instructions that can be iterated over
|
|
351
|
+
* — e.g. to pack a list of instructions that gradually reallocate the size of an account
|
|
352
|
+
* one `REALLOC_LIMIT` (10'240 bytes) at a time.
|
|
353
|
+
*
|
|
354
|
+
* @example
|
|
355
|
+
* ```ts
|
|
356
|
+
* const plan = getMessagePackerInstructionPlanFromInstructions([
|
|
357
|
+
* instructionA,
|
|
358
|
+
* instructionB,
|
|
359
|
+
* instructionC,
|
|
360
|
+
* ]);
|
|
361
|
+
*
|
|
362
|
+
* const messagePacker = plan.getMessagePacker();
|
|
363
|
+
* firstTransactionMessage = messagePacker.packMessageToCapacity(firstTransactionMessage);
|
|
364
|
+
* // Contains instruction A and instruction B.
|
|
365
|
+
* secondTransactionMessage = messagePacker.packMessageToCapacity(secondTransactionMessage);
|
|
366
|
+
* // Contains instruction C.
|
|
367
|
+
* messagePacker.done(); // true
|
|
368
|
+
* ```
|
|
369
|
+
*
|
|
370
|
+
* @see {@link MessagePackerInstructionPlan}
|
|
371
|
+
* @see {@link getReallocMessagePackerInstructionPlan}
|
|
372
|
+
*/
|
|
373
|
+
export declare function getMessagePackerInstructionPlanFromInstructions<TInstruction extends Instruction = Instruction>(instructions: TInstruction[]): MessagePackerInstructionPlan;
|
|
374
|
+
/**
|
|
375
|
+
* Creates a {@link MessagePackerInstructionPlan} that packs a list of realloc instructions.
|
|
376
|
+
*
|
|
377
|
+
* That is, it splits instruction by chunks of `REALLOC_LIMIT` (10'240) bytes until
|
|
378
|
+
* the given total size is reached.
|
|
379
|
+
*
|
|
380
|
+
* @example
|
|
381
|
+
* ```ts
|
|
382
|
+
* const plan = getReallocMessagePackerInstructionPlan({
|
|
383
|
+
* totalSize: additionalDataSize,
|
|
384
|
+
* getInstruction: (size) => getExtendInstruction({ length: size }),
|
|
385
|
+
* });
|
|
386
|
+
* ```
|
|
387
|
+
*
|
|
388
|
+
* @see {@link MessagePackerInstructionPlan}
|
|
389
|
+
*/
|
|
390
|
+
export declare function getReallocMessagePackerInstructionPlan({ getInstruction, totalSize, }: {
|
|
391
|
+
getInstruction: (size: number) => Instruction;
|
|
392
|
+
totalSize: number;
|
|
393
|
+
}): MessagePackerInstructionPlan;
|
|
394
|
+
//# sourceMappingURL=instruction-plan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instruction-plan.d.ts","sourceRoot":"","sources":["../../src/instruction-plan.ts"],"names":[],"mappings":"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"}
|
package/package.json
CHANGED
|
@@ -1,11 +1,86 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solana/instruction-plans",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "",
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
"version": "3.0.0-canary-20250718212840",
|
|
4
|
+
"description": "Construct, plan and execute transactions from multiple instructions.",
|
|
5
|
+
"exports": {
|
|
6
|
+
"edge-light": {
|
|
7
|
+
"import": "./dist/index.node.mjs",
|
|
8
|
+
"require": "./dist/index.node.cjs"
|
|
9
|
+
},
|
|
10
|
+
"workerd": {
|
|
11
|
+
"import": "./dist/index.node.mjs",
|
|
12
|
+
"require": "./dist/index.node.cjs"
|
|
13
|
+
},
|
|
14
|
+
"browser": {
|
|
15
|
+
"import": "./dist/index.browser.mjs",
|
|
16
|
+
"require": "./dist/index.browser.cjs"
|
|
17
|
+
},
|
|
18
|
+
"node": {
|
|
19
|
+
"import": "./dist/index.node.mjs",
|
|
20
|
+
"require": "./dist/index.node.cjs"
|
|
21
|
+
},
|
|
22
|
+
"react-native": "./dist/index.native.mjs",
|
|
23
|
+
"types": "./dist/types/index.d.ts"
|
|
24
|
+
},
|
|
25
|
+
"browser": {
|
|
26
|
+
"./dist/index.node.cjs": "./dist/index.browser.cjs",
|
|
27
|
+
"./dist/index.node.mjs": "./dist/index.browser.mjs"
|
|
28
|
+
},
|
|
29
|
+
"main": "./dist/index.node.cjs",
|
|
30
|
+
"module": "./dist/index.node.mjs",
|
|
31
|
+
"react-native": "./dist/index.native.mjs",
|
|
32
|
+
"types": "./dist/types/index.d.ts",
|
|
33
|
+
"type": "commonjs",
|
|
34
|
+
"files": [
|
|
35
|
+
"./dist/"
|
|
36
|
+
],
|
|
37
|
+
"sideEffects": false,
|
|
38
|
+
"keywords": [
|
|
39
|
+
"blockchain",
|
|
40
|
+
"solana",
|
|
41
|
+
"web3"
|
|
42
|
+
],
|
|
43
|
+
"author": "Solana Labs Maintainers <maintainers@solanalabs.com>",
|
|
44
|
+
"license": "MIT",
|
|
45
|
+
"repository": {
|
|
46
|
+
"type": "git",
|
|
47
|
+
"url": "https://github.com/anza-xyz/kit"
|
|
48
|
+
},
|
|
49
|
+
"bugs": {
|
|
50
|
+
"url": "https://github.com/anza-xyz/kit/issues"
|
|
8
51
|
},
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
|
|
52
|
+
"browserslist": [
|
|
53
|
+
"supports bigint and not dead",
|
|
54
|
+
"maintained node versions"
|
|
55
|
+
],
|
|
56
|
+
"dependencies": {
|
|
57
|
+
"@solana/errors": "3.0.0-canary-20250718212840",
|
|
58
|
+
"@solana/promises": "3.0.0-canary-20250718212840",
|
|
59
|
+
"@solana/instructions": "3.0.0-canary-20250718212840",
|
|
60
|
+
"@solana/transactions": "3.0.0-canary-20250718212840",
|
|
61
|
+
"@solana/transaction-messages": "3.0.0-canary-20250718212840"
|
|
62
|
+
},
|
|
63
|
+
"peerDependencies": {
|
|
64
|
+
"typescript": ">=5.3.3"
|
|
65
|
+
},
|
|
66
|
+
"engines": {
|
|
67
|
+
"node": ">=20.18.0"
|
|
68
|
+
},
|
|
69
|
+
"scripts": {
|
|
70
|
+
"compile:docs": "typedoc",
|
|
71
|
+
"compile:js": "tsup --config build-scripts/tsup.config.package.ts",
|
|
72
|
+
"compile:typedefs": "tsc -p ./tsconfig.declarations.json",
|
|
73
|
+
"dev": "jest -c ../../node_modules/@solana/test-config/jest-dev.config.ts --rootDir . --watch",
|
|
74
|
+
"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 && (([ \"$PUBLISH_TAG\" != \"canary\" ] && pnpm dist-tag add $npm_package_name@$npm_package_version latest) || true))",
|
|
75
|
+
"publish-packages": "pnpm prepublishOnly && pnpm publish-impl",
|
|
76
|
+
"style:fix": "pnpm eslint --fix src && pnpm prettier --log-level warn --ignore-unknown --write ./*",
|
|
77
|
+
"test:lint": "TERM_OVERRIDE=\"${TURBO_HASH:+dumb}\" TERM=${TERM_OVERRIDE:-$TERM} jest -c ../../node_modules/@solana/test-config/jest-lint.config.ts --rootDir . --silent",
|
|
78
|
+
"test:prettier": "TERM_OVERRIDE=\"${TURBO_HASH:+dumb}\" TERM=${TERM_OVERRIDE:-$TERM} jest -c ../../node_modules/@solana/test-config/jest-prettier.config.ts --rootDir . --silent",
|
|
79
|
+
"test:treeshakability:browser": "agadoo dist/index.browser.mjs",
|
|
80
|
+
"test:treeshakability:native": "agadoo dist/index.native.mjs",
|
|
81
|
+
"test:treeshakability:node": "agadoo dist/index.node.mjs",
|
|
82
|
+
"test:typecheck": "tsc --noEmit",
|
|
83
|
+
"test:unit:browser": "TERM_OVERRIDE=\"${TURBO_HASH:+dumb}\" TERM=${TERM_OVERRIDE:-$TERM} jest -c ../../node_modules/@solana/test-config/jest-unit.config.browser.ts --rootDir . --silent",
|
|
84
|
+
"test:unit:node": "TERM_OVERRIDE=\"${TURBO_HASH:+dumb}\" TERM=${TERM_OVERRIDE:-$TERM} jest -c ../../node_modules/@solana/test-config/jest-unit.config.node.ts --rootDir . --silent"
|
|
85
|
+
}
|
|
86
|
+
}
|
package/.bash_logout
DELETED
package/.bashrc
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
# ~/.bashrc: executed by bash(1) for non-login shells.
|
|
2
|
-
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
|
|
3
|
-
# for examples
|
|
4
|
-
|
|
5
|
-
# If not running interactively, don't do anything
|
|
6
|
-
case $- in
|
|
7
|
-
*i*) ;;
|
|
8
|
-
*) return;;
|
|
9
|
-
esac
|
|
10
|
-
|
|
11
|
-
# don't put duplicate lines or lines starting with space in the history.
|
|
12
|
-
# See bash(1) for more options
|
|
13
|
-
HISTCONTROL=ignoreboth
|
|
14
|
-
|
|
15
|
-
# append to the history file, don't overwrite it
|
|
16
|
-
shopt -s histappend
|
|
17
|
-
|
|
18
|
-
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
|
|
19
|
-
HISTSIZE=1000
|
|
20
|
-
HISTFILESIZE=2000
|
|
21
|
-
|
|
22
|
-
# check the window size after each command and, if necessary,
|
|
23
|
-
# update the values of LINES and COLUMNS.
|
|
24
|
-
shopt -s checkwinsize
|
|
25
|
-
|
|
26
|
-
# If set, the pattern "**" used in a pathname expansion context will
|
|
27
|
-
# match all files and zero or more directories and subdirectories.
|
|
28
|
-
#shopt -s globstar
|
|
29
|
-
|
|
30
|
-
# make less more friendly for non-text input files, see lesspipe(1)
|
|
31
|
-
#[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
|
|
32
|
-
|
|
33
|
-
# set variable identifying the chroot you work in (used in the prompt below)
|
|
34
|
-
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
|
|
35
|
-
debian_chroot=$(cat /etc/debian_chroot)
|
|
36
|
-
fi
|
|
37
|
-
|
|
38
|
-
# set a fancy prompt (non-color, unless we know we "want" color)
|
|
39
|
-
case "$TERM" in
|
|
40
|
-
xterm-color|*-256color) color_prompt=yes;;
|
|
41
|
-
esac
|
|
42
|
-
|
|
43
|
-
# uncomment for a colored prompt, if the terminal has the capability; turned
|
|
44
|
-
# off by default to not distract the user: the focus in a terminal window
|
|
45
|
-
# should be on the output of commands, not on the prompt
|
|
46
|
-
#force_color_prompt=yes
|
|
47
|
-
|
|
48
|
-
if [ -n "$force_color_prompt" ]; then
|
|
49
|
-
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
|
|
50
|
-
# We have color support; assume it's compliant with Ecma-48
|
|
51
|
-
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
|
|
52
|
-
# a case would tend to support setf rather than setaf.)
|
|
53
|
-
color_prompt=yes
|
|
54
|
-
else
|
|
55
|
-
color_prompt=
|
|
56
|
-
fi
|
|
57
|
-
fi
|
|
58
|
-
|
|
59
|
-
if [ "$color_prompt" = yes ]; then
|
|
60
|
-
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
|
|
61
|
-
else
|
|
62
|
-
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
|
|
63
|
-
fi
|
|
64
|
-
unset color_prompt force_color_prompt
|
|
65
|
-
|
|
66
|
-
# If this is an xterm set the title to user@host:dir
|
|
67
|
-
case "$TERM" in
|
|
68
|
-
xterm*|rxvt*)
|
|
69
|
-
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
|
|
70
|
-
;;
|
|
71
|
-
*)
|
|
72
|
-
;;
|
|
73
|
-
esac
|
|
74
|
-
|
|
75
|
-
# enable color support of ls and also add handy aliases
|
|
76
|
-
if [ -x /usr/bin/dircolors ]; then
|
|
77
|
-
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
|
|
78
|
-
alias ls='ls --color=auto'
|
|
79
|
-
#alias dir='dir --color=auto'
|
|
80
|
-
#alias vdir='vdir --color=auto'
|
|
81
|
-
|
|
82
|
-
#alias grep='grep --color=auto'
|
|
83
|
-
#alias fgrep='fgrep --color=auto'
|
|
84
|
-
#alias egrep='egrep --color=auto'
|
|
85
|
-
fi
|
|
86
|
-
|
|
87
|
-
# colored GCC warnings and errors
|
|
88
|
-
#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
|
|
89
|
-
|
|
90
|
-
# some more ls aliases
|
|
91
|
-
#alias ll='ls -l'
|
|
92
|
-
#alias la='ls -A'
|
|
93
|
-
#alias l='ls -CF'
|
|
94
|
-
|
|
95
|
-
# Alias definitions.
|
|
96
|
-
# You may want to put all your additions into a separate file like
|
|
97
|
-
# ~/.bash_aliases, instead of adding them here directly.
|
|
98
|
-
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
|
|
99
|
-
|
|
100
|
-
if [ -f ~/.bash_aliases ]; then
|
|
101
|
-
. ~/.bash_aliases
|
|
102
|
-
fi
|
|
103
|
-
|
|
104
|
-
# enable programmable completion features (you don't need to enable
|
|
105
|
-
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
|
|
106
|
-
# sources /etc/bash.bashrc).
|
|
107
|
-
if ! shopt -oq posix; then
|
|
108
|
-
if [ -f /usr/share/bash-completion/bash_completion ]; then
|
|
109
|
-
. /usr/share/bash-completion/bash_completion
|
|
110
|
-
elif [ -f /etc/bash_completion ]; then
|
|
111
|
-
. /etc/bash_completion
|
|
112
|
-
fi
|
|
113
|
-
fi
|
|
Binary file
|
|
Binary file
|
package/.npm/_cacache/index-v5/a6/aa/29e44d5a310c9b93c5aa5fba31edf53f53cfa917687cfe0458292b3a2017
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
3d8a1521c0ac537da42611d55e42cb96f9d78495 {"key":"pacote:tarball:file:/home/jacob_creech","integrity":"sha512-kFX9Q6wT6aBNHnUvK6shbG5+Ufae001AcpA+5l8qHS+zQ3rQagLOk/RB4skdis0A4M/h0MOsb28NCsFDqJsnHw==","time":1752789773163,"size":3571}
|
|
3
|
-
28dd201d2d1e608c0dfa1a82cedbb508a0ed702b {"key":"pacote:tarball:file:/home/jacob_creech","integrity":"sha512-CrIePuXfDwzK3uRu2h60xhNq6XrvFMk53otVh8HrQYSnxKvNf6Llkc6Ei+Vqh5pgUELIQJMDCuGeyFvb1iY2CQ==","time":1752789856056,"size":9293}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
0 verbose cli /usr/bin/node /usr/bin/npm
|
|
2
|
-
1 info using npm@9.2.0
|
|
3
|
-
2 info using node@v18.19.0
|
|
4
|
-
3 timing npm:load:whichnode Completed in 0ms
|
|
5
|
-
4 timing config:load:defaults Completed in 2ms
|
|
6
|
-
5 timing config:load:file:/usr/share/nodejs/npm/npmrc Completed in 3ms
|
|
7
|
-
6 timing config:load:builtin Completed in 3ms
|
|
8
|
-
7 timing config:load:cli Completed in 2ms
|
|
9
|
-
8 timing config:load:env Completed in 0ms
|
|
10
|
-
9 timing config:load:project Completed in 1ms
|
|
11
|
-
10 timing config:load:file:/home/jacob_creech/.npmrc Completed in 1ms
|
|
12
|
-
11 timing config:load:user Completed in 1ms
|
|
13
|
-
12 timing config:load:file:/etc/npmrc Completed in 0ms
|
|
14
|
-
13 timing config:load:global Completed in 0ms
|
|
15
|
-
14 timing config:load:setEnvs Completed in 1ms
|
|
16
|
-
15 timing config:load Completed in 10ms
|
|
17
|
-
16 timing npm:load:configload Completed in 10ms
|
|
18
|
-
17 timing npm:load:mkdirpcache Completed in 1ms
|
|
19
|
-
18 timing npm:load:mkdirplogs Completed in 0ms
|
|
20
|
-
19 verbose title npm
|
|
21
|
-
20 verbose argv "--version"
|
|
22
|
-
21 timing npm:load:setTitle Completed in 2ms
|
|
23
|
-
22 timing config:load:flatten Completed in 3ms
|
|
24
|
-
23 timing npm:load:display Completed in 4ms
|
|
25
|
-
24 verbose logfile logs-max:10 dir:/home/jacob_creech/.npm/_logs/2025-07-17T21_52_29_821Z-
|
|
26
|
-
25 verbose logfile /home/jacob_creech/.npm/_logs/2025-07-17T21_52_29_821Z-debug-0.log
|
|
27
|
-
26 timing npm:load:logFile Completed in 5ms
|
|
28
|
-
27 timing npm:load:timers Completed in 0ms
|
|
29
|
-
28 timing npm:load:configScope Completed in 0ms
|
|
30
|
-
29 timing npm:load Completed in 23ms
|
|
31
|
-
30 verbose exit 0
|
|
32
|
-
31 timing npm Completed in 31ms
|
|
33
|
-
32 info ok
|