@solana-program/compute-budget 0.6.1 → 0.8.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.
Files changed (37) hide show
  1. package/dist/src/index.js +271 -53
  2. package/dist/src/index.js.map +1 -1
  3. package/dist/src/index.mjs +212 -2
  4. package/dist/src/index.mjs.map +1 -1
  5. package/dist/types/constants.d.ts +12 -0
  6. package/dist/types/constants.d.ts.map +1 -0
  7. package/dist/types/estimateAndSetComputeLimit.d.ts +24 -0
  8. package/dist/types/estimateAndSetComputeLimit.d.ts.map +1 -0
  9. package/dist/types/estimateComputeLimit.d.ts +63 -0
  10. package/dist/types/estimateComputeLimit.d.ts.map +1 -0
  11. package/dist/types/estimateComputeLimitInternal.d.ts +87 -0
  12. package/dist/types/estimateComputeLimitInternal.d.ts.map +1 -0
  13. package/dist/types/generated/instructions/requestHeapFrame.d.ts +2 -2
  14. package/dist/types/generated/instructions/requestHeapFrame.d.ts.map +1 -1
  15. package/dist/types/generated/instructions/requestUnits.d.ts +2 -2
  16. package/dist/types/generated/instructions/requestUnits.d.ts.map +1 -1
  17. package/dist/types/generated/instructions/setComputeUnitLimit.d.ts +2 -2
  18. package/dist/types/generated/instructions/setComputeUnitLimit.d.ts.map +1 -1
  19. package/dist/types/generated/instructions/setComputeUnitPrice.d.ts +2 -2
  20. package/dist/types/generated/instructions/setComputeUnitPrice.d.ts.map +1 -1
  21. package/dist/types/generated/instructions/setLoadedAccountsDataSizeLimit.d.ts +2 -2
  22. package/dist/types/generated/instructions/setLoadedAccountsDataSizeLimit.d.ts.map +1 -1
  23. package/dist/types/generated/programs/computeBudget.d.ts +1 -1
  24. package/dist/types/generated/programs/computeBudget.d.ts.map +1 -1
  25. package/dist/types/generated/shared/index.d.ts +1 -1
  26. package/dist/types/generated/shared/index.d.ts.map +1 -1
  27. package/dist/types/index.d.ts +5 -0
  28. package/dist/types/index.d.ts.map +1 -1
  29. package/dist/types/internal.d.ts +35 -0
  30. package/dist/types/internal.d.ts.map +1 -0
  31. package/dist/types/internalMoveToKit.d.ts +20 -0
  32. package/dist/types/internalMoveToKit.d.ts.map +1 -0
  33. package/dist/types/setComputeLimit.d.ts +36 -0
  34. package/dist/types/setComputeLimit.d.ts.map +1 -0
  35. package/dist/types/setComputePrice.d.ts +34 -0
  36. package/dist/types/setComputePrice.d.ts.map +1 -0
  37. package/package.json +7 -18
package/dist/src/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var web3_js = require('@solana/web3.js');
3
+ var kit = require('@solana/kit');
4
4
 
5
5
  // src/generated/instructions/requestHeapFrame.ts
6
6
  var COMPUTE_BUDGET_PROGRAM_ADDRESS = "ComputeBudget111111111111111111111111111111";
@@ -14,19 +14,19 @@ var ComputeBudgetInstruction = /* @__PURE__ */ ((ComputeBudgetInstruction2) => {
14
14
  })(ComputeBudgetInstruction || {});
