@solana/web3.js 1.13.1 → 1.14.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.
@@ -4876,10 +4876,6 @@ const GetSignatureStatusesRpcResult = jsonRpcResultAndContext(array(nullable(Sig
4876
4876
  */
4877
4877
 
4878
4878
  const GetMinimumBalanceForRentExemptionRpcResult = jsonRpcResult(number());
4879
- /**
4880
- * @internal
4881
- */
4882
-
4883
4879
  const ConfirmedTransactionResult = type({
4884
4880
  signatures: array(string()),
4885
4881
  message: type({
@@ -4897,13 +4893,6 @@ const ConfirmedTransactionResult = type({
4897
4893
  recentBlockhash: string()
4898
4894
  })
4899
4895
  });
4900
- const TransactionFromConfirmed = coerce(instance(Transaction), ConfirmedTransactionResult, result => {
4901
- const {
4902
- message,
4903
- signatures
4904
- } = result;
4905
- return Transaction.populate(new Message(message), signatures);
4906
- });
4907
4896
  const ParsedInstructionResult = type({
4908
4897
  parsed: unknown(),
4909
4898
  program: string(),
@@ -4999,7 +4988,7 @@ const GetConfirmedBlockRpcResult = jsonRpcResult(nullable(type({
4999
4988
  previousBlockhash: string(),
5000
4989
  parentSlot: number(),
5001
4990
  transactions: array(type({
5002
- transaction: TransactionFromConfirmed,
4991
+ transaction: ConfirmedTransactionResult,
5003
4992
  meta: nullable(ConfirmedTransactionMetaResult)
5004
4993
  })),
5005
4994
  rewards: optional(array(type({
@@ -5027,9 +5016,9 @@ const GetConfirmedBlockSignaturesRpcResult = jsonRpcResult(nullable(type({
5027
5016
 
5028
5017
  const GetConfirmedTransactionRpcResult = jsonRpcResult(nullable(type({
5029
5018
  slot: number(),
5030
- transaction: TransactionFromConfirmed,
5031
5019
  meta: ConfirmedTransactionMetaResult,
5032
- blockTime: optional(nullable(number()))
5020
+ blockTime: optional(nullable(number())),
5021
+ transaction: ConfirmedTransactionResult
5033
5022
  })));
5034
5023
  /**
5035
5024
  * Expected JSON RPC response for the "getConfirmedTransaction" message
@@ -5842,7 +5831,8 @@ class Connection {
5842
5831
  }
5843
5832
  /**
5844
5833
  * Fetch the current total currency supply of the cluster in lamports
5845
- * @deprecated Deprecated since v1.2.8. Use `Connection.getSupply()` instead.
5834
+ *
5835
+ * @deprecated Deprecated since v1.2.8. Please use {@link getSupply} instead.
5846
5836
  */
5847
5837
 
5848
5838
 
@@ -6051,13 +6041,12 @@ class Connection {
6051
6041
  return res.result;
6052
6042
  }
6053
6043
  /**
6054
- * Fetch a list of Transactions and transaction statuses from the cluster
6055
- * for a confirmed block
6044
+ * Fetch a processed block from the cluster.
6056
6045
  */
6057
6046
 
6058
6047
 
6059
- async getConfirmedBlock(slot, commitment) {
6060
- const args = this._buildArgsAtLeastConfirmed([slot], commitment);
6048
+ async getBlock(slot, opts) {
6049
+ const args = this._buildArgsAtLeastConfirmed([slot], opts && opts.commitment);
6061
6050
 
6062
6051
  const unsafeRes = await this._rpcRequest('getConfirmedBlock', args);
6063
6052
  const res = create(unsafeRes, GetConfirmedBlockRpcResult);
@@ -6067,12 +6056,73 @@ class Connection {
6067
6056
  }
6068
6057
 
6069
6058
  const result = res.result;
6059
+ if (!result) return result;
6060
+ return { ...result,
6061
+ transactions: result.transactions.map(({
6062
+ transaction,
6063
+ meta
6064
+ }) => {
6065
+ const message = new Message(transaction.message);
6066
+ return {
6067
+ meta,
6068
+ transaction: { ...transaction,
6069
+ message
6070
+ }
6071
+ };
6072
+ })
6073
+ };
6074
+ }
6075
+ /**
6076
+ * Fetch a processed transaction from the cluster.
6077
+ */
6078
+
6079
+
6080
+ async getTransaction(signature, opts) {
6081
+ const args = this._buildArgsAtLeastConfirmed([signature], opts && opts.commitment);
6082
+
6083
+ const unsafeRes = await this._rpcRequest('getConfirmedTransaction', args);
6084
+ const res = create(unsafeRes, GetConfirmedTransactionRpcResult);
6085
+
6086
+ if ('error' in res) {
6087
+ throw new Error('failed to get confirmed transaction: ' + res.error.message);
6088
+ }
6089
+
6090
+ const result = res.result;
6091
+ if (!result) return result;
6092
+ return { ...result,
6093
+ transaction: { ...result.transaction,
6094
+ message: new Message(result.transaction.message)
6095
+ }
6096
+ };
6097
+ }
6098
+ /**
6099
+ * Fetch a list of Transactions and transaction statuses from the cluster
6100
+ * for a confirmed block.
6101
+ *
6102
+ * @deprecated Deprecated since v1.13.0. Please use {@link getBlock} instead.
6103
+ */
6104
+
6105
+
6106
+ async getConfirmedBlock(slot, commitment) {
6107
+ const result = await this.getBlock(slot, {
6108
+ commitment
6109
+ });
6070
6110
 
6071
6111
  if (!result) {
6072
6112
  throw new Error('Confirmed block ' + slot + ' not found');
6073
6113
  }
6074
6114
 
6075
- return result;
6115
+ return { ...result,
6116
+ transactions: result.transactions.map(({
6117
+ transaction,
6118
+ meta
6119
+ }) => {
6120
+ return {
6121
+ meta,
6122
+ transaction: Transaction.populate(transaction.message, transaction.signatures)
6123
+ };
6124
+ })
6125
+ };
6076
6126
  }
6077
6127
  /**
6078
6128
  * Fetch a list of Signatures from the cluster for a confirmed block, excluding rewards
@@ -6106,16 +6156,17 @@ class Connection {
6106
6156
 
6107
6157
 
6108
6158
  async getConfirmedTransaction(signature, commitment) {
6109
- const args = this._buildArgsAtLeastConfirmed([signature], commitment);
6110
-
6111
- const unsafeRes = await this._rpcRequest('getConfirmedTransaction', args);
6112
- const res = create(unsafeRes, GetConfirmedTransactionRpcResult);
6113
-
6114
- if ('error' in res) {
6115
- throw new Error('failed to get confirmed transaction: ' + res.error.message);
6116
- }
6117
-
6118
- return res.result;
6159
+ const result = await this.getTransaction(signature, {
6160
+ commitment
6161
+ });
6162
+ if (!result) return result;
6163
+ const {
6164
+ message,
6165
+ signatures
6166
+ } = result.transaction;
6167
+ return { ...result,
6168
+ transaction: Transaction.populate(message, signatures)
6169
+ };
6119
6170
  }
6120
6171
  /**
6121
6172
  * Fetch parsed transaction details for a confirmed transaction
@@ -6163,7 +6214,8 @@ class Connection {
6163
6214
  /**
6164
6215
  * Fetch a list of all the confirmed signatures for transactions involving an address
6165
6216
  * within a specified slot range. Max range allowed is 10,000 slots.
6166
- * @deprecated Deprecated since v1.3. Use `Connection.getConfirmedSignaturesForAddress2()` instead.
6217
+ *
6218
+ * @deprecated Deprecated since v1.3. Please use {@link getConfirmedSignaturesForAddress2} instead.
6167
6219
  *
6168
6220
  * @param address queried address
6169
6221
  * @param startSlot start slot, inclusive