@solana/web3.js 1.44.1 → 1.45.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.
@@ -2541,24 +2541,27 @@ class Transaction {
2541
2541
  return this._message;
2542
2542
  }
2543
2543
 
2544
- const {
2545
- nonceInfo
2546
- } = this;
2544
+ let recentBlockhash;
2545
+ let instructions;
2547
2546
 
2548
- if (nonceInfo && this.instructions[0] != nonceInfo.nonceInstruction) {
2549
- this.recentBlockhash = nonceInfo.nonce;
2550
- this.instructions.unshift(nonceInfo.nonceInstruction);
2551
- }
2547
+ if (this.nonceInfo) {
2548
+ recentBlockhash = this.nonceInfo.nonce;
2552
2549
 
2553
- const {
2554
- recentBlockhash
2555
- } = this;
2550
+ if (this.instructions[0] != this.nonceInfo.nonceInstruction) {
2551
+ instructions = [this.nonceInfo.nonceInstruction, ...this.instructions];
2552
+ } else {
2553
+ instructions = this.instructions;
2554
+ }
2555
+ } else {
2556
+ recentBlockhash = this.recentBlockhash;
2557
+ instructions = this.instructions;
2558
+ }
2556
2559
 
2557
2560
  if (!recentBlockhash) {
2558
2561
  throw new Error('Transaction recentBlockhash required');
2559
2562
  }
2560
2563
 
2561
- if (this.instructions.length < 1) {
2564
+ if (instructions.length < 1) {
2562
2565
  console.warn('No instructions provided');
2563
2566
  }
2564
2567
 
@@ -2573,15 +2576,15 @@ class Transaction {
2573
2576
  throw new Error('Transaction fee payer required');
2574
2577
  }
2575
2578
 
2576
- for (let i = 0; i < this.instructions.length; i++) {
2577
- if (this.instructions[i].programId === undefined) {
2579
+ for (let i = 0; i < instructions.length; i++) {
2580
+ if (instructions[i].programId === undefined) {
2578
2581
  throw new Error(`Transaction instruction index ${i} has undefined program id`);
2579
2582
  }
2580
2583
  }
2581
2584
 
2582
2585
  const programIds = [];
2583
2586
  const accountMetas = [];
2584
- this.instructions.forEach(instruction => {
2587
+ instructions.forEach(instruction => {
2585
2588
  instruction.keys.forEach(accountMeta => {
2586
2589
  accountMetas.push({ ...accountMeta
2587
2590
  });
@@ -2691,7 +2694,7 @@ class Transaction {
2691
2694
  }
2692
2695
  });
2693
2696
  const accountKeys = signedKeys.concat(unsignedKeys);
2694
- const instructions = this.instructions.map(instruction => {
2697
+ const compiledInstructions = instructions.map(instruction => {
2695
2698
  const {
2696
2699
  data,
2697
2700
  programId
@@ -2702,7 +2705,7 @@ class Transaction {
2702
2705
  data: bs58__default["default"].encode(data)
2703
2706
  };
2704
2707
  });
2705
- instructions.forEach(instruction => {
2708
+ compiledInstructions.forEach(instruction => {
2706
2709
  assert(instruction.programIdIndex >= 0);
2707
2710
  instruction.accounts.forEach(keyIndex => assert(keyIndex >= 0));
2708
2711
  });
@@ -2714,7 +2717,7 @@ class Transaction {
2714
2717
  },
2715
2718
  accountKeys,
2716
2719
  recentBlockhash,
2717
- instructions
2720
+ instructions: compiledInstructions
2718
2721
  });
2719
2722
  }
2720
2723
  /**
@@ -4596,6 +4599,7 @@ function makeWebsocketUrl(endpoint) {
4596
4599
  return url.toString();
4597
4600
  }
4598
4601
 
4602
+ var _process$env$npm_pack;
4599
4603
  const PublicKeyFromString = superstruct.coerce(superstruct.instance(PublicKey), superstruct.string(), value => new PublicKey(value));
4600
4604
  const RawAccountDataResult = superstruct.tuple([superstruct.string(), superstruct.literal('base64')]);
4601
4605
  const BufferFromRawAccountData = superstruct.coerce(superstruct.instance(buffer.Buffer), RawAccountDataResult, value => buffer.Buffer.from(value[0], 'base64'));
@@ -4806,7 +4810,7 @@ function createRpcClient(url, useHttps, httpHeaders, customFetch, fetchMiddlewar
4806
4810
  agent,
4807
4811
  headers: Object.assign({
4808
4812
  'Content-Type': 'application/json'
4809
- }, httpHeaders || {})
4813
+ }, httpHeaders || {}, COMMON_HTTP_HEADERS)
4810
4814
  };
4811
4815
 
4812
4816
  try {
@@ -5479,9 +5483,14 @@ const LogsNotificationResult = superstruct.type({
5479
5483
  * Filter for log subscriptions.
5480
5484
  */
5481
5485
 
5486
+ /** @internal */
5487
+ const COMMON_HTTP_HEADERS = {
5488
+ 'solana-client': `js/${(_process$env$npm_pack = "0.0.0-development") !== null && _process$env$npm_pack !== void 0 ? _process$env$npm_pack : 'UNKNOWN'}`
5489
+ };
5482
5490
  /**
5483
5491
  * A connection to a fullnode JSON RPC endpoint
5484
5492
  */
5493
+
5485
5494
  class Connection {
5486
5495
  /** @internal */
5487
5496
 
@@ -6757,7 +6766,13 @@ class Connection {
6757
6766
  throw new Error('failed to get transactions: ' + res.error.message);
6758
6767
  }
6759
6768
 
6760
- return res.result;
6769
+ const result = res.result;
6770
+ if (!result) return result;
6771
+ return { ...result,
6772
+ transaction: { ...result.transaction,
6773
+ message: new Message(result.transaction.message)
6774
+ }
6775
+ };
6761
6776
  });
6762
6777
  return res;
6763
6778
  }