@solana-program/compute-budget 0.13.0 → 0.15.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/dist/src/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var kit = require('@solana/kit');
4
+ var programClientCore = require('@solana/kit/program-client-core');
4
5
 
5
6
  // src/generated/instructions/requestHeapFrame.ts
6
7
  var COMPUTE_BUDGET_PROGRAM_ADDRESS = "ComputeBudget111111111111111111111111111111";
@@ -29,7 +30,10 @@ function identifyComputeBudgetInstruction(instruction) {
29
30
  if (kit.containsBytes(data, kit.getU8Encoder().encode(4), 0)) {
30
31
  return 4 /* SetLoadedAccountsDataSizeLimit */;
31
32
  }
32
- throw new Error("The provided instruction could not be identified as a computeBudget instruction.");
33
+ throw new kit.SolanaError(kit.SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_INSTRUCTION, {
34
+ instructionData: data,
35
+ programName: "computeBudget"
36
+ });
33
37
  }
34
38
  function parseComputeBudgetInstruction(instruction) {
35
39
  const instructionType = identifyComputeBudgetInstruction(instruction);
@@ -65,9 +69,28 @@ function parseComputeBudgetInstruction(instruction) {
65
69
  };
66
70
  }
67
71
  default:
68
- throw new Error(`Unrecognized instruction type: ${instructionType}`);
72
+ throw new kit.SolanaError(kit.SOLANA_ERROR__PROGRAM_CLIENTS__UNRECOGNIZED_INSTRUCTION_TYPE, {
73
+ instructionType,
74
+ programName: "computeBudget"
75
+ });
69
76
  }
70
77
  }
78
+ function computeBudgetProgram() {
79
+ return (client) => {
80
+ return {
81
+ ...client,
82
+ computeBudget: {
83
+ instructions: {
84
+ requestUnits: (input) => programClientCore.addSelfPlanAndSendFunctions(client, getRequestUnitsInstruction(input)),
85
+ requestHeapFrame: (input) => programClientCore.addSelfPlanAndSendFunctions(client, getRequestHeapFrameInstruction(input)),
86
+ setComputeUnitLimit: (input) => programClientCore.addSelfPlanAndSendFunctions(client, getSetComputeUnitLimitInstruction(input)),
87
+ setComputeUnitPrice: (input) => programClientCore.addSelfPlanAndSendFunctions(client, getSetComputeUnitPriceInstruction(input)),
88
+ setLoadedAccountsDataSizeLimit: (input) => programClientCore.addSelfPlanAndSendFunctions(client, getSetLoadedAccountsDataSizeLimitInstruction(input))
89
+ }
90
+ }
91
+ };
92
+ };
93
+ }
71
94
 
72
95
  // src/generated/instructions/requestHeapFrame.ts
73
96
  var REQUEST_HEAP_FRAME_DISCRIMINATOR = 1;
