@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.
@@ -2510,24 +2510,27 @@ class Transaction {
2510
2510
  return this._message;
2511
2511
  }
2512
2512
 
2513
- const {
2514
- nonceInfo
2515
- } = this;
2513
+ let recentBlockhash;
2514
+ let instructions;
2516
2515
 
2517
- if (nonceInfo && this.instructions[0] != nonceInfo.nonceInstruction) {
2518
- this.recentBlockhash = nonceInfo.nonce;
2519
- this.instructions.unshift(nonceInfo.nonceInstruction);
2520
- }
2516
+ if (this.nonceInfo) {
2517
+ recentBlockhash = this.nonceInfo.nonce;
2521
2518
 
2522
- const {
2523
- recentBlockhash
2524
- } = this;
2519
+ if (this.instructions[0] != this.nonceInfo.nonceInstruction) {
2520
+ instructions = [this.nonceInfo.nonceInstruction, ...this.instructions];
2521
+ } else {
2522
+ instructions = this.instructions;
2523
+ }
2524
+ } else {
2525
+ recentBlockhash = this.recentBlockhash;
2526
+ instructions = this.instructions;
2527
+ }
2525
2528
 
2526
2529
  if (!recentBlockhash) {
2527
2530
  throw new Error('Transaction recentBlockhash required');
2528
2531
  }
2529
2532
 
2530
- if (this.instructions.length < 1) {
2533
+ if (instructions.length < 1) {
2531
2534
  console.warn('No instructions provided');
2532
2535
  }
2533
2536
 
@@ -2542,15 +2545,15 @@ class Transaction {
2542
2545
  throw new Error('Transaction fee payer required');
2543
2546
  }
2544
2547
 
2545
- for (let i = 0; i < this.instructions.length; i++) {
2546
- if (this.instructions[i].programId === undefined) {
2548
+ for (let i = 0; i < instructions.length; i++) {
2549
+ if (instructions[i].programId === undefined) {
2547
2550
  throw new Error(`Transaction instruction index ${i} has undefined program id`);
2548
2551
  }
2549
2552
  }
2550
2553
 
2551
2554
  const programIds = [];
2552
2555
  const accountMetas = [];
2553
- this.instructions.forEach(instruction => {
2556
+ instructions.forEach(instruction => {
2554
2557
  instruction.keys.forEach(accountMeta => {
2555
2558
  accountMetas.push({ ...accountMeta
2556
2559
  });
@@ -2660,7 +2663,7 @@ class Transaction {
2660
2663
  }
2661
2664
  });
2662
2665
  const accountKeys = signedKeys.concat(unsignedKeys);
2663
- const instructions = this.instructions.map(instruction => {
2666
+ const compiledInstructions = instructions.map(instruction => {
2664
2667
  const {
2665
2668
  data,
2666
2669
  programId
@@ -2671,7 +2674,7 @@ class Transaction {
2671
2674
  data: bs58.encode(data)
2672
2675
  };
2673
2676
  });
2674
- instructions.forEach(instruction => {
2677
+ compiledInstructions.forEach(instruction => {
2675
2678
  assert(instruction.programIdIndex >= 0);
2676
2679
  instruction.accounts.forEach(keyIndex => assert(keyIndex >= 0));
2677
2680
  });
@@ -2683,7 +2686,7 @@ class Transaction {
2683
2686
  },
2684
2687
  accountKeys,
2685
2688
  recentBlockhash,
2686
- instructions
2689
+ instructions: compiledInstructions
2687
2690
  });
2688
2691
  }
2689
2692
  /**