@solana/web3.js 1.40.1 → 1.41.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/lib/index.iife.js CHANGED
@@ -15757,6 +15757,136 @@ var solanaWeb3 = (function (exports) {
15757
15757
 
15758
15758
  }
15759
15759
 
15760
+ /**
15761
+ * Compute Budget Instruction class
15762
+ */
15763
+
15764
+ class ComputeBudgetInstruction {
15765
+ /**
15766
+ * @internal
15767
+ */
15768
+ constructor() {}
15769
+ /**
15770
+ * Decode a compute budget instruction and retrieve the instruction type.
15771
+ */
15772
+
15773
+
15774
+ static decodeInstructionType(instruction) {
15775
+ this.checkProgramId(instruction.programId);
15776
+ const instructionTypeLayout = u8('instruction');
15777
+ const typeIndex = instructionTypeLayout.decode(instruction.data);
15778
+ let type;
15779
+
15780
+ for (const [ixType, layout] of Object.entries(COMPUTE_BUDGET_INSTRUCTION_LAYOUTS)) {
15781
+ if (layout.index == typeIndex) {
15782
+ type = ixType;
15783
+ break;
15784
+ }
15785
+ }
15786
+
15787
+ if (!type) {
15788
+ throw new Error('Instruction type incorrect; not a ComputeBudgetInstruction');
15789
+ }
15790
+
15791
+ return type;
15792
+ }
15793
+ /**
15794
+ * Decode request units compute budget instruction and retrieve the instruction params.
15795
+ */
15796
+
15797
+
15798
+ static decodeRequestUnits(instruction) {
15799
+ this.checkProgramId(instruction.programId);
15800
+ const {
15801
+ units,
15802
+ additionalFee
15803
+ } = decodeData(COMPUTE_BUDGET_INSTRUCTION_LAYOUTS.RequestUnits, instruction.data);
15804
+ return {
15805
+ units,
15806
+ additionalFee
15807
+ };
15808
+ }
15809
+ /**
15810
+ * Decode request heap frame compute budget instruction and retrieve the instruction params.
15811
+ */
15812
+
15813
+
15814
+ static decodeRequestHeapFrame(instruction) {
15815
+ this.checkProgramId(instruction.programId);
15816
+ const {
15817
+ bytes
15818
+ } = decodeData(COMPUTE_BUDGET_INSTRUCTION_LAYOUTS.RequestHeapFrame, instruction.data);
15819
+ return {
15820
+ bytes
15821
+ };
15822
+ }
15823
+ /**
15824
+ * @internal
15825
+ */
15826
+
15827
+
15828
+ static checkProgramId(programId) {
15829
+ if (!programId.equals(ComputeBudgetProgram.programId)) {
15830
+ throw new Error('invalid instruction; programId is not ComputeBudgetProgram');
15831
+ }
15832
+ }
15833
+
15834
+ }
15835
+ /**
15836
+ * An enumeration of valid ComputeBudgetInstructionType's
15837
+ */
15838
+
15839
+ /**
15840
+ * An enumeration of valid ComputeBudget InstructionType's
15841
+ * @internal
15842
+ */
15843
+ const COMPUTE_BUDGET_INSTRUCTION_LAYOUTS = Object.freeze({
15844
+ RequestUnits: {
15845
+ index: 0,
15846
+ layout: struct([u8('instruction'), u32('units'), u32('additionalFee')])
15847
+ },
15848
+ RequestHeapFrame: {
15849
+ index: 1,
15850
+ layout: struct([u8('instruction'), u32('bytes')])
15851
+ }
15852
+ });
15853
+ /**
15854
+ * Factory class for transaction instructions to interact with the Compute Budget program
15855
+ */
15856
+
15857
+ class ComputeBudgetProgram {
15858
+ /**
15859
+ * @internal
15860
+ */
15861
+ constructor() {}
15862
+ /**
15863
+ * Public key that identifies the Compute Budget program
15864
+ */
15865
+
15866
+
15867
+ static requestUnits(params) {
15868
+ const type = COMPUTE_BUDGET_INSTRUCTION_LAYOUTS.RequestUnits;
15869
+ const data = encodeData(type, params);
15870
+ return new TransactionInstruction({
15871
+ keys: [],
15872
+ programId: this.programId,
15873
+ data
15874
+ });
15875
+ }
15876
+
15877
+ static requestHeapFrame(params) {
15878
+ const type = COMPUTE_BUDGET_INSTRUCTION_LAYOUTS.RequestHeapFrame;
15879
+ const data = encodeData(type, params);
15880
+ return new TransactionInstruction({
15881
+ keys: [],
15882
+ programId: this.programId,
15883
+ data
15884
+ });
15885
+ }
15886
+
15887
+ }
15888
+ ComputeBudgetProgram.programId = new PublicKey('ComputeBudget111111111111111111111111111111');
15889
+
15760
15890
  var browserPonyfill = {exports: {}};
15761
15891
 
15762
15892
  (function (module, exports) {
@@ -29975,6 +30105,9 @@ var solanaWeb3 = (function (exports) {
29975
30105
  exports.BPF_LOADER_DEPRECATED_PROGRAM_ID = BPF_LOADER_DEPRECATED_PROGRAM_ID;
29976
30106
  exports.BPF_LOADER_PROGRAM_ID = BPF_LOADER_PROGRAM_ID;
29977
30107
  exports.BpfLoader = BpfLoader;
30108
+ exports.COMPUTE_BUDGET_INSTRUCTION_LAYOUTS = COMPUTE_BUDGET_INSTRUCTION_LAYOUTS;
30109
+ exports.ComputeBudgetInstruction = ComputeBudgetInstruction;
30110
+ exports.ComputeBudgetProgram = ComputeBudgetProgram;
29978
30111
  exports.Connection = Connection;
29979
30112
  exports.Ed25519Program = Ed25519Program;
29980
30113
  exports.Enum = Enum;