@@ -261,22 +284,19 @@ function parseSetLoadedAccountsDataSizeLimitInstruction(instruction) {
261
284
  // src/constants.ts
262
285
  var PROVISORY_COMPUTE_UNIT_LIMIT = 0;
263
286
  var MAX_COMPUTE_UNIT_LIMIT = 14e5;
264
- function getSetComputeUnitLimitInstructionIndexAndUnits(transactionMessage) {
265
- const index = getSetComputeUnitLimitInstructionIndex(transactionMessage);
287
+ function findSetComputeUnitLimitInstructionIndexAndUnits(transactionMessage) {
288
+ const index = transactionMessage.instructions.findIndex(isSetComputeUnitLimitInstruction);
266
289
  if (index < 0) {
267
290
  return null;
268
291
  }
269
292
  const units = kit.getU32Decoder().decode(transactionMessage.instructions[index].data, 1);
270
293
  return { index, units };
271
294
  }
272
- function getSetComputeUnitLimitInstructionIndex(transactionMessage) {
273
- return transactionMessage.instructions.findIndex(isSetComputeUnitLimitInstruction);
274
- }
275
295
  function isSetComputeUnitLimitInstruction(instruction) {
276
296
  return instruction.programAddress === COMPUTE_BUDGET_PROGRAM_ADDRESS && identifyComputeBudgetInstruction(instruction.data) === 2 /* SetComputeUnitLimit */;
277
297
  }
278
- function getSetComputeUnitPriceInstructionIndexAndMicroLamports(transactionMessage) {
279
- const index = getSetComputeUnitPriceInstructionIndex(transactionMessage);
298
+ function findSetComputeUnitPriceInstructionIndexAndMicroLamports(transactionMessage) {
299
+ const index = transactionMessage.instructions.findIndex(isSetComputeUnitPriceInstruction);
280
300
  if (index < 0) {
281
301
  return null;
282
302
  }
@@ -286,9 +306,6 @@ function getSetComputeUnitPriceInstructionIndexAndMicroLamports(transactionMessa
286
306
  );
287
307
  return { index, microLamports };
288
308
  }
289
- function getSetComputeUnitPriceInstructionIndex(transactionMessage) {
290
- return transactionMessage.instructions.findIndex(isSetComputeUnitPriceInstruction);
291
- }
292
309
  function isSetComputeUnitPriceInstruction(instruction) {
293
310
  return instruction.programAddress === COMPUTE_BUDGET_PROGRAM_ADDRESS && identifyComputeBudgetInstruction(instruction.data) === 3 /* SetComputeUnitPrice */;
294
311
  }
@@ -300,7 +317,7 @@ function fillProvisorySetComputeUnitLimitInstruction(transactionMessage) {
300
317
  }
301
318
  function updateOrAppendSetComputeUnitLimitInstruction(units, transactionMessage) {
302
319
  const getUnits = (previousUnits2) => typeof units === "function" ? units(previousUnits2) : units;
303
- const instructionDetails = getSetComputeUnitLimitInstructionIndexAndUnits(transactionMessage);
320
+ const instructionDetails = findSetComputeUnitLimitInstructionIndexAndUnits(transactionMessage);
304
321
  if (!instructionDetails) {
305
322
  return kit.appendTransactionMessageInstruction(
306
323
  getSetComputeUnitLimitInstruction({ units: getUnits(null) }),
@@ -324,7 +341,7 @@ function updateOrAppendSetComputeUnitLimitInstruction(units, transactionMessage)
324
341
  // src/estimateAndSetComputeLimit.ts
325
342
  function estimateAndUpdateProvisoryComputeUnitLimitFactory(estimateComputeUnitLimit2) {
326
343
  return async function fn(transactionMessage, config) {
327
- const instructionDetails = getSetComputeUnitLimitInstructionIndexAndUnits(transactionMessage);
344
+ const instructionDetails = findSetComputeUnitLimitInstructionIndexAndUnits(transactionMessage);
328
345
  if (instructionDetails && instructionDetails.units !== PROVISORY_COMPUTE_UNIT_LIMIT && instructionDetails.units !== MAX_COMPUTE_UNIT_LIMIT) {
329
346
  return transactionMessage;
330
347
  }
@@ -358,24 +375,18 @@ async function simulateTransactionAndGetConsumedUnits({
358
375
  }) {
359
376
  const wireTransactionBytes = kit.getBase64EncodedWireTransaction(transaction);
360
377
  try {
361
- const {
362
- value: { err: transactionError, unitsConsumed }
363
- } = await rpc.simulateTransaction(wireTransactionBytes, {
364
- ...simulateConfig,
365
- encoding: "base64",
366
- sigVerify: false
367
- }).send({ abortSignal });
368
- if (unitsConsumed == null) {
378
+ const response = await rpc.simulateTransaction(wireTransactionBytes, { ...simulateConfig, encoding: "base64", sigVerify: false }).send({ abortSignal });
379
+ const { err: transactionError, ...simulationResult } = response.value;
380
+ if (simulationResult.unitsConsumed == null) {
369
381
  throw new kit.SolanaError(kit.SOLANA_ERROR__TRANSACTION__FAILED_TO_ESTIMATE_COMPUTE_LIMIT);
370
382
  }
371
- const downcastUnitsConsumed = unitsConsumed > 4294967295n ? 4294967295 : Number(unitsConsumed);
372
383
  if (transactionError) {
373
384
  throw new kit.SolanaError(kit.SOLANA_ERROR__TRANSACTION__FAILED_WHEN_SIMULATING_TO_ESTIMATE_COMPUTE_LIMIT, {
374
- cause: kit.getSolanaErrorFromTransactionError(transactionError),
375
- unitsConsumed: downcastUnitsConsumed
385
+ ...simulationResult,
386
+ cause: kit.getSolanaErrorFromTransactionError(transactionError)
376
387
  });
377
388
  }
378
- return downcastUnitsConsumed;
389
+ return simulationResult.unitsConsumed > 4294967295n ? 4294967295 : Number(simulationResult.unitsConsumed);
379
390
  } catch (e) {
380
391
  if (kit.isSolanaError(e, kit.SOLANA_ERROR__TRANSACTION__FAILED_WHEN_SIMULATING_TO_ESTIMATE_COMPUTE_LIMIT)) throw e;
381
392
  throw new kit.SolanaError(kit.SOLANA_ERROR__TRANSACTION__FAILED_TO_ESTIMATE_COMPUTE_LIMIT, { cause: e });
@@ -402,7 +413,7 @@ function setTransactionMessageComputeUnitPrice(microLamports, transactionMessage
402
413
  }
403
414
  function updateOrAppendSetComputeUnitPriceInstruction(microLamports, transactionMessage) {
404
415
  const getMicroLamports = (previousMicroLamports2) => typeof microLamports === "function" ? microLamports(previousMicroLamports2) : microLamports;
405
- const instructionDetails = getSetComputeUnitPriceInstructionIndexAndMicroLamports(transactionMessage);
416
+ const instructionDetails = findSetComputeUnitPriceInstructionIndexAndMicroLamports(transactionMessage);
406
417
  if (!instructionDetails) {
407
418
  return kit.appendTransactionMessageInstruction(
408
419
  getSetComputeUnitPriceInstruction({
@@ -436,9 +447,12 @@ exports.REQUEST_UNITS_DISCRIMINATOR = REQUEST_UNITS_DISCRIMINATOR;
436
447
  exports.SET_COMPUTE_UNIT_LIMIT_DISCRIMINATOR = SET_COMPUTE_UNIT_LIMIT_DISCRIMINATOR;
437
448
  exports.SET_COMPUTE_UNIT_PRICE_DISCRIMINATOR = SET_COMPUTE_UNIT_PRICE_DISCRIMINATOR;
438
449
  exports.SET_LOADED_ACCOUNTS_DATA_SIZE_LIMIT_DISCRIMINATOR = SET_LOADED_ACCOUNTS_DATA_SIZE_LIMIT_DISCRIMINATOR;
450
+ exports.computeBudgetProgram = computeBudgetProgram;
439
451
  exports.estimateAndUpdateProvisoryComputeUnitLimitFactory = estimateAndUpdateProvisoryComputeUnitLimitFactory;
440
452
  exports.estimateComputeUnitLimitFactory = estimateComputeUnitLimitFactory;
441
453
  exports.fillProvisorySetComputeUnitLimitInstruction = fillProvisorySetComputeUnitLimitInstruction;
454
+ exports.findSetComputeUnitLimitInstructionIndexAndUnits = findSetComputeUnitLimitInstructionIndexAndUnits;
455
+ exports.findSetComputeUnitPriceInstructionIndexAndMicroLamports = findSetComputeUnitPriceInstructionIndexAndMicroLamports;
442
456
  exports.getRequestHeapFrameDiscriminatorBytes = getRequestHeapFrameDiscriminatorBytes;
443
457
  exports.getRequestHeapFrameInstruction = getRequestHeapFrameInstruction;
444
458
  exports.getRequestHeapFrameInstructionDataCodec = getRequestHeapFrameInstructionDataCodec;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/generated/programs/computeBudget.ts","../../src/generated/instructions/requestHeapFrame.ts","../../src/generated/instructions/requestUnits.ts","../../src/generated/instructions/setComputeUnitLimit.ts","../../src/generated/instructions/setComputeUnitPrice.ts","../../src/generated/instructions/setLoadedAccountsDataSizeLimit.ts","../../src/constants.ts","../../src/internal.ts","../../src/setComputeLimit.ts","../../src/estimateAndSetComputeLimit.ts","../../src/estimateComputeLimitInternal.ts","../../src/estimateComputeLimit.ts","../../src/setComputePrice.ts"],"names":["ComputeBudgetInstruction","containsBytes","getU8Encoder","transformEncoder","getStructEncoder","getU32Encoder","getStructDecoder","getU8Decoder","getU32Decoder","combineCodec","getU64Encoder","getU64Decoder","previousUnits","appendTransactionMessageInstruction","estimateComputeUnitLimit","isTransactionMessageWithDurableNonceLifetime","pipe","compileTransaction","getBase64EncodedWireTransaction","SolanaError","SOLANA_ERROR__TRANSACTION__FAILED_TO_ESTIMATE_COMPUTE_LIMIT","SOLANA_ERROR__TRANSACTION__FAILED_WHEN_SIMULATING_TO_ESTIMATE_COMPUTE_LIMIT","getSolanaErrorFromTransactionError","isSolanaError","previousMicroLamports"],"mappings":";;;;;AA6BO,IAAM,8BACT,GAAA;AAEQ,IAAA,wBAAA,qBAAAA,yBAAL,KAAA;AACH,EAAAA,yBAAA,CAAA,yBAAA,CAAA,cAAA,CAAA,GAAA,CAAA,CAAA,GAAA,cAAA;AACA,EAAAA,yBAAA,CAAA,yBAAA,CAAA,kBAAA,CAAA,GAAA,CAAA,CAAA,GAAA,kBAAA;AACA,EAAAA,yBAAA,CAAA,yBAAA,CAAA,qBAAA,CAAA,GAAA,CAAA,CAAA,GAAA,qBAAA;AACA,EAAAA,yBAAA,CAAA,yBAAA,CAAA,qBAAA,CAAA,GAAA,CAAA,CAAA,GAAA,qBAAA;AACA,EAAAA,yBAAA,CAAA,yBAAA,CAAA,gCAAA,CAAA,GAAA,CAAA,CAAA,GAAA,gCAAA;AALQ,EAAAA,OAAAA,yBAAAA;AAAA,CAAA,EAAA,wBAAA,IAAA,EAAA;AAQL,SAAS,iCACZ,WACwB,EAAA;AACxB,EAAA,MAAM,IAAO,GAAA,MAAA,IAAU,WAAc,GAAA,WAAA,CAAY,IAAO,GAAA,WAAA;AACxD,EAAI,IAAAC,iBAAA,CAAc,MAAMC,g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I,GAAA,aAAA;AACjF,EAAM,MAAA,kBAAA,GAAqB,uDAAuD,kBAAkB,CAAA;AAEpG,EAAA,IAAI,CAAC,kBAAoB,EAAA;AACrB,IAAOX,OAAAA,uCAAAA;AAAA,MACH,iCAAkC,CAAA;AAAA,QAC9B,aAAA,EAAe,iBAAiB,IAAI;AAAA,OACvC,CAAA;AAAA,MACD;AAAA,KACJ;AAAA;AAGJ,EAAA,MAAM,EAAE,KAAA,EAAO,aAAe,EAAA,qBAAA,EAA0B,GAAA,kBAAA;AACxD,EAAM,MAAA,gBAAA,GAAmB,iBAAiB,qBAAqB,CAAA;AAC/D,EAAA,IAAI,qBAAqB,qBAAuB,EAAA;AAC5C,IAAO,OAAA,kBAAA;AAAA;AAGX,EAAA,MAAM,iBAAiB,iCAAkC,CAAA;AAAA,IACrD,aAAe,EAAA;AAAA,GAClB,CAAA;AACD,EAAA,MAAM,eAAkB,GAAA,CAAC,GAAG,kBAAA,CAAmB,YAAY,CAAA;AAC3D,EAAgB,eAAA,CAAA,MAAA,CAAO,KAAO,EAAA,CAAA,EAAG,cAAc,CAAA;AAC/C,EAAA,OAAO,OAAO,MAAO,CAAA;AAAA,IACjB,GAAG,kBAAA;AAAA,IACH,YAAc,EAAA;AAAA,GACjB,CAAA;AACL","file":"index.js","sourcesContent":["/**\n * This code was AUTOGENERATED using the Codama library.\n * Please DO NOT EDIT THIS FILE, instead use visitors\n * to add features, then rerun Codama to update it.\n *\n * @see https://github.com/codama-idl/codama\n */\n\nimport {\n containsBytes,\n getU8Encoder,\n type Address,\n type Instruction,\n type InstructionWithData,\n type ReadonlyUint8Array,\n} from '@solana/kit';\nimport {\n parseRequestHeapFrameInstruction,\n parseRequestUnitsInstruction,\n parseSetComputeUnitLimitInstruction,\n parseSetComputeUnitPriceInstruction,\n parseSetLoadedAccountsDataSizeLimitInstruction,\n type ParsedRequestHeapFrameInstruction,\n type ParsedRequestUnitsInstruction,\n type ParsedSetComputeUnitLimitInstruction,\n type ParsedSetComputeUnitPriceInstruction,\n type ParsedSetLoadedAccountsDataSizeLimitInstruction,\n} from '../instructions';\n\nexport const COMPUTE_BUDGET_PROGRAM_ADDRESS =\n 'ComputeBudget111111111111111111111111111111' as Address<'ComputeBudget111111111111111111111111111111'>;\n\nexport enum ComputeBudgetInstruction {\n RequestUnits,\n RequestHeapFrame,\n SetComputeUnitLimit,\n SetComputeUnitPrice,\n SetLoadedAccountsDataSizeLimit,\n}\n\nexport function identifyComputeBudgetInstruction(\n instruction: { data: ReadonlyUint8Array } | ReadonlyUint8Array,\n): ComputeBudgetInstruction {\n const data = 'data' in instruction ? instruction.data : instruction;\n if (containsBytes(data, getU8Encoder().encode(0), 0)) {\n return ComputeBudgetInstruction.RequestUnits;\n }\n if (containsBytes(data, getU8Encoder().encode(1), 0)) {\n return ComputeBudgetInstruction.RequestHeapFrame;\n }\n if (containsBytes(data, getU8Encoder().encode(2), 0)) {\n return ComputeBudgetInstruction.SetComputeUnitLimit;\n }\n if (containsBytes(data, getU8Encoder().encode(3), 0)) {\n return ComputeBudgetInstruction.SetComputeUnitPrice;\n }\n if (containsBytes(data, getU8Encoder().encode(4), 0)) {\n return ComputeBudgetInstruction.SetLoadedAccountsDataSizeLimit;\n }\n throw new Error('The provided instruction could not be identified as a computeBudget instruction.');\n}\n\nexport type ParsedComputeBudgetInstruction<TProgram extends string = 'ComputeBudget111111111111111111111111111111'> =\n | ({ instructionType: ComputeBudgetInstruction.RequestUnits } & ParsedRequestUnitsInstruction<TProgram>)\n | ({ instructionType: ComputeBudgetInstruction.RequestHeapFrame } & ParsedRequestHeapFrameInstruction<TProgram>)\n | ({\n instructionType: ComputeBudgetInstruction.SetComputeUnitLimit;\n } & ParsedSetComputeUnitLimitInstruction<TProgram>)\n | ({\n instructionType: ComputeBudgetInstruction.SetComputeUnitPrice;\n } & ParsedSetComputeUnitPriceInstruction<TProgram>)\n | ({\n instructionType: ComputeBudgetInstruction.SetLoadedAccountsDataSizeLimit;\n } & ParsedSetLoadedAccountsDataSizeLimitInstruction<TProgram>);\n\nexport function parseComputeBudgetInstruction<TProgram extends string>(\n instruction: Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array>,\n): ParsedComputeBudgetInstruction<TProgram> {\n const instructionType = identifyComputeBudgetInstruction(instruction);\n switch (instructionType) {\n case ComputeBudgetInstruction.RequestUnits: {\n return {\n instructionType: ComputeBudgetInstruction.RequestUnits,\n ...parseRequestUnitsInstruction(instruction),\n };\n }\n case ComputeBudgetInstruction.RequestHeapFrame: {\n return {\n instructionType: ComputeBudgetInstruction.RequestHeapFrame,\n ...parseRequestHeapFrameInstruction(instruction),\n };\n }\n case ComputeBudgetInstruction.SetComputeUnitLimit: {\n return {\n instructionType: ComputeBudgetInstruction.SetComputeUnitLimit,\n ...parseSetComputeUnitLimitInstruction(instruction),\n };\n }\n case ComputeBudgetInstruction.SetComputeUnitPrice: {\n return {\n instructionType: ComputeBudgetInstruction.SetComputeUnitPrice,\n ...parseSetComputeUnitPriceInstruction(instruction),\n };\n }\n case ComputeBudgetInstruction.SetLoadedAccountsDataSizeLimit: {\n return {\n instructionType: ComputeBudgetInstruction.SetLoadedAccountsDataSizeLimit,\n ...parseSetLoadedAccountsDataSizeLimitInstruction(instruction),\n };\n }\n default:\n throw new Error(`Unrecognized instruction type: ${instructionType as string}`);\n }\n}\n","/**\n * This code was AUTOGENERATED using the Codama library.\n * Please DO NOT EDIT THIS FILE, instead use visitors\n * to add features, then rerun Codama to update it.\n *\n * @see https://github.com/codama-idl/codama\n */\n\nimport {\n combineCodec,\n getStructDecoder,\n getStructEncoder,\n getU32Decoder,\n getU32Encoder,\n getU8Decoder,\n getU8Encoder,\n transformEncoder,\n type AccountMeta,\n type Address,\n type FixedSizeCodec,\n type FixedSizeDecoder,\n type FixedSizeEncoder,\n type Instruction,\n type InstructionWithAccounts,\n type InstructionWithData,\n type ReadonlyUint8Array,\n} from '@solana/kit';\nimport { COMPUTE_BUDGET_PROGRAM_ADDRESS } from '../programs';\n\nexport const REQUEST_HEAP_FRAME_DISCRIMINATOR = 1;\n\nexport function getRequestHeapFrameDiscriminatorBytes() {\n return getU8Encoder().encode(REQUEST_HEAP_FRAME_DISCRIMINATOR);\n}\n\nexport type RequestHeapFrameInstruction<\n TProgram extends string = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS,\n TRemainingAccounts extends readonly AccountMeta<string>[] = [],\n> = Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array> & InstructionWithAccounts<TRemainingAccounts>;\n\nexport type RequestHeapFrameInstructionData = {\n discriminator: number;\n /**\n * Requested transaction-wide program heap size in bytes.\n * Must be multiple of 1024. Applies to each program, including CPIs.\n */\n bytes: number;\n};\n\nexport type RequestHeapFrameInstructionDataArgs = {\n /**\n * Requested transaction-wide program heap size in bytes.\n * Must be multiple of 1024. Applies to each program, including CPIs.\n */\n bytes: number;\n};\n\nexport function getRequestHeapFrameInstructionDataEncoder(): FixedSizeEncoder<RequestHeapFrameInstructionDataArgs> {\n return transformEncoder(\n getStructEncoder([\n ['discriminator', getU8Encoder()],\n ['bytes', getU32Encoder()],\n ]),\n value => ({ ...value, discriminator: REQUEST_HEAP_FRAME_DISCRIMINATOR }),\n );\n}\n\nexport function getRequestHeapFrameInstructionDataDecoder(): FixedSizeDecoder<RequestHeapFrameInstructionData> {\n return getStructDecoder([\n ['discriminator', getU8Decoder()],\n ['bytes', getU32Decoder()],\n ]);\n}\n\nexport function getRequestHeapFrameInstructionDataCodec(): FixedSizeCodec<\n RequestHeapFrameInstructionDataArgs,\n RequestHeapFrameInstructionData\n> {\n return combineCodec(getRequestHeapFrameInstructionDataEncoder(), getRequestHeapFrameInstructionDataDecoder());\n}\n\nexport type RequestHeapFrameInput = {\n bytes: RequestHeapFrameInstructionDataArgs['bytes'];\n};\n\nexport function getRequestHeapFrameInstruction<TProgramAddress extends Address = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS>(\n input: RequestHeapFrameInput,\n config?: { programAddress?: TProgramAddress },\n): RequestHeapFrameInstruction<TProgramAddress> {\n // Program address.\n const programAddress = config?.programAddress ?? COMPUTE_BUDGET_PROGRAM_ADDRESS;\n\n // Original args.\n const args = { ...input };\n\n return Object.freeze({\n data: getRequestHeapFrameInstructionDataEncoder().encode(args as RequestHeapFrameInstructionDataArgs),\n programAddress,\n } as RequestHeapFrameInstruction<TProgramAddress>);\n}\n\nexport type ParsedRequestHeapFrameInstruction<TProgram extends string = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS> = {\n programAddress: Address<TProgram>;\n data: RequestHeapFrameInstructionData;\n};\n\nexport function parseRequestHeapFrameInstruction<TProgram extends string>(\n instruction: Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array>,\n): ParsedRequestHeapFrameInstruction<TProgram> {\n return {\n programAddress: instruction.programAddress,\n data: getRequestHeapFrameInstructionDataDecoder().decode(instruction.data),\n };\n}\n","/**\n * This code was AUTOGENERATED using the Codama library.\n * Please DO NOT EDIT THIS FILE, instead use visitors\n * to add features, then rerun Codama to update it.\n *\n * @see https://github.com/codama-idl/codama\n */\n\nimport {\n combineCodec,\n getStructDecoder,\n getStructEncoder,\n getU32Decoder,\n getU32Encoder,\n getU8Decoder,\n getU8Encoder,\n transformEncoder,\n type AccountMeta,\n type Address,\n type FixedSizeCodec,\n type FixedSizeDecoder,\n type FixedSizeEncoder,\n type Instruction,\n type InstructionWithAccounts,\n type InstructionWithData,\n type ReadonlyUint8Array,\n} from '@solana/kit';\nimport { COMPUTE_BUDGET_PROGRAM_ADDRESS } from '../programs';\n\nexport const REQUEST_UNITS_DISCRIMINATOR = 0;\n\nexport function getRequestUnitsDiscriminatorBytes() {\n return getU8Encoder().encode(REQUEST_UNITS_DISCRIMINATOR);\n}\n\nexport type RequestUnitsInstruction<\n TProgram extends string = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS,\n TRemainingAccounts extends readonly AccountMeta<string>[] = [],\n> = Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array> & InstructionWithAccounts<TRemainingAccounts>;\n\nexport type RequestUnitsInstructionData = {\n discriminator: number;\n /** Units to request for transaction-wide compute. */\n units: number;\n /** Prioritization fee lamports. */\n additionalFee: number;\n};\n\nexport type RequestUnitsInstructionDataArgs = {\n /** Units to request for transaction-wide compute. */\n units: number;\n /** Prioritization fee lamports. */\n additionalFee: number;\n};\n\nexport function getRequestUnitsInstructionDataEncoder(): FixedSizeEncoder<RequestUnitsInstructionDataArgs> {\n return transformEncoder(\n getStructEncoder([\n ['discriminator', getU8Encoder()],\n ['units', getU32Encoder()],\n ['additionalFee', getU32Encoder()],\n ]),\n value => ({ ...value, discriminator: REQUEST_UNITS_DISCRIMINATOR }),\n );\n}\n\nexport function getRequestUnitsInstructionDataDecoder(): FixedSizeDecoder<RequestUnitsInstructionData> {\n return getStructDecoder([\n ['discriminator', getU8Decoder()],\n ['units', getU32Decoder()],\n ['additionalFee', getU32Decoder()],\n ]);\n}\n\nexport function getRequestUnitsInstructionDataCodec(): FixedSizeCodec<\n RequestUnitsInstructionDataArgs,\n RequestUnitsInstructionData\n> {\n return combineCodec(getRequestUnitsInstructionDataEncoder(), getRequestUnitsInstructionDataDecoder());\n}\n\nexport type RequestUnitsInput = {\n units: RequestUnitsInstructionDataArgs['units'];\n additionalFee: RequestUnitsInstructionDataArgs['additionalFee'];\n};\n\nexport function getRequestUnitsInstruction<TProgramAddress extends Address = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS>(\n input: RequestUnitsInput,\n config?: { programAddress?: TProgramAddress },\n): RequestUnitsInstruction<TProgramAddress> {\n // Program address.\n const programAddress = config?.programAddress ?? COMPUTE_BUDGET_PROGRAM_ADDRESS;\n\n // Original args.\n const args = { ...input };\n\n return Object.freeze({\n data: getRequestUnitsInstructionDataEncoder().encode(args as RequestUnitsInstructionDataArgs),\n programAddress,\n } as RequestUnitsInstruction<TProgramAddress>);\n}\n\nexport type ParsedRequestUnitsInstruction<TProgram extends string = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS> = {\n programAddress: Address<TProgram>;\n data: RequestUnitsInstructionData;\n};\n\nexport function parseRequestUnitsInstruction<TProgram extends string>(\n instruction: Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array>,\n): ParsedRequestUnitsInstruction<TProgram> {\n return {\n programAddress: instruction.programAddress,\n data: getRequestUnitsInstructionDataDecoder().decode(instruction.data),\n };\n}\n","/**\n * This code was AUTOGENERATED using the Codama library.\n * Please DO NOT EDIT THIS FILE, instead use visitors\n * to add features, then rerun Codama to update it.\n *\n * @see https://github.com/codama-idl/codama\n */\n\nimport {\n combineCodec,\n getStructDecoder,\n getStructEncoder,\n getU32Decoder,\n getU32Encoder,\n getU8Decoder,\n getU8Encoder,\n transformEncoder,\n type AccountMeta,\n type Address,\n type FixedSizeCodec,\n type FixedSizeDecoder,\n type FixedSizeEncoder,\n type Instruction,\n type InstructionWithAccounts,\n type InstructionWithData,\n type ReadonlyUint8Array,\n} from '@solana/kit';\nimport { COMPUTE_BUDGET_PROGRAM_ADDRESS } from '../programs';\n\nexport const SET_COMPUTE_UNIT_LIMIT_DISCRIMINATOR = 2;\n\nexport function getSetComputeUnitLimitDiscriminatorBytes() {\n return getU8Encoder().encode(SET_COMPUTE_UNIT_LIMIT_DISCRIMINATOR);\n}\n\nexport type SetComputeUnitLimitInstruction<\n TProgram extends string = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS,\n TRemainingAccounts extends readonly AccountMeta<string>[] = [],\n> = Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array> & InstructionWithAccounts<TRemainingAccounts>;\n\nexport type SetComputeUnitLimitInstructionData = {\n discriminator: number;\n /** Transaction-wide compute unit limit. */\n units: number;\n};\n\nexport type SetComputeUnitLimitInstructionDataArgs = {\n /** Transaction-wide compute unit limit. */\n units: number;\n};\n\nexport function getSetComputeUnitLimitInstructionDataEncoder(): FixedSizeEncoder<SetComputeUnitLimitInstructionDataArgs> {\n return transformEncoder(\n getStructEncoder([\n ['discriminator', getU8Encoder()],\n ['units', getU32Encoder()],\n ]),\n value => ({ ...value, discriminator: SET_COMPUTE_UNIT_LIMIT_DISCRIMINATOR }),\n );\n}\n\nexport function getSetComputeUnitLimitInstructionDataDecoder(): FixedSizeDecoder<SetComputeUnitLimitInstructionData> {\n return getStructDecoder([\n ['discriminator', getU8Decoder()],\n ['units', getU32Decoder()],\n ]);\n}\n\nexport function getSetComputeUnitLimitInstructionDataCodec(): FixedSizeCodec<\n SetComputeUnitLimitInstructionDataArgs,\n SetComputeUnitLimitInstructionData\n> {\n return combineCodec(getSetComputeUnitLimitInstructionDataEncoder(), getSetComputeUnitLimitInstructionDataDecoder());\n}\n\nexport type SetComputeUnitLimitInput = {\n units: SetComputeUnitLimitInstructionDataArgs['units'];\n};\n\nexport function getSetComputeUnitLimitInstruction<\n TProgramAddress extends Address = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS,\n>(\n input: SetComputeUnitLimitInput,\n config?: { programAddress?: TProgramAddress },\n): SetComputeUnitLimitInstruction<TProgramAddress> {\n // Program address.\n const programAddress = config?.programAddress ?? COMPUTE_BUDGET_PROGRAM_ADDRESS;\n\n // Original args.\n const args = { ...input };\n\n return Object.freeze({\n data: getSetComputeUnitLimitInstructionDataEncoder().encode(args as SetComputeUnitLimitInstructionDataArgs),\n programAddress,\n } as SetComputeUnitLimitInstruction<TProgramAddress>);\n}\n\nexport type ParsedSetComputeUnitLimitInstruction<TProgram extends string = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS> = {\n programAddress: Address<TProgram>;\n data: SetComputeUnitLimitInstructionData;\n};\n\nexport function parseSetComputeUnitLimitInstruction<TProgram extends string>(\n instruction: Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array>,\n): ParsedSetComputeUnitLimitInstruction<TProgram> {\n return {\n programAddress: instruction.programAddress,\n data: getSetComputeUnitLimitInstructionDataDecoder().decode(instruction.data),\n };\n}\n","/**\n * This code was AUTOGENERATED using the Codama library.\n * Please DO NOT EDIT THIS FILE, instead use visitors\n * to add features, then rerun Codama to update it.\n *\n * @see https://github.com/codama-idl/codama\n */\n\nimport {\n combineCodec,\n getStructDecoder,\n getStructEncoder,\n getU64Decoder,\n getU64Encoder,\n getU8Decoder,\n getU8Encoder,\n transformEncoder,\n type AccountMeta,\n type Address,\n type FixedSizeCodec,\n type FixedSizeDecoder,\n type FixedSizeEncoder,\n type Instruction,\n type InstructionWithAccounts,\n type InstructionWithData,\n type ReadonlyUint8Array,\n} from '@solana/kit';\nimport { COMPUTE_BUDGET_PROGRAM_ADDRESS } from '../programs';\n\nexport const SET_COMPUTE_UNIT_PRICE_DISCRIMINATOR = 3;\n\nexport function getSetComputeUnitPriceDiscriminatorBytes() {\n return getU8Encoder().encode(SET_COMPUTE_UNIT_PRICE_DISCRIMINATOR);\n}\n\nexport type SetComputeUnitPriceInstruction<\n TProgram extends string = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS,\n TRemainingAccounts extends readonly AccountMeta<string>[] = [],\n> = Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array> & InstructionWithAccounts<TRemainingAccounts>;\n\nexport type SetComputeUnitPriceInstructionData = {\n discriminator: number;\n /** Transaction compute unit price used for prioritization fees. */\n microLamports: bigint;\n};\n\nexport type SetComputeUnitPriceInstructionDataArgs = {\n /** Transaction compute unit price used for prioritization fees. */\n microLamports: number | bigint;\n};\n\nexport function getSetComputeUnitPriceInstructionDataEncoder(): FixedSizeEncoder<SetComputeUnitPriceInstructionDataArgs> {\n return transformEncoder(\n getStructEncoder([\n ['discriminator', getU8Encoder()],\n ['microLamports', getU64Encoder()],\n ]),\n value => ({ ...value, discriminator: SET_COMPUTE_UNIT_PRICE_DISCRIMINATOR }),\n );\n}\n\nexport function getSetComputeUnitPriceInstructionDataDecoder(): FixedSizeDecoder<SetComputeUnitPriceInstructionData> {\n return getStructDecoder([\n ['discriminator', getU8Decoder()],\n ['microLamports', getU64Decoder()],\n ]);\n}\n\nexport function getSetComputeUnitPriceInstructionDataCodec(): FixedSizeCodec<\n SetComputeUnitPriceInstructionDataArgs,\n SetComputeUnitPriceInstructionData\n> {\n return combineCodec(getSetComputeUnitPriceInstructionDataEncoder(), getSetComputeUnitPriceInstructionDataDecoder());\n}\n\nexport type SetComputeUnitPriceInput = {\n microLamports: SetComputeUnitPriceInstructionDataArgs['microLamports'];\n};\n\nexport function getSetComputeUnitPriceInstruction<\n TProgramAddress extends Address = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS,\n>(\n input: SetComputeUnitPriceInput,\n config?: { programAddress?: TProgramAddress },\n): SetComputeUnitPriceInstruction<TProgramAddress> {\n // Program address.\n const programAddress = config?.programAddress ?? COMPUTE_BUDGET_PROGRAM_ADDRESS;\n\n // Original args.\n const args = { ...input };\n\n return Object.freeze({\n data: getSetComputeUnitPriceInstructionDataEncoder().encode(args as SetComputeUnitPriceInstructionDataArgs),\n programAddress,\n } as SetComputeUnitPriceInstruction<TProgramAddress>);\n}\n\nexport type ParsedSetComputeUnitPriceInstruction<TProgram extends string = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS> = {\n programAddress: Address<TProgram>;\n data: SetComputeUnitPriceInstructionData;\n};\n\nexport function parseSetComputeUnitPriceInstruction<TProgram extends string>(\n instruction: Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array>,\n): ParsedSetComputeUnitPriceInstruction<TProgram> {\n return {\n programAddress: instruction.programAddress,\n data: getSetComputeUnitPriceInstructionDataDecoder().decode(instruction.data),\n };\n}\n","/**\n * This code was AUTOGENERATED using the Codama library.\n * Please DO NOT EDIT THIS FILE, instead use visitors\n * to add features, then rerun Codama to update it.\n *\n * @see https://github.com/codama-idl/codama\n */\n\nimport {\n combineCodec,\n getStructDecoder,\n getStructEncoder,\n getU32Decoder,\n getU32Encoder,\n getU8Decoder,\n getU8Encoder,\n transformEncoder,\n type AccountMeta,\n type Address,\n type FixedSizeCodec,\n type FixedSizeDecoder,\n type FixedSizeEncoder,\n type Instruction,\n type InstructionWithAccounts,\n type InstructionWithData,\n type ReadonlyUint8Array,\n} from '@solana/kit';\nimport { COMPUTE_BUDGET_PROGRAM_ADDRESS } from '../programs';\n\nexport const SET_LOADED_ACCOUNTS_DATA_SIZE_LIMIT_DISCRIMINATOR = 4;\n\nexport function getSetLoadedAccountsDataSizeLimitDiscriminatorBytes() {\n return getU8Encoder().encode(SET_LOADED_ACCOUNTS_DATA_SIZE_LIMIT_DISCRIMINATOR);\n}\n\nexport type SetLoadedAccountsDataSizeLimitInstruction<\n TProgram extends string = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS,\n TRemainingAccounts extends readonly AccountMeta<string>[] = [],\n> = Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array> & InstructionWithAccounts<TRemainingAccounts>;\n\nexport type SetLoadedAccountsDataSizeLimitInstructionData = { discriminator: number; accountDataSizeLimit: number };\n\nexport type SetLoadedAccountsDataSizeLimitInstructionDataArgs = { accountDataSizeLimit: number };\n\nexport function getSetLoadedAccountsDataSizeLimitInstructionDataEncoder(): FixedSizeEncoder<SetLoadedAccountsDataSizeLimitInstructionDataArgs> {\n return transformEncoder(\n getStructEncoder([\n ['discriminator', getU8Encoder()],\n ['accountDataSizeLimit', getU32Encoder()],\n ]),\n value => ({ ...value, discriminator: SET_LOADED_ACCOUNTS_DATA_SIZE_LIMIT_DISCRIMINATOR }),\n );\n}\n\nexport function getSetLoadedAccountsDataSizeLimitInstructionDataDecoder(): FixedSizeDecoder<SetLoadedAccountsDataSizeLimitInstructionData> {\n return getStructDecoder([\n ['discriminator', getU8Decoder()],\n ['accountDataSizeLimit', getU32Decoder()],\n ]);\n}\n\nexport function getSetLoadedAccountsDataSizeLimitInstructionDataCodec(): FixedSizeCodec<\n SetLoadedAccountsDataSizeLimitInstructionDataArgs,\n SetLoadedAccountsDataSizeLimitInstructionData\n> {\n return combineCodec(\n getSetLoadedAccountsDataSizeLimitInstructionDataEncoder(),\n getSetLoadedAccountsDataSizeLimitInstructionDataDecoder(),\n );\n}\n\nexport type SetLoadedAccountsDataSizeLimitInput = {\n accountDataSizeLimit: SetLoadedAccountsDataSizeLimitInstructionDataArgs['accountDataSizeLimit'];\n};\n\nexport function getSetLoadedAccountsDataSizeLimitInstruction<\n TProgramAddress extends Address = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS,\n>(\n input: SetLoadedAccountsDataSizeLimitInput,\n config?: { programAddress?: TProgramAddress },\n): SetLoadedAccountsDataSizeLimitInstruction<TProgramAddress> {\n // Program address.\n const programAddress = config?.programAddress ?? COMPUTE_BUDGET_PROGRAM_ADDRESS;\n\n // Original args.\n const args = { ...input };\n\n return Object.freeze({\n data: getSetLoadedAccountsDataSizeLimitInstructionDataEncoder().encode(\n args as SetLoadedAccountsDataSizeLimitInstructionDataArgs,\n ),\n programAddress,\n } as SetLoadedAccountsDataSizeLimitInstruction<TProgramAddress>);\n}\n\nexport type ParsedSetLoadedAccountsDataSizeLimitInstruction<\n TProgram extends string = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS,\n> = { programAddress: Address<TProgram>; data: SetLoadedAccountsDataSizeLimitInstructionData };\n\nexport function parseSetLoadedAccountsDataSizeLimitInstruction<TProgram extends string>(\n instruction: Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array>,\n): ParsedSetLoadedAccountsDataSizeLimitInstruction<TProgram> {\n return {\n programAddress: instruction.programAddress,\n data: getSetLoadedAccountsDataSizeLimitInstructionDataDecoder().decode(instruction.data),\n };\n}\n","/**\n * A provisory compute unit limit is used to indicate that the transaction\n * should be estimated for compute units before being sent to the network.\n *\n * Setting it to zero ensures the transaction fails unless it is properly estimated.\n */\nexport const PROVISORY_COMPUTE_UNIT_LIMIT = 0;\n\n/**\n * The maximum compute unit limit that can be set for a transaction.\n */\nexport const MAX_COMPUTE_UNIT_LIMIT = 1_400_000;\n","import {\n TransactionMessage,\n getU32Decoder,\n getU64Decoder,\n Instruction,\n MicroLamports,\n ReadonlyUint8Array,\n} from '@solana/kit';\nimport {\n COMPUTE_BUDGET_PROGRAM_ADDRESS,\n ComputeBudgetInstruction,\n identifyComputeBudgetInstruction,\n SetComputeUnitLimitInstruction,\n SetComputeUnitPriceInstruction,\n} from './generated';\n\n/**\n * Finds the index of the first `SetComputeUnitLimit` instruction in a transaction message\n * and its set limit, if any.\n */\nexport function getSetComputeUnitLimitInstructionIndexAndUnits(\n transactionMessage: TransactionMessage,\n): { index: number; units: number } | null {\n const index = getSetComputeUnitLimitInstructionIndex(transactionMessage);\n if (index < 0) {\n return null;\n }\n\n const units = getU32Decoder().decode(transactionMessage.instructions[index].data as ReadonlyUint8Array, 1);\n\n return { index, units };\n}\n\n/**\n * Finds the index of the first `SetComputeUnitLimit` instruction in a transaction message, if any.\n */\nexport function getSetComputeUnitLimitInstructionIndex(transactionMessage: TransactionMessage) {\n return transactionMessage.instructions.findIndex(isSetComputeUnitLimitInstruction);\n}\n\n/**\n * Checks if the given instruction is a `SetComputeUnitLimit` instruction.\n */\nexport function isSetComputeUnitLimitInstruction(\n instruction: Instruction,\n): instruction is SetComputeUnitLimitInstruction {\n return (\n instruction.programAddress === COMPUTE_BUDGET_PROGRAM_ADDRESS &&\n identifyComputeBudgetInstruction(instruction.data as Uint8Array) ===\n ComputeBudgetInstruction.SetComputeUnitLimit\n );\n}\n\n/**\n * Finds the index of the first `SetComputeUnitPrice` instruction in a transaction message\n * and its set micro-lamports, if any.\n */\nexport function getSetComputeUnitPriceInstructionIndexAndMicroLamports(\n transactionMessage: TransactionMessage,\n): { index: number; microLamports: MicroLamports } | null {\n const index = getSetComputeUnitPriceInstructionIndex(transactionMessage);\n if (index < 0) {\n return null;\n }\n\n const microLamports = getU64Decoder().decode(\n transactionMessage.instructions[index].data as ReadonlyUint8Array,\n 1,\n ) as MicroLamports;\n\n return { index, microLamports };\n}\n\n/**\n * Finds the index of the first `SetComputeUnitPrice` instruction in a transaction message, if any.\n */\nexport function getSetComputeUnitPriceInstructionIndex(transactionMessage: TransactionMessage) {\n return transactionMessage.instructions.findIndex(isSetComputeUnitPriceInstruction);\n}\n\n/**\n * Checks if the given instruction is a `SetComputeUnitPrice` instruction.\n */\nexport function isSetComputeUnitPriceInstruction(\n instruction: Instruction,\n): instruction is SetComputeUnitPriceInstruction {\n return (\n instruction.programAddress === COMPUTE_BUDGET_PROGRAM_ADDRESS &&\n identifyComputeBudgetInstruction(instruction.data as Uint8Array) ===\n ComputeBudgetInstruction.SetComputeUnitPrice\n );\n}\n","import { appendTransactionMessageInstruction, TransactionMessage } from '@solana/kit';\nimport { PROVISORY_COMPUTE_UNIT_LIMIT } from './constants';\nimport { getSetComputeUnitLimitInstruction } from './generated';\nimport { getSetComputeUnitLimitInstructionIndexAndUnits } from './internal';\n\n/**\n * Appends a `SetComputeUnitLimit` instruction with a provisory\n * compute unit limit to a given transaction message\n * if and only if it does not already have one.\n *\n * @example\n * ```ts\n * const transactionMessage = pipe(\n * createTransactionMessage({ version: 0 }),\n * fillProvisorySetComputeUnitLimitInstruction,\n * // ...\n * );\n * ```\n */\nexport function fillProvisorySetComputeUnitLimitInstruction<TTransactionMessage extends TransactionMessage>(\n transactionMessage: TTransactionMessage,\n) {\n return updateOrAppendSetComputeUnitLimitInstruction(\n previousUnits => (previousUnits === null ? PROVISORY_COMPUTE_UNIT_LIMIT : previousUnits),\n transactionMessage,\n );\n}\n\n/**\n * Updates the first `SetComputeUnitLimit` instruction in a transaction message\n * with the given units, or appends a new instruction if none exists.\n * A function of the current value can be provided instead of a static value.\n *\n * @param units - The new compute unit limit, or a function that takes the previous\n * compute unit limit and returns the new limit.\n * @param transactionMessage - The transaction message to update.\n *\n * @example\n * ```ts\n * const updatedTransactionMessage = updateOrAppendSetComputeUnitLimitInstruction(\n * // E.g. Keep the current limit if it is set, otherwise set it to the maximum.\n * (currentUnits) => currentUnits === null ? MAX_COMPUTE_UNIT_LIMIT : currentUnits,\n * transactionMessage,\n * );\n * ```\n */\nexport function updateOrAppendSetComputeUnitLimitInstruction<TTransactionMessage extends TransactionMessage>(\n units: number | ((previousUnits: number | null) => number),\n transactionMessage: TTransactionMessage,\n): TTransactionMessage {\n const getUnits = (previousUnits: number | null): number =>\n typeof units === 'function' ? units(previousUnits) : units;\n const instructionDetails = getSetComputeUnitLimitInstructionIndexAndUnits(transactionMessage);\n\n if (!instructionDetails) {\n return appendTransactionMessageInstruction(\n getSetComputeUnitLimitInstruction({ units: getUnits(null) }),\n transactionMessage,\n ) as TTransactionMessage;\n }\n\n const { index, units: previousUnits } = instructionDetails;\n const newUnits = getUnits(previousUnits);\n if (newUnits === previousUnits) {\n return transactionMessage;\n }\n\n const newInstruction = getSetComputeUnitLimitInstruction({ units: newUnits });\n const newInstructions = [...transactionMessage.instructions];\n newInstructions.splice(index, 1, newInstruction);\n return Object.freeze({\n ...transactionMessage,\n instructions: newInstructions,\n }) as TTransactionMessage;\n}\n","import { TransactionMessage, TransactionMessageWithFeePayer } from '@solana/kit';\nimport { MAX_COMPUTE_UNIT_LIMIT, PROVISORY_COMPUTE_UNIT_LIMIT } from './constants';\nimport {\n EstimateComputeUnitLimitFactoryFunction,\n EstimateComputeUnitLimitFactoryFunctionConfig,\n} from './estimateComputeLimitInternal';\nimport { getSetComputeUnitLimitInstructionIndexAndUnits } from './internal';\nimport { updateOrAppendSetComputeUnitLimitInstruction } from './setComputeLimit';\n\ntype EstimateAndUpdateProvisoryComputeUnitLimitFactoryFunction = <\n TTransactionMessage extends TransactionMessage & TransactionMessageWithFeePayer,\n>(\n transactionMessage: TTransactionMessage,\n config?: EstimateComputeUnitLimitFactoryFunctionConfig,\n) => Promise<TTransactionMessage>;\n\n/**\n * Given a transaction message, if it does not have an explicit compute unit limit,\n * estimates the compute unit limit and updates the transaction message with\n * the estimated limit. Otherwise, returns the transaction message unchanged.\n *\n * It requires a function that estimates the compute unit limit.\n *\n * @example\n * ```ts\n * const estimateAndUpdateCUs = estimateAndUpdateProvisoryComputeUnitLimitFactory(\n * estimateComputeUnitLimitFactory({ rpc })\n * );\n *\n * const transactionMessageWithCUs = await estimateAndUpdateCUs(transactionMessage);\n * ```\n *\n * @see {@link estimateAndUpdateProvisoryComputeUnitLimitFactory}\n */\nexport function estimateAndUpdateProvisoryComputeUnitLimitFactory(\n estimateComputeUnitLimit: EstimateComputeUnitLimitFactoryFunction,\n): EstimateAndUpdateProvisoryComputeUnitLimitFactoryFunction {\n return async function fn(transactionMessage, config) {\n const instructionDetails = getSetComputeUnitLimitInstructionIndexAndUnits(transactionMessage);\n\n // If the transaction message already has a compute unit limit instruction\n // which is set to a specific value — i.e. not 0 or the maximum limit —\n // we don't need to estimate the compute unit limit.\n if (\n instructionDetails &&\n instructionDetails.units !== PROVISORY_COMPUTE_UNIT_LIMIT &&\n instructionDetails.units !== MAX_COMPUTE_UNIT_LIMIT\n ) {\n return transactionMessage;\n }\n\n return updateOrAppendSetComputeUnitLimitInstruction(\n await estimateComputeUnitLimit(transactionMessage, config),\n transactionMessage,\n );\n };\n}\n","import {\n TransactionMessage,\n Commitment,\n compileTransaction,\n getBase64EncodedWireTransaction,\n getSolanaErrorFromTransactionError,\n isSolanaError,\n isTransactionMessageWithDurableNonceLifetime,\n pipe,\n Rpc,\n SimulateTransactionApi,\n Slot,\n SOLANA_ERROR__TRANSACTION__FAILED_TO_ESTIMATE_COMPUTE_LIMIT,\n SOLANA_ERROR__TRANSACTION__FAILED_WHEN_SIMULATING_TO_ESTIMATE_COMPUTE_LIMIT,\n SolanaError,\n Transaction,\n TransactionMessageWithFeePayer,\n} from '@solana/kit';\nimport { updateOrAppendSetComputeUnitLimitInstruction } from './setComputeLimit';\nimport { MAX_COMPUTE_UNIT_LIMIT } from './constants';\n\nexport type EstimateComputeUnitLimitFactoryConfig = Readonly<{\n /** An object that supports the {@link SimulateTransactionApi} of the Solana RPC API */\n rpc: Rpc<SimulateTransactionApi>;\n}>;\n\nexport type EstimateComputeUnitLimitFactoryFunction = (\n transactionMessage: TransactionMessage & TransactionMessageWithFeePayer,\n config?: EstimateComputeUnitLimitFactoryFunctionConfig,\n) => Promise<number>;\n\nexport type EstimateComputeUnitLimitFactoryFunctionConfig = {\n abortSignal?: AbortSignal;\n /**\n * Compute the estimate as of the highest slot that has reached this level of commitment.\n *\n * @defaultValue Whichever default is applied by the underlying {@link RpcApi} in use. For\n * example, when using an API created by a `createSolanaRpc*()` helper, the default commitment\n * is `\"confirmed\"` unless configured otherwise. Unmitigated by an API layer on the client, the\n * default commitment applied by the server is `\"finalized\"`.\n */\n commitment?: Commitment;\n /**\n * Prevents accessing stale data by enforcing that the RPC node has processed transactions up to\n * this slot\n */\n minContextSlot?: Slot;\n};\n\ntype EstimateComputeUnitLimitConfig = EstimateComputeUnitLimitFactoryFunctionConfig &\n Readonly<{\n rpc: Rpc<SimulateTransactionApi>;\n transactionMessage: TransactionMessage & TransactionMessageWithFeePayer;\n }>;\n\n/**\n * Simulates a transaction message on the network and returns the number of compute units it\n * consumed during simulation.\n *\n * The estimate this function returns can be used to set a compute unit limit on the transaction.\n * Correctly budgeting a compute unit limit for your transaction message can increase the probability\n * that your transaction will be accepted for processing.\n *\n * If you don't declare a compute unit limit on your transaction, validators will assume an upper\n * limit of 200K compute units (CU) per instruction. Since validators have an incentive to pack as\n * many transactions into each block as possible, they may choose to include transactions that they\n * know will fit into the remaining compute budget for the current block over transactions that\n * might not. For this reason, you should set a compute unit limit on each of your transaction\n * messages, whenever possible.\n *\n * ## Example\n *\n * ```ts\n * import { getSetComputeLimitInstruction } from '@solana-program/compute-budget';\n * import { createSolanaRpc, getComputeUnitEstimateForTransactionMessageFactory, pipe } from '@solana/kit';\n *\n * // Create an estimator function.\n * const rpc = createSolanaRpc('http://127.0.0.1:8899');\n * const getComputeUnitEstimateForTransactionMessage =\n * getComputeUnitEstimateForTransactionMessageFactory({ rpc });\n *\n * // Create your transaction message.\n * const transactionMessage = pipe(\n * createTransactionMessage({ version: 'legacy' }),\n * /* ... *\\/\n * );\n *\n * // Request an estimate of the actual compute units this message will consume.\n * const computeUnitsEstimate =\n * await getComputeUnitEstimateForTransactionMessage(transactionMessage);\n *\n * // Set the transaction message's compute unit budget.\n * const transactionMessageWithComputeUnitLimit = prependTransactionMessageInstruction(\n * getSetComputeLimitInstruction({ units: computeUnitsEstimate }),\n * transactionMessage,\n * );\n * ```\n *\n * > [!WARNING]\n * > The compute unit estimate is just that &ndash; an estimate. The compute unit consumption of the\n * > actual transaction might be higher or lower than what was observed in simulation. Unless you\n * > are confident that your particular transaction message will consume the same or fewer compute\n * > units as was estimated, you might like to augment the estimate by either a fixed number of CUs\n * > or a multiplier.\n *\n * > [!NOTE]\n * > If you are preparing an _unsigned_ transaction, destined to be signed and submitted to the\n * > network by a wallet, you might like to leave it up to the wallet to determine the compute unit\n * > limit. Consider that the wallet might have a more global view of how many compute units certain\n * > types of transactions consume, and might be able to make better estimates of an appropriate\n * > compute unit budget.\n */\nexport async function estimateComputeUnitLimit({\n transactionMessage,\n ...configs\n}: EstimateComputeUnitLimitConfig): Promise<number> {\n const replaceRecentBlockhash = !isTransactionMessageWithDurableNonceLifetime(transactionMessage);\n const transaction = pipe(\n transactionMessage,\n m => updateOrAppendSetComputeUnitLimitInstruction(MAX_COMPUTE_UNIT_LIMIT, m),\n compileTransaction,\n );\n\n return await simulateTransactionAndGetConsumedUnits({\n transaction,\n replaceRecentBlockhash,\n ...configs,\n });\n}\n\ntype SimulateTransactionAndGetConsumedUnitsConfig = Omit<EstimateComputeUnitLimitConfig, 'transactionMessage'> &\n Readonly<{ replaceRecentBlockhash?: boolean; transaction: Transaction }>;\n\nasync function simulateTransactionAndGetConsumedUnits({\n abortSignal,\n rpc,\n transaction,\n ...simulateConfig\n}: SimulateTransactionAndGetConsumedUnitsConfig): Promise<number> {\n const wireTransactionBytes = getBase64EncodedWireTransaction(transaction);\n\n try {\n const {\n value: { err: transactionError, unitsConsumed },\n } = await rpc\n .simulateTransaction(wireTransactionBytes, {\n ...simulateConfig,\n encoding: 'base64',\n sigVerify: false,\n })\n .send({ abortSignal });\n if (unitsConsumed == null) {\n // This should never be hit, because all RPCs should support `unitsConsumed` by now.\n throw new SolanaError(SOLANA_ERROR__TRANSACTION__FAILED_TO_ESTIMATE_COMPUTE_LIMIT);\n }\n // FIXME(https://github.com/anza-xyz/agave/issues/1295): The simulation response returns\n // compute units as a u64, but the `SetComputeLimit` instruction only accepts a u32. Until\n // this changes, downcast it.\n const downcastUnitsConsumed = unitsConsumed > 4_294_967_295n ? 4_294_967_295 : Number(unitsConsumed);\n if (transactionError) {\n throw new SolanaError(SOLANA_ERROR__TRANSACTION__FAILED_WHEN_SIMULATING_TO_ESTIMATE_COMPUTE_LIMIT, {\n cause: getSolanaErrorFromTransactionError(transactionError),\n unitsConsumed: downcastUnitsConsumed,\n });\n }\n return downcastUnitsConsumed;\n } catch (e) {\n if (isSolanaError(e, SOLANA_ERROR__TRANSACTION__FAILED_WHEN_SIMULATING_TO_ESTIMATE_COMPUTE_LIMIT)) throw e;\n throw new SolanaError(SOLANA_ERROR__TRANSACTION__FAILED_TO_ESTIMATE_COMPUTE_LIMIT, { cause: e });\n }\n}\n","import {\n estimateComputeUnitLimit,\n EstimateComputeUnitLimitFactoryConfig,\n EstimateComputeUnitLimitFactoryFunction,\n} from './estimateComputeLimitInternal';\n\n/**\n * Use this utility to estimate the actual compute unit cost of a given transaction message.\n *\n * Correctly budgeting a compute unit limit for your transaction message can increase the\n * probability that your transaction will be accepted for processing. If you don't declare a compute\n * unit limit on your transaction, validators will assume an upper limit of 200K compute units (CU)\n * per instruction.\n *\n * Since validators have an incentive to pack as many transactions into each block as possible, they\n * may choose to include transactions that they know will fit into the remaining compute budget for\n * the current block over transactions that might not. For this reason, you should set a compute\n * unit limit on each of your transaction messages, whenever possible.\n *\n * > [!WARNING]\n * > The compute unit estimate is just that -- an estimate. The compute unit consumption of the\n * > actual transaction might be higher or lower than what was observed in simulation. Unless you\n * > are confident that your particular transaction message will consume the same or fewer compute\n * > units as was estimated, you might like to augment the estimate by either a fixed number of CUs\n * > or a multiplier.\n *\n * > [!NOTE]\n * > If you are preparing an _unsigned_ transaction, destined to be signed and submitted to the\n * > network by a wallet, you might like to leave it up to the wallet to determine the compute unit\n * > limit. Consider that the wallet might have a more global view of how many compute units certain\n * > types of transactions consume, and might be able to make better estimates of an appropriate\n * > compute unit budget.\n *\n * > [!INFO]\n * > In the event that a transaction message does not already have a `SetComputeUnitLimit`\n * > instruction, this function will add one before simulation. This ensures that the compute unit\n * > consumption of the `SetComputeUnitLimit` instruction itself is included in the estimate.\n *\n * @param config\n *\n * @example\n * ```ts\n * import { getSetComputeUnitLimitInstruction } from '@solana-program/compute-budget';\n * import { createSolanaRpc, estimateComputeUnitLimitFactory, pipe } from '@solana/kit';\n *\n * // Create an estimator function.\n * const rpc = createSolanaRpc('http://127.0.0.1:8899');\n * const estimateComputeUnitLimit = estimateComputeUnitLimitFactory({ rpc });\n *\n * // Create your transaction message.\n * const transactionMessage = pipe(\n * createTransactionMessage({ version: 'legacy' }),\n * /* ... *\\/\n * );\n *\n * // Request an estimate of the actual compute units this message will consume. This is done by\n * // simulating the transaction and grabbing the estimated compute units from the result.\n * const estimatedUnits = await estimateComputeUnitLimit(transactionMessage);\n *\n * // Set the transaction message's compute unit budget.\n * const transactionMessageWithComputeUnitLimit = prependTransactionMessageInstruction(\n * getSetComputeUnitLimitInstruction({ units: estimatedUnits }),\n * transactionMessage,\n * );\n * ```\n */\nexport function estimateComputeUnitLimitFactory({\n rpc,\n}: EstimateComputeUnitLimitFactoryConfig): EstimateComputeUnitLimitFactoryFunction {\n return async function estimateComputeUnitLimitFactoryFunction(transactionMessage, config) {\n return await estimateComputeUnitLimit({\n ...config,\n rpc,\n transactionMessage,\n });\n };\n}\n","import { appendTransactionMessageInstruction, TransactionMessage, MicroLamports } from '@solana/kit';\nimport { getSetComputeUnitPriceInstruction } from './generated';\nimport { getSetComputeUnitPriceInstructionIndexAndMicroLamports } from './internal';\n\n/**\n * Sets the compute unit price of a transaction message in micro-Lamports.\n *\n * @example\n * ```ts\n * const transactionMessage = pipe(\n * createTransactionMessage({ version: 0 }),\n * (m) => setTransactionMessageComputeUnitPrice(10_000, m),\n * // ...\n * );\n * ```\n */\nexport function setTransactionMessageComputeUnitPrice<TTransactionMessage extends TransactionMessage>(\n microLamports: number | bigint,\n transactionMessage: TTransactionMessage,\n) {\n return appendTransactionMessageInstruction(\n getSetComputeUnitPriceInstruction({ microLamports }),\n transactionMessage,\n );\n}\n\n/**\n * Updates the first `SetComputeUnitPrice` instruction in a transaction message\n * with the given micro-Lamports, or appends a new instruction if none exists.\n * A function of the current value can be provided instead of a static value.\n *\n * @param microLamports - The new compute unit price, or a function that\n * takes the previous price and returns the new one.\n * @param transactionMessage - The transaction message to update.\n *\n * @example\n * ```ts\n * const updatedTransactionMessage = updateOrAppendSetComputeUnitPriceInstruction(\n * // E.g. double the current price or set it to 10_000 if it isn't set.\n * (currentPrice) => currentPrice === null ? 10_000 : currentPrice * 2,\n * transactionMessage,\n * );\n * ```\n */\nexport function updateOrAppendSetComputeUnitPriceInstruction<TTransactionMessage extends TransactionMessage>(\n microLamports: MicroLamports | ((previousMicroLamports: MicroLamports | null) => MicroLamports),\n transactionMessage: TTransactionMessage,\n): TTransactionMessage {\n const getMicroLamports = (previousMicroLamports: MicroLamports | null): MicroLamports =>\n typeof microLamports === 'function' ? microLamports(previousMicroLamports) : microLamports;\n const instructionDetails = getSetComputeUnitPriceInstructionIndexAndMicroLamports(transactionMessage);\n\n if (!instructionDetails) {\n return appendTransactionMessageInstruction(\n getSetComputeUnitPriceInstruction({\n microLamports: getMicroLamports(null),\n }),\n transactionMessage,\n ) as TTransactionMessage;\n }\n\n const { index, microLamports: previousMicroLamports } = instructionDetails;\n const newMicroLamports = getMicroLamports(previousMicroLamports);\n if (newMicroLamports === previousMicroLamports) {\n return transactionMessage;\n }\n\n const newInstruction = getSetComputeUnitPriceInstruction({\n microLamports: newMicroLamports,\n });\n const newInstructions = [...transactionMessage.instructions];\n newInstructions.splice(index, 1, newInstruction);\n return Object.freeze({\n ...transactionMessage,\n instructions: newInstructions,\n }) as TTransactionMessage;\n}\n"]}
1
+ {"version":3,"sources":["../../src/generated/programs/computeBudget.ts","../../src/generated/instructions/requestHeapFrame.ts","../../src/generated/instructions/requestUnits.ts","../../src/generated/instructions/setComputeUnitLimit.ts","../../src/generated/instructions/setComputeUnitPrice.ts","../../src/generated/instructions/setLoadedAccountsDataSizeLimit.ts","../../src/constants.ts","../../src/introspect.ts","../../src/setComputeLimit.ts","../../src/estimateAndSetComputeLimit.ts","../../src/estimateComputeLimitInternal.ts","../../src/estimateComputeLimit.ts","../../src/setComputePrice.ts"],"names":["ComputeBudgetInstruction","containsBytes","getU8Encoder","SolanaError","SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_INSTRUCTION","SOLANA_ERROR__PROGRAM_CLIENTS__UNRECOGNIZED_INSTRUCTION_TYPE","addSelfPlanAndSendFunctions","transformEncoder","getStructEncoder","getU32Encoder","getStructDecoder","getU8Decoder","getU32Decoder","combineCodec","getU64Encoder","getU64Decoder","previousUnits","appendTransactionMessageInstruction","estimateComputeUnitLimit","isTransactionMessageWithDurableNonceLifetime","pipe","compileTransaction","getBase64EncodedWireTransaction","SOLANA_ERROR__TRANSACTION__FAILED_TO_ESTIMATE_COMPUTE_LIMIT","SOLANA_ERROR__TRANSACTION__FAILED_WHEN_SIMULATING_TO_ESTIMATE_COMPUTE_LIMIT","getSolanaErrorFromTransactionError","isSolanaError","previousMicroLamports"],"mappings":";;;;;;AA6CO,IAAM,8BACT,GAAA;AAEQ,IAAA,wBAAA,qBAAAA,yBAAL,KAAA;AACH,EAAAA,yBAAA,CAAA,yBAAA,CAAA,cAAA,CAAA,GAAA,CAAA,CAAA,GAAA,cAAA;AACA,EAAAA,yBAAA,CAAA,yBAAA,CAAA,kBAAA,CAAA,GAAA,CAAA,CAAA,GAAA,kBAAA;AACA,EAAAA,yBAAA,CAAA,yBAAA,CAAA,qBAAA,CAAA,GAAA,CAAA,CAAA,GAAA,qBAAA;AACA,EAAAA,yBAAA,CAAA,yBAAA,CAAA,qBAAA,CAAA,GAAA,CAAA,CAAA,GAAA,qBAAA;AACA,EAAAA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A;AACxD,EAAM,MAAA,gBAAA,GAAmB,iBAAiB,qBAAqB,CAAA;AAC/D,EAAA,IAAI,qBAAqB,qBAAuB,EAAA;AAC5C,IAAO,OAAA,kBAAA;AAAA;AAGX,EAAA,MAAM,iBAAiB,iCAAkC,CAAA;AAAA,IACrD,aAAe,EAAA;AAAA,GAClB,CAAA;AACD,EAAA,MAAM,eAAkB,GAAA,CAAC,GAAG,kBAAA,CAAmB,YAAY,CAAA;AAC3D,EAAgB,eAAA,CAAA,MAAA,CAAO,KAAO,EAAA,CAAA,EAAG,cAAc,CAAA;AAC/C,EAAA,OAAO,OAAO,MAAO,CAAA;AAAA,IACjB,GAAG,kBAAA;AAAA,IACH,YAAc,EAAA;AAAA,GACjB,CAAA;AACL","file":"index.js","sourcesContent":["/**\n * This code was AUTOGENERATED using the Codama library.\n * Please DO NOT EDIT THIS FILE, instead use visitors\n * to add features, then rerun Codama to update it.\n *\n * @see https://github.com/codama-idl/codama\n */\n\nimport {\n containsBytes,\n getU8Encoder,\n SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_INSTRUCTION,\n SOLANA_ERROR__PROGRAM_CLIENTS__UNRECOGNIZED_INSTRUCTION_TYPE,\n SolanaError,\n type Address,\n type ClientWithTransactionPlanning,\n type ClientWithTransactionSending,\n type Instruction,\n type InstructionWithData,\n type ReadonlyUint8Array,\n} from '@solana/kit';\nimport { addSelfPlanAndSendFunctions, type SelfPlanAndSendFunctions } from '@solana/kit/program-client-core';\nimport {\n getRequestHeapFrameInstruction,\n getRequestUnitsInstruction,\n getSetComputeUnitLimitInstruction,\n getSetComputeUnitPriceInstruction,\n getSetLoadedAccountsDataSizeLimitInstruction,\n parseRequestHeapFrameInstruction,\n parseRequestUnitsInstruction,\n parseSetComputeUnitLimitInstruction,\n parseSetComputeUnitPriceInstruction,\n parseSetLoadedAccountsDataSizeLimitInstruction,\n type ParsedRequestHeapFrameInstruction,\n type ParsedRequestUnitsInstruction,\n type ParsedSetComputeUnitLimitInstruction,\n type ParsedSetComputeUnitPriceInstruction,\n type ParsedSetLoadedAccountsDataSizeLimitInstruction,\n type RequestHeapFrameInput,\n type RequestUnitsInput,\n type SetComputeUnitLimitInput,\n type SetComputeUnitPriceInput,\n type SetLoadedAccountsDataSizeLimitInput,\n} from '../instructions';\n\nexport const COMPUTE_BUDGET_PROGRAM_ADDRESS =\n 'ComputeBudget111111111111111111111111111111' as Address<'ComputeBudget111111111111111111111111111111'>;\n\nexport enum ComputeBudgetInstruction {\n RequestUnits,\n RequestHeapFrame,\n SetComputeUnitLimit,\n SetComputeUnitPrice,\n SetLoadedAccountsDataSizeLimit,\n}\n\nexport function identifyComputeBudgetInstruction(\n instruction: { data: ReadonlyUint8Array } | ReadonlyUint8Array,\n): ComputeBudgetInstruction {\n const data = 'data' in instruction ? instruction.data : instruction;\n if (containsBytes(data, getU8Encoder().encode(0), 0)) {\n return ComputeBudgetInstruction.RequestUnits;\n }\n if (containsBytes(data, getU8Encoder().encode(1), 0)) {\n return ComputeBudgetInstruction.RequestHeapFrame;\n }\n if (containsBytes(data, getU8Encoder().encode(2), 0)) {\n return ComputeBudgetInstruction.SetComputeUnitLimit;\n }\n if (containsBytes(data, getU8Encoder().encode(3), 0)) {\n return ComputeBudgetInstruction.SetComputeUnitPrice;\n }\n if (containsBytes(data, getU8Encoder().encode(4), 0)) {\n return ComputeBudgetInstruction.SetLoadedAccountsDataSizeLimit;\n }\n throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_INSTRUCTION, {\n instructionData: data,\n programName: 'computeBudget',\n });\n}\n\nexport type ParsedComputeBudgetInstruction<TProgram extends string = 'ComputeBudget111111111111111111111111111111'> =\n | ({ instructionType: ComputeBudgetInstruction.RequestUnits } & ParsedRequestUnitsInstruction<TProgram>)\n | ({ instructionType: ComputeBudgetInstruction.RequestHeapFrame } & ParsedRequestHeapFrameInstruction<TProgram>)\n | ({\n instructionType: ComputeBudgetInstruction.SetComputeUnitLimit;\n } & ParsedSetComputeUnitLimitInstruction<TProgram>)\n | ({\n instructionType: ComputeBudgetInstruction.SetComputeUnitPrice;\n } & ParsedSetComputeUnitPriceInstruction<TProgram>)\n | ({\n instructionType: ComputeBudgetInstruction.SetLoadedAccountsDataSizeLimit;\n } & ParsedSetLoadedAccountsDataSizeLimitInstruction<TProgram>);\n\nexport function parseComputeBudgetInstruction<TProgram extends string>(\n instruction: Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array>,\n): ParsedComputeBudgetInstruction<TProgram> {\n const instructionType = identifyComputeBudgetInstruction(instruction);\n switch (instructionType) {\n case ComputeBudgetInstruction.RequestUnits: {\n return {\n instructionType: ComputeBudgetInstruction.RequestUnits,\n ...parseRequestUnitsInstruction(instruction),\n };\n }\n case ComputeBudgetInstruction.RequestHeapFrame: {\n return {\n instructionType: ComputeBudgetInstruction.RequestHeapFrame,\n ...parseRequestHeapFrameInstruction(instruction),\n };\n }\n case ComputeBudgetInstruction.SetComputeUnitLimit: {\n return {\n instructionType: ComputeBudgetInstruction.SetComputeUnitLimit,\n ...parseSetComputeUnitLimitInstruction(instruction),\n };\n }\n case ComputeBudgetInstruction.SetComputeUnitPrice: {\n return {\n instructionType: ComputeBudgetInstruction.SetComputeUnitPrice,\n ...parseSetComputeUnitPriceInstruction(instruction),\n };\n }\n case ComputeBudgetInstruction.SetLoadedAccountsDataSizeLimit: {\n return {\n instructionType: ComputeBudgetInstruction.SetLoadedAccountsDataSizeLimit,\n ...parseSetLoadedAccountsDataSizeLimitInstruction(instruction),\n };\n }\n default:\n throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__UNRECOGNIZED_INSTRUCTION_TYPE, {\n instructionType: instructionType as string,\n programName: 'computeBudget',\n });\n }\n}\n\nexport type ComputeBudgetPlugin = { instructions: ComputeBudgetPluginInstructions };\n\nexport type ComputeBudgetPluginInstructions = {\n requestUnits: (\n input: RequestUnitsInput,\n ) => ReturnType<typeof getRequestUnitsInstruction> & SelfPlanAndSendFunctions;\n requestHeapFrame: (\n input: RequestHeapFrameInput,\n ) => ReturnType<typeof getRequestHeapFrameInstruction> & SelfPlanAndSendFunctions;\n setComputeUnitLimit: (\n input: SetComputeUnitLimitInput,\n ) => ReturnType<typeof getSetComputeUnitLimitInstruction> & SelfPlanAndSendFunctions;\n setComputeUnitPrice: (\n input: SetComputeUnitPriceInput,\n ) => ReturnType<typeof getSetComputeUnitPriceInstruction> & SelfPlanAndSendFunctions;\n setLoadedAccountsDataSizeLimit: (\n input: SetLoadedAccountsDataSizeLimitInput,\n ) => ReturnType<typeof getSetLoadedAccountsDataSizeLimitInstruction> & SelfPlanAndSendFunctions;\n};\n\nexport type ComputeBudgetPluginRequirements = ClientWithTransactionPlanning & ClientWithTransactionSending;\n\nexport function computeBudgetProgram() {\n return <T extends ComputeBudgetPluginRequirements>(client: T) => {\n return {\n ...client,\n computeBudget: <ComputeBudgetPlugin>{\n instructions: {\n requestUnits: input => addSelfPlanAndSendFunctions(client, getRequestUnitsInstruction(input)),\n requestHeapFrame: input =>\n addSelfPlanAndSendFunctions(client, getRequestHeapFrameInstruction(input)),\n setComputeUnitLimit: input =>\n addSelfPlanAndSendFunctions(client, getSetComputeUnitLimitInstruction(input)),\n setComputeUnitPrice: input =>\n addSelfPlanAndSendFunctions(client, getSetComputeUnitPriceInstruction(input)),\n setLoadedAccountsDataSizeLimit: input =>\n addSelfPlanAndSendFunctions(client, getSetLoadedAccountsDataSizeLimitInstruction(input)),\n },\n },\n };\n };\n}\n","/**\n * This code was AUTOGENERATED using the Codama library.\n * Please DO NOT EDIT THIS FILE, instead use visitors\n * to add features, then rerun Codama to update it.\n *\n * @see https://github.com/codama-idl/codama\n */\n\nimport {\n combineCodec,\n getStructDecoder,\n getStructEncoder,\n getU32Decoder,\n getU32Encoder,\n getU8Decoder,\n getU8Encoder,\n transformEncoder,\n type AccountMeta,\n type Address,\n type FixedSizeCodec,\n type FixedSizeDecoder,\n type FixedSizeEncoder,\n type Instruction,\n type InstructionWithAccounts,\n type InstructionWithData,\n type ReadonlyUint8Array,\n} from '@solana/kit';\nimport { COMPUTE_BUDGET_PROGRAM_ADDRESS } from '../programs';\n\nexport const REQUEST_HEAP_FRAME_DISCRIMINATOR = 1;\n\nexport function getRequestHeapFrameDiscriminatorBytes() {\n return getU8Encoder().encode(REQUEST_HEAP_FRAME_DISCRIMINATOR);\n}\n\nexport type RequestHeapFrameInstruction<\n TProgram extends string = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS,\n TRemainingAccounts extends readonly AccountMeta<string>[] = [],\n> = Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array> & InstructionWithAccounts<TRemainingAccounts>;\n\nexport type RequestHeapFrameInstructionData = {\n discriminator: number;\n /**\n * Requested transaction-wide program heap size in bytes.\n * Must be multiple of 1024. Applies to each program, including CPIs.\n */\n bytes: number;\n};\n\nexport type RequestHeapFrameInstructionDataArgs = {\n /**\n * Requested transaction-wide program heap size in bytes.\n * Must be multiple of 1024. Applies to each program, including CPIs.\n */\n bytes: number;\n};\n\nexport function getRequestHeapFrameInstructionDataEncoder(): FixedSizeEncoder<RequestHeapFrameInstructionDataArgs> {\n return transformEncoder(\n getStructEncoder([\n ['discriminator', getU8Encoder()],\n ['bytes', getU32Encoder()],\n ]),\n value => ({ ...value, discriminator: REQUEST_HEAP_FRAME_DISCRIMINATOR }),\n );\n}\n\nexport function getRequestHeapFrameInstructionDataDecoder(): FixedSizeDecoder<RequestHeapFrameInstructionData> {\n return getStructDecoder([\n ['discriminator', getU8Decoder()],\n ['bytes', getU32Decoder()],\n ]);\n}\n\nexport function getRequestHeapFrameInstructionDataCodec(): FixedSizeCodec<\n RequestHeapFrameInstructionDataArgs,\n RequestHeapFrameInstructionData\n> {\n return combineCodec(getRequestHeapFrameInstructionDataEncoder(), getRequestHeapFrameInstructionDataDecoder());\n}\n\nexport type RequestHeapFrameInput = {\n bytes: RequestHeapFrameInstructionDataArgs['bytes'];\n};\n\nexport function getRequestHeapFrameInstruction<TProgramAddress extends Address = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS>(\n input: RequestHeapFrameInput,\n config?: { programAddress?: TProgramAddress },\n): RequestHeapFrameInstruction<TProgramAddress> {\n // Program address.\n const programAddress = config?.programAddress ?? COMPUTE_BUDGET_PROGRAM_ADDRESS;\n\n // Original args.\n const args = { ...input };\n\n return Object.freeze({\n data: getRequestHeapFrameInstructionDataEncoder().encode(args as RequestHeapFrameInstructionDataArgs),\n programAddress,\n } as RequestHeapFrameInstruction<TProgramAddress>);\n}\n\nexport type ParsedRequestHeapFrameInstruction<TProgram extends string = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS> = {\n programAddress: Address<TProgram>;\n data: RequestHeapFrameInstructionData;\n};\n\nexport function parseRequestHeapFrameInstruction<TProgram extends string>(\n instruction: Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array>,\n): ParsedRequestHeapFrameInstruction<TProgram> {\n return {\n programAddress: instruction.programAddress,\n data: getRequestHeapFrameInstructionDataDecoder().decode(instruction.data),\n };\n}\n","/**\n * This code was AUTOGENERATED using the Codama library.\n * Please DO NOT EDIT THIS FILE, instead use visitors\n * to add features, then rerun Codama to update it.\n *\n * @see https://github.com/codama-idl/codama\n */\n\nimport {\n combineCodec,\n getStructDecoder,\n getStructEncoder,\n getU32Decoder,\n getU32Encoder,\n getU8Decoder,\n getU8Encoder,\n transformEncoder,\n type AccountMeta,\n type Address,\n type FixedSizeCodec,\n type FixedSizeDecoder,\n type FixedSizeEncoder,\n type Instruction,\n type InstructionWithAccounts,\n type InstructionWithData,\n type ReadonlyUint8Array,\n} from '@solana/kit';\nimport { COMPUTE_BUDGET_PROGRAM_ADDRESS } from '../programs';\n\nexport const REQUEST_UNITS_DISCRIMINATOR = 0;\n\nexport function getRequestUnitsDiscriminatorBytes() {\n return getU8Encoder().encode(REQUEST_UNITS_DISCRIMINATOR);\n}\n\nexport type RequestUnitsInstruction<\n TProgram extends string = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS,\n TRemainingAccounts extends readonly AccountMeta<string>[] = [],\n> = Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array> & InstructionWithAccounts<TRemainingAccounts>;\n\nexport type RequestUnitsInstructionData = {\n discriminator: number;\n /** Units to request for transaction-wide compute. */\n units: number;\n /** Prioritization fee lamports. */\n additionalFee: number;\n};\n\nexport type RequestUnitsInstructionDataArgs = {\n /** Units to request for transaction-wide compute. */\n units: number;\n /** Prioritization fee lamports. */\n additionalFee: number;\n};\n\nexport function getRequestUnitsInstructionDataEncoder(): FixedSizeEncoder<RequestUnitsInstructionDataArgs> {\n return transformEncoder(\n getStructEncoder([\n ['discriminator', getU8Encoder()],\n ['units', getU32Encoder()],\n ['additionalFee', getU32Encoder()],\n ]),\n value => ({ ...value, discriminator: REQUEST_UNITS_DISCRIMINATOR }),\n );\n}\n\nexport function getRequestUnitsInstructionDataDecoder(): FixedSizeDecoder<RequestUnitsInstructionData> {\n return getStructDecoder([\n ['discriminator', getU8Decoder()],\n ['units', getU32Decoder()],\n ['additionalFee', getU32Decoder()],\n ]);\n}\n\nexport function getRequestUnitsInstructionDataCodec(): FixedSizeCodec<\n RequestUnitsInstructionDataArgs,\n RequestUnitsInstructionData\n> {\n return combineCodec(getRequestUnitsInstructionDataEncoder(), getRequestUnitsInstructionDataDecoder());\n}\n\nexport type RequestUnitsInput = {\n units: RequestUnitsInstructionDataArgs['units'];\n additionalFee: RequestUnitsInstructionDataArgs['additionalFee'];\n};\n\nexport function getRequestUnitsInstruction<TProgramAddress extends Address = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS>(\n input: RequestUnitsInput,\n config?: { programAddress?: TProgramAddress },\n): RequestUnitsInstruction<TProgramAddress> {\n // Program address.\n const programAddress = config?.programAddress ?? COMPUTE_BUDGET_PROGRAM_ADDRESS;\n\n // Original args.\n const args = { ...input };\n\n return Object.freeze({\n data: getRequestUnitsInstructionDataEncoder().encode(args as RequestUnitsInstructionDataArgs),\n programAddress,\n } as RequestUnitsInstruction<TProgramAddress>);\n}\n\nexport type ParsedRequestUnitsInstruction<TProgram extends string = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS> = {\n programAddress: Address<TProgram>;\n data: RequestUnitsInstructionData;\n};\n\nexport function parseRequestUnitsInstruction<TProgram extends string>(\n instruction: Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array>,\n): ParsedRequestUnitsInstruction<TProgram> {\n return {\n programAddress: instruction.programAddress,\n data: getRequestUnitsInstructionDataDecoder().decode(instruction.data),\n };\n}\n","/**\n * This code was AUTOGENERATED using the Codama library.\n * Please DO NOT EDIT THIS FILE, instead use visitors\n * to add features, then rerun Codama to update it.\n *\n * @see https://github.com/codama-idl/codama\n */\n\nimport {\n combineCodec,\n getStructDecoder,\n getStructEncoder,\n getU32Decoder,\n getU32Encoder,\n getU8Decoder,\n getU8Encoder,\n transformEncoder,\n type AccountMeta,\n type Address,\n type FixedSizeCodec,\n type FixedSizeDecoder,\n type FixedSizeEncoder,\n type Instruction,\n type InstructionWithAccounts,\n type InstructionWithData,\n type ReadonlyUint8Array,\n} from '@solana/kit';\nimport { COMPUTE_BUDGET_PROGRAM_ADDRESS } from '../programs';\n\nexport const SET_COMPUTE_UNIT_LIMIT_DISCRIMINATOR = 2;\n\nexport function getSetComputeUnitLimitDiscriminatorBytes() {\n return getU8Encoder().encode(SET_COMPUTE_UNIT_LIMIT_DISCRIMINATOR);\n}\n\nexport type SetComputeUnitLimitInstruction<\n TProgram extends string = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS,\n TRemainingAccounts extends readonly AccountMeta<string>[] = [],\n> = Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array> & InstructionWithAccounts<TRemainingAccounts>;\n\nexport type SetComputeUnitLimitInstructionData = {\n discriminator: number;\n /** Transaction-wide compute unit limit. */\n units: number;\n};\n\nexport type SetComputeUnitLimitInstructionDataArgs = {\n /** Transaction-wide compute unit limit. */\n units: number;\n};\n\nexport function getSetComputeUnitLimitInstructionDataEncoder(): FixedSizeEncoder<SetComputeUnitLimitInstructionDataArgs> {\n return transformEncoder(\n getStructEncoder([\n ['discriminator', getU8Encoder()],\n ['units', getU32Encoder()],\n ]),\n value => ({ ...value, discriminator: SET_COMPUTE_UNIT_LIMIT_DISCRIMINATOR }),\n );\n}\n\nexport function getSetComputeUnitLimitInstructionDataDecoder(): FixedSizeDecoder<SetComputeUnitLimitInstructionData> {\n return getStructDecoder([\n ['discriminator', getU8Decoder()],\n ['units', getU32Decoder()],\n ]);\n}\n\nexport function getSetComputeUnitLimitInstructionDataCodec(): FixedSizeCodec<\n SetComputeUnitLimitInstructionDataArgs,\n SetComputeUnitLimitInstructionData\n> {\n return combineCodec(getSetComputeUnitLimitInstructionDataEncoder(), getSetComputeUnitLimitInstructionDataDecoder());\n}\n\nexport type SetComputeUnitLimitInput = {\n units: SetComputeUnitLimitInstructionDataArgs['units'];\n};\n\nexport function getSetComputeUnitLimitInstruction<\n TProgramAddress extends Address = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS,\n>(\n input: SetComputeUnitLimitInput,\n config?: { programAddress?: TProgramAddress },\n): SetComputeUnitLimitInstruction<TProgramAddress> {\n // Program address.\n const programAddress = config?.programAddress ?? COMPUTE_BUDGET_PROGRAM_ADDRESS;\n\n // Original args.\n const args = { ...input };\n\n return Object.freeze({\n data: getSetComputeUnitLimitInstructionDataEncoder().encode(args as SetComputeUnitLimitInstructionDataArgs),\n programAddress,\n } as SetComputeUnitLimitInstruction<TProgramAddress>);\n}\n\nexport type ParsedSetComputeUnitLimitInstruction<TProgram extends string = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS> = {\n programAddress: Address<TProgram>;\n data: SetComputeUnitLimitInstructionData;\n};\n\nexport function parseSetComputeUnitLimitInstruction<TProgram extends string>(\n instruction: Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array>,\n): ParsedSetComputeUnitLimitInstruction<TProgram> {\n return {\n programAddress: instruction.programAddress,\n data: getSetComputeUnitLimitInstructionDataDecoder().decode(instruction.data),\n };\n}\n","/**\n * This code was AUTOGENERATED using the Codama library.\n * Please DO NOT EDIT THIS FILE, instead use visitors\n * to add features, then rerun Codama to update it.\n *\n * @see https://github.com/codama-idl/codama\n */\n\nimport {\n combineCodec,\n getStructDecoder,\n getStructEncoder,\n getU64Decoder,\n getU64Encoder,\n getU8Decoder,\n getU8Encoder,\n transformEncoder,\n type AccountMeta,\n type Address,\n type FixedSizeCodec,\n type FixedSizeDecoder,\n type FixedSizeEncoder,\n type Instruction,\n type InstructionWithAccounts,\n type InstructionWithData,\n type ReadonlyUint8Array,\n} from '@solana/kit';\nimport { COMPUTE_BUDGET_PROGRAM_ADDRESS } from '../programs';\n\nexport const SET_COMPUTE_UNIT_PRICE_DISCRIMINATOR = 3;\n\nexport function getSetComputeUnitPriceDiscriminatorBytes() {\n return getU8Encoder().encode(SET_COMPUTE_UNIT_PRICE_DISCRIMINATOR);\n}\n\nexport type SetComputeUnitPriceInstruction<\n TProgram extends string = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS,\n TRemainingAccounts extends readonly AccountMeta<string>[] = [],\n> = Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array> & InstructionWithAccounts<TRemainingAccounts>;\n\nexport type SetComputeUnitPriceInstructionData = {\n discriminator: number;\n /** Transaction compute unit price used for prioritization fees. */\n microLamports: bigint;\n};\n\nexport type SetComputeUnitPriceInstructionDataArgs = {\n /** Transaction compute unit price used for prioritization fees. */\n microLamports: number | bigint;\n};\n\nexport function getSetComputeUnitPriceInstructionDataEncoder(): FixedSizeEncoder<SetComputeUnitPriceInstructionDataArgs> {\n return transformEncoder(\n getStructEncoder([\n ['discriminator', getU8Encoder()],\n ['microLamports', getU64Encoder()],\n ]),\n value => ({ ...value, discriminator: SET_COMPUTE_UNIT_PRICE_DISCRIMINATOR }),\n );\n}\n\nexport function getSetComputeUnitPriceInstructionDataDecoder(): FixedSizeDecoder<SetComputeUnitPriceInstructionData> {\n return getStructDecoder([\n ['discriminator', getU8Decoder()],\n ['microLamports', getU64Decoder()],\n ]);\n}\n\nexport function getSetComputeUnitPriceInstructionDataCodec(): FixedSizeCodec<\n SetComputeUnitPriceInstructionDataArgs,\n SetComputeUnitPriceInstructionData\n> {\n return combineCodec(getSetComputeUnitPriceInstructionDataEncoder(), getSetComputeUnitPriceInstructionDataDecoder());\n}\n\nexport type SetComputeUnitPriceInput = {\n microLamports: SetComputeUnitPriceInstructionDataArgs['microLamports'];\n};\n\nexport function getSetComputeUnitPriceInstruction<\n TProgramAddress extends Address = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS,\n>(\n input: SetComputeUnitPriceInput,\n config?: { programAddress?: TProgramAddress },\n): SetComputeUnitPriceInstruction<TProgramAddress> {\n // Program address.\n const programAddress = config?.programAddress ?? COMPUTE_BUDGET_PROGRAM_ADDRESS;\n\n // Original args.\n const args = { ...input };\n\n return Object.freeze({\n data: getSetComputeUnitPriceInstructionDataEncoder().encode(args as SetComputeUnitPriceInstructionDataArgs),\n programAddress,\n } as SetComputeUnitPriceInstruction<TProgramAddress>);\n}\n\nexport type ParsedSetComputeUnitPriceInstruction<TProgram extends string = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS> = {\n programAddress: Address<TProgram>;\n data: SetComputeUnitPriceInstructionData;\n};\n\nexport function parseSetComputeUnitPriceInstruction<TProgram extends string>(\n instruction: Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array>,\n): ParsedSetComputeUnitPriceInstruction<TProgram> {\n return {\n programAddress: instruction.programAddress,\n data: getSetComputeUnitPriceInstructionDataDecoder().decode(instruction.data),\n };\n}\n","/**\n * This code was AUTOGENERATED using the Codama library.\n * Please DO NOT EDIT THIS FILE, instead use visitors\n * to add features, then rerun Codama to update it.\n *\n * @see https://github.com/codama-idl/codama\n */\n\nimport {\n combineCodec,\n getStructDecoder,\n getStructEncoder,\n getU32Decoder,\n getU32Encoder,\n getU8Decoder,\n getU8Encoder,\n transformEncoder,\n type AccountMeta,\n type Address,\n type FixedSizeCodec,\n type FixedSizeDecoder,\n type FixedSizeEncoder,\n type Instruction,\n type InstructionWithAccounts,\n type InstructionWithData,\n type ReadonlyUint8Array,\n} from '@solana/kit';\nimport { COMPUTE_BUDGET_PROGRAM_ADDRESS } from '../programs';\n\nexport const SET_LOADED_ACCOUNTS_DATA_SIZE_LIMIT_DISCRIMINATOR = 4;\n\nexport function getSetLoadedAccountsDataSizeLimitDiscriminatorBytes() {\n return getU8Encoder().encode(SET_LOADED_ACCOUNTS_DATA_SIZE_LIMIT_DISCRIMINATOR);\n}\n\nexport type SetLoadedAccountsDataSizeLimitInstruction<\n TProgram extends string = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS,\n TRemainingAccounts extends readonly AccountMeta<string>[] = [],\n> = Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array> & InstructionWithAccounts<TRemainingAccounts>;\n\nexport type SetLoadedAccountsDataSizeLimitInstructionData = { discriminator: number; accountDataSizeLimit: number };\n\nexport type SetLoadedAccountsDataSizeLimitInstructionDataArgs = { accountDataSizeLimit: number };\n\nexport function getSetLoadedAccountsDataSizeLimitInstructionDataEncoder(): FixedSizeEncoder<SetLoadedAccountsDataSizeLimitInstructionDataArgs> {\n return transformEncoder(\n getStructEncoder([\n ['discriminator', getU8Encoder()],\n ['accountDataSizeLimit', getU32Encoder()],\n ]),\n value => ({ ...value, discriminator: SET_LOADED_ACCOUNTS_DATA_SIZE_LIMIT_DISCRIMINATOR }),\n );\n}\n\nexport function getSetLoadedAccountsDataSizeLimitInstructionDataDecoder(): FixedSizeDecoder<SetLoadedAccountsDataSizeLimitInstructionData> {\n return getStructDecoder([\n ['discriminator', getU8Decoder()],\n ['accountDataSizeLimit', getU32Decoder()],\n ]);\n}\n\nexport function getSetLoadedAccountsDataSizeLimitInstructionDataCodec(): FixedSizeCodec<\n SetLoadedAccountsDataSizeLimitInstructionDataArgs,\n SetLoadedAccountsDataSizeLimitInstructionData\n> {\n return combineCodec(\n getSetLoadedAccountsDataSizeLimitInstructionDataEncoder(),\n getSetLoadedAccountsDataSizeLimitInstructionDataDecoder(),\n );\n}\n\nexport type SetLoadedAccountsDataSizeLimitInput = {\n accountDataSizeLimit: SetLoadedAccountsDataSizeLimitInstructionDataArgs['accountDataSizeLimit'];\n};\n\nexport function getSetLoadedAccountsDataSizeLimitInstruction<\n TProgramAddress extends Address = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS,\n>(\n input: SetLoadedAccountsDataSizeLimitInput,\n config?: { programAddress?: TProgramAddress },\n): SetLoadedAccountsDataSizeLimitInstruction<TProgramAddress> {\n // Program address.\n const programAddress = config?.programAddress ?? COMPUTE_BUDGET_PROGRAM_ADDRESS;\n\n // Original args.\n const args = { ...input };\n\n return Object.freeze({\n data: getSetLoadedAccountsDataSizeLimitInstructionDataEncoder().encode(\n args as SetLoadedAccountsDataSizeLimitInstructionDataArgs,\n ),\n programAddress,\n } as SetLoadedAccountsDataSizeLimitInstruction<TProgramAddress>);\n}\n\nexport type ParsedSetLoadedAccountsDataSizeLimitInstruction<\n TProgram extends string = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS,\n> = { programAddress: Address<TProgram>; data: SetLoadedAccountsDataSizeLimitInstructionData };\n\nexport function parseSetLoadedAccountsDataSizeLimitInstruction<TProgram extends string>(\n instruction: Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array>,\n): ParsedSetLoadedAccountsDataSizeLimitInstruction<TProgram> {\n return {\n programAddress: instruction.programAddress,\n data: getSetLoadedAccountsDataSizeLimitInstructionDataDecoder().decode(instruction.data),\n };\n}\n","/**\n * A provisory compute unit limit is used to indicate that the transaction\n * should be estimated for compute units before being sent to the network.\n *\n * Setting it to zero ensures the transaction fails unless it is properly estimated.\n */\nexport const PROVISORY_COMPUTE_UNIT_LIMIT = 0;\n\n/**\n * The maximum compute unit limit that can be set for a transaction.\n */\nexport const MAX_COMPUTE_UNIT_LIMIT = 1_400_000;\n","import {\n TransactionMessage,\n getU32Decoder,\n getU64Decoder,\n Instruction,\n MicroLamports,\n ReadonlyUint8Array,\n} from '@solana/kit';\nimport {\n COMPUTE_BUDGET_PROGRAM_ADDRESS,\n ComputeBudgetInstruction,\n identifyComputeBudgetInstruction,\n SetComputeUnitLimitInstruction,\n SetComputeUnitPriceInstruction,\n} from './generated';\n\n/**\n * Finds the index of the first `SetComputeUnitLimit` instruction in a transaction message\n * and its set limit, if any.\n */\nexport function findSetComputeUnitLimitInstructionIndexAndUnits(\n transactionMessage: TransactionMessage,\n): { index: number; units: number } | null {\n const index = transactionMessage.instructions.findIndex(isSetComputeUnitLimitInstruction);\n if (index < 0) {\n return null;\n }\n\n const units = getU32Decoder().decode(transactionMessage.instructions[index].data as ReadonlyUint8Array, 1);\n\n return { index, units };\n}\n\n/**\n * Checks if the given instruction is a `SetComputeUnitLimit` instruction.\n */\nfunction isSetComputeUnitLimitInstruction(instruction: Instruction): instruction is SetComputeUnitLimitInstruction {\n return (\n instruction.programAddress === COMPUTE_BUDGET_PROGRAM_ADDRESS &&\n identifyComputeBudgetInstruction(instruction.data as Uint8Array) ===\n ComputeBudgetInstruction.SetComputeUnitLimit\n );\n}\n\n/**\n * Finds the index of the first `SetComputeUnitPrice` instruction in a transaction message\n * and its set micro-lamports, if any.\n */\nexport function findSetComputeUnitPriceInstructionIndexAndMicroLamports(\n transactionMessage: TransactionMessage,\n): { index: number; microLamports: MicroLamports } | null {\n const index = transactionMessage.instructions.findIndex(isSetComputeUnitPriceInstruction);\n if (index < 0) {\n return null;\n }\n\n const microLamports = getU64Decoder().decode(\n transactionMessage.instructions[index].data as ReadonlyUint8Array,\n 1,\n ) as MicroLamports;\n\n return { index, microLamports };\n}\n\n/**\n * Checks if the given instruction is a `SetComputeUnitPrice` instruction.\n */\nfunction isSetComputeUnitPriceInstruction(instruction: Instruction): instruction is SetComputeUnitPriceInstruction {\n return (\n instruction.programAddress === COMPUTE_BUDGET_PROGRAM_ADDRESS &&\n identifyComputeBudgetInstruction(instruction.data as Uint8Array) ===\n ComputeBudgetInstruction.SetComputeUnitPrice\n );\n}\n","import { appendTransactionMessageInstruction, TransactionMessage } from '@solana/kit';\nimport { PROVISORY_COMPUTE_UNIT_LIMIT } from './constants';\nimport { getSetComputeUnitLimitInstruction } from './generated';\nimport { findSetComputeUnitLimitInstructionIndexAndUnits } from './introspect';\n\n/**\n * Appends a `SetComputeUnitLimit` instruction with a provisory\n * compute unit limit to a given transaction message\n * if and only if it does not already have one.\n *\n * @example\n * ```ts\n * const transactionMessage = pipe(\n * createTransactionMessage({ version: 0 }),\n * fillProvisorySetComputeUnitLimitInstruction,\n * // ...\n * );\n * ```\n */\nexport function fillProvisorySetComputeUnitLimitInstruction<TTransactionMessage extends TransactionMessage>(\n transactionMessage: TTransactionMessage,\n) {\n return updateOrAppendSetComputeUnitLimitInstruction(\n previousUnits => (previousUnits === null ? PROVISORY_COMPUTE_UNIT_LIMIT : previousUnits),\n transactionMessage,\n );\n}\n\n/**\n * Updates the first `SetComputeUnitLimit` instruction in a transaction message\n * with the given units, or appends a new instruction if none exists.\n * A function of the current value can be provided instead of a static value.\n *\n * @param units - The new compute unit limit, or a function that takes the previous\n * compute unit limit and returns the new limit.\n * @param transactionMessage - The transaction message to update.\n *\n * @example\n * ```ts\n * const updatedTransactionMessage = updateOrAppendSetComputeUnitLimitInstruction(\n * // E.g. Keep the current limit if it is set, otherwise set it to the maximum.\n * (currentUnits) => currentUnits === null ? MAX_COMPUTE_UNIT_LIMIT : currentUnits,\n * transactionMessage,\n * );\n * ```\n */\nexport function updateOrAppendSetComputeUnitLimitInstruction<TTransactionMessage extends TransactionMessage>(\n units: number | ((previousUnits: number | null) => number),\n transactionMessage: TTransactionMessage,\n): TTransactionMessage {\n const getUnits = (previousUnits: number | null): number =>\n typeof units === 'function' ? units(previousUnits) : units;\n const instructionDetails = findSetComputeUnitLimitInstructionIndexAndUnits(transactionMessage);\n\n if (!instructionDetails) {\n return appendTransactionMessageInstruction(\n getSetComputeUnitLimitInstruction({ units: getUnits(null) }),\n transactionMessage,\n ) as TTransactionMessage;\n }\n\n const { index, units: previousUnits } = instructionDetails;\n const newUnits = getUnits(previousUnits);\n if (newUnits === previousUnits) {\n return transactionMessage;\n }\n\n const newInstruction = getSetComputeUnitLimitInstruction({ units: newUnits });\n const newInstructions = [...transactionMessage.instructions];\n newInstructions.splice(index, 1, newInstruction);\n return Object.freeze({\n ...transactionMessage,\n instructions: newInstructions,\n }) as TTransactionMessage;\n}\n","import { TransactionMessage, TransactionMessageWithFeePayer } from '@solana/kit';\nimport { MAX_COMPUTE_UNIT_LIMIT, PROVISORY_COMPUTE_UNIT_LIMIT } from './constants';\nimport {\n EstimateComputeUnitLimitFactoryFunction,\n EstimateComputeUnitLimitFactoryFunctionConfig,\n} from './estimateComputeLimitInternal';\nimport { findSetComputeUnitLimitInstructionIndexAndUnits } from './introspect';\nimport { updateOrAppendSetComputeUnitLimitInstruction } from './setComputeLimit';\n\ntype EstimateAndUpdateProvisoryComputeUnitLimitFactoryFunction = <\n TTransactionMessage extends TransactionMessage & TransactionMessageWithFeePayer,\n>(\n transactionMessage: TTransactionMessage,\n config?: EstimateComputeUnitLimitFactoryFunctionConfig,\n) => Promise<TTransactionMessage>;\n\n/**\n * Given a transaction message, if it does not have an explicit compute unit limit,\n * estimates the compute unit limit and updates the transaction message with\n * the estimated limit. Otherwise, returns the transaction message unchanged.\n *\n * It requires a function that estimates the compute unit limit.\n *\n * @example\n * ```ts\n * const estimateAndUpdateCUs = estimateAndUpdateProvisoryComputeUnitLimitFactory(\n * estimateComputeUnitLimitFactory({ rpc })\n * );\n *\n * const transactionMessageWithCUs = await estimateAndUpdateCUs(transactionMessage);\n * ```\n *\n * @see {@link estimateAndUpdateProvisoryComputeUnitLimitFactory}\n */\nexport function estimateAndUpdateProvisoryComputeUnitLimitFactory(\n estimateComputeUnitLimit: EstimateComputeUnitLimitFactoryFunction,\n): EstimateAndUpdateProvisoryComputeUnitLimitFactoryFunction {\n return async function fn(transactionMessage, config) {\n const instructionDetails = findSetComputeUnitLimitInstructionIndexAndUnits(transactionMessage);\n\n // If the transaction message already has a compute unit limit instruction\n // which is set to a specific value — i.e. not 0 or the maximum limit —\n // we don't need to estimate the compute unit limit.\n if (\n instructionDetails &&\n instructionDetails.units !== PROVISORY_COMPUTE_UNIT_LIMIT &&\n instructionDetails.units !== MAX_COMPUTE_UNIT_LIMIT\n ) {\n return transactionMessage;\n }\n\n return updateOrAppendSetComputeUnitLimitInstruction(\n await estimateComputeUnitLimit(transactionMessage, config),\n transactionMessage,\n );\n };\n}\n","import {\n TransactionMessage,\n Commitment,\n compileTransaction,\n getBase64EncodedWireTransaction,\n getSolanaErrorFromTransactionError,\n isSolanaError,\n isTransactionMessageWithDurableNonceLifetime,\n pipe,\n Rpc,\n RpcSimulateTransactionResult,\n SimulateTransactionApi,\n Slot,\n SOLANA_ERROR__TRANSACTION__FAILED_TO_ESTIMATE_COMPUTE_LIMIT,\n SOLANA_ERROR__TRANSACTION__FAILED_WHEN_SIMULATING_TO_ESTIMATE_COMPUTE_LIMIT,\n SolanaError,\n Transaction,\n TransactionMessageWithFeePayer,\n} from '@solana/kit';\nimport { updateOrAppendSetComputeUnitLimitInstruction } from './setComputeLimit';\nimport { MAX_COMPUTE_UNIT_LIMIT } from './constants';\n\nexport type EstimateComputeUnitLimitFactoryConfig = Readonly<{\n /** An object that supports the {@link SimulateTransactionApi} of the Solana RPC API */\n rpc: Rpc<SimulateTransactionApi>;\n}>;\n\nexport type EstimateComputeUnitLimitFactoryFunction = (\n transactionMessage: TransactionMessage & TransactionMessageWithFeePayer,\n config?: EstimateComputeUnitLimitFactoryFunctionConfig,\n) => Promise<number>;\n\nexport type EstimateComputeUnitLimitFactoryFunctionConfig = {\n abortSignal?: AbortSignal;\n /**\n * Compute the estimate as of the highest slot that has reached this level of commitment.\n *\n * @defaultValue Whichever default is applied by the underlying {@link RpcApi} in use. For\n * example, when using an API created by a `createSolanaRpc*()` helper, the default commitment\n * is `\"confirmed\"` unless configured otherwise. Unmitigated by an API layer on the client, the\n * default commitment applied by the server is `\"finalized\"`.\n */\n commitment?: Commitment;\n /**\n * Prevents accessing stale data by enforcing that the RPC node has processed transactions up to\n * this slot\n */\n minContextSlot?: Slot;\n};\n\ntype EstimateComputeUnitLimitConfig = EstimateComputeUnitLimitFactoryFunctionConfig &\n Readonly<{\n rpc: Rpc<SimulateTransactionApi>;\n transactionMessage: TransactionMessage & TransactionMessageWithFeePayer;\n }>;\n\n/**\n * Simulates a transaction message on the network and returns the number of compute units it\n * consumed during simulation.\n *\n * The estimate this function returns can be used to set a compute unit limit on the transaction.\n * Correctly budgeting a compute unit limit for your transaction message can increase the probability\n * that your transaction will be accepted for processing.\n *\n * If you don't declare a compute unit limit on your transaction, validators will assume an upper\n * limit of 200K compute units (CU) per instruction. Since validators have an incentive to pack as\n * many transactions into each block as possible, they may choose to include transactions that they\n * know will fit into the remaining compute budget for the current block over transactions that\n * might not. For this reason, you should set a compute unit limit on each of your transaction\n * messages, whenever possible.\n *\n * ## Example\n *\n * ```ts\n * import { getSetComputeLimitInstruction } from '@solana-program/compute-budget';\n * import { createSolanaRpc, getComputeUnitEstimateForTransactionMessageFactory, pipe } from '@solana/kit';\n *\n * // Create an estimator function.\n * const rpc = createSolanaRpc('http://127.0.0.1:8899');\n * const getComputeUnitEstimateForTransactionMessage =\n * getComputeUnitEstimateForTransactionMessageFactory({ rpc });\n *\n * // Create your transaction message.\n * const transactionMessage = pipe(\n * createTransactionMessage({ version: 'legacy' }),\n * /* ... *\\/\n * );\n *\n * // Request an estimate of the actual compute units this message will consume.\n * const computeUnitsEstimate =\n * await getComputeUnitEstimateForTransactionMessage(transactionMessage);\n *\n * // Set the transaction message's compute unit budget.\n * const transactionMessageWithComputeUnitLimit = prependTransactionMessageInstruction(\n * getSetComputeLimitInstruction({ units: computeUnitsEstimate }),\n * transactionMessage,\n * );\n * ```\n *\n * > [!WARNING]\n * > The compute unit estimate is just that &ndash; an estimate. The compute unit consumption of the\n * > actual transaction might be higher or lower than what was observed in simulation. Unless you\n * > are confident that your particular transaction message will consume the same or fewer compute\n * > units as was estimated, you might like to augment the estimate by either a fixed number of CUs\n * > or a multiplier.\n *\n * > [!NOTE]\n * > If you are preparing an _unsigned_ transaction, destined to be signed and submitted to the\n * > network by a wallet, you might like to leave it up to the wallet to determine the compute unit\n * > limit. Consider that the wallet might have a more global view of how many compute units certain\n * > types of transactions consume, and might be able to make better estimates of an appropriate\n * > compute unit budget.\n */\nexport async function estimateComputeUnitLimit({\n transactionMessage,\n ...configs\n}: EstimateComputeUnitLimitConfig): Promise<number> {\n const replaceRecentBlockhash = !isTransactionMessageWithDurableNonceLifetime(transactionMessage);\n const transaction = pipe(\n transactionMessage,\n m => updateOrAppendSetComputeUnitLimitInstruction(MAX_COMPUTE_UNIT_LIMIT, m),\n compileTransaction,\n );\n\n return await simulateTransactionAndGetConsumedUnits({\n transaction,\n replaceRecentBlockhash,\n ...configs,\n });\n}\n\ntype SimulateTransactionAndGetConsumedUnitsConfig = Omit<EstimateComputeUnitLimitConfig, 'transactionMessage'> &\n Readonly<{ replaceRecentBlockhash?: boolean; transaction: Transaction }>;\n\nasync function simulateTransactionAndGetConsumedUnits({\n abortSignal,\n rpc,\n transaction,\n ...simulateConfig\n}: SimulateTransactionAndGetConsumedUnitsConfig): Promise<number> {\n const wireTransactionBytes = getBase64EncodedWireTransaction(transaction);\n\n try {\n const response = await rpc\n .simulateTransaction(wireTransactionBytes, { ...simulateConfig, encoding: 'base64', sigVerify: false })\n .send({ abortSignal });\n const { err: transactionError, ...simulationResult } = response.value as RpcSimulateTransactionResult;\n if (simulationResult.unitsConsumed == null) {\n // This should never be hit, because all RPCs should support `unitsConsumed` by now.\n throw new SolanaError(SOLANA_ERROR__TRANSACTION__FAILED_TO_ESTIMATE_COMPUTE_LIMIT);\n }\n if (transactionError) {\n throw new SolanaError(SOLANA_ERROR__TRANSACTION__FAILED_WHEN_SIMULATING_TO_ESTIMATE_COMPUTE_LIMIT, {\n ...simulationResult,\n cause: getSolanaErrorFromTransactionError(transactionError),\n });\n }\n // FIXME(https://github.com/anza-xyz/agave/issues/1295): The simulation response returns\n // compute units as a u64, but the `SetComputeLimit` instruction only accepts a u32. Until\n // this changes, downcast it.\n return simulationResult.unitsConsumed > 4_294_967_295n ? 4_294_967_295 : Number(simulationResult.unitsConsumed);\n } catch (e) {\n if (isSolanaError(e, SOLANA_ERROR__TRANSACTION__FAILED_WHEN_SIMULATING_TO_ESTIMATE_COMPUTE_LIMIT)) throw e;\n throw new SolanaError(SOLANA_ERROR__TRANSACTION__FAILED_TO_ESTIMATE_COMPUTE_LIMIT, { cause: e });\n }\n}\n","import {\n estimateComputeUnitLimit,\n EstimateComputeUnitLimitFactoryConfig,\n EstimateComputeUnitLimitFactoryFunction,\n} from './estimateComputeLimitInternal';\n\n/**\n * Use this utility to estimate the actual compute unit cost of a given transaction message.\n *\n * Correctly budgeting a compute unit limit for your transaction message can increase the\n * probability that your transaction will be accepted for processing. If you don't declare a compute\n * unit limit on your transaction, validators will assume an upper limit of 200K compute units (CU)\n * per instruction.\n *\n * Since validators have an incentive to pack as many transactions into each block as possible, they\n * may choose to include transactions that they know will fit into the remaining compute budget for\n * the current block over transactions that might not. For this reason, you should set a compute\n * unit limit on each of your transaction messages, whenever possible.\n *\n * > [!WARNING]\n * > The compute unit estimate is just that -- an estimate. The compute unit consumption of the\n * > actual transaction might be higher or lower than what was observed in simulation. Unless you\n * > are confident that your particular transaction message will consume the same or fewer compute\n * > units as was estimated, you might like to augment the estimate by either a fixed number of CUs\n * > or a multiplier.\n *\n * > [!NOTE]\n * > If you are preparing an _unsigned_ transaction, destined to be signed and submitted to the\n * > network by a wallet, you might like to leave it up to the wallet to determine the compute unit\n * > limit. Consider that the wallet might have a more global view of how many compute units certain\n * > types of transactions consume, and might be able to make better estimates of an appropriate\n * > compute unit budget.\n *\n * > [!INFO]\n * > In the event that a transaction message does not already have a `SetComputeUnitLimit`\n * > instruction, this function will add one before simulation. This ensures that the compute unit\n * > consumption of the `SetComputeUnitLimit` instruction itself is included in the estimate.\n *\n * @param config\n *\n * @example\n * ```ts\n * import { getSetComputeUnitLimitInstruction } from '@solana-program/compute-budget';\n * import { createSolanaRpc, estimateComputeUnitLimitFactory, pipe } from '@solana/kit';\n *\n * // Create an estimator function.\n * const rpc = createSolanaRpc('http://127.0.0.1:8899');\n * const estimateComputeUnitLimit = estimateComputeUnitLimitFactory({ rpc });\n *\n * // Create your transaction message.\n * const transactionMessage = pipe(\n * createTransactionMessage({ version: 'legacy' }),\n * /* ... *\\/\n * );\n *\n * // Request an estimate of the actual compute units this message will consume. This is done by\n * // simulating the transaction and grabbing the estimated compute units from the result.\n * const estimatedUnits = await estimateComputeUnitLimit(transactionMessage);\n *\n * // Set the transaction message's compute unit budget.\n * const transactionMessageWithComputeUnitLimit = prependTransactionMessageInstruction(\n * getSetComputeUnitLimitInstruction({ units: estimatedUnits }),\n * transactionMessage,\n * );\n * ```\n */\nexport function estimateComputeUnitLimitFactory({\n rpc,\n}: EstimateComputeUnitLimitFactoryConfig): EstimateComputeUnitLimitFactoryFunction {\n return async function estimateComputeUnitLimitFactoryFunction(transactionMessage, config) {\n return await estimateComputeUnitLimit({\n ...config,\n rpc,\n transactionMessage,\n });\n };\n}\n","import { appendTransactionMessageInstruction, TransactionMessage, MicroLamports } from '@solana/kit';\nimport { getSetComputeUnitPriceInstruction } from './generated';\nimport { findSetComputeUnitPriceInstructionIndexAndMicroLamports } from './introspect';\n\n/**\n * Sets the compute unit price of a transaction message in micro-Lamports.\n *\n * @example\n * ```ts\n * const transactionMessage = pipe(\n * createTransactionMessage({ version: 0 }),\n * (m) => setTransactionMessageComputeUnitPrice(10_000, m),\n * // ...\n * );\n * ```\n */\nexport function setTransactionMessageComputeUnitPrice<TTransactionMessage extends TransactionMessage>(\n microLamports: number | bigint,\n transactionMessage: TTransactionMessage,\n) {\n return appendTransactionMessageInstruction(\n getSetComputeUnitPriceInstruction({ microLamports }),\n transactionMessage,\n );\n}\n\n/**\n * Updates the first `SetComputeUnitPrice` instruction in a transaction message\n * with the given micro-Lamports, or appends a new instruction if none exists.\n * A function of the current value can be provided instead of a static value.\n *\n * @param microLamports - The new compute unit price, or a function that\n * takes the previous price and returns the new one.\n * @param transactionMessage - The transaction message to update.\n *\n * @example\n * ```ts\n * const updatedTransactionMessage = updateOrAppendSetComputeUnitPriceInstruction(\n * // E.g. double the current price or set it to 10_000 if it isn't set.\n * (currentPrice) => currentPrice === null ? 10_000 : currentPrice * 2,\n * transactionMessage,\n * );\n * ```\n */\nexport function updateOrAppendSetComputeUnitPriceInstruction<TTransactionMessage extends TransactionMessage>(\n microLamports: MicroLamports | ((previousMicroLamports: MicroLamports | null) => MicroLamports),\n transactionMessage: TTransactionMessage,\n): TTransactionMessage {\n const getMicroLamports = (previousMicroLamports: MicroLamports | null): MicroLamports =>\n typeof microLamports === 'function' ? microLamports(previousMicroLamports) : microLamports;\n const instructionDetails = findSetComputeUnitPriceInstructionIndexAndMicroLamports(transactionMessage);\n\n if (!instructionDetails) {\n return appendTransactionMessageInstruction(\n getSetComputeUnitPriceInstruction({\n microLamports: getMicroLamports(null),\n }),\n transactionMessage,\n ) as TTransactionMessage;\n }\n\n const { index, microLamports: previousMicroLamports } = instructionDetails;\n const newMicroLamports = getMicroLamports(previousMicroLamports);\n if (newMicroLamports === previousMicroLamports) {\n return transactionMessage;\n }\n\n const newInstruction = getSetComputeUnitPriceInstruction({\n microLamports: newMicroLamports,\n });\n const newInstructions = [...transactionMessage.instructions];\n newInstructions.splice(index, 1, newInstruction);\n return Object.freeze({\n ...transactionMessage,\n instructions: newInstructions,\n }) as TTransactionMessage;\n}\n"]}
@@ -1,4 +1,5 @@
1
- import { containsBytes, getU8Encoder, transformEncoder, getStructEncoder, getU32Encoder, getStructDecoder, getU8Decoder, getU32Decoder, combineCodec, getU64Encoder, getU64Decoder, appendTransactionMessageInstruction, isTransactionMessageWithDurableNonceLifetime, pipe, compileTransaction, getBase64EncodedWireTransaction, SolanaError, SOLANA_ERROR__TRANSACTION__FAILED_TO_ESTIMATE_COMPUTE_LIMIT, SOLANA_ERROR__TRANSACTION__FAILED_WHEN_SIMULATING_TO_ESTIMATE_COMPUTE_LIMIT, getSolanaErrorFromTransactionError, isSolanaError } from '@solana/kit';
1
+ import { containsBytes, getU8Encoder, SolanaError, SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_INSTRUCTION, SOLANA_ERROR__PROGRAM_CLIENTS__UNRECOGNIZED_INSTRUCTION_TYPE, transformEncoder, getStructEncoder, getU32Encoder, getStructDecoder, getU8Decoder, getU32Decoder, combineCodec, getU64Encoder, getU64Decoder, appendTransactionMessageInstruction, isTransactionMessageWithDurableNonceLifetime, pipe, compileTransaction, getBase64EncodedWireTransaction, SOLANA_ERROR__TRANSACTION__FAILED_TO_ESTIMATE_COMPUTE_LIMIT, SOLANA_ERROR__TRANSACTION__FAILED_WHEN_SIMULATING_TO_ESTIMATE_COMPUTE_LIMIT, getSolanaErrorFromTransactionError, isSolanaError } from '@solana/kit';
2
+ import { addSelfPlanAndSendFunctions } from '@solana/kit/program-client-core';
2
3
 
3
4
  // src/generated/instructions/requestHeapFrame.ts
4
5
  var COMPUTE_BUDGET_PROGRAM_ADDRESS = "ComputeBudget111111111111111111111111111111";
@@ -27,7 +28,10 @@ function identifyComputeBudgetInstruction(instruction) {
27
28
  if (containsBytes(data, getU8Encoder().encode(4), 0)) {
28
29
  return 4 /* SetLoadedAccountsDataSizeLimit */;
29
30
  }
30
- throw new Error("The provided instruction could not be identified as a computeBudget instruction.");
31
+ throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_INSTRUCTION, {
32
+ instructionData: data,
33
+ programName: "computeBudget"
34
+ });
31
35
  }
32
36
  function parseComputeBudgetInstruction(instruction) {
33
37
  const instructionType = identifyComputeBudgetInstruction(instruction);
@@ -63,9 +67,28 @@ function parseComputeBudgetInstruction(instruction) {
63
67
  };
64
68
  }
65
69
  default:
66
- throw new Error(`Unrecognized instruction type: ${instructionType}`);
70
+ throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__UNRECOGNIZED_INSTRUCTION_TYPE, {
71
+ instructionType,
72
+ programName: "computeBudget"
73
+ });
67
74
  }
68
75
  }
76
+ function computeBudgetProgram() {
77
+ return (client) => {
78
+ return {
79
+ ...client,
80
+ computeBudget: {
81
+ instructions: {
82
+ requestUnits: (input) => addSelfPlanAndSendFunctions(client, getRequestUnitsInstruction(input)),
83
+ requestHeapFrame: (input) => addSelfPlanAndSendFunctions(client, getRequestHeapFrameInstruction(input)),
84
+ setComputeUnitLimit: (input) => addSelfPlanAndSendFunctions(client, getSetComputeUnitLimitInstruction(input)),
85
+ setComputeUnitPrice: (input) => addSelfPlanAndSendFunctions(client, getSetComputeUnitPriceInstruction(input)),
86
+ setLoadedAccountsDataSizeLimit: (input) => addSelfPlanAndSendFunctions(client, getSetLoadedAccountsDataSizeLimitInstruction(input))
87
+ }
88
+ }
89
+ };
90
+ };
91
+ }
69
92
 
70
93
  // src/generated/instructions/requestHeapFrame.ts
71
94
  var REQUEST_HEAP_FRAME_DISCRIMINATOR = 1;
@@ -259,22 +282,19 @@ function parseSetLoadedAccountsDataSizeLimitInstruction(instruction) {
259
282
  // src/constants.ts
260
283
  var PROVISORY_COMPUTE_UNIT_LIMIT = 0;
261
284
  var MAX_COMPUTE_UNIT_LIMIT = 14e5;
262
- function getSetComputeUnitLimitInstructionIndexAndUnits(transactionMessage) {
263
- const index = getSetComputeUnitLimitInstructionIndex(transactionMessage);
285
+ function findSetComputeUnitLimitInstructionIndexAndUnits(transactionMessage) {
286
+ const index = transactionMessage.instructions.findIndex(isSetComputeUnitLimitInstruction);
264
287
  if (index < 0) {
265
288
  return null;
266
289
  }
267
290
  const units = getU32Decoder().decode(transactionMessage.instructions[index].data, 1);
268
291
  return { index, units };
269
292
  }
270
- function getSetComputeUnitLimitInstructionIndex(transactionMessage) {
271
- return transactionMessage.instructions.findIndex(isSetComputeUnitLimitInstruction);
272
- }
273
293
  function isSetComputeUnitLimitInstruction(instruction) {
274
294
  return instruction.programAddress === COMPUTE_BUDGET_PROGRAM_ADDRESS && identifyComputeBudgetInstruction(instruction.data) === 2 /* SetComputeUnitLimit */;
275
295
  }
276
- function getSetComputeUnitPriceInstructionIndexAndMicroLamports(transactionMessage) {
277
- const index = getSetComputeUnitPriceInstructionIndex(transactionMessage);
296
+ function findSetComputeUnitPriceInstructionIndexAndMicroLamports(transactionMessage) {
297
+ const index = transactionMessage.instructions.findIndex(isSetComputeUnitPriceInstruction);
278
298
  if (index < 0) {
279
299
  return null;
280
300
  }
@@ -284,9 +304,6 @@ function getSetComputeUnitPriceInstructionIndexAndMicroLamports(transactionMessa
284
304
  );
285
305
  return { index, microLamports };
286
306
  }
287
- function getSetComputeUnitPriceInstructionIndex(transactionMessage) {
288
- return transactionMessage.instructions.findIndex(isSetComputeUnitPriceInstruction);
289
- }
290
307
  function isSetComputeUnitPriceInstruction(instruction) {
291
308
  return instruction.programAddress === COMPUTE_BUDGET_PROGRAM_ADDRESS && identifyComputeBudgetInstruction(instruction.data) === 3 /* SetComputeUnitPrice */;
292
309
  }
@@ -298,7 +315,7 @@ function fillProvisorySetComputeUnitLimitInstruction(transactionMessage) {
298
315
  }
299
316
  function updateOrAppendSetComputeUnitLimitInstruction(units, transactionMessage) {
300
317
  const getUnits = (previousUnits2) => typeof units === "function" ? units(previousUnits2) : units;
301
- const instructionDetails = getSetComputeUnitLimitInstructionIndexAndUnits(transactionMessage);
318
+ const instructionDetails = findSetComputeUnitLimitInstructionIndexAndUnits(transactionMessage);
302
319
  if (!instructionDetails) {
303
320
  return appendTransactionMessageInstruction(
304
321
  getSetComputeUnitLimitInstruction({ units: getUnits(null) }),
@@ -322,7 +339,7 @@ function updateOrAppendSetComputeUnitLimitInstruction(units, transactionMessage)
322
339
  // src/estimateAndSetComputeLimit.ts
323
340
  function estimateAndUpdateProvisoryComputeUnitLimitFactory(estimateComputeUnitLimit2) {
324
341
  return async function fn(transactionMessage, config) {
325
- const instructionDetails = getSetComputeUnitLimitInstructionIndexAndUnits(transactionMessage);
342
+ const instructionDetails = findSetComputeUnitLimitInstructionIndexAndUnits(transactionMessage);
326
343
  if (instructionDetails && instructionDetails.units !== PROVISORY_COMPUTE_UNIT_LIMIT && instructionDetails.units !== MAX_COMPUTE_UNIT_LIMIT) {
327
344
  return transactionMessage;
328
345
  }
@@ -356,24 +373,18 @@ async function simulateTransactionAndGetConsumedUnits({
356
373
  }) {
357
374
  const wireTransactionBytes = getBase64EncodedWireTransaction(transaction);
358
375
  try {
359
- const {
360
- value: { err: transactionError, unitsConsumed }
361
- } = await rpc.simulateTransaction(wireTransactionBytes, {
362
- ...simulateConfig,
363
- encoding: "base64",
364
- sigVerify: false
365
- }).send({ abortSignal });
366
- if (unitsConsumed == null) {
376
+ const response = await rpc.simulateTransaction(wireTransactionBytes, { ...simulateConfig, encoding: "base64", sigVerify: false }).send({ abortSignal });
377
+ const { err: transactionError, ...simulationResult } = response.value;
378
+ if (simulationResult.unitsConsumed == null) {
367
379
  throw new SolanaError(SOLANA_ERROR__TRANSACTION__FAILED_TO_ESTIMATE_COMPUTE_LIMIT);
368
380
  }
369
- const downcastUnitsConsumed = unitsConsumed > 4294967295n ? 4294967295 : Number(unitsConsumed);
370
381
  if (transactionError) {
371
382
  throw new SolanaError(SOLANA_ERROR__TRANSACTION__FAILED_WHEN_SIMULATING_TO_ESTIMATE_COMPUTE_LIMIT, {
372
- cause: getSolanaErrorFromTransactionError(transactionError),
373
- unitsConsumed: downcastUnitsConsumed
383
+ ...simulationResult,
384
+ cause: getSolanaErrorFromTransactionError(transactionError)
374
385
  });
375
386
  }
376
- return downcastUnitsConsumed;
387
+ return simulationResult.unitsConsumed > 4294967295n ? 4294967295 : Number(simulationResult.unitsConsumed);
377
388
  } catch (e) {
378
389
  if (isSolanaError(e, SOLANA_ERROR__TRANSACTION__FAILED_WHEN_SIMULATING_TO_ESTIMATE_COMPUTE_LIMIT)) throw e;
379
390
  throw new SolanaError(SOLANA_ERROR__TRANSACTION__FAILED_TO_ESTIMATE_COMPUTE_LIMIT, { cause: e });
@@ -400,7 +411,7 @@ function setTransactionMessageComputeUnitPrice(microLamports, transactionMessage
400
411
  }
401
412
  function updateOrAppendSetComputeUnitPriceInstruction(microLamports, transactionMessage) {
402
413
  const getMicroLamports = (previousMicroLamports2) => typeof microLamports === "function" ? microLamports(previousMicroLamports2) : microLamports;
403
- const instructionDetails = getSetComputeUnitPriceInstructionIndexAndMicroLamports(transactionMessage);
414
+ const instructionDetails = findSetComputeUnitPriceInstructionIndexAndMicroLamports(transactionMessage);
404
415
  if (!instructionDetails) {
405
416
  return appendTransactionMessageInstruction(
406
417
  getSetComputeUnitPriceInstruction({
@@ -425,6 +436,6 @@ function updateOrAppendSetComputeUnitPriceInstruction(microLamports, transaction
425
436
  });
426
437
  }
427
438
 
428
- export { COMPUTE_BUDGET_PROGRAM_ADDRESS, ComputeBudgetInstruction, MAX_COMPUTE_UNIT_LIMIT, PROVISORY_COMPUTE_UNIT_LIMIT, REQUEST_HEAP_FRAME_DISCRIMINATOR, REQUEST_UNITS_DISCRIMINATOR, SET_COMPUTE_UNIT_LIMIT_DISCRIMINATOR, SET_COMPUTE_UNIT_PRICE_DISCRIMINATOR, SET_LOADED_ACCOUNTS_DATA_SIZE_LIMIT_DISCRIMINATOR, estimateAndUpdateProvisoryComputeUnitLimitFactory, estimateComputeUnitLimitFactory, fillProvisorySetComputeUnitLimitInstruction, getRequestHeapFrameDiscriminatorBytes, getRequestHeapFrameInstruction, getRequestHeapFrameInstructionDataCodec, getRequestHeapFrameInstructionDataDecoder, getRequestHeapFrameInstructionDataEncoder, getRequestUnitsDiscriminatorBytes, getRequestUnitsInstruction, getRequestUnitsInstructionDataCodec, getRequestUnitsInstructionDataDecoder, getRequestUnitsInstructionDataEncoder, getSetComputeUnitLimitDiscriminatorBytes, getSetComputeUnitLimitInstruction, getSetComputeUnitLimitInstructionDataCodec, getSetComputeUnitLimitInstructionDataDecoder, getSetComputeUnitLimitInstructionDataEncoder, getSetComputeUnitPriceDiscriminatorBytes, getSetComputeUnitPriceInstruction, getSetComputeUnitPriceInstructionDataCodec, getSetComputeUnitPriceInstructionDataDecoder, getSetComputeUnitPriceInstructionDataEncoder, getSetLoadedAccountsDataSizeLimitDiscriminatorBytes, getSetLoadedAccountsDataSizeLimitInstruction, getSetLoadedAccountsDataSizeLimitInstructionDataCodec, getSetLoadedAccountsDataSizeLimitInstructionDataDecoder, getSetLoadedAccountsDataSizeLimitInstructionDataEncoder, identifyComputeBudgetInstruction, parseComputeBudgetInstruction, parseRequestHeapFrameInstruction, parseRequestUnitsInstruction, parseSetComputeUnitLimitInstruction, parseSetComputeUnitPriceInstruction, parseSetLoadedAccountsDataSizeLimitInstruction, setTransactionMessageComputeUnitPrice, updateOrAppendSetComputeUnitLimitInstruction, updateOrAppendSetComputeUnitPriceInstruction };
439
+ export { COMPUTE_BUDGET_PROGRAM_ADDRESS, ComputeBudgetInstruction, MAX_COMPUTE_UNIT_LIMIT, PROVISORY_COMPUTE_UNIT_LIMIT, REQUEST_HEAP_FRAME_DISCRIMINATOR, REQUEST_UNITS_DISCRIMINATOR, SET_COMPUTE_UNIT_LIMIT_DISCRIMINATOR, SET_COMPUTE_UNIT_PRICE_DISCRIMINATOR, SET_LOADED_ACCOUNTS_DATA_SIZE_LIMIT_DISCRIMINATOR, computeBudgetProgram, estimateAndUpdateProvisoryComputeUnitLimitFactory, estimateComputeUnitLimitFactory, fillProvisorySetComputeUnitLimitInstruction, findSetComputeUnitLimitInstructionIndexAndUnits, findSetComputeUnitPriceInstructionIndexAndMicroLamports, getRequestHeapFrameDiscriminatorBytes, getRequestHeapFrameInstruction, getRequestHeapFrameInstructionDataCodec, getRequestHeapFrameInstructionDataDecoder, getRequestHeapFrameInstructionDataEncoder, getRequestUnitsDiscriminatorBytes, getRequestUnitsInstruction, getRequestUnitsInstructionDataCodec, getRequestUnitsInstructionDataDecoder, getRequestUnitsInstructionDataEncoder, getSetComputeUnitLimitDiscriminatorBytes, getSetComputeUnitLimitInstruction, getSetComputeUnitLimitInstructionDataCodec, getSetComputeUnitLimitInstructionDataDecoder, getSetComputeUnitLimitInstructionDataEncoder, getSetComputeUnitPriceDiscriminatorBytes, getSetComputeUnitPriceInstruction, getSetComputeUnitPriceInstructionDataCodec, getSetComputeUnitPriceInstructionDataDecoder, getSetComputeUnitPriceInstructionDataEncoder, getSetLoadedAccountsDataSizeLimitDiscriminatorBytes, getSetLoadedAccountsDataSizeLimitInstruction, getSetLoadedAccountsDataSizeLimitInstructionDataCodec, getSetLoadedAccountsDataSizeLimitInstructionDataDecoder, getSetLoadedAccountsDataSizeLimitInstructionDataEncoder, identifyComputeBudgetInstruction, parseComputeBudgetInstruction, parseRequestHeapFrameInstruction, parseRequestUnitsInstruction, parseSetComputeUnitLimitInstruction, parseSetComputeUnitPriceInstruction, parseSetLoadedAccountsDataSizeLimitInstruction, setTransactionMessageComputeUnitPrice, updateOrAppendSetComputeUnitLimitInstruction, updateOrAppendSetComputeUnitPriceInstruction };
429
440
  //# sourceMappingURL=index.mjs.map
430
441
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/generated/programs/computeBudget.ts","../../src/generated/instructions/requestHeapFrame.ts","../../src/generated/instructions/requestUnits.ts","../../src/generated/instructions/setComputeUnitLimit.ts","../../src/generated/instructions/setComputeUnitPrice.ts","../../src/generated/instructions/setLoadedAccountsDataSizeLimit.ts","../../src/constants.ts","../../src/internal.ts","../../src/setComputeLimit.ts","../../src/estimateAndSetComputeLimit.ts","../../src/estimateComputeLimitInternal.ts","../../src/estimateComputeLimit.ts","../../src/setComputePrice.ts"],"names":["ComputeBudgetInstruction","getU8Encoder","transformEncoder","getStructEncoder","getU32Encoder","getStructDecoder","getU8Decoder","getU32Decoder","combineCodec","getU64Decoder","previousUnits","estimateComputeUnitLimit","appendTransactionMessageInstruction","previousMicroLamports"],"mappings":";;;AA6BO,IAAM,8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,CAAO,KAAO,EAAA,CAAA,EAAG,cAAc,CAAA;AAC/C,EAAA,OAAO,OAAO,MAAO,CAAA;AAAA,IACjB,GAAG,kBAAA;AAAA,IACH,YAAc,EAAA;AAAA,GACjB,CAAA;AACL","file":"index.mjs","sourcesContent":["/**\n * This code was AUTOGENERATED using the Codama library.\n * Please DO NOT EDIT THIS FILE, instead use visitors\n * to add features, then rerun Codama to update it.\n *\n * @see https://github.com/codama-idl/codama\n */\n\nimport {\n containsBytes,\n getU8Encoder,\n type Address,\n type Instruction,\n type InstructionWithData,\n type ReadonlyUint8Array,\n} from '@solana/kit';\nimport {\n parseRequestHeapFrameInstruction,\n parseRequestUnitsInstruction,\n parseSetComputeUnitLimitInstruction,\n parseSetComputeUnitPriceInstruction,\n parseSetLoadedAccountsDataSizeLimitInstruction,\n type ParsedRequestHeapFrameInstruction,\n type ParsedRequestUnitsInstruction,\n type ParsedSetComputeUnitLimitInstruction,\n type ParsedSetComputeUnitPriceInstruction,\n type ParsedSetLoadedAccountsDataSizeLimitInstruction,\n} from '../instructions';\n\nexport const COMPUTE_BUDGET_PROGRAM_ADDRESS =\n 'ComputeBudget111111111111111111111111111111' as Address<'ComputeBudget111111111111111111111111111111'>;\n\nexport enum ComputeBudgetInstruction {\n RequestUnits,\n RequestHeapFrame,\n SetComputeUnitLimit,\n SetComputeUnitPrice,\n SetLoadedAccountsDataSizeLimit,\n}\n\nexport function identifyComputeBudgetInstruction(\n instruction: { data: ReadonlyUint8Array } | ReadonlyUint8Array,\n): ComputeBudgetInstruction {\n const data = 'data' in instruction ? instruction.data : instruction;\n if (containsBytes(data, getU8Encoder().encode(0), 0)) {\n return ComputeBudgetInstruction.RequestUnits;\n }\n if (containsBytes(data, getU8Encoder().encode(1), 0)) {\n return ComputeBudgetInstruction.RequestHeapFrame;\n }\n if (containsBytes(data, getU8Encoder().encode(2), 0)) {\n return ComputeBudgetInstruction.SetComputeUnitLimit;\n }\n if (containsBytes(data, getU8Encoder().encode(3), 0)) {\n return ComputeBudgetInstruction.SetComputeUnitPrice;\n }\n if (containsBytes(data, getU8Encoder().encode(4), 0)) {\n return ComputeBudgetInstruction.SetLoadedAccountsDataSizeLimit;\n }\n throw new Error('The provided instruction could not be identified as a computeBudget instruction.');\n}\n\nexport type ParsedComputeBudgetInstruction<TProgram extends string = 'ComputeBudget111111111111111111111111111111'> =\n | ({ instructionType: ComputeBudgetInstruction.RequestUnits } & ParsedRequestUnitsInstruction<TProgram>)\n | ({ instructionType: ComputeBudgetInstruction.RequestHeapFrame } & ParsedRequestHeapFrameInstruction<TProgram>)\n | ({\n instructionType: ComputeBudgetInstruction.SetComputeUnitLimit;\n } & ParsedSetComputeUnitLimitInstruction<TProgram>)\n | ({\n instructionType: ComputeBudgetInstruction.SetComputeUnitPrice;\n } & ParsedSetComputeUnitPriceInstruction<TProgram>)\n | ({\n instructionType: ComputeBudgetInstruction.SetLoadedAccountsDataSizeLimit;\n } & ParsedSetLoadedAccountsDataSizeLimitInstruction<TProgram>);\n\nexport function parseComputeBudgetInstruction<TProgram extends string>(\n instruction: Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array>,\n): ParsedComputeBudgetInstruction<TProgram> {\n const instructionType = identifyComputeBudgetInstruction(instruction);\n switch (instructionType) {\n case ComputeBudgetInstruction.RequestUnits: {\n return {\n instructionType: ComputeBudgetInstruction.RequestUnits,\n ...parseRequestUnitsInstruction(instruction),\n };\n }\n case ComputeBudgetInstruction.RequestHeapFrame: {\n return {\n instructionType: ComputeBudgetInstruction.RequestHeapFrame,\n ...parseRequestHeapFrameInstruction(instruction),\n };\n }\n case ComputeBudgetInstruction.SetComputeUnitLimit: {\n return {\n instructionType: ComputeBudgetInstruction.SetComputeUnitLimit,\n ...parseSetComputeUnitLimitInstruction(instruction),\n };\n }\n case ComputeBudgetInstruction.SetComputeUnitPrice: {\n return {\n instructionType: ComputeBudgetInstruction.SetComputeUnitPrice,\n ...parseSetComputeUnitPriceInstruction(instruction),\n };\n }\n case ComputeBudgetInstruction.SetLoadedAccountsDataSizeLimit: {\n return {\n instructionType: ComputeBudgetInstruction.SetLoadedAccountsDataSizeLimit,\n ...parseSetLoadedAccountsDataSizeLimitInstruction(instruction),\n };\n }\n default:\n throw new Error(`Unrecognized instruction type: ${instructionType as string}`);\n }\n}\n","/**\n * This code was AUTOGENERATED using the Codama library.\n * Please DO NOT EDIT THIS FILE, instead use visitors\n * to add features, then rerun Codama to update it.\n *\n * @see https://github.com/codama-idl/codama\n */\n\nimport {\n combineCodec,\n getStructDecoder,\n getStructEncoder,\n getU32Decoder,\n getU32Encoder,\n getU8Decoder,\n getU8Encoder,\n transformEncoder,\n type AccountMeta,\n type Address,\n type FixedSizeCodec,\n type FixedSizeDecoder,\n type FixedSizeEncoder,\n type Instruction,\n type InstructionWithAccounts,\n type InstructionWithData,\n type ReadonlyUint8Array,\n} from '@solana/kit';\nimport { COMPUTE_BUDGET_PROGRAM_ADDRESS } from '../programs';\n\nexport const REQUEST_HEAP_FRAME_DISCRIMINATOR = 1;\n\nexport function getRequestHeapFrameDiscriminatorBytes() {\n return getU8Encoder().encode(REQUEST_HEAP_FRAME_DISCRIMINATOR);\n}\n\nexport type RequestHeapFrameInstruction<\n TProgram extends string = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS,\n TRemainingAccounts extends readonly AccountMeta<string>[] = [],\n> = Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array> & InstructionWithAccounts<TRemainingAccounts>;\n\nexport type RequestHeapFrameInstructionData = {\n discriminator: number;\n /**\n * Requested transaction-wide program heap size in bytes.\n * Must be multiple of 1024. Applies to each program, including CPIs.\n */\n bytes: number;\n};\n\nexport type RequestHeapFrameInstructionDataArgs = {\n /**\n * Requested transaction-wide program heap size in bytes.\n * Must be multiple of 1024. Applies to each program, including CPIs.\n */\n bytes: number;\n};\n\nexport function getRequestHeapFrameInstructionDataEncoder(): FixedSizeEncoder<RequestHeapFrameInstructionDataArgs> {\n return transformEncoder(\n getStructEncoder([\n ['discriminator', getU8Encoder()],\n ['bytes', getU32Encoder()],\n ]),\n value => ({ ...value, discriminator: REQUEST_HEAP_FRAME_DISCRIMINATOR }),\n );\n}\n\nexport function getRequestHeapFrameInstructionDataDecoder(): FixedSizeDecoder<RequestHeapFrameInstructionData> {\n return getStructDecoder([\n ['discriminator', getU8Decoder()],\n ['bytes', getU32Decoder()],\n ]);\n}\n\nexport function getRequestHeapFrameInstructionDataCodec(): FixedSizeCodec<\n RequestHeapFrameInstructionDataArgs,\n RequestHeapFrameInstructionData\n> {\n return combineCodec(getRequestHeapFrameInstructionDataEncoder(), getRequestHeapFrameInstructionDataDecoder());\n}\n\nexport type RequestHeapFrameInput = {\n bytes: RequestHeapFrameInstructionDataArgs['bytes'];\n};\n\nexport function getRequestHeapFrameInstruction<TProgramAddress extends Address = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS>(\n input: RequestHeapFrameInput,\n config?: { programAddress?: TProgramAddress },\n): RequestHeapFrameInstruction<TProgramAddress> {\n // Program address.\n const programAddress = config?.programAddress ?? COMPUTE_BUDGET_PROGRAM_ADDRESS;\n\n // Original args.\n const args = { ...input };\n\n return Object.freeze({\n data: getRequestHeapFrameInstructionDataEncoder().encode(args as RequestHeapFrameInstructionDataArgs),\n programAddress,\n } as RequestHeapFrameInstruction<TProgramAddress>);\n}\n\nexport type ParsedRequestHeapFrameInstruction<TProgram extends string = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS> = {\n programAddress: Address<TProgram>;\n data: RequestHeapFrameInstructionData;\n};\n\nexport function parseRequestHeapFrameInstruction<TProgram extends string>(\n instruction: Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array>,\n): ParsedRequestHeapFrameInstruction<TProgram> {\n return {\n programAddress: instruction.programAddress,\n data: getRequestHeapFrameInstructionDataDecoder().decode(instruction.data),\n };\n}\n","/**\n * This code was AUTOGENERATED using the Codama library.\n * Please DO NOT EDIT THIS FILE, instead use visitors\n * to add features, then rerun Codama to update it.\n *\n * @see https://github.com/codama-idl/codama\n */\n\nimport {\n combineCodec,\n getStructDecoder,\n getStructEncoder,\n getU32Decoder,\n getU32Encoder,\n getU8Decoder,\n getU8Encoder,\n transformEncoder,\n type AccountMeta,\n type Address,\n type FixedSizeCodec,\n type FixedSizeDecoder,\n type FixedSizeEncoder,\n type Instruction,\n type InstructionWithAccounts,\n type InstructionWithData,\n type ReadonlyUint8Array,\n} from '@solana/kit';\nimport { COMPUTE_BUDGET_PROGRAM_ADDRESS } from '../programs';\n\nexport const REQUEST_UNITS_DISCRIMINATOR = 0;\n\nexport function getRequestUnitsDiscriminatorBytes() {\n return getU8Encoder().encode(REQUEST_UNITS_DISCRIMINATOR);\n}\n\nexport type RequestUnitsInstruction<\n TProgram extends string = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS,\n TRemainingAccounts extends readonly AccountMeta<string>[] = [],\n> = Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array> & InstructionWithAccounts<TRemainingAccounts>;\n\nexport type RequestUnitsInstructionData = {\n discriminator: number;\n /** Units to request for transaction-wide compute. */\n units: number;\n /** Prioritization fee lamports. */\n additionalFee: number;\n};\n\nexport type RequestUnitsInstructionDataArgs = {\n /** Units to request for transaction-wide compute. */\n units: number;\n /** Prioritization fee lamports. */\n additionalFee: number;\n};\n\nexport function getRequestUnitsInstructionDataEncoder(): FixedSizeEncoder<RequestUnitsInstructionDataArgs> {\n return transformEncoder(\n getStructEncoder([\n ['discriminator', getU8Encoder()],\n ['units', getU32Encoder()],\n ['additionalFee', getU32Encoder()],\n ]),\n value => ({ ...value, discriminator: REQUEST_UNITS_DISCRIMINATOR }),\n );\n}\n\nexport function getRequestUnitsInstructionDataDecoder(): FixedSizeDecoder<RequestUnitsInstructionData> {\n return getStructDecoder([\n ['discriminator', getU8Decoder()],\n ['units', getU32Decoder()],\n ['additionalFee', getU32Decoder()],\n ]);\n}\n\nexport function getRequestUnitsInstructionDataCodec(): FixedSizeCodec<\n RequestUnitsInstructionDataArgs,\n RequestUnitsInstructionData\n> {\n return combineCodec(getRequestUnitsInstructionDataEncoder(), getRequestUnitsInstructionDataDecoder());\n}\n\nexport type RequestUnitsInput = {\n units: RequestUnitsInstructionDataArgs['units'];\n additionalFee: RequestUnitsInstructionDataArgs['additionalFee'];\n};\n\nexport function getRequestUnitsInstruction<TProgramAddress extends Address = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS>(\n input: RequestUnitsInput,\n config?: { programAddress?: TProgramAddress },\n): RequestUnitsInstruction<TProgramAddress> {\n // Program address.\n const programAddress = config?.programAddress ?? COMPUTE_BUDGET_PROGRAM_ADDRESS;\n\n // Original args.\n const args = { ...input };\n\n return Object.freeze({\n data: getRequestUnitsInstructionDataEncoder().encode(args as RequestUnitsInstructionDataArgs),\n programAddress,\n } as RequestUnitsInstruction<TProgramAddress>);\n}\n\nexport type ParsedRequestUnitsInstruction<TProgram extends string = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS> = {\n programAddress: Address<TProgram>;\n data: RequestUnitsInstructionData;\n};\n\nexport function parseRequestUnitsInstruction<TProgram extends string>(\n instruction: Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array>,\n): ParsedRequestUnitsInstruction<TProgram> {\n return {\n programAddress: instruction.programAddress,\n data: getRequestUnitsInstructionDataDecoder().decode(instruction.data),\n };\n}\n","/**\n * This code was AUTOGENERATED using the Codama library.\n * Please DO NOT EDIT THIS FILE, instead use visitors\n * to add features, then rerun Codama to update it.\n *\n * @see https://github.com/codama-idl/codama\n */\n\nimport {\n combineCodec,\n getStructDecoder,\n getStructEncoder,\n getU32Decoder,\n getU32Encoder,\n getU8Decoder,\n getU8Encoder,\n transformEncoder,\n type AccountMeta,\n type Address,\n type FixedSizeCodec,\n type FixedSizeDecoder,\n type FixedSizeEncoder,\n type Instruction,\n type InstructionWithAccounts,\n type InstructionWithData,\n type ReadonlyUint8Array,\n} from '@solana/kit';\nimport { COMPUTE_BUDGET_PROGRAM_ADDRESS } from '../programs';\n\nexport const SET_COMPUTE_UNIT_LIMIT_DISCRIMINATOR = 2;\n\nexport function getSetComputeUnitLimitDiscriminatorBytes() {\n return getU8Encoder().encode(SET_COMPUTE_UNIT_LIMIT_DISCRIMINATOR);\n}\n\nexport type SetComputeUnitLimitInstruction<\n TProgram extends string = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS,\n TRemainingAccounts extends readonly AccountMeta<string>[] = [],\n> = Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array> & InstructionWithAccounts<TRemainingAccounts>;\n\nexport type SetComputeUnitLimitInstructionData = {\n discriminator: number;\n /** Transaction-wide compute unit limit. */\n units: number;\n};\n\nexport type SetComputeUnitLimitInstructionDataArgs = {\n /** Transaction-wide compute unit limit. */\n units: number;\n};\n\nexport function getSetComputeUnitLimitInstructionDataEncoder(): FixedSizeEncoder<SetComputeUnitLimitInstructionDataArgs> {\n return transformEncoder(\n getStructEncoder([\n ['discriminator', getU8Encoder()],\n ['units', getU32Encoder()],\n ]),\n value => ({ ...value, discriminator: SET_COMPUTE_UNIT_LIMIT_DISCRIMINATOR }),\n );\n}\n\nexport function getSetComputeUnitLimitInstructionDataDecoder(): FixedSizeDecoder<SetComputeUnitLimitInstructionData> {\n return getStructDecoder([\n ['discriminator', getU8Decoder()],\n ['units', getU32Decoder()],\n ]);\n}\n\nexport function getSetComputeUnitLimitInstructionDataCodec(): FixedSizeCodec<\n SetComputeUnitLimitInstructionDataArgs,\n SetComputeUnitLimitInstructionData\n> {\n return combineCodec(getSetComputeUnitLimitInstructionDataEncoder(), getSetComputeUnitLimitInstructionDataDecoder());\n}\n\nexport type SetComputeUnitLimitInput = {\n units: SetComputeUnitLimitInstructionDataArgs['units'];\n};\n\nexport function getSetComputeUnitLimitInstruction<\n TProgramAddress extends Address = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS,\n>(\n input: SetComputeUnitLimitInput,\n config?: { programAddress?: TProgramAddress },\n): SetComputeUnitLimitInstruction<TProgramAddress> {\n // Program address.\n const programAddress = config?.programAddress ?? COMPUTE_BUDGET_PROGRAM_ADDRESS;\n\n // Original args.\n const args = { ...input };\n\n return Object.freeze({\n data: getSetComputeUnitLimitInstructionDataEncoder().encode(args as SetComputeUnitLimitInstructionDataArgs),\n programAddress,\n } as SetComputeUnitLimitInstruction<TProgramAddress>);\n}\n\nexport type ParsedSetComputeUnitLimitInstruction<TProgram extends string = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS> = {\n programAddress: Address<TProgram>;\n data: SetComputeUnitLimitInstructionData;\n};\n\nexport function parseSetComputeUnitLimitInstruction<TProgram extends string>(\n instruction: Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array>,\n): ParsedSetComputeUnitLimitInstruction<TProgram> {\n return {\n programAddress: instruction.programAddress,\n data: getSetComputeUnitLimitInstructionDataDecoder().decode(instruction.data),\n };\n}\n","/**\n * This code was AUTOGENERATED using the Codama library.\n * Please DO NOT EDIT THIS FILE, instead use visitors\n * to add features, then rerun Codama to update it.\n *\n * @see https://github.com/codama-idl/codama\n */\n\nimport {\n combineCodec,\n getStructDecoder,\n getStructEncoder,\n getU64Decoder,\n getU64Encoder,\n getU8Decoder,\n getU8Encoder,\n transformEncoder,\n type AccountMeta,\n type Address,\n type FixedSizeCodec,\n type FixedSizeDecoder,\n type FixedSizeEncoder,\n type Instruction,\n type InstructionWithAccounts,\n type InstructionWithData,\n type ReadonlyUint8Array,\n} from '@solana/kit';\nimport { COMPUTE_BUDGET_PROGRAM_ADDRESS } from '../programs';\n\nexport const SET_COMPUTE_UNIT_PRICE_DISCRIMINATOR = 3;\n\nexport function getSetComputeUnitPriceDiscriminatorBytes() {\n return getU8Encoder().encode(SET_COMPUTE_UNIT_PRICE_DISCRIMINATOR);\n}\n\nexport type SetComputeUnitPriceInstruction<\n TProgram extends string = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS,\n TRemainingAccounts extends readonly AccountMeta<string>[] = [],\n> = Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array> & InstructionWithAccounts<TRemainingAccounts>;\n\nexport type SetComputeUnitPriceInstructionData = {\n discriminator: number;\n /** Transaction compute unit price used for prioritization fees. */\n microLamports: bigint;\n};\n\nexport type SetComputeUnitPriceInstructionDataArgs = {\n /** Transaction compute unit price used for prioritization fees. */\n microLamports: number | bigint;\n};\n\nexport function getSetComputeUnitPriceInstructionDataEncoder(): FixedSizeEncoder<SetComputeUnitPriceInstructionDataArgs> {\n return transformEncoder(\n getStructEncoder([\n ['discriminator', getU8Encoder()],\n ['microLamports', getU64Encoder()],\n ]),\n value => ({ ...value, discriminator: SET_COMPUTE_UNIT_PRICE_DISCRIMINATOR }),\n );\n}\n\nexport function getSetComputeUnitPriceInstructionDataDecoder(): FixedSizeDecoder<SetComputeUnitPriceInstructionData> {\n return getStructDecoder([\n ['discriminator', getU8Decoder()],\n ['microLamports', getU64Decoder()],\n ]);\n}\n\nexport function getSetComputeUnitPriceInstructionDataCodec(): FixedSizeCodec<\n SetComputeUnitPriceInstructionDataArgs,\n SetComputeUnitPriceInstructionData\n> {\n return combineCodec(getSetComputeUnitPriceInstructionDataEncoder(), getSetComputeUnitPriceInstructionDataDecoder());\n}\n\nexport type SetComputeUnitPriceInput = {\n microLamports: SetComputeUnitPriceInstructionDataArgs['microLamports'];\n};\n\nexport function getSetComputeUnitPriceInstruction<\n TProgramAddress extends Address = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS,\n>(\n input: SetComputeUnitPriceInput,\n config?: { programAddress?: TProgramAddress },\n): SetComputeUnitPriceInstruction<TProgramAddress> {\n // Program address.\n const programAddress = config?.programAddress ?? COMPUTE_BUDGET_PROGRAM_ADDRESS;\n\n // Original args.\n const args = { ...input };\n\n return Object.freeze({\n data: getSetComputeUnitPriceInstructionDataEncoder().encode(args as SetComputeUnitPriceInstructionDataArgs),\n programAddress,\n } as SetComputeUnitPriceInstruction<TProgramAddress>);\n}\n\nexport type ParsedSetComputeUnitPriceInstruction<TProgram extends string = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS> = {\n programAddress: Address<TProgram>;\n data: SetComputeUnitPriceInstructionData;\n};\n\nexport function parseSetComputeUnitPriceInstruction<TProgram extends string>(\n instruction: Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array>,\n): ParsedSetComputeUnitPriceInstruction<TProgram> {\n return {\n programAddress: instruction.programAddress,\n data: getSetComputeUnitPriceInstructionDataDecoder().decode(instruction.data),\n };\n}\n","/**\n * This code was AUTOGENERATED using the Codama library.\n * Please DO NOT EDIT THIS FILE, instead use visitors\n * to add features, then rerun Codama to update it.\n *\n * @see https://github.com/codama-idl/codama\n */\n\nimport {\n combineCodec,\n getStructDecoder,\n getStructEncoder,\n getU32Decoder,\n getU32Encoder,\n getU8Decoder,\n getU8Encoder,\n transformEncoder,\n type AccountMeta,\n type Address,\n type FixedSizeCodec,\n type FixedSizeDecoder,\n type FixedSizeEncoder,\n type Instruction,\n type InstructionWithAccounts,\n type InstructionWithData,\n type ReadonlyUint8Array,\n} from '@solana/kit';\nimport { COMPUTE_BUDGET_PROGRAM_ADDRESS } from '../programs';\n\nexport const SET_LOADED_ACCOUNTS_DATA_SIZE_LIMIT_DISCRIMINATOR = 4;\n\nexport function getSetLoadedAccountsDataSizeLimitDiscriminatorBytes() {\n return getU8Encoder().encode(SET_LOADED_ACCOUNTS_DATA_SIZE_LIMIT_DISCRIMINATOR);\n}\n\nexport type SetLoadedAccountsDataSizeLimitInstruction<\n TProgram extends string = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS,\n TRemainingAccounts extends readonly AccountMeta<string>[] = [],\n> = Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array> & InstructionWithAccounts<TRemainingAccounts>;\n\nexport type SetLoadedAccountsDataSizeLimitInstructionData = { discriminator: number; accountDataSizeLimit: number };\n\nexport type SetLoadedAccountsDataSizeLimitInstructionDataArgs = { accountDataSizeLimit: number };\n\nexport function getSetLoadedAccountsDataSizeLimitInstructionDataEncoder(): FixedSizeEncoder<SetLoadedAccountsDataSizeLimitInstructionDataArgs> {\n return transformEncoder(\n getStructEncoder([\n ['discriminator', getU8Encoder()],\n ['accountDataSizeLimit', getU32Encoder()],\n ]),\n value => ({ ...value, discriminator: SET_LOADED_ACCOUNTS_DATA_SIZE_LIMIT_DISCRIMINATOR }),\n );\n}\n\nexport function getSetLoadedAccountsDataSizeLimitInstructionDataDecoder(): FixedSizeDecoder<SetLoadedAccountsDataSizeLimitInstructionData> {\n return getStructDecoder([\n ['discriminator', getU8Decoder()],\n ['accountDataSizeLimit', getU32Decoder()],\n ]);\n}\n\nexport function getSetLoadedAccountsDataSizeLimitInstructionDataCodec(): FixedSizeCodec<\n SetLoadedAccountsDataSizeLimitInstructionDataArgs,\n SetLoadedAccountsDataSizeLimitInstructionData\n> {\n return combineCodec(\n getSetLoadedAccountsDataSizeLimitInstructionDataEncoder(),\n getSetLoadedAccountsDataSizeLimitInstructionDataDecoder(),\n );\n}\n\nexport type SetLoadedAccountsDataSizeLimitInput = {\n accountDataSizeLimit: SetLoadedAccountsDataSizeLimitInstructionDataArgs['accountDataSizeLimit'];\n};\n\nexport function getSetLoadedAccountsDataSizeLimitInstruction<\n TProgramAddress extends Address = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS,\n>(\n input: SetLoadedAccountsDataSizeLimitInput,\n config?: { programAddress?: TProgramAddress },\n): SetLoadedAccountsDataSizeLimitInstruction<TProgramAddress> {\n // Program address.\n const programAddress = config?.programAddress ?? COMPUTE_BUDGET_PROGRAM_ADDRESS;\n\n // Original args.\n const args = { ...input };\n\n return Object.freeze({\n data: getSetLoadedAccountsDataSizeLimitInstructionDataEncoder().encode(\n args as SetLoadedAccountsDataSizeLimitInstructionDataArgs,\n ),\n programAddress,\n } as SetLoadedAccountsDataSizeLimitInstruction<TProgramAddress>);\n}\n\nexport type ParsedSetLoadedAccountsDataSizeLimitInstruction<\n TProgram extends string = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS,\n> = { programAddress: Address<TProgram>; data: SetLoadedAccountsDataSizeLimitInstructionData };\n\nexport function parseSetLoadedAccountsDataSizeLimitInstruction<TProgram extends string>(\n instruction: Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array>,\n): ParsedSetLoadedAccountsDataSizeLimitInstruction<TProgram> {\n return {\n programAddress: instruction.programAddress,\n data: getSetLoadedAccountsDataSizeLimitInstructionDataDecoder().decode(instruction.data),\n };\n}\n","/**\n * A provisory compute unit limit is used to indicate that the transaction\n * should be estimated for compute units before being sent to the network.\n *\n * Setting it to zero ensures the transaction fails unless it is properly estimated.\n */\nexport const PROVISORY_COMPUTE_UNIT_LIMIT = 0;\n\n/**\n * The maximum compute unit limit that can be set for a transaction.\n */\nexport const MAX_COMPUTE_UNIT_LIMIT = 1_400_000;\n","import {\n TransactionMessage,\n getU32Decoder,\n getU64Decoder,\n Instruction,\n MicroLamports,\n ReadonlyUint8Array,\n} from '@solana/kit';\nimport {\n COMPUTE_BUDGET_PROGRAM_ADDRESS,\n ComputeBudgetInstruction,\n identifyComputeBudgetInstruction,\n SetComputeUnitLimitInstruction,\n SetComputeUnitPriceInstruction,\n} from './generated';\n\n/**\n * Finds the index of the first `SetComputeUnitLimit` instruction in a transaction message\n * and its set limit, if any.\n */\nexport function getSetComputeUnitLimitInstructionIndexAndUnits(\n transactionMessage: TransactionMessage,\n): { index: number; units: number } | null {\n const index = getSetComputeUnitLimitInstructionIndex(transactionMessage);\n if (index < 0) {\n return null;\n }\n\n const units = getU32Decoder().decode(transactionMessage.instructions[index].data as ReadonlyUint8Array, 1);\n\n return { index, units };\n}\n\n/**\n * Finds the index of the first `SetComputeUnitLimit` instruction in a transaction message, if any.\n */\nexport function getSetComputeUnitLimitInstructionIndex(transactionMessage: TransactionMessage) {\n return transactionMessage.instructions.findIndex(isSetComputeUnitLimitInstruction);\n}\n\n/**\n * Checks if the given instruction is a `SetComputeUnitLimit` instruction.\n */\nexport function isSetComputeUnitLimitInstruction(\n instruction: Instruction,\n): instruction is SetComputeUnitLimitInstruction {\n return (\n instruction.programAddress === COMPUTE_BUDGET_PROGRAM_ADDRESS &&\n identifyComputeBudgetInstruction(instruction.data as Uint8Array) ===\n ComputeBudgetInstruction.SetComputeUnitLimit\n );\n}\n\n/**\n * Finds the index of the first `SetComputeUnitPrice` instruction in a transaction message\n * and its set micro-lamports, if any.\n */\nexport function getSetComputeUnitPriceInstructionIndexAndMicroLamports(\n transactionMessage: TransactionMessage,\n): { index: number; microLamports: MicroLamports } | null {\n const index = getSetComputeUnitPriceInstructionIndex(transactionMessage);\n if (index < 0) {\n return null;\n }\n\n const microLamports = getU64Decoder().decode(\n transactionMessage.instructions[index].data as ReadonlyUint8Array,\n 1,\n ) as MicroLamports;\n\n return { index, microLamports };\n}\n\n/**\n * Finds the index of the first `SetComputeUnitPrice` instruction in a transaction message, if any.\n */\nexport function getSetComputeUnitPriceInstructionIndex(transactionMessage: TransactionMessage) {\n return transactionMessage.instructions.findIndex(isSetComputeUnitPriceInstruction);\n}\n\n/**\n * Checks if the given instruction is a `SetComputeUnitPrice` instruction.\n */\nexport function isSetComputeUnitPriceInstruction(\n instruction: Instruction,\n): instruction is SetComputeUnitPriceInstruction {\n return (\n instruction.programAddress === COMPUTE_BUDGET_PROGRAM_ADDRESS &&\n identifyComputeBudgetInstruction(instruction.data as Uint8Array) ===\n ComputeBudgetInstruction.SetComputeUnitPrice\n );\n}\n","import { appendTransactionMessageInstruction, TransactionMessage } from '@solana/kit';\nimport { PROVISORY_COMPUTE_UNIT_LIMIT } from './constants';\nimport { getSetComputeUnitLimitInstruction } from './generated';\nimport { getSetComputeUnitLimitInstructionIndexAndUnits } from './internal';\n\n/**\n * Appends a `SetComputeUnitLimit` instruction with a provisory\n * compute unit limit to a given transaction message\n * if and only if it does not already have one.\n *\n * @example\n * ```ts\n * const transactionMessage = pipe(\n * createTransactionMessage({ version: 0 }),\n * fillProvisorySetComputeUnitLimitInstruction,\n * // ...\n * );\n * ```\n */\nexport function fillProvisorySetComputeUnitLimitInstruction<TTransactionMessage extends TransactionMessage>(\n transactionMessage: TTransactionMessage,\n) {\n return updateOrAppendSetComputeUnitLimitInstruction(\n previousUnits => (previousUnits === null ? PROVISORY_COMPUTE_UNIT_LIMIT : previousUnits),\n transactionMessage,\n );\n}\n\n/**\n * Updates the first `SetComputeUnitLimit` instruction in a transaction message\n * with the given units, or appends a new instruction if none exists.\n * A function of the current value can be provided instead of a static value.\n *\n * @param units - The new compute unit limit, or a function that takes the previous\n * compute unit limit and returns the new limit.\n * @param transactionMessage - The transaction message to update.\n *\n * @example\n * ```ts\n * const updatedTransactionMessage = updateOrAppendSetComputeUnitLimitInstruction(\n * // E.g. Keep the current limit if it is set, otherwise set it to the maximum.\n * (currentUnits) => currentUnits === null ? MAX_COMPUTE_UNIT_LIMIT : currentUnits,\n * transactionMessage,\n * );\n * ```\n */\nexport function updateOrAppendSetComputeUnitLimitInstruction<TTransactionMessage extends TransactionMessage>(\n units: number | ((previousUnits: number | null) => number),\n transactionMessage: TTransactionMessage,\n): TTransactionMessage {\n const getUnits = (previousUnits: number | null): number =>\n typeof units === 'function' ? units(previousUnits) : units;\n const instructionDetails = getSetComputeUnitLimitInstructionIndexAndUnits(transactionMessage);\n\n if (!instructionDetails) {\n return appendTransactionMessageInstruction(\n getSetComputeUnitLimitInstruction({ units: getUnits(null) }),\n transactionMessage,\n ) as TTransactionMessage;\n }\n\n const { index, units: previousUnits } = instructionDetails;\n const newUnits = getUnits(previousUnits);\n if (newUnits === previousUnits) {\n return transactionMessage;\n }\n\n const newInstruction = getSetComputeUnitLimitInstruction({ units: newUnits });\n const newInstructions = [...transactionMessage.instructions];\n newInstructions.splice(index, 1, newInstruction);\n return Object.freeze({\n ...transactionMessage,\n instructions: newInstructions,\n }) as TTransactionMessage;\n}\n","import { TransactionMessage, TransactionMessageWithFeePayer } from '@solana/kit';\nimport { MAX_COMPUTE_UNIT_LIMIT, PROVISORY_COMPUTE_UNIT_LIMIT } from './constants';\nimport {\n EstimateComputeUnitLimitFactoryFunction,\n EstimateComputeUnitLimitFactoryFunctionConfig,\n} from './estimateComputeLimitInternal';\nimport { getSetComputeUnitLimitInstructionIndexAndUnits } from './internal';\nimport { updateOrAppendSetComputeUnitLimitInstruction } from './setComputeLimit';\n\ntype EstimateAndUpdateProvisoryComputeUnitLimitFactoryFunction = <\n TTransactionMessage extends TransactionMessage & TransactionMessageWithFeePayer,\n>(\n transactionMessage: TTransactionMessage,\n config?: EstimateComputeUnitLimitFactoryFunctionConfig,\n) => Promise<TTransactionMessage>;\n\n/**\n * Given a transaction message, if it does not have an explicit compute unit limit,\n * estimates the compute unit limit and updates the transaction message with\n * the estimated limit. Otherwise, returns the transaction message unchanged.\n *\n * It requires a function that estimates the compute unit limit.\n *\n * @example\n * ```ts\n * const estimateAndUpdateCUs = estimateAndUpdateProvisoryComputeUnitLimitFactory(\n * estimateComputeUnitLimitFactory({ rpc })\n * );\n *\n * const transactionMessageWithCUs = await estimateAndUpdateCUs(transactionMessage);\n * ```\n *\n * @see {@link estimateAndUpdateProvisoryComputeUnitLimitFactory}\n */\nexport function estimateAndUpdateProvisoryComputeUnitLimitFactory(\n estimateComputeUnitLimit: EstimateComputeUnitLimitFactoryFunction,\n): EstimateAndUpdateProvisoryComputeUnitLimitFactoryFunction {\n return async function fn(transactionMessage, config) {\n const instructionDetails = getSetComputeUnitLimitInstructionIndexAndUnits(transactionMessage);\n\n // If the transaction message already has a compute unit limit instruction\n // which is set to a specific value — i.e. not 0 or the maximum limit —\n // we don't need to estimate the compute unit limit.\n if (\n instructionDetails &&\n instructionDetails.units !== PROVISORY_COMPUTE_UNIT_LIMIT &&\n instructionDetails.units !== MAX_COMPUTE_UNIT_LIMIT\n ) {\n return transactionMessage;\n }\n\n return updateOrAppendSetComputeUnitLimitInstruction(\n await estimateComputeUnitLimit(transactionMessage, config),\n transactionMessage,\n );\n };\n}\n","import {\n TransactionMessage,\n Commitment,\n compileTransaction,\n getBase64EncodedWireTransaction,\n getSolanaErrorFromTransactionError,\n isSolanaError,\n isTransactionMessageWithDurableNonceLifetime,\n pipe,\n Rpc,\n SimulateTransactionApi,\n Slot,\n SOLANA_ERROR__TRANSACTION__FAILED_TO_ESTIMATE_COMPUTE_LIMIT,\n SOLANA_ERROR__TRANSACTION__FAILED_WHEN_SIMULATING_TO_ESTIMATE_COMPUTE_LIMIT,\n SolanaError,\n Transaction,\n TransactionMessageWithFeePayer,\n} from '@solana/kit';\nimport { updateOrAppendSetComputeUnitLimitInstruction } from './setComputeLimit';\nimport { MAX_COMPUTE_UNIT_LIMIT } from './constants';\n\nexport type EstimateComputeUnitLimitFactoryConfig = Readonly<{\n /** An object that supports the {@link SimulateTransactionApi} of the Solana RPC API */\n rpc: Rpc<SimulateTransactionApi>;\n}>;\n\nexport type EstimateComputeUnitLimitFactoryFunction = (\n transactionMessage: TransactionMessage & TransactionMessageWithFeePayer,\n config?: EstimateComputeUnitLimitFactoryFunctionConfig,\n) => Promise<number>;\n\nexport type EstimateComputeUnitLimitFactoryFunctionConfig = {\n abortSignal?: AbortSignal;\n /**\n * Compute the estimate as of the highest slot that has reached this level of commitment.\n *\n * @defaultValue Whichever default is applied by the underlying {@link RpcApi} in use. For\n * example, when using an API created by a `createSolanaRpc*()` helper, the default commitment\n * is `\"confirmed\"` unless configured otherwise. Unmitigated by an API layer on the client, the\n * default commitment applied by the server is `\"finalized\"`.\n */\n commitment?: Commitment;\n /**\n * Prevents accessing stale data by enforcing that the RPC node has processed transactions up to\n * this slot\n */\n minContextSlot?: Slot;\n};\n\ntype EstimateComputeUnitLimitConfig = EstimateComputeUnitLimitFactoryFunctionConfig &\n Readonly<{\n rpc: Rpc<SimulateTransactionApi>;\n transactionMessage: TransactionMessage & TransactionMessageWithFeePayer;\n }>;\n\n/**\n * Simulates a transaction message on the network and returns the number of compute units it\n * consumed during simulation.\n *\n * The estimate this function returns can be used to set a compute unit limit on the transaction.\n * Correctly budgeting a compute unit limit for your transaction message can increase the probability\n * that your transaction will be accepted for processing.\n *\n * If you don't declare a compute unit limit on your transaction, validators will assume an upper\n * limit of 200K compute units (CU) per instruction. Since validators have an incentive to pack as\n * many transactions into each block as possible, they may choose to include transactions that they\n * know will fit into the remaining compute budget for the current block over transactions that\n * might not. For this reason, you should set a compute unit limit on each of your transaction\n * messages, whenever possible.\n *\n * ## Example\n *\n * ```ts\n * import { getSetComputeLimitInstruction } from '@solana-program/compute-budget';\n * import { createSolanaRpc, getComputeUnitEstimateForTransactionMessageFactory, pipe } from '@solana/kit';\n *\n * // Create an estimator function.\n * const rpc = createSolanaRpc('http://127.0.0.1:8899');\n * const getComputeUnitEstimateForTransactionMessage =\n * getComputeUnitEstimateForTransactionMessageFactory({ rpc });\n *\n * // Create your transaction message.\n * const transactionMessage = pipe(\n * createTransactionMessage({ version: 'legacy' }),\n * /* ... *\\/\n * );\n *\n * // Request an estimate of the actual compute units this message will consume.\n * const computeUnitsEstimate =\n * await getComputeUnitEstimateForTransactionMessage(transactionMessage);\n *\n * // Set the transaction message's compute unit budget.\n * const transactionMessageWithComputeUnitLimit = prependTransactionMessageInstruction(\n * getSetComputeLimitInstruction({ units: computeUnitsEstimate }),\n * transactionMessage,\n * );\n * ```\n *\n * > [!WARNING]\n * > The compute unit estimate is just that &ndash; an estimate. The compute unit consumption of the\n * > actual transaction might be higher or lower than what was observed in simulation. Unless you\n * > are confident that your particular transaction message will consume the same or fewer compute\n * > units as was estimated, you might like to augment the estimate by either a fixed number of CUs\n * > or a multiplier.\n *\n * > [!NOTE]\n * > If you are preparing an _unsigned_ transaction, destined to be signed and submitted to the\n * > network by a wallet, you might like to leave it up to the wallet to determine the compute unit\n * > limit. Consider that the wallet might have a more global view of how many compute units certain\n * > types of transactions consume, and might be able to make better estimates of an appropriate\n * > compute unit budget.\n */\nexport async function estimateComputeUnitLimit({\n transactionMessage,\n ...configs\n}: EstimateComputeUnitLimitConfig): Promise<number> {\n const replaceRecentBlockhash = !isTransactionMessageWithDurableNonceLifetime(transactionMessage);\n const transaction = pipe(\n transactionMessage,\n m => updateOrAppendSetComputeUnitLimitInstruction(MAX_COMPUTE_UNIT_LIMIT, m),\n compileTransaction,\n );\n\n return await simulateTransactionAndGetConsumedUnits({\n transaction,\n replaceRecentBlockhash,\n ...configs,\n });\n}\n\ntype SimulateTransactionAndGetConsumedUnitsConfig = Omit<EstimateComputeUnitLimitConfig, 'transactionMessage'> &\n Readonly<{ replaceRecentBlockhash?: boolean; transaction: Transaction }>;\n\nasync function simulateTransactionAndGetConsumedUnits({\n abortSignal,\n rpc,\n transaction,\n ...simulateConfig\n}: SimulateTransactionAndGetConsumedUnitsConfig): Promise<number> {\n const wireTransactionBytes = getBase64EncodedWireTransaction(transaction);\n\n try {\n const {\n value: { err: transactionError, unitsConsumed },\n } = await rpc\n .simulateTransaction(wireTransactionBytes, {\n ...simulateConfig,\n encoding: 'base64',\n sigVerify: false,\n })\n .send({ abortSignal });\n if (unitsConsumed == null) {\n // This should never be hit, because all RPCs should support `unitsConsumed` by now.\n throw new SolanaError(SOLANA_ERROR__TRANSACTION__FAILED_TO_ESTIMATE_COMPUTE_LIMIT);\n }\n // FIXME(https://github.com/anza-xyz/agave/issues/1295): The simulation response returns\n // compute units as a u64, but the `SetComputeLimit` instruction only accepts a u32. Until\n // this changes, downcast it.\n const downcastUnitsConsumed = unitsConsumed > 4_294_967_295n ? 4_294_967_295 : Number(unitsConsumed);\n if (transactionError) {\n throw new SolanaError(SOLANA_ERROR__TRANSACTION__FAILED_WHEN_SIMULATING_TO_ESTIMATE_COMPUTE_LIMIT, {\n cause: getSolanaErrorFromTransactionError(transactionError),\n unitsConsumed: downcastUnitsConsumed,\n });\n }\n return downcastUnitsConsumed;\n } catch (e) {\n if (isSolanaError(e, SOLANA_ERROR__TRANSACTION__FAILED_WHEN_SIMULATING_TO_ESTIMATE_COMPUTE_LIMIT)) throw e;\n throw new SolanaError(SOLANA_ERROR__TRANSACTION__FAILED_TO_ESTIMATE_COMPUTE_LIMIT, { cause: e });\n }\n}\n","import {\n estimateComputeUnitLimit,\n EstimateComputeUnitLimitFactoryConfig,\n EstimateComputeUnitLimitFactoryFunction,\n} from './estimateComputeLimitInternal';\n\n/**\n * Use this utility to estimate the actual compute unit cost of a given transaction message.\n *\n * Correctly budgeting a compute unit limit for your transaction message can increase the\n * probability that your transaction will be accepted for processing. If you don't declare a compute\n * unit limit on your transaction, validators will assume an upper limit of 200K compute units (CU)\n * per instruction.\n *\n * Since validators have an incentive to pack as many transactions into each block as possible, they\n * may choose to include transactions that they know will fit into the remaining compute budget for\n * the current block over transactions that might not. For this reason, you should set a compute\n * unit limit on each of your transaction messages, whenever possible.\n *\n * > [!WARNING]\n * > The compute unit estimate is just that -- an estimate. The compute unit consumption of the\n * > actual transaction might be higher or lower than what was observed in simulation. Unless you\n * > are confident that your particular transaction message will consume the same or fewer compute\n * > units as was estimated, you might like to augment the estimate by either a fixed number of CUs\n * > or a multiplier.\n *\n * > [!NOTE]\n * > If you are preparing an _unsigned_ transaction, destined to be signed and submitted to the\n * > network by a wallet, you might like to leave it up to the wallet to determine the compute unit\n * > limit. Consider that the wallet might have a more global view of how many compute units certain\n * > types of transactions consume, and might be able to make better estimates of an appropriate\n * > compute unit budget.\n *\n * > [!INFO]\n * > In the event that a transaction message does not already have a `SetComputeUnitLimit`\n * > instruction, this function will add one before simulation. This ensures that the compute unit\n * > consumption of the `SetComputeUnitLimit` instruction itself is included in the estimate.\n *\n * @param config\n *\n * @example\n * ```ts\n * import { getSetComputeUnitLimitInstruction } from '@solana-program/compute-budget';\n * import { createSolanaRpc, estimateComputeUnitLimitFactory, pipe } from '@solana/kit';\n *\n * // Create an estimator function.\n * const rpc = createSolanaRpc('http://127.0.0.1:8899');\n * const estimateComputeUnitLimit = estimateComputeUnitLimitFactory({ rpc });\n *\n * // Create your transaction message.\n * const transactionMessage = pipe(\n * createTransactionMessage({ version: 'legacy' }),\n * /* ... *\\/\n * );\n *\n * // Request an estimate of the actual compute units this message will consume. This is done by\n * // simulating the transaction and grabbing the estimated compute units from the result.\n * const estimatedUnits = await estimateComputeUnitLimit(transactionMessage);\n *\n * // Set the transaction message's compute unit budget.\n * const transactionMessageWithComputeUnitLimit = prependTransactionMessageInstruction(\n * getSetComputeUnitLimitInstruction({ units: estimatedUnits }),\n * transactionMessage,\n * );\n * ```\n */\nexport function estimateComputeUnitLimitFactory({\n rpc,\n}: EstimateComputeUnitLimitFactoryConfig): EstimateComputeUnitLimitFactoryFunction {\n return async function estimateComputeUnitLimitFactoryFunction(transactionMessage, config) {\n return await estimateComputeUnitLimit({\n ...config,\n rpc,\n transactionMessage,\n });\n };\n}\n","import { appendTransactionMessageInstruction, TransactionMessage, MicroLamports } from '@solana/kit';\nimport { getSetComputeUnitPriceInstruction } from './generated';\nimport { getSetComputeUnitPriceInstructionIndexAndMicroLamports } from './internal';\n\n/**\n * Sets the compute unit price of a transaction message in micro-Lamports.\n *\n * @example\n * ```ts\n * const transactionMessage = pipe(\n * createTransactionMessage({ version: 0 }),\n * (m) => setTransactionMessageComputeUnitPrice(10_000, m),\n * // ...\n * );\n * ```\n */\nexport function setTransactionMessageComputeUnitPrice<TTransactionMessage extends TransactionMessage>(\n microLamports: number | bigint,\n transactionMessage: TTransactionMessage,\n) {\n return appendTransactionMessageInstruction(\n getSetComputeUnitPriceInstruction({ microLamports }),\n transactionMessage,\n );\n}\n\n/**\n * Updates the first `SetComputeUnitPrice` instruction in a transaction message\n * with the given micro-Lamports, or appends a new instruction if none exists.\n * A function of the current value can be provided instead of a static value.\n *\n * @param microLamports - The new compute unit price, or a function that\n * takes the previous price and returns the new one.\n * @param transactionMessage - The transaction message to update.\n *\n * @example\n * ```ts\n * const updatedTransactionMessage = updateOrAppendSetComputeUnitPriceInstruction(\n * // E.g. double the current price or set it to 10_000 if it isn't set.\n * (currentPrice) => currentPrice === null ? 10_000 : currentPrice * 2,\n * transactionMessage,\n * );\n * ```\n */\nexport function updateOrAppendSetComputeUnitPriceInstruction<TTransactionMessage extends TransactionMessage>(\n microLamports: MicroLamports | ((previousMicroLamports: MicroLamports | null) => MicroLamports),\n transactionMessage: TTransactionMessage,\n): TTransactionMessage {\n const getMicroLamports = (previousMicroLamports: MicroLamports | null): MicroLamports =>\n typeof microLamports === 'function' ? microLamports(previousMicroLamports) : microLamports;\n const instructionDetails = getSetComputeUnitPriceInstructionIndexAndMicroLamports(transactionMessage);\n\n if (!instructionDetails) {\n return appendTransactionMessageInstruction(\n getSetComputeUnitPriceInstruction({\n microLamports: getMicroLamports(null),\n }),\n transactionMessage,\n ) as TTransactionMessage;\n }\n\n const { index, microLamports: previousMicroLamports } = instructionDetails;\n const newMicroLamports = getMicroLamports(previousMicroLamports);\n if (newMicroLamports === previousMicroLamports) {\n return transactionMessage;\n }\n\n const newInstruction = getSetComputeUnitPriceInstruction({\n microLamports: newMicroLamports,\n });\n const newInstructions = [...transactionMessage.instructions];\n newInstructions.splice(index, 1, newInstruction);\n return Object.freeze({\n ...transactionMessage,\n instructions: newInstructions,\n }) as TTransactionMessage;\n}\n"]}
1
+ {"version":3,"sources":["../../src/generated/programs/computeBudget.ts","../../src/generated/instructions/requestHeapFrame.ts","../../src/generated/instructions/requestUnits.ts","../../src/generated/instructions/setComputeUnitLimit.ts","../../src/generated/instructions/setComputeUnitPrice.ts","../../src/generated/instructions/setLoadedAccountsDataSizeLimit.ts","../../src/constants.ts","../../src/introspect.ts","../../src/setComputeLimit.ts","../../src/estimateAndSetComputeLimit.ts","../../src/estimateComputeLimitInternal.ts","../../src/estimateComputeLimit.ts","../../src/setComputePrice.ts"],"names":["ComputeBudgetInstruction","getU8Encoder","transformEncoder","getStructEncoder","getU32Encoder","getStructDecoder","getU8Decoder","getU32Decoder","combineCodec","getU64Decoder","previousUnits","estimateComputeUnitLimit","SolanaError","appendTransactionMessageInstruction","previousMicroLamports"],"mappings":";;;;AA6CO,IAAM,8BACT,GAAA;AAEQ,IAAA,wBAAA,qBAAAA,yBAAL,KAAA;AACH,EAAAA,yBAAA,CAAA,yBAAA,CAAA,cAAA,CAAA,GAAA,CAAA,CAAA,GAAA,cAAA;AACA,EAAAA,yBAAA,CAAA,yBAAA,CAAA,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,CAAA;AAAA,MACD;AAAA,KACJ;AAAA;AAGJ,EAAA,MAAM,EAAE,KAAA,EAAO,aAAe,EAAA,qBAAA,EAA0B,GAAA,kBAAA;AACxD,EAAM,MAAA,gBAAA,GAAmB,iBAAiB,qBAAqB,CAAA;AAC/D,EAAA,IAAI,qBAAqB,qBAAuB,EAAA;AAC5C,IAAO,OAAA,kBAAA;AAAA;AAGX,EAAA,MAAM,iBAAiB,iCAAkC,CAAA;AAAA,IACrD,aAAe,EAAA;AAAA,GAClB,CAAA;AACD,EAAA,MAAM,eAAkB,GAAA,CAAC,GAAG,kBAAA,CAAmB,YAAY,CAAA;AAC3D,EAAgB,eAAA,CAAA,MAAA,CAAO,KAAO,EAAA,CAAA,EAAG,cAAc,CAAA;AAC/C,EAAA,OAAO,OAAO,MAAO,CAAA;AAAA,IACjB,GAAG,kBAAA;AAAA,IACH,YAAc,EAAA;AAAA,GACjB,CAAA;AACL","file":"index.mjs","sourcesContent":["/**\n * This code was AUTOGENERATED using the Codama library.\n * Please DO NOT EDIT THIS FILE, instead use visitors\n * to add features, then rerun Codama to update it.\n *\n * @see https://github.com/codama-idl/codama\n */\n\nimport {\n containsBytes,\n getU8Encoder,\n SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_INSTRUCTION,\n SOLANA_ERROR__PROGRAM_CLIENTS__UNRECOGNIZED_INSTRUCTION_TYPE,\n SolanaError,\n type Address,\n type ClientWithTransactionPlanning,\n type ClientWithTransactionSending,\n type Instruction,\n type InstructionWithData,\n type ReadonlyUint8Array,\n} from '@solana/kit';\nimport { addSelfPlanAndSendFunctions, type SelfPlanAndSendFunctions } from '@solana/kit/program-client-core';\nimport {\n getRequestHeapFrameInstruction,\n getRequestUnitsInstruction,\n getSetComputeUnitLimitInstruction,\n getSetComputeUnitPriceInstruction,\n getSetLoadedAccountsDataSizeLimitInstruction,\n parseRequestHeapFrameInstruction,\n parseRequestUnitsInstruction,\n parseSetComputeUnitLimitInstruction,\n parseSetComputeUnitPriceInstruction,\n parseSetLoadedAccountsDataSizeLimitInstruction,\n type ParsedRequestHeapFrameInstruction,\n type ParsedRequestUnitsInstruction,\n type ParsedSetComputeUnitLimitInstruction,\n type ParsedSetComputeUnitPriceInstruction,\n type ParsedSetLoadedAccountsDataSizeLimitInstruction,\n type RequestHeapFrameInput,\n type RequestUnitsInput,\n type SetComputeUnitLimitInput,\n type SetComputeUnitPriceInput,\n type SetLoadedAccountsDataSizeLimitInput,\n} from '../instructions';\n\nexport const COMPUTE_BUDGET_PROGRAM_ADDRESS =\n 'ComputeBudget111111111111111111111111111111' as Address<'ComputeBudget111111111111111111111111111111'>;\n\nexport enum ComputeBudgetInstruction {\n RequestUnits,\n RequestHeapFrame,\n SetComputeUnitLimit,\n SetComputeUnitPrice,\n SetLoadedAccountsDataSizeLimit,\n}\n\nexport function identifyComputeBudgetInstruction(\n instruction: { data: ReadonlyUint8Array } | ReadonlyUint8Array,\n): ComputeBudgetInstruction {\n const data = 'data' in instruction ? instruction.data : instruction;\n if (containsBytes(data, getU8Encoder().encode(0), 0)) {\n return ComputeBudgetInstruction.RequestUnits;\n }\n if (containsBytes(data, getU8Encoder().encode(1), 0)) {\n return ComputeBudgetInstruction.RequestHeapFrame;\n }\n if (containsBytes(data, getU8Encoder().encode(2), 0)) {\n return ComputeBudgetInstruction.SetComputeUnitLimit;\n }\n if (containsBytes(data, getU8Encoder().encode(3), 0)) {\n return ComputeBudgetInstruction.SetComputeUnitPrice;\n }\n if (containsBytes(data, getU8Encoder().encode(4), 0)) {\n return ComputeBudgetInstruction.SetLoadedAccountsDataSizeLimit;\n }\n throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_INSTRUCTION, {\n instructionData: data,\n programName: 'computeBudget',\n });\n}\n\nexport type ParsedComputeBudgetInstruction<TProgram extends string = 'ComputeBudget111111111111111111111111111111'> =\n | ({ instructionType: ComputeBudgetInstruction.RequestUnits } & ParsedRequestUnitsInstruction<TProgram>)\n | ({ instructionType: ComputeBudgetInstruction.RequestHeapFrame } & ParsedRequestHeapFrameInstruction<TProgram>)\n | ({\n instructionType: ComputeBudgetInstruction.SetComputeUnitLimit;\n } & ParsedSetComputeUnitLimitInstruction<TProgram>)\n | ({\n instructionType: ComputeBudgetInstruction.SetComputeUnitPrice;\n } & ParsedSetComputeUnitPriceInstruction<TProgram>)\n | ({\n instructionType: ComputeBudgetInstruction.SetLoadedAccountsDataSizeLimit;\n } & ParsedSetLoadedAccountsDataSizeLimitInstruction<TProgram>);\n\nexport function parseComputeBudgetInstruction<TProgram extends string>(\n instruction: Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array>,\n): ParsedComputeBudgetInstruction<TProgram> {\n const instructionType = identifyComputeBudgetInstruction(instruction);\n switch (instructionType) {\n case ComputeBudgetInstruction.RequestUnits: {\n return {\n instructionType: ComputeBudgetInstruction.RequestUnits,\n ...parseRequestUnitsInstruction(instruction),\n };\n }\n case ComputeBudgetInstruction.RequestHeapFrame: {\n return {\n instructionType: ComputeBudgetInstruction.RequestHeapFrame,\n ...parseRequestHeapFrameInstruction(instruction),\n };\n }\n case ComputeBudgetInstruction.SetComputeUnitLimit: {\n return {\n instructionType: ComputeBudgetInstruction.SetComputeUnitLimit,\n ...parseSetComputeUnitLimitInstruction(instruction),\n };\n }\n case ComputeBudgetInstruction.SetComputeUnitPrice: {\n return {\n instructionType: ComputeBudgetInstruction.SetComputeUnitPrice,\n ...parseSetComputeUnitPriceInstruction(instruction),\n };\n }\n case ComputeBudgetInstruction.SetLoadedAccountsDataSizeLimit: {\n return {\n instructionType: ComputeBudgetInstruction.SetLoadedAccountsDataSizeLimit,\n ...parseSetLoadedAccountsDataSizeLimitInstruction(instruction),\n };\n }\n default:\n throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__UNRECOGNIZED_INSTRUCTION_TYPE, {\n instructionType: instructionType as string,\n programName: 'computeBudget',\n });\n }\n}\n\nexport type ComputeBudgetPlugin = { instructions: ComputeBudgetPluginInstructions };\n\nexport type ComputeBudgetPluginInstructions = {\n requestUnits: (\n input: RequestUnitsInput,\n ) => ReturnType<typeof getRequestUnitsInstruction> & SelfPlanAndSendFunctions;\n requestHeapFrame: (\n input: RequestHeapFrameInput,\n ) => ReturnType<typeof getRequestHeapFrameInstruction> & SelfPlanAndSendFunctions;\n setComputeUnitLimit: (\n input: SetComputeUnitLimitInput,\n ) => ReturnType<typeof getSetComputeUnitLimitInstruction> & SelfPlanAndSendFunctions;\n setComputeUnitPrice: (\n input: SetComputeUnitPriceInput,\n ) => ReturnType<typeof getSetComputeUnitPriceInstruction> & SelfPlanAndSendFunctions;\n setLoadedAccountsDataSizeLimit: (\n input: SetLoadedAccountsDataSizeLimitInput,\n ) => ReturnType<typeof getSetLoadedAccountsDataSizeLimitInstruction> & SelfPlanAndSendFunctions;\n};\n\nexport type ComputeBudgetPluginRequirements = ClientWithTransactionPlanning & ClientWithTransactionSending;\n\nexport function computeBudgetProgram() {\n return <T extends ComputeBudgetPluginRequirements>(client: T) => {\n return {\n ...client,\n computeBudget: <ComputeBudgetPlugin>{\n instructions: {\n requestUnits: input => addSelfPlanAndSendFunctions(client, getRequestUnitsInstruction(input)),\n requestHeapFrame: input =>\n addSelfPlanAndSendFunctions(client, getRequestHeapFrameInstruction(input)),\n setComputeUnitLimit: input =>\n addSelfPlanAndSendFunctions(client, getSetComputeUnitLimitInstruction(input)),\n setComputeUnitPrice: input =>\n addSelfPlanAndSendFunctions(client, getSetComputeUnitPriceInstruction(input)),\n setLoadedAccountsDataSizeLimit: input =>\n addSelfPlanAndSendFunctions(client, getSetLoadedAccountsDataSizeLimitInstruction(input)),\n },\n },\n };\n };\n}\n","/**\n * This code was AUTOGENERATED using the Codama library.\n * Please DO NOT EDIT THIS FILE, instead use visitors\n * to add features, then rerun Codama to update it.\n *\n * @see https://github.com/codama-idl/codama\n */\n\nimport {\n combineCodec,\n getStructDecoder,\n getStructEncoder,\n getU32Decoder,\n getU32Encoder,\n getU8Decoder,\n getU8Encoder,\n transformEncoder,\n type AccountMeta,\n type Address,\n type FixedSizeCodec,\n type FixedSizeDecoder,\n type FixedSizeEncoder,\n type Instruction,\n type InstructionWithAccounts,\n type InstructionWithData,\n type ReadonlyUint8Array,\n} from '@solana/kit';\nimport { COMPUTE_BUDGET_PROGRAM_ADDRESS } from '../programs';\n\nexport const REQUEST_HEAP_FRAME_DISCRIMINATOR = 1;\n\nexport function getRequestHeapFrameDiscriminatorBytes() {\n return getU8Encoder().encode(REQUEST_HEAP_FRAME_DISCRIMINATOR);\n}\n\nexport type RequestHeapFrameInstruction<\n TProgram extends string = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS,\n TRemainingAccounts extends readonly AccountMeta<string>[] = [],\n> = Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array> & InstructionWithAccounts<TRemainingAccounts>;\n\nexport type RequestHeapFrameInstructionData = {\n discriminator: number;\n /**\n * Requested transaction-wide program heap size in bytes.\n * Must be multiple of 1024. Applies to each program, including CPIs.\n */\n bytes: number;\n};\n\nexport type RequestHeapFrameInstructionDataArgs = {\n /**\n * Requested transaction-wide program heap size in bytes.\n * Must be multiple of 1024. Applies to each program, including CPIs.\n */\n bytes: number;\n};\n\nexport function getRequestHeapFrameInstructionDataEncoder(): FixedSizeEncoder<RequestHeapFrameInstructionDataArgs> {\n return transformEncoder(\n getStructEncoder([\n ['discriminator', getU8Encoder()],\n ['bytes', getU32Encoder()],\n ]),\n value => ({ ...value, discriminator: REQUEST_HEAP_FRAME_DISCRIMINATOR }),\n );\n}\n\nexport function getRequestHeapFrameInstructionDataDecoder(): FixedSizeDecoder<RequestHeapFrameInstructionData> {\n return getStructDecoder([\n ['discriminator', getU8Decoder()],\n ['bytes', getU32Decoder()],\n ]);\n}\n\nexport function getRequestHeapFrameInstructionDataCodec(): FixedSizeCodec<\n RequestHeapFrameInstructionDataArgs,\n RequestHeapFrameInstructionData\n> {\n return combineCodec(getRequestHeapFrameInstructionDataEncoder(), getRequestHeapFrameInstructionDataDecoder());\n}\n\nexport type RequestHeapFrameInput = {\n bytes: RequestHeapFrameInstructionDataArgs['bytes'];\n};\n\nexport function getRequestHeapFrameInstruction<TProgramAddress extends Address = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS>(\n input: RequestHeapFrameInput,\n config?: { programAddress?: TProgramAddress },\n): RequestHeapFrameInstruction<TProgramAddress> {\n // Program address.\n const programAddress = config?.programAddress ?? COMPUTE_BUDGET_PROGRAM_ADDRESS;\n\n // Original args.\n const args = { ...input };\n\n return Object.freeze({\n data: getRequestHeapFrameInstructionDataEncoder().encode(args as RequestHeapFrameInstructionDataArgs),\n programAddress,\n } as RequestHeapFrameInstruction<TProgramAddress>);\n}\n\nexport type ParsedRequestHeapFrameInstruction<TProgram extends string = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS> = {\n programAddress: Address<TProgram>;\n data: RequestHeapFrameInstructionData;\n};\n\nexport function parseRequestHeapFrameInstruction<TProgram extends string>(\n instruction: Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array>,\n): ParsedRequestHeapFrameInstruction<TProgram> {\n return {\n programAddress: instruction.programAddress,\n data: getRequestHeapFrameInstructionDataDecoder().decode(instruction.data),\n };\n}\n","/**\n * This code was AUTOGENERATED using the Codama library.\n * Please DO NOT EDIT THIS FILE, instead use visitors\n * to add features, then rerun Codama to update it.\n *\n * @see https://github.com/codama-idl/codama\n */\n\nimport {\n combineCodec,\n getStructDecoder,\n getStructEncoder,\n getU32Decoder,\n getU32Encoder,\n getU8Decoder,\n getU8Encoder,\n transformEncoder,\n type AccountMeta,\n type Address,\n type FixedSizeCodec,\n type FixedSizeDecoder,\n type FixedSizeEncoder,\n type Instruction,\n type InstructionWithAccounts,\n type InstructionWithData,\n type ReadonlyUint8Array,\n} from '@solana/kit';\nimport { COMPUTE_BUDGET_PROGRAM_ADDRESS } from '../programs';\n\nexport const REQUEST_UNITS_DISCRIMINATOR = 0;\n\nexport function getRequestUnitsDiscriminatorBytes() {\n return getU8Encoder().encode(REQUEST_UNITS_DISCRIMINATOR);\n}\n\nexport type RequestUnitsInstruction<\n TProgram extends string = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS,\n TRemainingAccounts extends readonly AccountMeta<string>[] = [],\n> = Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array> & InstructionWithAccounts<TRemainingAccounts>;\n\nexport type RequestUnitsInstructionData = {\n discriminator: number;\n /** Units to request for transaction-wide compute. */\n units: number;\n /** Prioritization fee lamports. */\n additionalFee: number;\n};\n\nexport type RequestUnitsInstructionDataArgs = {\n /** Units to request for transaction-wide compute. */\n units: number;\n /** Prioritization fee lamports. */\n additionalFee: number;\n};\n\nexport function getRequestUnitsInstructionDataEncoder(): FixedSizeEncoder<RequestUnitsInstructionDataArgs> {\n return transformEncoder(\n getStructEncoder([\n ['discriminator', getU8Encoder()],\n ['units', getU32Encoder()],\n ['additionalFee', getU32Encoder()],\n ]),\n value => ({ ...value, discriminator: REQUEST_UNITS_DISCRIMINATOR }),\n );\n}\n\nexport function getRequestUnitsInstructionDataDecoder(): FixedSizeDecoder<RequestUnitsInstructionData> {\n return getStructDecoder([\n ['discriminator', getU8Decoder()],\n ['units', getU32Decoder()],\n ['additionalFee', getU32Decoder()],\n ]);\n}\n\nexport function getRequestUnitsInstructionDataCodec(): FixedSizeCodec<\n RequestUnitsInstructionDataArgs,\n RequestUnitsInstructionData\n> {\n return combineCodec(getRequestUnitsInstructionDataEncoder(), getRequestUnitsInstructionDataDecoder());\n}\n\nexport type RequestUnitsInput = {\n units: RequestUnitsInstructionDataArgs['units'];\n additionalFee: RequestUnitsInstructionDataArgs['additionalFee'];\n};\n\nexport function getRequestUnitsInstruction<TProgramAddress extends Address = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS>(\n input: RequestUnitsInput,\n config?: { programAddress?: TProgramAddress },\n): RequestUnitsInstruction<TProgramAddress> {\n // Program address.\n const programAddress = config?.programAddress ?? COMPUTE_BUDGET_PROGRAM_ADDRESS;\n\n // Original args.\n const args = { ...input };\n\n return Object.freeze({\n data: getRequestUnitsInstructionDataEncoder().encode(args as RequestUnitsInstructionDataArgs),\n programAddress,\n } as RequestUnitsInstruction<TProgramAddress>);\n}\n\nexport type ParsedRequestUnitsInstruction<TProgram extends string = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS> = {\n programAddress: Address<TProgram>;\n data: RequestUnitsInstructionData;\n};\n\nexport function parseRequestUnitsInstruction<TProgram extends string>(\n instruction: Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array>,\n): ParsedRequestUnitsInstruction<TProgram> {\n return {\n programAddress: instruction.programAddress,\n data: getRequestUnitsInstructionDataDecoder().decode(instruction.data),\n };\n}\n","/**\n * This code was AUTOGENERATED using the Codama library.\n * Please DO NOT EDIT THIS FILE, instead use visitors\n * to add features, then rerun Codama to update it.\n *\n * @see https://github.com/codama-idl/codama\n */\n\nimport {\n combineCodec,\n getStructDecoder,\n getStructEncoder,\n getU32Decoder,\n getU32Encoder,\n getU8Decoder,\n getU8Encoder,\n transformEncoder,\n type AccountMeta,\n type Address,\n type FixedSizeCodec,\n type FixedSizeDecoder,\n type FixedSizeEncoder,\n type Instruction,\n type InstructionWithAccounts,\n type InstructionWithData,\n type ReadonlyUint8Array,\n} from '@solana/kit';\nimport { COMPUTE_BUDGET_PROGRAM_ADDRESS } from '../programs';\n\nexport const SET_COMPUTE_UNIT_LIMIT_DISCRIMINATOR = 2;\n\nexport function getSetComputeUnitLimitDiscriminatorBytes() {\n return getU8Encoder().encode(SET_COMPUTE_UNIT_LIMIT_DISCRIMINATOR);\n}\n\nexport type SetComputeUnitLimitInstruction<\n TProgram extends string = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS,\n TRemainingAccounts extends readonly AccountMeta<string>[] = [],\n> = Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array> & InstructionWithAccounts<TRemainingAccounts>;\n\nexport type SetComputeUnitLimitInstructionData = {\n discriminator: number;\n /** Transaction-wide compute unit limit. */\n units: number;\n};\n\nexport type SetComputeUnitLimitInstructionDataArgs = {\n /** Transaction-wide compute unit limit. */\n units: number;\n};\n\nexport function getSetComputeUnitLimitInstructionDataEncoder(): FixedSizeEncoder<SetComputeUnitLimitInstructionDataArgs> {\n return transformEncoder(\n getStructEncoder([\n ['discriminator', getU8Encoder()],\n ['units', getU32Encoder()],\n ]),\n value => ({ ...value, discriminator: SET_COMPUTE_UNIT_LIMIT_DISCRIMINATOR }),\n );\n}\n\nexport function getSetComputeUnitLimitInstructionDataDecoder(): FixedSizeDecoder<SetComputeUnitLimitInstructionData> {\n return getStructDecoder([\n ['discriminator', getU8Decoder()],\n ['units', getU32Decoder()],\n ]);\n}\n\nexport function getSetComputeUnitLimitInstructionDataCodec(): FixedSizeCodec<\n SetComputeUnitLimitInstructionDataArgs,\n SetComputeUnitLimitInstructionData\n> {\n return combineCodec(getSetComputeUnitLimitInstructionDataEncoder(), getSetComputeUnitLimitInstructionDataDecoder());\n}\n\nexport type SetComputeUnitLimitInput = {\n units: SetComputeUnitLimitInstructionDataArgs['units'];\n};\n\nexport function getSetComputeUnitLimitInstruction<\n TProgramAddress extends Address = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS,\n>(\n input: SetComputeUnitLimitInput,\n config?: { programAddress?: TProgramAddress },\n): SetComputeUnitLimitInstruction<TProgramAddress> {\n // Program address.\n const programAddress = config?.programAddress ?? COMPUTE_BUDGET_PROGRAM_ADDRESS;\n\n // Original args.\n const args = { ...input };\n\n return Object.freeze({\n data: getSetComputeUnitLimitInstructionDataEncoder().encode(args as SetComputeUnitLimitInstructionDataArgs),\n programAddress,\n } as SetComputeUnitLimitInstruction<TProgramAddress>);\n}\n\nexport type ParsedSetComputeUnitLimitInstruction<TProgram extends string = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS> = {\n programAddress: Address<TProgram>;\n data: SetComputeUnitLimitInstructionData;\n};\n\nexport function parseSetComputeUnitLimitInstruction<TProgram extends string>(\n instruction: Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array>,\n): ParsedSetComputeUnitLimitInstruction<TProgram> {\n return {\n programAddress: instruction.programAddress,\n data: getSetComputeUnitLimitInstructionDataDecoder().decode(instruction.data),\n };\n}\n","/**\n * This code was AUTOGENERATED using the Codama library.\n * Please DO NOT EDIT THIS FILE, instead use visitors\n * to add features, then rerun Codama to update it.\n *\n * @see https://github.com/codama-idl/codama\n */\n\nimport {\n combineCodec,\n getStructDecoder,\n getStructEncoder,\n getU64Decoder,\n getU64Encoder,\n getU8Decoder,\n getU8Encoder,\n transformEncoder,\n type AccountMeta,\n type Address,\n type FixedSizeCodec,\n type FixedSizeDecoder,\n type FixedSizeEncoder,\n type Instruction,\n type InstructionWithAccounts,\n type InstructionWithData,\n type ReadonlyUint8Array,\n} from '@solana/kit';\nimport { COMPUTE_BUDGET_PROGRAM_ADDRESS } from '../programs';\n\nexport const SET_COMPUTE_UNIT_PRICE_DISCRIMINATOR = 3;\n\nexport function getSetComputeUnitPriceDiscriminatorBytes() {\n return getU8Encoder().encode(SET_COMPUTE_UNIT_PRICE_DISCRIMINATOR);\n}\n\nexport type SetComputeUnitPriceInstruction<\n TProgram extends string = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS,\n TRemainingAccounts extends readonly AccountMeta<string>[] = [],\n> = Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array> & InstructionWithAccounts<TRemainingAccounts>;\n\nexport type SetComputeUnitPriceInstructionData = {\n discriminator: number;\n /** Transaction compute unit price used for prioritization fees. */\n microLamports: bigint;\n};\n\nexport type SetComputeUnitPriceInstructionDataArgs = {\n /** Transaction compute unit price used for prioritization fees. */\n microLamports: number | bigint;\n};\n\nexport function getSetComputeUnitPriceInstructionDataEncoder(): FixedSizeEncoder<SetComputeUnitPriceInstructionDataArgs> {\n return transformEncoder(\n getStructEncoder([\n ['discriminator', getU8Encoder()],\n ['microLamports', getU64Encoder()],\n ]),\n value => ({ ...value, discriminator: SET_COMPUTE_UNIT_PRICE_DISCRIMINATOR }),\n );\n}\n\nexport function getSetComputeUnitPriceInstructionDataDecoder(): FixedSizeDecoder<SetComputeUnitPriceInstructionData> {\n return getStructDecoder([\n ['discriminator', getU8Decoder()],\n ['microLamports', getU64Decoder()],\n ]);\n}\n\nexport function getSetComputeUnitPriceInstructionDataCodec(): FixedSizeCodec<\n SetComputeUnitPriceInstructionDataArgs,\n SetComputeUnitPriceInstructionData\n> {\n return combineCodec(getSetComputeUnitPriceInstructionDataEncoder(), getSetComputeUnitPriceInstructionDataDecoder());\n}\n\nexport type SetComputeUnitPriceInput = {\n microLamports: SetComputeUnitPriceInstructionDataArgs['microLamports'];\n};\n\nexport function getSetComputeUnitPriceInstruction<\n TProgramAddress extends Address = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS,\n>(\n input: SetComputeUnitPriceInput,\n config?: { programAddress?: TProgramAddress },\n): SetComputeUnitPriceInstruction<TProgramAddress> {\n // Program address.\n const programAddress = config?.programAddress ?? COMPUTE_BUDGET_PROGRAM_ADDRESS;\n\n // Original args.\n const args = { ...input };\n\n return Object.freeze({\n data: getSetComputeUnitPriceInstructionDataEncoder().encode(args as SetComputeUnitPriceInstructionDataArgs),\n programAddress,\n } as SetComputeUnitPriceInstruction<TProgramAddress>);\n}\n\nexport type ParsedSetComputeUnitPriceInstruction<TProgram extends string = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS> = {\n programAddress: Address<TProgram>;\n data: SetComputeUnitPriceInstructionData;\n};\n\nexport function parseSetComputeUnitPriceInstruction<TProgram extends string>(\n instruction: Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array>,\n): ParsedSetComputeUnitPriceInstruction<TProgram> {\n return {\n programAddress: instruction.programAddress,\n data: getSetComputeUnitPriceInstructionDataDecoder().decode(instruction.data),\n };\n}\n","/**\n * This code was AUTOGENERATED using the Codama library.\n * Please DO NOT EDIT THIS FILE, instead use visitors\n * to add features, then rerun Codama to update it.\n *\n * @see https://github.com/codama-idl/codama\n */\n\nimport {\n combineCodec,\n getStructDecoder,\n getStructEncoder,\n getU32Decoder,\n getU32Encoder,\n getU8Decoder,\n getU8Encoder,\n transformEncoder,\n type AccountMeta,\n type Address,\n type FixedSizeCodec,\n type FixedSizeDecoder,\n type FixedSizeEncoder,\n type Instruction,\n type InstructionWithAccounts,\n type InstructionWithData,\n type ReadonlyUint8Array,\n} from '@solana/kit';\nimport { COMPUTE_BUDGET_PROGRAM_ADDRESS } from '../programs';\n\nexport const SET_LOADED_ACCOUNTS_DATA_SIZE_LIMIT_DISCRIMINATOR = 4;\n\nexport function getSetLoadedAccountsDataSizeLimitDiscriminatorBytes() {\n return getU8Encoder().encode(SET_LOADED_ACCOUNTS_DATA_SIZE_LIMIT_DISCRIMINATOR);\n}\n\nexport type SetLoadedAccountsDataSizeLimitInstruction<\n TProgram extends string = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS,\n TRemainingAccounts extends readonly AccountMeta<string>[] = [],\n> = Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array> & InstructionWithAccounts<TRemainingAccounts>;\n\nexport type SetLoadedAccountsDataSizeLimitInstructionData = { discriminator: number; accountDataSizeLimit: number };\n\nexport type SetLoadedAccountsDataSizeLimitInstructionDataArgs = { accountDataSizeLimit: number };\n\nexport function getSetLoadedAccountsDataSizeLimitInstructionDataEncoder(): FixedSizeEncoder<SetLoadedAccountsDataSizeLimitInstructionDataArgs> {\n return transformEncoder(\n getStructEncoder([\n ['discriminator', getU8Encoder()],\n ['accountDataSizeLimit', getU32Encoder()],\n ]),\n value => ({ ...value, discriminator: SET_LOADED_ACCOUNTS_DATA_SIZE_LIMIT_DISCRIMINATOR }),\n );\n}\n\nexport function getSetLoadedAccountsDataSizeLimitInstructionDataDecoder(): FixedSizeDecoder<SetLoadedAccountsDataSizeLimitInstructionData> {\n return getStructDecoder([\n ['discriminator', getU8Decoder()],\n ['accountDataSizeLimit', getU32Decoder()],\n ]);\n}\n\nexport function getSetLoadedAccountsDataSizeLimitInstructionDataCodec(): FixedSizeCodec<\n SetLoadedAccountsDataSizeLimitInstructionDataArgs,\n SetLoadedAccountsDataSizeLimitInstructionData\n> {\n return combineCodec(\n getSetLoadedAccountsDataSizeLimitInstructionDataEncoder(),\n getSetLoadedAccountsDataSizeLimitInstructionDataDecoder(),\n );\n}\n\nexport type SetLoadedAccountsDataSizeLimitInput = {\n accountDataSizeLimit: SetLoadedAccountsDataSizeLimitInstructionDataArgs['accountDataSizeLimit'];\n};\n\nexport function getSetLoadedAccountsDataSizeLimitInstruction<\n TProgramAddress extends Address = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS,\n>(\n input: SetLoadedAccountsDataSizeLimitInput,\n config?: { programAddress?: TProgramAddress },\n): SetLoadedAccountsDataSizeLimitInstruction<TProgramAddress> {\n // Program address.\n const programAddress = config?.programAddress ?? COMPUTE_BUDGET_PROGRAM_ADDRESS;\n\n // Original args.\n const args = { ...input };\n\n return Object.freeze({\n data: getSetLoadedAccountsDataSizeLimitInstructionDataEncoder().encode(\n args as SetLoadedAccountsDataSizeLimitInstructionDataArgs,\n ),\n programAddress,\n } as SetLoadedAccountsDataSizeLimitInstruction<TProgramAddress>);\n}\n\nexport type ParsedSetLoadedAccountsDataSizeLimitInstruction<\n TProgram extends string = typeof COMPUTE_BUDGET_PROGRAM_ADDRESS,\n> = { programAddress: Address<TProgram>; data: SetLoadedAccountsDataSizeLimitInstructionData };\n\nexport function parseSetLoadedAccountsDataSizeLimitInstruction<TProgram extends string>(\n instruction: Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array>,\n): ParsedSetLoadedAccountsDataSizeLimitInstruction<TProgram> {\n return {\n programAddress: instruction.programAddress,\n data: getSetLoadedAccountsDataSizeLimitInstructionDataDecoder().decode(instruction.data),\n };\n}\n","/**\n * A provisory compute unit limit is used to indicate that the transaction\n * should be estimated for compute units before being sent to the network.\n *\n * Setting it to zero ensures the transaction fails unless it is properly estimated.\n */\nexport const PROVISORY_COMPUTE_UNIT_LIMIT = 0;\n\n/**\n * The maximum compute unit limit that can be set for a transaction.\n */\nexport const MAX_COMPUTE_UNIT_LIMIT = 1_400_000;\n","import {\n TransactionMessage,\n getU32Decoder,\n getU64Decoder,\n Instruction,\n MicroLamports,\n ReadonlyUint8Array,\n} from '@solana/kit';\nimport {\n COMPUTE_BUDGET_PROGRAM_ADDRESS,\n ComputeBudgetInstruction,\n identifyComputeBudgetInstruction,\n SetComputeUnitLimitInstruction,\n SetComputeUnitPriceInstruction,\n} from './generated';\n\n/**\n * Finds the index of the first `SetComputeUnitLimit` instruction in a transaction message\n * and its set limit, if any.\n */\nexport function findSetComputeUnitLimitInstructionIndexAndUnits(\n transactionMessage: TransactionMessage,\n): { index: number; units: number } | null {\n const index = transactionMessage.instructions.findIndex(isSetComputeUnitLimitInstruction);\n if (index < 0) {\n return null;\n }\n\n const units = getU32Decoder().decode(transactionMessage.instructions[index].data as ReadonlyUint8Array, 1);\n\n return { index, units };\n}\n\n/**\n * Checks if the given instruction is a `SetComputeUnitLimit` instruction.\n */\nfunction isSetComputeUnitLimitInstruction(instruction: Instruction): instruction is SetComputeUnitLimitInstruction {\n return (\n instruction.programAddress === COMPUTE_BUDGET_PROGRAM_ADDRESS &&\n identifyComputeBudgetInstruction(instruction.data as Uint8Array) ===\n ComputeBudgetInstruction.SetComputeUnitLimit\n );\n}\n\n/**\n * Finds the index of the first `SetComputeUnitPrice` instruction in a transaction message\n * and its set micro-lamports, if any.\n */\nexport function findSetComputeUnitPriceInstructionIndexAndMicroLamports(\n transactionMessage: TransactionMessage,\n): { index: number; microLamports: MicroLamports } | null {\n const index = transactionMessage.instructions.findIndex(isSetComputeUnitPriceInstruction);\n if (index < 0) {\n return null;\n }\n\n const microLamports = getU64Decoder().decode(\n transactionMessage.instructions[index].data as ReadonlyUint8Array,\n 1,\n ) as MicroLamports;\n\n return { index, microLamports };\n}\n\n/**\n * Checks if the given instruction is a `SetComputeUnitPrice` instruction.\n */\nfunction isSetComputeUnitPriceInstruction(instruction: Instruction): instruction is SetComputeUnitPriceInstruction {\n return (\n instruction.programAddress === COMPUTE_BUDGET_PROGRAM_ADDRESS &&\n identifyComputeBudgetInstruction(instruction.data as Uint8Array) ===\n ComputeBudgetInstruction.SetComputeUnitPrice\n );\n}\n","import { appendTransactionMessageInstruction, TransactionMessage } from '@solana/kit';\nimport { PROVISORY_COMPUTE_UNIT_LIMIT } from './constants';\nimport { getSetComputeUnitLimitInstruction } from './generated';\nimport { findSetComputeUnitLimitInstructionIndexAndUnits } from './introspect';\n\n/**\n * Appends a `SetComputeUnitLimit` instruction with a provisory\n * compute unit limit to a given transaction message\n * if and only if it does not already have one.\n *\n * @example\n * ```ts\n * const transactionMessage = pipe(\n * createTransactionMessage({ version: 0 }),\n * fillProvisorySetComputeUnitLimitInstruction,\n * // ...\n * );\n * ```\n */\nexport function fillProvisorySetComputeUnitLimitInstruction<TTransactionMessage extends TransactionMessage>(\n transactionMessage: TTransactionMessage,\n) {\n return updateOrAppendSetComputeUnitLimitInstruction(\n previousUnits => (previousUnits === null ? PROVISORY_COMPUTE_UNIT_LIMIT : previousUnits),\n transactionMessage,\n );\n}\n\n/**\n * Updates the first `SetComputeUnitLimit` instruction in a transaction message\n * with the given units, or appends a new instruction if none exists.\n * A function of the current value can be provided instead of a static value.\n *\n * @param units - The new compute unit limit, or a function that takes the previous\n * compute unit limit and returns the new limit.\n * @param transactionMessage - The transaction message to update.\n *\n * @example\n * ```ts\n * const updatedTransactionMessage = updateOrAppendSetComputeUnitLimitInstruction(\n * // E.g. Keep the current limit if it is set, otherwise set it to the maximum.\n * (currentUnits) => currentUnits === null ? MAX_COMPUTE_UNIT_LIMIT : currentUnits,\n * transactionMessage,\n * );\n * ```\n */\nexport function updateOrAppendSetComputeUnitLimitInstruction<TTransactionMessage extends TransactionMessage>(\n units: number | ((previousUnits: number | null) => number),\n transactionMessage: TTransactionMessage,\n): TTransactionMessage {\n const getUnits = (previousUnits: number | null): number =>\n typeof units === 'function' ? units(previousUnits) : units;\n const instructionDetails = findSetComputeUnitLimitInstructionIndexAndUnits(transactionMessage);\n\n if (!instructionDetails) {\n return appendTransactionMessageInstruction(\n getSetComputeUnitLimitInstruction({ units: getUnits(null) }),\n transactionMessage,\n ) as TTransactionMessage;\n }\n\n const { index, units: previousUnits } = instructionDetails;\n const newUnits = getUnits(previousUnits);\n if (newUnits === previousUnits) {\n return transactionMessage;\n }\n\n const newInstruction = getSetComputeUnitLimitInstruction({ units: newUnits });\n const newInstructions = [...transactionMessage.instructions];\n newInstructions.splice(index, 1, newInstruction);\n return Object.freeze({\n ...transactionMessage,\n instructions: newInstructions,\n }) as TTransactionMessage;\n}\n","import { TransactionMessage, TransactionMessageWithFeePayer } from '@solana/kit';\nimport { MAX_COMPUTE_UNIT_LIMIT, PROVISORY_COMPUTE_UNIT_LIMIT } from './constants';\nimport {\n EstimateComputeUnitLimitFactoryFunction,\n EstimateComputeUnitLimitFactoryFunctionConfig,\n} from './estimateComputeLimitInternal';\nimport { findSetComputeUnitLimitInstructionIndexAndUnits } from './introspect';\nimport { updateOrAppendSetComputeUnitLimitInstruction } from './setComputeLimit';\n\ntype EstimateAndUpdateProvisoryComputeUnitLimitFactoryFunction = <\n TTransactionMessage extends TransactionMessage & TransactionMessageWithFeePayer,\n>(\n transactionMessage: TTransactionMessage,\n config?: EstimateComputeUnitLimitFactoryFunctionConfig,\n) => Promise<TTransactionMessage>;\n\n/**\n * Given a transaction message, if it does not have an explicit compute unit limit,\n * estimates the compute unit limit and updates the transaction message with\n * the estimated limit. Otherwise, returns the transaction message unchanged.\n *\n * It requires a function that estimates the compute unit limit.\n *\n * @example\n * ```ts\n * const estimateAndUpdateCUs = estimateAndUpdateProvisoryComputeUnitLimitFactory(\n * estimateComputeUnitLimitFactory({ rpc })\n * );\n *\n * const transactionMessageWithCUs = await estimateAndUpdateCUs(transactionMessage);\n * ```\n *\n * @see {@link estimateAndUpdateProvisoryComputeUnitLimitFactory}\n */\nexport function estimateAndUpdateProvisoryComputeUnitLimitFactory(\n estimateComputeUnitLimit: EstimateComputeUnitLimitFactoryFunction,\n): EstimateAndUpdateProvisoryComputeUnitLimitFactoryFunction {\n return async function fn(transactionMessage, config) {\n const instructionDetails = findSetComputeUnitLimitInstructionIndexAndUnits(transactionMessage);\n\n // If the transaction message already has a compute unit limit instruction\n // which is set to a specific value — i.e. not 0 or the maximum limit —\n // we don't need to estimate the compute unit limit.\n if (\n instructionDetails &&\n instructionDetails.units !== PROVISORY_COMPUTE_UNIT_LIMIT &&\n instructionDetails.units !== MAX_COMPUTE_UNIT_LIMIT\n ) {\n return transactionMessage;\n }\n\n return updateOrAppendSetComputeUnitLimitInstruction(\n await estimateComputeUnitLimit(transactionMessage, config),\n transactionMessage,\n );\n };\n}\n","import {\n TransactionMessage,\n Commitment,\n compileTransaction,\n getBase64EncodedWireTransaction,\n getSolanaErrorFromTransactionError,\n isSolanaError,\n isTransactionMessageWithDurableNonceLifetime,\n pipe,\n Rpc,\n RpcSimulateTransactionResult,\n SimulateTransactionApi,\n Slot,\n SOLANA_ERROR__TRANSACTION__FAILED_TO_ESTIMATE_COMPUTE_LIMIT,\n SOLANA_ERROR__TRANSACTION__FAILED_WHEN_SIMULATING_TO_ESTIMATE_COMPUTE_LIMIT,\n SolanaError,\n Transaction,\n TransactionMessageWithFeePayer,\n} from '@solana/kit';\nimport { updateOrAppendSetComputeUnitLimitInstruction } from './setComputeLimit';\nimport { MAX_COMPUTE_UNIT_LIMIT } from './constants';\n\nexport type EstimateComputeUnitLimitFactoryConfig = Readonly<{\n /** An object that supports the {@link SimulateTransactionApi} of the Solana RPC API */\n rpc: Rpc<SimulateTransactionApi>;\n}>;\n\nexport type EstimateComputeUnitLimitFactoryFunction = (\n transactionMessage: TransactionMessage & TransactionMessageWithFeePayer,\n config?: EstimateComputeUnitLimitFactoryFunctionConfig,\n) => Promise<number>;\n\nexport type EstimateComputeUnitLimitFactoryFunctionConfig = {\n abortSignal?: AbortSignal;\n /**\n * Compute the estimate as of the highest slot that has reached this level of commitment.\n *\n * @defaultValue Whichever default is applied by the underlying {@link RpcApi} in use. For\n * example, when using an API created by a `createSolanaRpc*()` helper, the default commitment\n * is `\"confirmed\"` unless configured otherwise. Unmitigated by an API layer on the client, the\n * default commitment applied by the server is `\"finalized\"`.\n */\n commitment?: Commitment;\n /**\n * Prevents accessing stale data by enforcing that the RPC node has processed transactions up to\n * this slot\n */\n minContextSlot?: Slot;\n};\n\ntype EstimateComputeUnitLimitConfig = EstimateComputeUnitLimitFactoryFunctionConfig &\n Readonly<{\n rpc: Rpc<SimulateTransactionApi>;\n transactionMessage: TransactionMessage & TransactionMessageWithFeePayer;\n }>;\n\n/**\n * Simulates a transaction message on the network and returns the number of compute units it\n * consumed during simulation.\n *\n * The estimate this function returns can be used to set a compute unit limit on the transaction.\n * Correctly budgeting a compute unit limit for your transaction message can increase the probability\n * that your transaction will be accepted for processing.\n *\n * If you don't declare a compute unit limit on your transaction, validators will assume an upper\n * limit of 200K compute units (CU) per instruction. Since validators have an incentive to pack as\n * many transactions into each block as possible, they may choose to include transactions that they\n * know will fit into the remaining compute budget for the current block over transactions that\n * might not. For this reason, you should set a compute unit limit on each of your transaction\n * messages, whenever possible.\n *\n * ## Example\n *\n * ```ts\n * import { getSetComputeLimitInstruction } from '@solana-program/compute-budget';\n * import { createSolanaRpc, getComputeUnitEstimateForTransactionMessageFactory, pipe } from '@solana/kit';\n *\n * // Create an estimator function.\n * const rpc = createSolanaRpc('http://127.0.0.1:8899');\n * const getComputeUnitEstimateForTransactionMessage =\n * getComputeUnitEstimateForTransactionMessageFactory({ rpc });\n *\n * // Create your transaction message.\n * const transactionMessage = pipe(\n * createTransactionMessage({ version: 'legacy' }),\n * /* ... *\\/\n * );\n *\n * // Request an estimate of the actual compute units this message will consume.\n * const computeUnitsEstimate =\n * await getComputeUnitEstimateForTransactionMessage(transactionMessage);\n *\n * // Set the transaction message's compute unit budget.\n * const transactionMessageWithComputeUnitLimit = prependTransactionMessageInstruction(\n * getSetComputeLimitInstruction({ units: computeUnitsEstimate }),\n * transactionMessage,\n * );\n * ```\n *\n * > [!WARNING]\n * > The compute unit estimate is just that &ndash; an estimate. The compute unit consumption of the\n * > actual transaction might be higher or lower than what was observed in simulation. Unless you\n * > are confident that your particular transaction message will consume the same or fewer compute\n * > units as was estimated, you might like to augment the estimate by either a fixed number of CUs\n * > or a multiplier.\n *\n * > [!NOTE]\n * > If you are preparing an _unsigned_ transaction, destined to be signed and submitted to the\n * > network by a wallet, you might like to leave it up to the wallet to determine the compute unit\n * > limit. Consider that the wallet might have a more global view of how many compute units certain\n * > types of transactions consume, and might be able to make better estimates of an appropriate\n * > compute unit budget.\n */\nexport async function estimateComputeUnitLimit({\n transactionMessage,\n ...configs\n}: EstimateComputeUnitLimitConfig): Promise<number> {\n const replaceRecentBlockhash = !isTransactionMessageWithDurableNonceLifetime(transactionMessage);\n const transaction = pipe(\n transactionMessage,\n m => updateOrAppendSetComputeUnitLimitInstruction(MAX_COMPUTE_UNIT_LIMIT, m),\n compileTransaction,\n );\n\n return await simulateTransactionAndGetConsumedUnits({\n transaction,\n replaceRecentBlockhash,\n ...configs,\n });\n}\n\ntype SimulateTransactionAndGetConsumedUnitsConfig = Omit<EstimateComputeUnitLimitConfig, 'transactionMessage'> &\n Readonly<{ replaceRecentBlockhash?: boolean; transaction: Transaction }>;\n\nasync function simulateTransactionAndGetConsumedUnits({\n abortSignal,\n rpc,\n transaction,\n ...simulateConfig\n}: SimulateTransactionAndGetConsumedUnitsConfig): Promise<number> {\n const wireTransactionBytes = getBase64EncodedWireTransaction(transaction);\n\n try {\n const response = await rpc\n .simulateTransaction(wireTransactionBytes, { ...simulateConfig, encoding: 'base64', sigVerify: false })\n .send({ abortSignal });\n const { err: transactionError, ...simulationResult } = response.value as RpcSimulateTransactionResult;\n if (simulationResult.unitsConsumed == null) {\n // This should never be hit, because all RPCs should support `unitsConsumed` by now.\n throw new SolanaError(SOLANA_ERROR__TRANSACTION__FAILED_TO_ESTIMATE_COMPUTE_LIMIT);\n }\n if (transactionError) {\n throw new SolanaError(SOLANA_ERROR__TRANSACTION__FAILED_WHEN_SIMULATING_TO_ESTIMATE_COMPUTE_LIMIT, {\n ...simulationResult,\n cause: getSolanaErrorFromTransactionError(transactionError),\n });\n }\n // FIXME(https://github.com/anza-xyz/agave/issues/1295): The simulation response returns\n // compute units as a u64, but the `SetComputeLimit` instruction only accepts a u32. Until\n // this changes, downcast it.\n return simulationResult.unitsConsumed > 4_294_967_295n ? 4_294_967_295 : Number(simulationResult.unitsConsumed);\n } catch (e) {\n if (isSolanaError(e, SOLANA_ERROR__TRANSACTION__FAILED_WHEN_SIMULATING_TO_ESTIMATE_COMPUTE_LIMIT)) throw e;\n throw new SolanaError(SOLANA_ERROR__TRANSACTION__FAILED_TO_ESTIMATE_COMPUTE_LIMIT, { cause: e });\n }\n}\n","import {\n estimateComputeUnitLimit,\n EstimateComputeUnitLimitFactoryConfig,\n EstimateComputeUnitLimitFactoryFunction,\n} from './estimateComputeLimitInternal';\n\n/**\n * Use this utility to estimate the actual compute unit cost of a given transaction message.\n *\n * Correctly budgeting a compute unit limit for your transaction message can increase the\n * probability that your transaction will be accepted for processing. If you don't declare a compute\n * unit limit on your transaction, validators will assume an upper limit of 200K compute units (CU)\n * per instruction.\n *\n * Since validators have an incentive to pack as many transactions into each block as possible, they\n * may choose to include transactions that they know will fit into the remaining compute budget for\n * the current block over transactions that might not. For this reason, you should set a compute\n * unit limit on each of your transaction messages, whenever possible.\n *\n * > [!WARNING]\n * > The compute unit estimate is just that -- an estimate. The compute unit consumption of the\n * > actual transaction might be higher or lower than what was observed in simulation. Unless you\n * > are confident that your particular transaction message will consume the same or fewer compute\n * > units as was estimated, you might like to augment the estimate by either a fixed number of CUs\n * > or a multiplier.\n *\n * > [!NOTE]\n * > If you are preparing an _unsigned_ transaction, destined to be signed and submitted to the\n * > network by a wallet, you might like to leave it up to the wallet to determine the compute unit\n * > limit. Consider that the wallet might have a more global view of how many compute units certain\n * > types of transactions consume, and might be able to make better estimates of an appropriate\n * > compute unit budget.\n *\n * > [!INFO]\n * > In the event that a transaction message does not already have a `SetComputeUnitLimit`\n * > instruction, this function will add one before simulation. This ensures that the compute unit\n * > consumption of the `SetComputeUnitLimit` instruction itself is included in the estimate.\n *\n * @param config\n *\n * @example\n * ```ts\n * import { getSetComputeUnitLimitInstruction } from '@solana-program/compute-budget';\n * import { createSolanaRpc, estimateComputeUnitLimitFactory, pipe } from '@solana/kit';\n *\n * // Create an estimator function.\n * const rpc = createSolanaRpc('http://127.0.0.1:8899');\n * const estimateComputeUnitLimit = estimateComputeUnitLimitFactory({ rpc });\n *\n * // Create your transaction message.\n * const transactionMessage = pipe(\n * createTransactionMessage({ version: 'legacy' }),\n * /* ... *\\/\n * );\n *\n * // Request an estimate of the actual compute units this message will consume. This is done by\n * // simulating the transaction and grabbing the estimated compute units from the result.\n * const estimatedUnits = await estimateComputeUnitLimit(transactionMessage);\n *\n * // Set the transaction message's compute unit budget.\n * const transactionMessageWithComputeUnitLimit = prependTransactionMessageInstruction(\n * getSetComputeUnitLimitInstruction({ units: estimatedUnits }),\n * transactionMessage,\n * );\n * ```\n */\nexport function estimateComputeUnitLimitFactory({\n rpc,\n}: EstimateComputeUnitLimitFactoryConfig): EstimateComputeUnitLimitFactoryFunction {\n return async function estimateComputeUnitLimitFactoryFunction(transactionMessage, config) {\n return await estimateComputeUnitLimit({\n ...config,\n rpc,\n transactionMessage,\n });\n };\n}\n","import { appendTransactionMessageInstruction, TransactionMessage, MicroLamports } from '@solana/kit';\nimport { getSetComputeUnitPriceInstruction } from './generated';\nimport { findSetComputeUnitPriceInstructionIndexAndMicroLamports } from './introspect';\n\n/**\n * Sets the compute unit price of a transaction message in micro-Lamports.\n *\n * @example\n * ```ts\n * const transactionMessage = pipe(\n * createTransactionMessage({ version: 0 }),\n * (m) => setTransactionMessageComputeUnitPrice(10_000, m),\n * // ...\n * );\n * ```\n */\nexport function setTransactionMessageComputeUnitPrice<TTransactionMessage extends TransactionMessage>(\n microLamports: number | bigint,\n transactionMessage: TTransactionMessage,\n) {\n return appendTransactionMessageInstruction(\n getSetComputeUnitPriceInstruction({ microLamports }),\n transactionMessage,\n );\n}\n\n/**\n * Updates the first `SetComputeUnitPrice` instruction in a transaction message\n * with the given micro-Lamports, or appends a new instruction if none exists.\n * A function of the current value can be provided instead of a static value.\n *\n * @param microLamports - The new compute unit price, or a function that\n * takes the previous price and returns the new one.\n * @param transactionMessage - The transaction message to update.\n *\n * @example\n * ```ts\n * const updatedTransactionMessage = updateOrAppendSetComputeUnitPriceInstruction(\n * // E.g. double the current price or set it to 10_000 if it isn't set.\n * (currentPrice) => currentPrice === null ? 10_000 : currentPrice * 2,\n * transactionMessage,\n * );\n * ```\n */\nexport function updateOrAppendSetComputeUnitPriceInstruction<TTransactionMessage extends TransactionMessage>(\n microLamports: MicroLamports | ((previousMicroLamports: MicroLamports | null) => MicroLamports),\n transactionMessage: TTransactionMessage,\n): TTransactionMessage {\n const getMicroLamports = (previousMicroLamports: MicroLamports | null): MicroLamports =>\n typeof microLamports === 'function' ? microLamports(previousMicroLamports) : microLamports;\n const instructionDetails = findSetComputeUnitPriceInstructionIndexAndMicroLamports(transactionMessage);\n\n if (!instructionDetails) {\n return appendTransactionMessageInstruction(\n getSetComputeUnitPriceInstruction({\n microLamports: getMicroLamports(null),\n }),\n transactionMessage,\n ) as TTransactionMessage;\n }\n\n const { index, microLamports: previousMicroLamports } = instructionDetails;\n const newMicroLamports = getMicroLamports(previousMicroLamports);\n if (newMicroLamports === previousMicroLamports) {\n return transactionMessage;\n }\n\n const newInstruction = getSetComputeUnitPriceInstruction({\n microLamports: newMicroLamports,\n });\n const newInstructions = [...transactionMessage.instructions];\n newInstructions.splice(index, 1, newInstruction);\n return Object.freeze({\n ...transactionMessage,\n instructions: newInstructions,\n }) as TTransactionMessage;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"estimateComputeLimitInternal.d.ts","sourceRoot":"","sources":["../../src/estimateComputeLimitInternal.ts"],"names":[],"mappings":"AAAA,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,CAAC,sBAAsB,CAAC,CAAC;CACpC,CAAC,CAAC;AAEH,MAAM,MAAM,uCAAuC,GAAG,CAClD,kBAAkB,EAAE,kBAAkB,GAAG,8BAA8B,EACvE,MAAM,CAAC,EAAE,6CAA6C,KACrD,OAAO,CAAC,MAAM,CAAC,CAAC;AAErB,MAAM,MAAM,6CAA6C,GAAG;IACxD,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B;;;;;;;OAOG;IACH,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB;;;OAGG;IACH,cAAc,CAAC,EAAE,IAAI,CAAC;CACzB,CAAC;AAEF,KAAK,8BAA8B,GAAG,6CAA6C,GAC/E,QAAQ,CAAC;IACL,GAAG,EAAE,GAAG,CAAC,sBAAsB,CAAC,CAAC;IACjC,kBAAkB,EAAE,kBAAkB,GAAG,8BAA8B,CAAC;CAC3E,CAAC,CAAC;AAEP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,wBAAsB,wBAAwB,CAAC,EAC3C,kBAAkB,EAClB,GAAG,OAAO,EACb,EAAE,8BAA8B,GAAG,OAAO,CAAC,MAAM,CAAC,CAalD"}
@@ -5,8 +5,9 @@
5
5
  *
6
6
  * @see https://github.com/codama-idl/codama
7
7
  */
8
- import { type Address, type Instruction, type InstructionWithData, type ReadonlyUint8Array } from '@solana/kit';
9
- import { type ParsedRequestHeapFrameInstruction, type ParsedRequestUnitsInstruction, type ParsedSetComputeUnitLimitInstruction, type ParsedSetComputeUnitPriceInstruction, type ParsedSetLoadedAccountsDataSizeLimitInstruction } from '../instructions';
8
+ import { type Address, type ClientWithTransactionPlanning, type ClientWithTransactionSending, type Instruction, type InstructionWithData, type ReadonlyUint8Array } from '@solana/kit';
9
+ import { type SelfPlanAndSendFunctions } from '@solana/kit/program-client-core';
10
+ import { getRequestHeapFrameInstruction, getRequestUnitsInstruction, getSetComputeUnitLimitInstruction, getSetComputeUnitPriceInstruction, getSetLoadedAccountsDataSizeLimitInstruction, type ParsedRequestHeapFrameInstruction, type ParsedRequestUnitsInstruction, type ParsedSetComputeUnitLimitInstruction, type ParsedSetComputeUnitPriceInstruction, type ParsedSetLoadedAccountsDataSizeLimitInstruction, type RequestHeapFrameInput, type RequestUnitsInput, type SetComputeUnitLimitInput, type SetComputeUnitPriceInput, type SetLoadedAccountsDataSizeLimitInput } from '../instructions';
10
11
  export declare const COMPUTE_BUDGET_PROGRAM_ADDRESS: Address<"ComputeBudget111111111111111111111111111111">;
11
12
  export declare enum ComputeBudgetInstruction {
12
13
  RequestUnits = 0,
@@ -30,4 +31,18 @@ export type ParsedComputeBudgetInstruction<TProgram extends string = 'ComputeBud
30
31
  instructionType: ComputeBudgetInstruction.SetLoadedAccountsDataSizeLimit;
31
32
  } & ParsedSetLoadedAccountsDataSizeLimitInstruction<TProgram>);
32
33
  export declare function parseComputeBudgetInstruction<TProgram extends string>(instruction: Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array>): ParsedComputeBudgetInstruction<TProgram>;
34
+ export type ComputeBudgetPlugin = {
35
+ instructions: ComputeBudgetPluginInstructions;
36
+ };
37
+ export type ComputeBudgetPluginInstructions = {
38
+ requestUnits: (input: RequestUnitsInput) => ReturnType<typeof getRequestUnitsInstruction> & SelfPlanAndSendFunctions;
39
+ requestHeapFrame: (input: RequestHeapFrameInput) => ReturnType<typeof getRequestHeapFrameInstruction> & SelfPlanAndSendFunctions;
40
+ setComputeUnitLimit: (input: SetComputeUnitLimitInput) => ReturnType<typeof getSetComputeUnitLimitInstruction> & SelfPlanAndSendFunctions;
41
+ setComputeUnitPrice: (input: SetComputeUnitPriceInput) => ReturnType<typeof getSetComputeUnitPriceInstruction> & SelfPlanAndSendFunctions;
42
+ setLoadedAccountsDataSizeLimit: (input: SetLoadedAccountsDataSizeLimitInput) => ReturnType<typeof getSetLoadedAccountsDataSizeLimitInstruction> & SelfPlanAndSendFunctions;
43
+ };
44
+ export type ComputeBudgetPluginRequirements = ClientWithTransactionPlanning & ClientWithTransactionSending;
45
+ export declare function computeBudgetProgram(): <T extends ComputeBudgetPluginRequirements>(client: T) => T & {
46
+ computeBudget: ComputeBudgetPlugin;
47
+ };
33
48
  //# sourceMappingURL=computeBudget.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"computeBudget.d.ts","sourceRoot":"","sources":["../../../../src/generated/programs/computeBudget.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAGH,KAAK,OAAO,EACZ,KAAK,WAAW,EAChB,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EAC1B,MAAM,aAAa,CAAC;AACrB,OAAO,EAMH,KAAK,iCAAiC,EACtC,KAAK,6BAA6B,EAClC,KAAK,oCAAoC,EACzC,KAAK,oCAAoC,EACzC,KAAK,+CAA+C,EACvD,MAAM,iBAAiB,CAAC;AAEzB,eAAO,MAAM,8BAA8B,EACU,OAAO,CAAC,6CAA6C,CAAC,CAAC;AAE5G,oBAAY,wBAAwB;IAChC,YAAY,IAAA;IACZ,gBAAgB,IAAA;IAChB,mBAAmB,IAAA;IACnB,mBAAmB,IAAA;IACnB,8BAA8B,IAAA;CACjC;AAED,wBAAgB,gCAAgC,CAC5C,WAAW,EAAE;IAAE,IAAI,EAAE,kBAAkB,CAAA;CAAE,GAAG,kBAAkB,GAC/D,wBAAwB,CAkB1B;AAED,MAAM,MAAM,8BAA8B,CAAC,QAAQ,SAAS,MAAM,GAAG,6CAA6C,IAC5G,CAAC;IAAE,eAAe,EAAE,wBAAwB,CAAC,YAAY,CAAA;CAAE,GAAG,6BAA6B,CAAC,QAAQ,CAAC,CAAC,GACtG,CAAC;IAAE,eAAe,EAAE,wBAAwB,CAAC,gBAAgB,CAAA;CAAE,GAAG,iCAAiC,CAAC,QAAQ,CAAC,CAAC,GAC9G,CAAC;IACG,eAAe,EAAE,wBAAwB,CAAC,mBAAmB,CAAC;CACjE,GAAG,oCAAoC,CAAC,QAAQ,CAAC,CAAC,GACnD,CA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9B,UAAU,CAAC,OAAO,iCAAiC,CAAC,GAAG,wBAAwB,CAAC;IACrF,mBAAmB,EAAE,CACjB,KAAK,EAAE,wBAAwB,KAC9B,UAAU,CAAC,OAAO,iCAAiC,CAAC,GAAG,wBAAwB,CAAC;IACrF,8BAA8B,EAAE,CAC5B,KAAK,EAAE,mCAAmC,KACzC,UAAU,CAAC,OAAO,4CAA4C,CAAC,GAAG,wBAAwB,CAAC;CACnG,CAAC;AAEF,MAAM,MAAM,+BAA+B,GAAG,6BAA6B,GAAG,4BAA4B,CAAC;AAE3G,wBAAgB,oBAAoB,KACxB,CAAC,SAAS,+BAA+B,EAAE,QAAQ,CAAC;mBAGpC,mBAAmB;EAe9C"}
@@ -2,6 +2,7 @@ export * from './generated';
2
2
  export * from './constants';
3
3
  export * from './estimateAndSetComputeLimit';
4
4
  export * from './estimateComputeLimit';
5
+ export * from './introspect';
5
6
  export * from './setComputeLimit';
6
7
  export * from './setComputePrice';
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAE5B,cAAc,aAAa,CAAC;AAC5B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAE5B,cAAc,aAAa,CAAC;AAC5B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wBAAwB,CAAC;AACvC,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { TransactionMessage, MicroLamports } from '@solana/kit';
2
+ /**
3
+ * Finds the index of the first `SetComputeUnitLimit` instruction in a transaction message
4
+ * and its set limit, if any.
5
+ */
6
+ export declare function findSetComputeUnitLimitInstructionIndexAndUnits(transactionMessage: TransactionMessage): {
7
+ index: number;
8
+ units: number;
9
+ } | null;
10
+ /**
11
+ * Finds the index of the first `SetComputeUnitPrice` instruction in a transaction message
12
+ * and its set micro-lamports, if any.
13
+ */
14
+ export declare function findSetComputeUnitPriceInstructionIndexAndMicroLamports(transactionMessage: TransactionMessage): {
15
+ index: number;
16
+ microLamports: MicroLamports;
17
+ } | null;
18
+ //# sourceMappingURL=introspect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"introspect.d.ts","sourceRoot":"","sources":["../../src/introspect.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,kBAAkB,EAIlB,aAAa,EAEhB,MAAM,aAAa,CAAC;AASrB;;;GAGG;AACH,wBAAgB,+CAA+C,CAC3D,kBAAkB,EAAE,kBAAkB,GACvC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CASzC;AAaD;;;GAGG;AACH,wBAAgB,uDAAuD,CACnE,kBAAkB,EAAE,kBAAkB,GACvC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,aAAa,CAAA;CAAE,GAAG,IAAI,CAYxD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solana-program/compute-budget",
3
- "version": "0.13.0",
3
+ "version": "0.15.0",
4
4
  "description": "JavaScript client for the Compute Budget program",
5
5
  "sideEffects": false,
6
6
  "module": "./dist/src/index.mjs",
@@ -32,11 +32,11 @@
32
32
  },
33
33
  "homepage": "https://github.com/solana-program/compute-budget#readme",
34
34
  "peerDependencies": {
35
- "@solana/kit": "^6.0.0"
35
+ "@solana/kit": "^6.3.0"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@solana/eslint-config-solana": "^3.0.3",
39
- "@solana/kit": "^6.0.0",
39
+ "@solana/kit": "^6.3.0",
40
40
  "@types/node": "^24",
41
41
  "@typescript-eslint/eslint-plugin": "^7.16.1",
42
42
  "@typescript-eslint/parser": "^7.16.1",
@@ -1,50 +0,0 @@
1
- /**
2
- * This code was AUTOGENERATED using the Codama library.
3
- * Please DO NOT EDIT THIS FILE, instead use visitors
4
- * to add features, then rerun Codama to update it.
5
- *
6
- * @see https://github.com/codama-idl/codama
7
- */
8
- import { type AccountMeta, type AccountSignerMeta, type Address, type ProgramDerivedAddress, type TransactionSigner } from '@solana/kit';
9
- /**
10
- * Asserts that the given value is not null or undefined.
11
- * @internal
12
- */
13
- export declare function expectSome<T>(value: T | null | undefined): T;
14
- /**
15
- * Asserts that the given value is a PublicKey.
16
- * @internal
17
- */
18
- export declare function expectAddress<T extends string = string>(value: Address<T> | ProgramDerivedAddress<T> | TransactionSigner<T> | null | undefined): Address<T>;
19
- /**
20
- * Asserts that the given value is a PDA.
21
- * @internal
22
- */
23
- export declare function expectProgramDerivedAddress<T extends string = string>(value: Address<T> | ProgramDerivedAddress<T> | TransactionSigner<T> | null | undefined): ProgramDerivedAddress<T>;
24
- /**
25
- * Asserts that the given value is a TransactionSigner.
26
- * @internal
27
- */
28
- export declare function expectTransactionSigner<T extends string = string>(value: Address<T> | ProgramDerivedAddress<T> | TransactionSigner<T> | null | undefined): TransactionSigner<T>;
29
- /**
30
- * Defines an instruction account to resolve.
31
- * @internal
32
- */
33
- export type ResolvedAccount<T extends string = string, U extends Address<T> | ProgramDerivedAddress<T> | TransactionSigner<T> | null = Address<T> | ProgramDerivedAddress<T> | TransactionSigner<T> | null> = {
34
- isWritable: boolean;
35
- value: U;
36
- };
37
- /**
38
- * Defines an instruction that stores additional bytes on-chain.
39
- * @internal
40
- */
41
- export type InstructionWithByteDelta = {
42
- byteDelta: number;
43
- };
44
- /**
45
- * Get account metas and signers from resolved accounts.
46
- * @internal
47
- */
48
- export declare function getAccountMetaFactory(programAddress: Address, optionalAccountStrategy: 'omitted' | 'programId'): (account: ResolvedAccount) => AccountMeta | AccountSignerMeta | undefined;
49
- export declare function isTransactionSigner<TAddress extends string = string>(value: Address<TAddress> | ProgramDerivedAddress<TAddress> | TransactionSigner<TAddress>): value is TransactionSigner<TAddress>;
50
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/generated/shared/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAIH,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,OAAO,EACZ,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,EAEzB,MAAM,aAAa,CAAC;AAErB;;;GAGG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,GAAG,SAAS,GAAG,CAAC,CAK5D;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EACnD,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,qBAAqB,CAAC,CAAC,CAAC,GAAG,iBAAiB,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,SAAS,GACvF,OAAO,CAAC,CAAC,CAAC,CAWZ;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EACjE,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,qBAAqB,CAAC,CAAC,CAAC,GAAG,iBAAiB,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,SAAS,GACvF,qBAAqB,CAAC,CAAC,CAAC,CAK1B;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EAC7D,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,qBAAqB,CAAC,CAAC,CAAC,GAAG,iBAAiB,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,SAAS,GACvF,iBAAiB,CAAC,CAAC,CAAC,CAKtB;AAED;;;GAGG;AACH,MAAM,MAAM,eAAe,CACvB,CAAC,SAAS,MAAM,GAAG,MAAM,EACzB,CAAC,SAAS,OAAO,CAAC,CAAC,CAAC,GAAG,qBAAqB,CAAC,CAAC,CAAC,GAAG,iBAAiB,CAAC,CAAC,CAAC,GAAG,IAAI,GACvE,OAAO,CAAC,CAAC,CAAC,GACV,qBAAqB,CAAC,CAAC,CAAC,GACxB,iBAAiB,CAAC,CAAC,CAAC,GACpB,IAAI,IACV;IACA,UAAU,EAAE,OAAO,CAAC;IACpB,KAAK,EAAE,CAAC,CAAC;CACZ,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACnC,SAAS,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,cAAc,EAAE,OAAO,EAAE,uBAAuB,EAAE,SAAS,GAAG,WAAW,IACnG,SAAS,eAAe,KAAG,WAAW,GAAG,iBAAiB,GAAG,SAAS,CAajF;AAED,wBAAgB,mBAAmB,CAAC,QAAQ,SAAS,MAAM,GAAG,MAAM,EAChE,KAAK,EAAE,OAAO,CAAC,QAAQ,CAAC,GAAG,qBAAqB,CAAC,QAAQ,CAAC,GAAG,iBAAiB,CAAC,QAAQ,CAAC,GACzF,KAAK,IAAI,iBAAiB,CAAC,QAAQ,CAAC,CAEtC"}
@@ -1,35 +0,0 @@
1
- import { TransactionMessage, Instruction, MicroLamports } from '@solana/kit';
2
- import { SetComputeUnitLimitInstruction, SetComputeUnitPriceInstruction } from './generated';
3
- /**
4
- * Finds the index of the first `SetComputeUnitLimit` instruction in a transaction message
5
- * and its set limit, if any.
6
- */
7
- export declare function getSetComputeUnitLimitInstructionIndexAndUnits(transactionMessage: TransactionMessage): {
8
- index: number;
9
- units: number;
10
- } | null;
11
- /**
12
- * Finds the index of the first `SetComputeUnitLimit` instruction in a transaction message, if any.
13
- */
14
- export declare function getSetComputeUnitLimitInstructionIndex(transactionMessage: TransactionMessage): number;
15
- /**
16
- * Checks if the given instruction is a `SetComputeUnitLimit` instruction.
17
- */
18
- export declare function isSetComputeUnitLimitInstruction(instruction: Instruction): instruction is SetComputeUnitLimitInstruction;
19
- /**
20
- * Finds the index of the first `SetComputeUnitPrice` instruction in a transaction message
21
- * and its set micro-lamports, if any.
22
- */
23
- export declare function getSetComputeUnitPriceInstructionIndexAndMicroLamports(transactionMessage: TransactionMessage): {
24
- index: number;
25
- microLamports: MicroLamports;
26
- } | null;
27
- /**
28
- * Finds the index of the first `SetComputeUnitPrice` instruction in a transaction message, if any.
29
- */
30
- export declare function getSetComputeUnitPriceInstructionIndex(transactionMessage: TransactionMessage): number;
31
- /**
32
- * Checks if the given instruction is a `SetComputeUnitPrice` instruction.
33
- */
34
- export declare function isSetComputeUnitPriceInstruction(instruction: Instruction): instruction is SetComputeUnitPriceInstruction;
35
- //# sourceMappingURL=internal.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../src/internal.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,kBAAkB,EAGlB,WAAW,EACX,aAAa,EAEhB,MAAM,aAAa,CAAC;AACrB,OAAO,EAIH,8BAA8B,EAC9B,8BAA8B,EACjC,MAAM,aAAa,CAAC;AAErB;;;GAGG;AACH,wBAAgB,8CAA8C,CAC1D,kBAAkB,EAAE,kBAAkB,GACvC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CASzC;AAED;;GAEG;AACH,wBAAgB,sCAAsC,CAAC,kBAAkB,EAAE,kBAAkB,UAE5F;AAED;;GAEG;AACH,wBAAgB,gCAAgC,CAC5C,WAAW,EAAE,WAAW,GACzB,WAAW,IAAI,8BAA8B,CAM/C;AAED;;;GAGG;AACH,wBAAgB,sDAAsD,CAClE,kBAAkB,EAAE,kBAAkB,GACvC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,aAAa,CAAA;CAAE,GAAG,IAAI,CAYxD;AAED;;GAEG;AACH,wBAAgB,sCAAsC,CAAC,kBAAkB,EAAE,kBAAkB,UAE5F;AAED;;GAEG;AACH,wBAAgB,gCAAgC,CAC5C,WAAW,EAAE,WAAW,GACzB,WAAW,IAAI,8BAA8B,CAM/C"}