15
15
  function identifyComputeBudgetInstruction(instruction) {
16
16
  const data = "data" in instruction ? instruction.data : instruction;
17
- if (web3_js.containsBytes(data, web3_js.getU8Encoder().encode(0), 0)) {
17
+ if (kit.containsBytes(data, kit.getU8Encoder().encode(0), 0)) {
18
18
  return 0 /* RequestUnits */;
19
19
  }
20
- if (web3_js.containsBytes(data, web3_js.getU8Encoder().encode(1), 0)) {
20
+ if (kit.containsBytes(data, kit.getU8Encoder().encode(1), 0)) {
21
21
  return 1 /* RequestHeapFrame */;
22
22
  }
23
- if (web3_js.containsBytes(data, web3_js.getU8Encoder().encode(2), 0)) {
23
+ if (kit.containsBytes(data, kit.getU8Encoder().encode(2), 0)) {
24
24
  return 2 /* SetComputeUnitLimit */;
25
25
  }
26
- if (web3_js.containsBytes(data, web3_js.getU8Encoder().encode(3), 0)) {
26
+ if (kit.containsBytes(data, kit.getU8Encoder().encode(3), 0)) {
27
27
  return 3 /* SetComputeUnitPrice */;
28
28
  }
29
- if (web3_js.containsBytes(data, web3_js.getU8Encoder().encode(4), 0)) {
29
+ if (kit.containsBytes(data, kit.getU8Encoder().encode(4), 0)) {
30
30
  return 4 /* SetLoadedAccountsDataSizeLimit */;
31
31
  }
32
32
  throw new Error(
@@ -37,25 +37,25 @@ function identifyComputeBudgetInstruction(instruction) {
37
37
  // src/generated/instructions/requestHeapFrame.ts
38
38
  var REQUEST_HEAP_FRAME_DISCRIMINATOR = 1;
39
39
  function getRequestHeapFrameDiscriminatorBytes() {
40
- return web3_js.getU8Encoder().encode(REQUEST_HEAP_FRAME_DISCRIMINATOR);
40
+ return kit.getU8Encoder().encode(REQUEST_HEAP_FRAME_DISCRIMINATOR);
41
41
  }
42
42
  function getRequestHeapFrameInstructionDataEncoder() {
43
- return web3_js.transformEncoder(
44
- web3_js.getStructEncoder([
45
- ["discriminator", web3_js.getU8Encoder()],
46
- ["bytes", web3_js.getU32Encoder()]
43
+ return kit.transformEncoder(
44
+ kit.getStructEncoder([
45
+ ["discriminator", kit.getU8Encoder()],
46
+ ["bytes", kit.getU32Encoder()]
47
47
  ]),
48
48
  (value) => ({ ...value, discriminator: REQUEST_HEAP_FRAME_DISCRIMINATOR })
49
49
  );
50
50
  }
51
51
  function getRequestHeapFrameInstructionDataDecoder() {
52
- return web3_js.getStructDecoder([
53
- ["discriminator", web3_js.getU8Decoder()],
54
- ["bytes", web3_js.getU32Decoder()]
52
+ return kit.getStructDecoder([
53
+ ["discriminator", kit.getU8Decoder()],
54
+ ["bytes", kit.getU32Decoder()]
55
55
  ]);
56
56
  }
57
57
  function getRequestHeapFrameInstructionDataCodec() {
58
- return web3_js.combineCodec(
58
+ return kit.combineCodec(
59
59
  getRequestHeapFrameInstructionDataEncoder(),
60
60
  getRequestHeapFrameInstructionDataDecoder()
61
61
  );
@@ -79,27 +79,27 @@ function parseRequestHeapFrameInstruction(instruction) {
79
79
  }
80
80
  var REQUEST_UNITS_DISCRIMINATOR = 0;
81
81
  function getRequestUnitsDiscriminatorBytes() {
82
- return web3_js.getU8Encoder().encode(REQUEST_UNITS_DISCRIMINATOR);
82
+ return kit.getU8Encoder().encode(REQUEST_UNITS_DISCRIMINATOR);
83
83
  }
84
84
  function getRequestUnitsInstructionDataEncoder() {
85
- return web3_js.transformEncoder(
86
- web3_js.getStructEncoder([
87
- ["discriminator", web3_js.getU8Encoder()],
88
- ["units", web3_js.getU32Encoder()],
89
- ["additionalFee", web3_js.getU32Encoder()]
85
+ return kit.transformEncoder(
86
+ kit.getStructEncoder([
87
+ ["discriminator", kit.getU8Encoder()],
88
+ ["units", kit.getU32Encoder()],
89
+ ["additionalFee", kit.getU32Encoder()]
90
90
  ]),
91
91
  (value) => ({ ...value, discriminator: REQUEST_UNITS_DISCRIMINATOR })
92
92
  );
93
93
  }
94
94
  function getRequestUnitsInstructionDataDecoder() {
95
- return web3_js.getStructDecoder([
96
- ["discriminator", web3_js.getU8Decoder()],
97
- ["units", web3_js.getU32Decoder()],
98
- ["additionalFee", web3_js.getU32Decoder()]
95
+ return kit.getStructDecoder([
96
+ ["discriminator", kit.getU8Decoder()],
97
+ ["units", kit.getU32Decoder()],
98
+ ["additionalFee", kit.getU32Decoder()]
99
99
  ]);
100
100
  }
101
101
  function getRequestUnitsInstructionDataCodec() {
102
- return web3_js.combineCodec(
102
+ return kit.combineCodec(
103
103
  getRequestUnitsInstructionDataEncoder(),
104
104
  getRequestUnitsInstructionDataDecoder()
105
105
  );
@@ -123,13 +123,13 @@ function parseRequestUnitsInstruction(instruction) {
123
123
  }
124
124
  var SET_COMPUTE_UNIT_LIMIT_DISCRIMINATOR = 2;
125
125
  function getSetComputeUnitLimitDiscriminatorBytes() {
126
- return web3_js.getU8Encoder().encode(SET_COMPUTE_UNIT_LIMIT_DISCRIMINATOR);
126
+ return kit.getU8Encoder().encode(SET_COMPUTE_UNIT_LIMIT_DISCRIMINATOR);
127
127
  }
128
128
  function getSetComputeUnitLimitInstructionDataEncoder() {
129
- return web3_js.transformEncoder(
130
- web3_js.getStructEncoder([
131
- ["discriminator", web3_js.getU8Encoder()],
132
- ["units", web3_js.getU32Encoder()]
129
+ return kit.transformEncoder(
130
+ kit.getStructEncoder([
131
+ ["discriminator", kit.getU8Encoder()],
132
+ ["units", kit.getU32Encoder()]
133
133
  ]),
134
134
  (value) => ({
135
135
  ...value,
@@ -138,13 +138,13 @@ function getSetComputeUnitLimitInstructionDataEncoder() {
138
138
  );
139
139
  }
140
140
  function getSetComputeUnitLimitInstructionDataDecoder() {
141
- return web3_js.getStructDecoder([
142
- ["discriminator", web3_js.getU8Decoder()],
143
- ["units", web3_js.getU32Decoder()]
141
+ return kit.getStructDecoder([
142
+ ["discriminator", kit.getU8Decoder()],
143
+ ["units", kit.getU32Decoder()]
144
144
  ]);
145
145
  }
146
146
  function getSetComputeUnitLimitInstructionDataCodec() {
147
- return web3_js.combineCodec(
147
+ return kit.combineCodec(
148
148
  getSetComputeUnitLimitInstructionDataEncoder(),
149
149
  getSetComputeUnitLimitInstructionDataDecoder()
150
150
  );
@@ -170,13 +170,13 @@ function parseSetComputeUnitLimitInstruction(instruction) {
170
170
  }
171
171
  var SET_COMPUTE_UNIT_PRICE_DISCRIMINATOR = 3;
172
172
  function getSetComputeUnitPriceDiscriminatorBytes() {
173
- return web3_js.getU8Encoder().encode(SET_COMPUTE_UNIT_PRICE_DISCRIMINATOR);
173
+ return kit.getU8Encoder().encode(SET_COMPUTE_UNIT_PRICE_DISCRIMINATOR);
174
174
  }
175
175
  function getSetComputeUnitPriceInstructionDataEncoder() {
176
- return web3_js.transformEncoder(
177
- web3_js.getStructEncoder([
178
- ["discriminator", web3_js.getU8Encoder()],
179
- ["microLamports", web3_js.getU64Encoder()]
176
+ return kit.transformEncoder(
177
+ kit.getStructEncoder([
178
+ ["discriminator", kit.getU8Encoder()],
179
+ ["microLamports", kit.getU64Encoder()]
180
180
  ]),
181
181
  (value) => ({
182
182
  ...value,
@@ -185,13 +185,13 @@ function getSetComputeUnitPriceInstructionDataEncoder() {
185
185
  );
186
186
  }
187
187
  function getSetComputeUnitPriceInstructionDataDecoder() {
188
- return web3_js.getStructDecoder([
189
- ["discriminator", web3_js.getU8Decoder()],
190
- ["microLamports", web3_js.getU64Decoder()]
188
+ return kit.getStructDecoder([
189
+ ["discriminator", kit.getU8Decoder()],
190
+ ["microLamports", kit.getU64Decoder()]
191
191
  ]);
192
192
  }
193
193
  function getSetComputeUnitPriceInstructionDataCodec() {
194
- return web3_js.combineCodec(
194
+ return kit.combineCodec(
195
195
  getSetComputeUnitPriceInstructionDataEncoder(),
196
196
  getSetComputeUnitPriceInstructionDataDecoder()
197
197
  );
@@ -217,15 +217,15 @@ function parseSetComputeUnitPriceInstruction(instruction) {
217
217
  }
218
218
  var SET_LOADED_ACCOUNTS_DATA_SIZE_LIMIT_DISCRIMINATOR = 4;
219
219
  function getSetLoadedAccountsDataSizeLimitDiscriminatorBytes() {
220
- return web3_js.getU8Encoder().encode(
220
+ return kit.getU8Encoder().encode(
221
221
  SET_LOADED_ACCOUNTS_DATA_SIZE_LIMIT_DISCRIMINATOR
222
222
  );
223
223
  }
224
224
  function getSetLoadedAccountsDataSizeLimitInstructionDataEncoder() {
225
- return web3_js.transformEncoder(
226
- web3_js.getStructEncoder([
227
- ["discriminator", web3_js.getU8Encoder()],
228
- ["accountDataSizeLimit", web3_js.getU32Encoder()]
225
+ return kit.transformEncoder(
226
+ kit.getStructEncoder([
227
+ ["discriminator", kit.getU8Encoder()],
228
+ ["accountDataSizeLimit", kit.getU32Encoder()]
229
229
  ]),
230
230
  (value) => ({
231
231
  ...value,
@@ -234,13 +234,13 @@ function getSetLoadedAccountsDataSizeLimitInstructionDataEncoder() {
234
234
  );
235
235
  }
236
236
  function getSetLoadedAccountsDataSizeLimitInstructionDataDecoder() {
237
- return web3_js.getStructDecoder([
238
- ["discriminator", web3_js.getU8Decoder()],
239
- ["accountDataSizeLimit", web3_js.getU32Decoder()]
237
+ return kit.getStructDecoder([
238
+ ["discriminator", kit.getU8Decoder()],
239
+ ["accountDataSizeLimit", kit.getU32Decoder()]
240
240
  ]);
241
241
  }
242
242
  function getSetLoadedAccountsDataSizeLimitInstructionDataCodec() {
243
- return web3_js.combineCodec(
243
+ return kit.combineCodec(
244
244
  getSetLoadedAccountsDataSizeLimitInstructionDataEncoder(),
245
245
  getSetLoadedAccountsDataSizeLimitInstructionDataDecoder()
246
246
  );
@@ -265,13 +265,228 @@ function parseSetLoadedAccountsDataSizeLimitInstruction(instruction) {
265
265
  };
266
266
  }
267
267
 
268
+ // src/constants.ts
269
+ var PROVISORY_COMPUTE_UNIT_LIMIT = 0;
270
+ var MAX_COMPUTE_UNIT_LIMIT = 14e5;
271
+ function getSetComputeUnitLimitInstructionIndexAndUnits(transactionMessage) {
272
+ const index = getSetComputeUnitLimitInstructionIndex(transactionMessage);
273
+ if (index < 0) {
274
+ return null;
275
+ }
276
+ const units = kit.getU32Decoder().decode(
277
+ transactionMessage.instructions[index].data,
278
+ 1
279
+ );
280
+ return { index, units };
281
+ }
282
+ function getSetComputeUnitLimitInstructionIndex(transactionMessage) {
283
+ return transactionMessage.instructions.findIndex(
284
+ isSetComputeUnitLimitInstruction
285
+ );
286
+ }
287
+ function isSetComputeUnitLimitInstruction(instruction) {
288
+ return instruction.programAddress === COMPUTE_BUDGET_PROGRAM_ADDRESS && identifyComputeBudgetInstruction(instruction.data) === 2 /* SetComputeUnitLimit */;
289
+ }
290
+ function getSetComputeUnitPriceInstructionIndexAndMicroLamports(transactionMessage) {
291
+ const index = getSetComputeUnitPriceInstructionIndex(transactionMessage);
292
+ if (index < 0) {
293
+ return null;
294
+ }
295
+ const microLamports = kit.getU64Decoder().decode(
296
+ transactionMessage.instructions[index].data,
297
+ 1
298
+ );
299
+ return { index, microLamports };
300
+ }
301
+ function getSetComputeUnitPriceInstructionIndex(transactionMessage) {
302
+ return transactionMessage.instructions.findIndex(
303
+ isSetComputeUnitPriceInstruction
304
+ );
305
+ }
306
+ function isSetComputeUnitPriceInstruction(instruction) {
307
+ return instruction.programAddress === COMPUTE_BUDGET_PROGRAM_ADDRESS && identifyComputeBudgetInstruction(instruction.data) === 3 /* SetComputeUnitPrice */;
308
+ }
309
+ function fillProvisorySetComputeUnitLimitInstruction(transactionMessage) {
310
+ return updateOrAppendSetComputeUnitLimitInstruction(
311
+ (previousUnits) => previousUnits === null ? PROVISORY_COMPUTE_UNIT_LIMIT : previousUnits,
312
+ transactionMessage
313
+ );
314
+ }
315
+ function updateOrAppendSetComputeUnitLimitInstruction(units, transactionMessage) {
316
+ const getUnits = (previousUnits2) => typeof units === "function" ? units(previousUnits2) : units;
317
+ const instructionDetails = getSetComputeUnitLimitInstructionIndexAndUnits(transactionMessage);
318
+ if (!instructionDetails) {
319
+ return kit.appendTransactionMessageInstruction(
320
+ getSetComputeUnitLimitInstruction({ units: getUnits(null) }),
321
+ transactionMessage
322
+ );
323
+ }
324
+ const { index, units: previousUnits } = instructionDetails;
325
+ const newUnits = getUnits(previousUnits);
326
+ if (newUnits === previousUnits) {
327
+ return transactionMessage;
328
+ }
329
+ const newInstruction = getSetComputeUnitLimitInstruction({ units: newUnits });
330
+ const newInstructions = [...transactionMessage.instructions];
331
+ newInstructions.splice(index, 1, newInstruction);
332
+ return Object.freeze({
333
+ ...transactionMessage,
334
+ instructions: newInstructions
335
+ });
336
+ }
337
+
338
+ // src/estimateAndSetComputeLimit.ts
339
+ function estimateAndUpdateProvisoryComputeUnitLimitFactory(estimateComputeUnitLimit2) {
340
+ return async function fn(transactionMessage, config) {
341
+ const instructionDetails = getSetComputeUnitLimitInstructionIndexAndUnits(transactionMessage);
342
+ if (instructionDetails && instructionDetails.units !== PROVISORY_COMPUTE_UNIT_LIMIT && instructionDetails.units !== MAX_COMPUTE_UNIT_LIMIT) {
343
+ return transactionMessage;
344
+ }
345
+ return updateOrAppendSetComputeUnitLimitInstruction(
346
+ await estimateComputeUnitLimit2(transactionMessage, config),
347
+ transactionMessage
348
+ );
349
+ };
350
+ }
351
+ var PROVISORY_BLOCKHASH_LIFETIME_CONSTRAINT = {
352
+ blockhash: "11111111111111111111111111111111",
353
+ lastValidBlockHeight: 0n
354
+ // This is not included in compiled transactions; it can be anything.
355
+ };
356
+ function fillMissingTransactionMessageLifetimeUsingProvisoryBlockhash(transactionMessage) {
357
+ if ("lifetimeConstraint" in transactionMessage) {
358
+ return transactionMessage;
359
+ }
360
+ return setTransactionMessageLifetimeUsingProvisoryBlockhash(
361
+ transactionMessage
362
+ );
363
+ }
364
+ function setTransactionMessageLifetimeUsingProvisoryBlockhash(transactionMessage) {
365
+ return kit.setTransactionMessageLifetimeUsingBlockhash(
366
+ PROVISORY_BLOCKHASH_LIFETIME_CONSTRAINT,
367
+ transactionMessage
368
+ );
369
+ }
370
+
371
+ // src/estimateComputeLimitInternal.ts
372
+ async function estimateComputeUnitLimit({
373
+ transactionMessage,
374
+ ...configs
375
+ }) {
376
+ const replaceRecentBlockhash = !kit.isDurableNonceTransaction(transactionMessage);
377
+ const transaction = kit.pipe(
378
+ transactionMessage,
379
+ fillMissingTransactionMessageLifetimeUsingProvisoryBlockhash,
380
+ (m) => updateOrAppendSetComputeUnitLimitInstruction(MAX_COMPUTE_UNIT_LIMIT, m),
381
+ kit.compileTransaction
382
+ );
383
+ return await simulateTransactionAndGetConsumedUnits({
384
+ transaction,
385
+ replaceRecentBlockhash,
386
+ ...configs
387
+ });
388
+ }
389
+ async function simulateTransactionAndGetConsumedUnits({
390
+ abortSignal,
391
+ rpc,
392
+ transaction,
393
+ ...simulateConfig
394
+ }) {
395
+ const wireTransactionBytes = kit.getBase64EncodedWireTransaction(transaction);
396
+ try {
397
+ const {
398
+ value: { err: transactionError, unitsConsumed }
399
+ } = await rpc.simulateTransaction(wireTransactionBytes, {
400
+ ...simulateConfig,
401
+ encoding: "base64",
402
+ sigVerify: false
403
+ }).send({ abortSignal });
404
+ if (unitsConsumed == null) {
405
+ throw new kit.SolanaError(
406
+ kit.SOLANA_ERROR__TRANSACTION__FAILED_TO_ESTIMATE_COMPUTE_LIMIT
407
+ );
408
+ }
409
+ const downcastUnitsConsumed = unitsConsumed > 4294967295n ? 4294967295 : Number(unitsConsumed);
410
+ if (transactionError) {
411
+ throw new kit.SolanaError(
412
+ kit.SOLANA_ERROR__TRANSACTION__FAILED_WHEN_SIMULATING_TO_ESTIMATE_COMPUTE_LIMIT,
413
+ {
414
+ cause: transactionError,
415
+ unitsConsumed: downcastUnitsConsumed
416
+ }
417
+ );
418
+ }
419
+ return downcastUnitsConsumed;
420
+ } catch (e) {
421
+ if (kit.isSolanaError(
422
+ e,
423
+ kit.SOLANA_ERROR__TRANSACTION__FAILED_WHEN_SIMULATING_TO_ESTIMATE_COMPUTE_LIMIT
424
+ ))
425
+ throw e;
426
+ throw new kit.SolanaError(
427
+ kit.SOLANA_ERROR__TRANSACTION__FAILED_TO_ESTIMATE_COMPUTE_LIMIT,
428
+ { cause: e }
429
+ );
430
+ }
431
+ }
432
+
433
+ // src/estimateComputeLimit.ts
434
+ function estimateComputeUnitLimitFactory({
435
+ rpc
436
+ }) {
437
+ return async function estimateComputeUnitLimitFactoryFunction(transactionMessage, config) {
438
+ return await estimateComputeUnitLimit({
439
+ ...config,
440
+ rpc,
441
+ transactionMessage
442
+ });
443
+ };
444
+ }
445
+ function setTransactionMessageComputeUnitPrice(microLamports, transactionMessage) {
446
+ return kit.appendTransactionMessageInstruction(
447
+ getSetComputeUnitPriceInstruction({ microLamports }),
448
+ transactionMessage
449
+ );
450
+ }
451
+ function updateOrAppendSetComputeUnitPriceInstruction(microLamports, transactionMessage) {
452
+ const getMicroLamports = (previousMicroLamports2) => typeof microLamports === "function" ? microLamports(previousMicroLamports2) : microLamports;
453
+ const instructionDetails = getSetComputeUnitPriceInstructionIndexAndMicroLamports(transactionMessage);
454
+ if (!instructionDetails) {
455
+ return kit.appendTransactionMessageInstruction(
456
+ getSetComputeUnitPriceInstruction({
457
+ microLamports: getMicroLamports(null)
458
+ }),
459
+ transactionMessage
460
+ );
461
+ }
462
+ const { index, microLamports: previousMicroLamports } = instructionDetails;
463
+ const newMicroLamports = getMicroLamports(previousMicroLamports);
464
+ if (newMicroLamports === previousMicroLamports) {
465
+ return transactionMessage;
466
+ }
467
+ const newInstruction = getSetComputeUnitPriceInstruction({
468
+ microLamports: newMicroLamports
469
+ });
470
+ const newInstructions = [...transactionMessage.instructions];
471
+ newInstructions.splice(index, 1, newInstruction);
472
+ return Object.freeze({
473
+ ...transactionMessage,
474
+ instructions: newInstructions
475
+ });
476
+ }
477
+
268
478
  exports.COMPUTE_BUDGET_PROGRAM_ADDRESS = COMPUTE_BUDGET_PROGRAM_ADDRESS;
269
479
  exports.ComputeBudgetInstruction = ComputeBudgetInstruction;
480
+ exports.MAX_COMPUTE_UNIT_LIMIT = MAX_COMPUTE_UNIT_LIMIT;
481
+ exports.PROVISORY_COMPUTE_UNIT_LIMIT = PROVISORY_COMPUTE_UNIT_LIMIT;
270
482
  exports.REQUEST_HEAP_FRAME_DISCRIMINATOR = REQUEST_HEAP_FRAME_DISCRIMINATOR;
271
483
  exports.REQUEST_UNITS_DISCRIMINATOR = REQUEST_UNITS_DISCRIMINATOR;
272
484
  exports.SET_COMPUTE_UNIT_LIMIT_DISCRIMINATOR = SET_COMPUTE_UNIT_LIMIT_DISCRIMINATOR;
273
485
  exports.SET_COMPUTE_UNIT_PRICE_DISCRIMINATOR = SET_COMPUTE_UNIT_PRICE_DISCRIMINATOR;
274
486
  exports.SET_LOADED_ACCOUNTS_DATA_SIZE_LIMIT_DISCRIMINATOR = SET_LOADED_ACCOUNTS_DATA_SIZE_LIMIT_DISCRIMINATOR;
487
+ exports.estimateAndUpdateProvisoryComputeUnitLimitFactory = estimateAndUpdateProvisoryComputeUnitLimitFactory;
488
+ exports.estimateComputeUnitLimitFactory = estimateComputeUnitLimitFactory;
489
+ exports.fillProvisorySetComputeUnitLimitInstruction = fillProvisorySetComputeUnitLimitInstruction;
275
490
  exports.getRequestHeapFrameDiscriminatorBytes = getRequestHeapFrameDiscriminatorBytes;
276
491
  exports.getRequestHeapFrameInstruction = getRequestHeapFrameInstruction;
277
492
  exports.getRequestHeapFrameInstructionDataCodec = getRequestHeapFrameInstructionDataCodec;
@@ -303,5 +518,8 @@ exports.parseRequestUnitsInstruction = parseRequestUnitsInstruction;
303
518
  exports.parseSetComputeUnitLimitInstruction = parseSetComputeUnitLimitInstruction;
304
519
  exports.parseSetComputeUnitPriceInstruction = parseSetComputeUnitPriceInstruction;
305
520
  exports.parseSetLoadedAccountsDataSizeLimitInstruction = parseSetLoadedAccountsDataSizeLimitInstruction;
521
+ exports.setTransactionMessageComputeUnitPrice = setTransactionMessageComputeUnitPrice;
522
+ exports.updateOrAppendSetComputeUnitLimitInstruction = updateOrAppendSetComputeUnitLimitInstruction;
523
+ exports.updateOrAppendSetComputeUnitPriceInstruction = updateOrAppendSetComputeUnitPriceInstruction;
306
524
  //# sourceMappingURL=index.js.map
307
525
  //# sourceMappingURL=index.js.map