@solana/web3.js 1.32.0 → 1.32.1

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
@@ -14832,7 +14832,8 @@ var solanaWeb3 = (function (exports) {
14832
14832
  async function sendAndConfirmTransaction(connection, transaction, signers, options) {
14833
14833
  const sendOptions = options && {
14834
14834
  skipPreflight: options.skipPreflight,
14835
- preflightCommitment: options.preflightCommitment || options.commitment
14835
+ preflightCommitment: options.preflightCommitment || options.commitment,
14836
+ maxRetries: options.maxRetries
14836
14837
  };
14837
14838
  const signature = await connection.sendTransaction(transaction, signers, sendOptions);
14838
14839
  const status = (await connection.confirmTransaction(signature, options && options.commitment)).value;
@@ -20400,8 +20401,31 @@ var solanaWeb3 = (function (exports) {
20400
20401
  preTokenBalances: optional(nullable(array(TokenBalanceResult))),
20401
20402
  postTokenBalances: optional(nullable(array(TokenBalanceResult)))
20402
20403
  });
20404
+ /**
20405
+ * Expected JSON RPC response for the "getBlock" message
20406
+ */
20407
+
20408
+ const GetBlockRpcResult = jsonRpcResult(nullable(type({
20409
+ blockhash: string(),
20410
+ previousBlockhash: string(),
20411
+ parentSlot: number(),
20412
+ transactions: array(type({
20413
+ transaction: ConfirmedTransactionResult,
20414
+ meta: nullable(ConfirmedTransactionMetaResult)
20415
+ })),
20416
+ rewards: optional(array(type({
20417
+ pubkey: string(),
20418
+ lamports: number(),
20419
+ postBalance: nullable(number()),
20420
+ rewardType: nullable(string())
20421
+ }))),
20422
+ blockTime: nullable(number()),
20423
+ blockHeight: nullable(number())
20424
+ })));
20403
20425
  /**
20404
20426
  * Expected JSON RPC response for the "getConfirmedBlock" message
20427
+ *
20428
+ * @deprecated Deprecated since Solana v1.8.0. Please use {@link GetBlockRpcResult} instead.
20405
20429
  */
20406
20430
 
20407
20431
  const GetConfirmedBlockRpcResult = jsonRpcResult(nullable(type({
@@ -20421,10 +20445,10 @@ var solanaWeb3 = (function (exports) {
20421
20445
  blockTime: nullable(number())
20422
20446
  })));
20423
20447
  /**
20424
- * Expected JSON RPC response for the "getConfirmedBlockSignatures" message
20448
+ * Expected JSON RPC response for the "getBlock" message
20425
20449
  */
20426
20450
 
20427
- const GetConfirmedBlockSignaturesRpcResult = jsonRpcResult(nullable(type({
20451
+ const GetBlockSignaturesRpcResult = jsonRpcResult(nullable(type({
20428
20452
  blockhash: string(),
20429
20453
  previousBlockhash: string(),
20430
20454
  parentSlot: number(),
@@ -20432,20 +20456,20 @@ var solanaWeb3 = (function (exports) {
20432
20456
  blockTime: nullable(number())
20433
20457
  })));
20434
20458
  /**
20435
- * Expected JSON RPC response for the "getConfirmedTransaction" message
20459
+ * Expected JSON RPC response for the "getTransaction" message
20436
20460
  */
20437
20461
 
20438
- const GetConfirmedTransactionRpcResult = jsonRpcResult(nullable(type({
20462
+ const GetTransactionRpcResult = jsonRpcResult(nullable(type({
20439
20463
  slot: number(),
20440
20464
  meta: ConfirmedTransactionMetaResult,
20441
20465
  blockTime: optional(nullable(number())),
20442
20466
  transaction: ConfirmedTransactionResult
20443
20467
  })));
20444
20468
  /**
20445
- * Expected JSON RPC response for the "getConfirmedTransaction" message
20469
+ * Expected parsed JSON RPC response for the "getTransaction" message
20446
20470
  */
20447
20471
 
20448
- const GetParsedConfirmedTransactionRpcResult = jsonRpcResult(nullable(type({
20472
+ const GetParsedTransactionRpcResult = jsonRpcResult(nullable(type({
20449
20473
  slot: number(),
20450
20474
  transaction: ParsedConfirmedTransactionResult,
20451
20475
  meta: nullable(ParsedConfirmedTransactionMetaResult),
@@ -20453,6 +20477,8 @@ var solanaWeb3 = (function (exports) {
20453
20477
  })));
20454
20478
  /**
20455
20479
  * Expected JSON RPC response for the "getRecentBlockhash" message
20480
+ *
20481
+ * @deprecated Deprecated since Solana v1.8.0. Please use {@link GetLatestBlockhashRpcResult} instead.
20456
20482
  */
20457
20483
 
20458
20484
  const GetRecentBlockhashAndContextRpcResult = jsonRpcResultAndContext(type({
@@ -20461,6 +20487,14 @@ var solanaWeb3 = (function (exports) {
20461
20487
  lamportsPerSignature: number()
20462
20488
  })
20463
20489
  }));
20490
+ /**
20491
+ * Expected JSON RPC response for the "getLatestBlockhash" message
20492
+ */
20493
+
20494
+ const GetLatestBlockhashRpcResult = jsonRpcResultAndContext(type({
20495
+ blockhash: string(),
20496
+ lastValidBlockHeight: number()
20497
+ }));
20464
20498
  const PerfSampleResult = type({
20465
20499
  slot: number(),
20466
20500
  numTransactions: number(),
@@ -21405,6 +21439,8 @@ var solanaWeb3 = (function (exports) {
21405
21439
  /**
21406
21440
  * Fetch a recent blockhash from the cluster, return with context
21407
21441
  * @return {Promise<RpcResponseAndContext<{blockhash: Blockhash, feeCalculator: FeeCalculator}>>}
21442
+ *
21443
+ * @deprecated Deprecated since Solana v1.8.0. Please use {@link getLatestBlockhash} instead.
21408
21444
  */
21409
21445
 
21410
21446
 
@@ -21440,6 +21476,8 @@ var solanaWeb3 = (function (exports) {
21440
21476
  }
21441
21477
  /**
21442
21478
  * Fetch the fee calculator for a recent blockhash from the cluster, return with context
21479
+ *
21480
+ * @deprecated Deprecated since Solana v1.8.0. Please use {@link getFeeForMessage} instead.
21443
21481
  */
21444
21482
 
21445
21483
 
@@ -21488,6 +21526,8 @@ var solanaWeb3 = (function (exports) {
21488
21526
  /**
21489
21527
  * Fetch a recent blockhash from the cluster
21490
21528
  * @return {Promise<{blockhash: Blockhash, feeCalculator: FeeCalculator}>}
21529
+ *
21530
+ * @deprecated Deprecated since Solana v1.8.0. Please use {@link getLatestBlockhash} instead.
21491
21531
  */
21492
21532
 
21493
21533
 
@@ -21499,6 +21539,38 @@ var solanaWeb3 = (function (exports) {
21499
21539
  throw new Error('failed to get recent blockhash: ' + e);
21500
21540
  }
21501
21541
  }
21542
+ /**
21543
+ * Fetch the latest blockhash from the cluster
21544
+ * @return {Promise<{blockhash: Blockhash, lastValidBlockHeight: number}>}
21545
+ */
21546
+
21547
+
21548
+ async getLatestBlockhash(commitment) {
21549
+ try {
21550
+ const res = await this.getLatestBlockhashAndContext(commitment);
21551
+ return res.value;
21552
+ } catch (e) {
21553
+ throw new Error('failed to get recent blockhash: ' + e);
21554
+ }
21555
+ }
21556
+ /**
21557
+ * Fetch the latest blockhash from the cluster
21558
+ * @return {Promise<{blockhash: Blockhash, lastValidBlockHeight: number}>}
21559
+ */
21560
+
21561
+
21562
+ async getLatestBlockhashAndContext(commitment) {
21563
+ const args = this._buildArgs([], commitment);
21564
+
21565
+ const unsafeRes = await this._rpcRequest('getLatestBlockhash', args);
21566
+ const res = create(unsafeRes, GetLatestBlockhashRpcResult);
21567
+
21568
+ if ('error' in res) {
21569
+ throw new Error('failed to get latest blockhash: ' + res.error.message);
21570
+ }
21571
+
21572
+ return res.result;
21573
+ }
21502
21574
  /**
21503
21575
  * Fetch the node version
21504
21576
  */
@@ -21537,8 +21609,8 @@ var solanaWeb3 = (function (exports) {
21537
21609
  async getBlock(slot, opts) {
21538
21610
  const args = this._buildArgsAtLeastConfirmed([slot], opts && opts.commitment);
21539
21611
 
21540
- const unsafeRes = await this._rpcRequest('getConfirmedBlock', args);
21541
- const res = create(unsafeRes, GetConfirmedBlockRpcResult);
21612
+ const unsafeRes = await this._rpcRequest('getBlock', args);
21613
+ const res = create(unsafeRes, GetBlockRpcResult);
21542
21614
 
21543
21615
  if ('error' in res) {
21544
21616
  throw new Error('failed to get confirmed block: ' + res.error.message);
@@ -21562,18 +21634,18 @@ var solanaWeb3 = (function (exports) {
21562
21634
  };
21563
21635
  }
21564
21636
  /**
21565
- * Fetch a processed transaction from the cluster.
21637
+ * Fetch a confirmed or finalized transaction from the cluster.
21566
21638
  */
21567
21639
 
21568
21640
 
21569
21641
  async getTransaction(signature, opts) {
21570
21642
  const args = this._buildArgsAtLeastConfirmed([signature], opts && opts.commitment);
21571
21643
 
21572
- const unsafeRes = await this._rpcRequest('getConfirmedTransaction', args);
21573
- const res = create(unsafeRes, GetConfirmedTransactionRpcResult);
21644
+ const unsafeRes = await this._rpcRequest('getTransaction', args);
21645
+ const res = create(unsafeRes, GetTransactionRpcResult);
21574
21646
 
21575
21647
  if ('error' in res) {
21576
- throw new Error('failed to get confirmed transaction: ' + res.error.message);
21648
+ throw new Error('failed to get transaction: ' + res.error.message);
21577
21649
  }
21578
21650
 
21579
21651
  const result = res.result;
@@ -21584,6 +21656,49 @@ var solanaWeb3 = (function (exports) {
21584
21656
  }
21585
21657
  };
21586
21658
  }
21659
+ /**
21660
+ * Fetch parsed transaction details for a confirmed or finalized transaction
21661
+ */
21662
+
21663
+
21664
+ async getParsedTransaction(signature, commitment) {
21665
+ const args = this._buildArgsAtLeastConfirmed([signature], commitment, 'jsonParsed');
21666
+
21667
+ const unsafeRes = await this._rpcRequest('getTransaction', args);
21668
+ const res = create(unsafeRes, GetParsedTransactionRpcResult);
21669
+
21670
+ if ('error' in res) {
21671
+ throw new Error('failed to get transaction: ' + res.error.message);
21672
+ }
21673
+
21674
+ return res.result;
21675
+ }
21676
+ /**
21677
+ * Fetch parsed transaction details for a batch of confirmed transactions
21678
+ */
21679
+
21680
+
21681
+ async getParsedTransactions(signatures, commitment) {
21682
+ const batch = signatures.map(signature => {
21683
+ const args = this._buildArgsAtLeastConfirmed([signature], commitment, 'jsonParsed');
21684
+
21685
+ return {
21686
+ methodName: 'getTransaction',
21687
+ args
21688
+ };
21689
+ });
21690
+ const unsafeRes = await this._rpcBatchRequest(batch);
21691
+ const res = unsafeRes.map(unsafeRes => {
21692
+ const res = create(unsafeRes, GetParsedTransactionRpcResult);
21693
+
21694
+ if ('error' in res) {
21695
+ throw new Error('failed to get transactions: ' + res.error.message);
21696
+ }
21697
+
21698
+ return res.result;
21699
+ });
21700
+ return res;
21701
+ }
21587
21702
  /**
21588
21703
  * Fetch a list of Transactions and transaction statuses from the cluster
21589
21704
  * for a confirmed block.
@@ -21593,18 +21708,39 @@ var solanaWeb3 = (function (exports) {
21593
21708
 
21594
21709
 
21595
21710
  async getConfirmedBlock(slot, commitment) {
21596
- const result = await this.getBlock(slot, {
21597
- commitment
21598
- });
21711
+ const args = this._buildArgsAtLeastConfirmed([slot], commitment);
21712
+
21713
+ const unsafeRes = await this._rpcRequest('getConfirmedBlock', args);
21714
+ const res = create(unsafeRes, GetConfirmedBlockRpcResult);
21715
+
21716
+ if ('error' in res) {
21717
+ throw new Error('failed to get confirmed block: ' + res.error.message);
21718
+ }
21719
+
21720
+ const result = res.result;
21599
21721
 
21600
21722
  if (!result) {
21601
21723
  throw new Error('Confirmed block ' + slot + ' not found');
21602
21724
  }
21603
21725
 
21604
- return { ...result,
21726
+ const block = { ...result,
21605
21727
  transactions: result.transactions.map(({
21606
21728
  transaction,
21607
21729
  meta
21730
+ }) => {
21731
+ const message = new Message(transaction.message);
21732
+ return {
21733
+ meta,
21734
+ transaction: { ...transaction,
21735
+ message
21736
+ }
21737
+ };
21738
+ })
21739
+ };
21740
+ return { ...block,
21741
+ transactions: block.transactions.map(({
21742
+ transaction,
21743
+ meta
21608
21744
  }) => {
21609
21745
  return {
21610
21746
  meta,
@@ -21621,7 +21757,7 @@ var solanaWeb3 = (function (exports) {
21621
21757
  async getBlocks(startSlot, endSlot, commitment) {
21622
21758
  const args = this._buildArgsAtLeastConfirmed(endSlot !== undefined ? [startSlot, endSlot] : [startSlot], commitment);
21623
21759
 
21624
- const unsafeRes = await this._rpcRequest('getConfirmedBlocks', args);
21760
+ const unsafeRes = await this._rpcRequest('getBlocks', args);
21625
21761
  const res = create(unsafeRes, jsonRpcResult(array(number())));
21626
21762
 
21627
21763
  if ('error' in res) {
@@ -21630,8 +21766,36 @@ var solanaWeb3 = (function (exports) {
21630
21766
 
21631
21767
  return res.result;
21632
21768
  }
21769
+ /**
21770
+ * Fetch a list of Signatures from the cluster for a block, excluding rewards
21771
+ */
21772
+
21773
+
21774
+ async getBlockSignatures(slot, commitment) {
21775
+ const args = this._buildArgsAtLeastConfirmed([slot], commitment, undefined, {
21776
+ transactionDetails: 'signatures',
21777
+ rewards: false
21778
+ });
21779
+
21780
+ const unsafeRes = await this._rpcRequest('getBlock', args);
21781
+ const res = create(unsafeRes, GetBlockSignaturesRpcResult);
21782
+
21783
+ if ('error' in res) {
21784
+ throw new Error('failed to get block: ' + res.error.message);
21785
+ }
21786
+
21787
+ const result = res.result;
21788
+
21789
+ if (!result) {
21790
+ throw new Error('Block ' + slot + ' not found');
21791
+ }
21792
+
21793
+ return result;
21794
+ }
21633
21795
  /**
21634
21796
  * Fetch a list of Signatures from the cluster for a confirmed block, excluding rewards
21797
+ *
21798
+ * @deprecated Deprecated since Solana v1.8.0. Please use {@link getBlockSignatures} instead.
21635
21799
  */
21636
21800
 
21637
21801
 
@@ -21642,7 +21806,7 @@ var solanaWeb3 = (function (exports) {
21642
21806
  });
21643
21807
 
21644
21808
  const unsafeRes = await this._rpcRequest('getConfirmedBlock', args);
21645
- const res = create(unsafeRes, GetConfirmedBlockSignaturesRpcResult);
21809
+ const res = create(unsafeRes, GetBlockSignaturesRpcResult);
21646
21810
 
21647
21811
  if ('error' in res) {
21648
21812
  throw new Error('failed to get confirmed block: ' + res.error.message);
@@ -21658,24 +21822,33 @@ var solanaWeb3 = (function (exports) {
21658
21822
  }
21659
21823
  /**
21660
21824
  * Fetch a transaction details for a confirmed transaction
21825
+ *
21826
+ * @deprecated Deprecated since Solana v1.8.0. Please use {@link getTransaction} instead.
21661
21827
  */
21662
21828
 
21663
21829
 
21664
21830
  async getConfirmedTransaction(signature, commitment) {
21665
- const result = await this.getTransaction(signature, {
21666
- commitment
21667
- });
21831
+ const args = this._buildArgsAtLeastConfirmed([signature], commitment);
21832
+
21833
+ const unsafeRes = await this._rpcRequest('getConfirmedTransaction', args);
21834
+ const res = create(unsafeRes, GetTransactionRpcResult);
21835
+
21836
+ if ('error' in res) {
21837
+ throw new Error('failed to get transaction: ' + res.error.message);
21838
+ }
21839
+
21840
+ const result = res.result;
21668
21841
  if (!result) return result;
21669
- const {
21670
- message,
21671
- signatures
21672
- } = result.transaction;
21842
+ const message = new Message(result.transaction.message);
21843
+ const signatures = result.transaction.signatures;
21673
21844
  return { ...result,
21674
21845
  transaction: Transaction.populate(message, signatures)
21675
21846
  };
21676
21847
  }
21677
21848
  /**
21678
21849
  * Fetch parsed transaction details for a confirmed transaction
21850
+ *
21851
+ * @deprecated Deprecated since Solana v1.8.0. Please use {@link getParsedTransaction} instead.
21679
21852
  */
21680
21853
 
21681
21854
 
@@ -21683,7 +21856,7 @@ var solanaWeb3 = (function (exports) {
21683
21856
  const args = this._buildArgsAtLeastConfirmed([signature], commitment, 'jsonParsed');
21684
21857
 
21685
21858
  const unsafeRes = await this._rpcRequest('getConfirmedTransaction', args);
21686
- const res = create(unsafeRes, GetParsedConfirmedTransactionRpcResult);
21859
+ const res = create(unsafeRes, GetParsedTransactionRpcResult);
21687
21860
 
21688
21861
  if ('error' in res) {
21689
21862
  throw new Error('failed to get confirmed transaction: ' + res.error.message);
@@ -21693,6 +21866,8 @@ var solanaWeb3 = (function (exports) {
21693
21866
  }
21694
21867
  /**
21695
21868
  * Fetch parsed transaction details for a batch of confirmed transactions
21869
+ *
21870
+ * @deprecated Deprecated since Solana v1.8.0. Please use {@link getParsedTransactions} instead.
21696
21871
  */
21697
21872
 
21698
21873
 
@@ -21707,7 +21882,7 @@ var solanaWeb3 = (function (exports) {
21707
21882
  });
21708
21883
  const unsafeRes = await this._rpcBatchRequest(batch);
21709
21884
  const res = unsafeRes.map(unsafeRes => {
21710
- const res = create(unsafeRes, GetParsedConfirmedTransactionRpcResult);
21885
+ const res = create(unsafeRes, GetParsedTransactionRpcResult);
21711
21886
 
21712
21887
  if ('error' in res) {
21713
21888
  throw new Error('failed to get confirmed transactions: ' + res.error.message);
@@ -22097,6 +22272,10 @@ var solanaWeb3 = (function (exports) {
22097
22272
  const skipPreflight = options && options.skipPreflight;
22098
22273
  const preflightCommitment = options && options.preflightCommitment || this.commitment;
22099
22274
 
22275
+ if (options && options.maxRetries) {
22276
+ config.maxRetries = options.maxRetries;
22277
+ }
22278
+
22100
22279
  if (skipPreflight) {
22101
22280
  config.skipPreflight = skipPreflight;
22102
22281
  }
@@ -28925,12 +29104,12 @@ var solanaWeb3 = (function (exports) {
28925
29104
  http: {
28926
29105
  devnet: 'http://api.devnet.solana.com',
28927
29106
  testnet: 'http://api.testnet.solana.com',
28928
- 'mainnet-beta': 'http://api.mainnet-beta.solana.com'
29107
+ 'mainnet-beta': 'http://api.mainnet-beta.solana.com/'
28929
29108
  },
28930
29109
  https: {
28931
29110
  devnet: 'https://api.devnet.solana.com',
28932
29111
  testnet: 'https://api.testnet.solana.com',
28933
- 'mainnet-beta': 'https://api.mainnet-beta.solana.com'
29112
+ 'mainnet-beta': 'https://api.mainnet-beta.solana.com/'
28934
29113
  }
28935
29114
  };
28936
29115