@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.
package/lib/index.d.ts CHANGED
@@ -1449,6 +1449,8 @@ declare module '@solana/web3.js' {
1449
1449
  */
1450
1450
  export type HttpHeaders = {
1451
1451
  [header: string]: string;
1452
+ } & {
1453
+ 'solana-client'?: never;
1452
1454
  };
1453
1455
  /**
1454
1456
  * The type of the JavaScript `fetch()` API
package/lib/index.esm.js CHANGED
@@ -2534,24 +2534,27 @@ class Transaction {
2534
2534
  return this._message;
2535
2535
  }
2536
2536
 
2537
- const {
2538
- nonceInfo
2539
- } = this;
2537
+ let recentBlockhash;
2538
+ let instructions;
2540
2539
 
2541
- if (nonceInfo && this.instructions[0] != nonceInfo.nonceInstruction) {
2542
- this.recentBlockhash = nonceInfo.nonce;
2543
- this.instructions.unshift(nonceInfo.nonceInstruction);
2544
- }
2540
+ if (this.nonceInfo) {
2541
+ recentBlockhash = this.nonceInfo.nonce;
2545
2542
 
2546
- const {
2547
- recentBlockhash
2548
- } = this;
2543
+ if (this.instructions[0] != this.nonceInfo.nonceInstruction) {
2544
+ instructions = [this.nonceInfo.nonceInstruction, ...this.instructions];
2545
+ } else {
2546
+ instructions = this.instructions;
2547
+ }
2548
+ } else {
2549
+ recentBlockhash = this.recentBlockhash;
2550
+ instructions = this.instructions;
2551
+ }
2549
2552
 
2550
2553
  if (!recentBlockhash) {
2551
2554
  throw new Error('Transaction recentBlockhash required');
2552
2555
  }
2553
2556
 
2554
- if (this.instructions.length < 1) {
2557
+ if (instructions.length < 1) {
2555
2558
  console.warn('No instructions provided');
2556
2559
  }
2557
2560
 
@@ -2566,15 +2569,15 @@ class Transaction {
2566
2569
  throw new Error('Transaction fee payer required');
2567
2570
  }
2568
2571
 
2569
- for (let i = 0; i < this.instructions.length; i++) {
2570
- if (this.instructions[i].programId === undefined) {
2572
+ for (let i = 0; i < instructions.length; i++) {
2573
+ if (instructions[i].programId === undefined) {
2571
2574
  throw new Error(`Transaction instruction index ${i} has undefined program id`);
2572
2575
  }
2573
2576
  }
2574
2577
 
2575
2578
  const programIds = [];
2576
2579
  const accountMetas = [];
2577
- this.instructions.forEach(instruction => {
2580
+ instructions.forEach(instruction => {
2578
2581
  instruction.keys.forEach(accountMeta => {
2579
2582
  accountMetas.push({ ...accountMeta
2580
2583
  });
@@ -2684,7 +2687,7 @@ class Transaction {
2684
2687
  }
2685
2688
  });
2686
2689
  const accountKeys = signedKeys.concat(unsignedKeys);
2687
- const instructions = this.instructions.map(instruction => {
2690
+ const compiledInstructions = instructions.map(instruction => {
2688
2691
  const {
2689
2692
  data,
2690
2693
  programId
@@ -2695,7 +2698,7 @@ class Transaction {
2695
2698
  data: bs58.encode(data)
2696
2699
  };
2697
2700
  });
2698
- instructions.forEach(instruction => {
2701
+ compiledInstructions.forEach(instruction => {
2699
2702
  assert(instruction.programIdIndex >= 0);
2700
2703
  instruction.accounts.forEach(keyIndex => assert(keyIndex >= 0));
2701
2704
  });
@@ -2707,7 +2710,7 @@ class Transaction {
2707
2710
  },
2708
2711
  accountKeys,
2709
2712
  recentBlockhash,
2710
- instructions
2713
+ instructions: compiledInstructions
2711
2714
  });
2712
2715
  }
2713
2716
  /**
@@ -4641,6 +4644,7 @@ function makeWebsocketUrl(endpoint) {
4641
4644
  return url.toString();
4642
4645
  }
4643
4646
 
4647
+ var _process$env$npm_pack;
4644
4648
  const PublicKeyFromString = coerce(instance(PublicKey), string(), value => new PublicKey(value));
4645
4649
  const RawAccountDataResult = tuple([string(), literal('base64')]);
4646
4650
  const BufferFromRawAccountData = coerce(instance(Buffer), RawAccountDataResult, value => Buffer.from(value[0], 'base64'));
@@ -4856,7 +4860,7 @@ function createRpcClient(url, useHttps, httpHeaders, customFetch, fetchMiddlewar
4856
4860
  agent,
4857
4861
  headers: Object.assign({
4858
4862
  'Content-Type': 'application/json'
4859
- }, httpHeaders || {})
4863
+ }, httpHeaders || {}, COMMON_HTTP_HEADERS)
4860
4864
  };
4861
4865
 
4862
4866
  try {
@@ -5530,9 +5534,14 @@ const LogsNotificationResult = type({
5530
5534
  * Filter for log subscriptions.
5531
5535
  */
5532
5536
 
5537
+ /** @internal */
5538
+ const COMMON_HTTP_HEADERS = {
5539
+ 'solana-client': `js/${(_process$env$npm_pack = "0.0.0-development") !== null && _process$env$npm_pack !== void 0 ? _process$env$npm_pack : 'UNKNOWN'}`
5540
+ };
5533
5541
  /**
5534
5542
  * A connection to a fullnode JSON RPC endpoint
5535
5543
  */
5544
+
5536
5545
  class Connection {
5537
5546
  /** @internal */
5538
5547
 
@@ -6808,7 +6817,13 @@ class Connection {
6808
6817
  throw new Error('failed to get transactions: ' + res.error.message);
6809
6818
  }
6810
6819
 
6811
- return res.result;
6820
+ const result = res.result;
6821
+ if (!result) return result;
6822
+ return { ...result,
6823
+ transaction: { ...result.transaction,
6824
+ message: new Message(result.transaction.message)
6825
+ }
6826
+ };
6812
6827
  });
6813
6828
  return res;
6814
6829
  }