@solana/web3.js 1.44.2 → 1.44.3

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.cjs.js CHANGED
@@ -2568,24 +2568,27 @@ class Transaction {
2568
2568
  return this._message;
2569
2569
  }
2570
2570
 
2571
- const {
2572
- nonceInfo
2573
- } = this;
2571
+ let recentBlockhash;
2572
+ let instructions;
2574
2573
 
2575
- if (nonceInfo && this.instructions[0] != nonceInfo.nonceInstruction) {
2576
- this.recentBlockhash = nonceInfo.nonce;
2577
- this.instructions.unshift(nonceInfo.nonceInstruction);
2578
- }
2574
+ if (this.nonceInfo) {
2575
+ recentBlockhash = this.nonceInfo.nonce;
2579
2576
 
2580
- const {
2581
- recentBlockhash
2582
- } = this;
2577
+ if (this.instructions[0] != this.nonceInfo.nonceInstruction) {
2578
+ instructions = [this.nonceInfo.nonceInstruction, ...this.instructions];
2579
+ } else {
2580
+ instructions = this.instructions;
2581
+ }
2582
+ } else {
2583
+ recentBlockhash = this.recentBlockhash;
2584
+ instructions = this.instructions;
2585
+ }
2583
2586
 
2584
2587
  if (!recentBlockhash) {
2585
2588
  throw new Error('Transaction recentBlockhash required');
2586
2589
  }
2587
2590
 
2588
- if (this.instructions.length < 1) {
2591
+ if (instructions.length < 1) {
2589
2592
  console.warn('No instructions provided');
2590
2593
  }
2591
2594
 
@@ -2600,15 +2603,15 @@ class Transaction {
2600
2603
  throw new Error('Transaction fee payer required');
2601
2604
  }
2602
2605
 
2603
- for (let i = 0; i < this.instructions.length; i++) {
2604
- if (this.instructions[i].programId === undefined) {
2606
+ for (let i = 0; i < instructions.length; i++) {
2607
+ if (instructions[i].programId === undefined) {
2605
2608
  throw new Error(`Transaction instruction index ${i} has undefined program id`);
2606
2609
  }
2607
2610
  }
2608
2611
 
2609
2612
  const programIds = [];
2610
2613
  const accountMetas = [];
2611
- this.instructions.forEach(instruction => {
2614
+ instructions.forEach(instruction => {
2612
2615
  instruction.keys.forEach(accountMeta => {
2613
2616
  accountMetas.push({ ...accountMeta
2614
2617
  });
@@ -2718,7 +2721,7 @@ class Transaction {
2718
2721
  }
2719
2722
  });
2720
2723
  const accountKeys = signedKeys.concat(unsignedKeys);
2721
- const instructions = this.instructions.map(instruction => {
2724
+ const compiledInstructions = instructions.map(instruction => {
2722
2725
  const {
2723
2726
  data,
2724
2727
  programId
@@ -2729,7 +2732,7 @@ class Transaction {
2729
2732
  data: bs58__default["default"].encode(data)
2730
2733
  };
2731
2734
  });
2732
- instructions.forEach(instruction => {
2735
+ compiledInstructions.forEach(instruction => {
2733
2736
  assert(instruction.programIdIndex >= 0);
2734
2737
  instruction.accounts.forEach(keyIndex => assert(keyIndex >= 0));
2735
2738
  });
@@ -2741,7 +2744,7 @@ class Transaction {
2741
2744
  },
2742
2745
  accountKeys,
2743
2746
  recentBlockhash,
2744
- instructions
2747
+ instructions: compiledInstructions
2745
2748
  });
2746
2749
  }
2747
2750
  /**