@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.
package/lib/index.cjs.js CHANGED
@@ -2974,10 +2974,6 @@ const GetSignatureStatusesRpcResult = jsonRpcResultAndContext(superstruct.array(
2974
2974
  */
2975
2975
 
2976
2976
  const GetMinimumBalanceForRentExemptionRpcResult = jsonRpcResult(superstruct.number());
2977
- /**
2978
- * @internal
2979
- */
2980
-
2981
2977
  const ConfirmedTransactionResult = superstruct.type({
2982
2978
  signatures: superstruct.array(superstruct.string()),
2983
2979
  message: superstruct.type({
@@ -2995,13 +2991,6 @@ const ConfirmedTransactionResult = superstruct.type({
2995
2991
  recentBlockhash: superstruct.string()
2996
2992
  })
2997
2993
  });
2998
- const TransactionFromConfirmed = superstruct.coerce(superstruct.instance(Transaction), ConfirmedTransactionResult, result => {
2999
- const {
3000
- message,
3001
- signatures
3002
- } = result;
3003
- return Transaction.populate(new Message(message), signatures);
3004
- });
3005
2994
  const ParsedInstructionResult = superstruct.type({
3006
2995
  parsed: superstruct.unknown(),
3007
2996
  program: superstruct.string(),
@@ -3097,7 +3086,7 @@ const GetConfirmedBlockRpcResult = jsonRpcResult(superstruct.nullable(superstruc
3097
3086
  previousBlockhash: superstruct.string(),
3098
3087
  parentSlot: superstruct.number(),
3099
3088
  transactions: superstruct.array(superstruct.type({
3100
- transaction: TransactionFromConfirmed,
3089
+ transaction: ConfirmedTransactionResult,
3101
3090
  meta: superstruct.nullable(ConfirmedTransactionMetaResult)
3102
3091
  })),
3103
3092
  rewards: superstruct.optional(superstruct.array(superstruct.type({
@@ -3125,9 +3114,9 @@ const GetConfirmedBlockSignaturesRpcResult = jsonRpcResult(superstruct.nullable(
3125
3114
 
3126
3115
  const GetConfirmedTransactionRpcResult = jsonRpcResult(superstruct.nullable(superstruct.type({
3127
3116
  slot: superstruct.number(),
3128
- transaction: TransactionFromConfirmed,
3129
3117
  meta: ConfirmedTransactionMetaResult,
3130
- blockTime: superstruct.optional(superstruct.nullable(superstruct.number()))
3118
+ blockTime: superstruct.optional(superstruct.nullable(superstruct.number())),
3119
+ transaction: ConfirmedTransactionResult
3131
3120
  })));
3132
3121
  /**
3133
3122
  * Expected JSON RPC response for the "getConfirmedTransaction" message
@@ -3940,7 +3929,8 @@ class Connection {
3940
3929
  }
3941
3930
  /**
3942
3931
  * Fetch the current total currency supply of the cluster in lamports
3943
- * @deprecated Deprecated since v1.2.8. Use `Connection.getSupply()` instead.
3932
+ *
3933
+ * @deprecated Deprecated since v1.2.8. Please use {@link getSupply} instead.
3944
3934
  */
3945
3935
 
3946
3936
 
@@ -4149,13 +4139,12 @@ class Connection {
4149
4139
  return res.result;
4150
4140
  }
4151
4141
  /**
4152
- * Fetch a list of Transactions and transaction statuses from the cluster
4153
- * for a confirmed block
4142
+ * Fetch a processed block from the cluster.
4154
4143
  */
4155
4144
 
4156
4145
 
4157
- async getConfirmedBlock(slot, commitment) {
4158
- const args = this._buildArgsAtLeastConfirmed([slot], commitment);
4146
+ async getBlock(slot, opts) {
4147
+ const args = this._buildArgsAtLeastConfirmed([slot], opts && opts.commitment);
4159
4148
 
4160
4149
  const unsafeRes = await this._rpcRequest('getConfirmedBlock', args);
4161
4150
  const res = superstruct.create(unsafeRes, GetConfirmedBlockRpcResult);
@@ -4165,12 +4154,73 @@ class Connection {
4165
4154
  }
4166
4155
 
4167
4156
  const result = res.result;
4157
+ if (!result) return result;
4158
+ return { ...result,
4159
+ transactions: result.transactions.map(({
4160
+ transaction,
4161
+ meta
4162
+ }) => {
4163
+ const message = new Message(transaction.message);
4164
+ return {
4165
+ meta,
4166
+ transaction: { ...transaction,
4167
+ message
4168
+ }
4169
+ };
4170
+ })
4171
+ };
4172
+ }
4173
+ /**
4174
+ * Fetch a processed transaction from the cluster.
4175
+ */
4176
+
4177
+
4178
+ async getTransaction(signature, opts) {
4179
+ const args = this._buildArgsAtLeastConfirmed([signature], opts && opts.commitment);
4180
+
4181
+ const unsafeRes = await this._rpcRequest('getConfirmedTransaction', args);
4182
+ const res = superstruct.create(unsafeRes, GetConfirmedTransactionRpcResult);
4183
+
4184
+ if ('error' in res) {
4185
+ throw new Error('failed to get confirmed transaction: ' + res.error.message);
4186
+ }
4187
+
4188
+ const result = res.result;
4189
+ if (!result) return result;
4190
+ return { ...result,
4191
+ transaction: { ...result.transaction,
4192
+ message: new Message(result.transaction.message)
4193
+ }
4194
+ };
4195
+ }
4196
+ /**
4197
+ * Fetch a list of Transactions and transaction statuses from the cluster
4198
+ * for a confirmed block.
4199
+ *
4200
+ * @deprecated Deprecated since v1.13.0. Please use {@link getBlock} instead.
4201
+ */
4202
+
4203
+
4204
+ async getConfirmedBlock(slot, commitment) {
4205
+ const result = await this.getBlock(slot, {
4206
+ commitment
4207
+ });
4168
4208
 
4169
4209
  if (!result) {
4170
4210
  throw new Error('Confirmed block ' + slot + ' not found');
4171
4211
  }
4172
4212
 
4173
- return result;
4213
+ return { ...result,
4214
+ transactions: result.transactions.map(({
4215
+ transaction,
4216
+ meta
4217
+ }) => {
4218
+ return {
4219
+ meta,
4220
+ transaction: Transaction.populate(transaction.message, transaction.signatures)
4221
+ };
4222
+ })
4223
+ };
4174
4224
  }
4175
4225
  /**
4176
4226
  * Fetch a list of Signatures from the cluster for a confirmed block, excluding rewards
@@ -4204,16 +4254,17 @@ class Connection {
4204
4254
 
4205
4255
 
4206
4256
  async getConfirmedTransaction(signature, commitment) {
4207
- const args = this._buildArgsAtLeastConfirmed([signature], commitment);
4208
-
4209
- const unsafeRes = await this._rpcRequest('getConfirmedTransaction', args);
4210
- const res = superstruct.create(unsafeRes, GetConfirmedTransactionRpcResult);
4211
-
4212
- if ('error' in res) {
4213
- throw new Error('failed to get confirmed transaction: ' + res.error.message);
4214
- }
4215
-
4216
- return res.result;
4257
+ const result = await this.getTransaction(signature, {
4258
+ commitment
4259
+ });
4260
+ if (!result) return result;
4261
+ const {
4262
+ message,
4263
+ signatures
4264
+ } = result.transaction;
4265
+ return { ...result,
4266
+ transaction: Transaction.populate(message, signatures)
4267
+ };
4217
4268
  }
4218
4269
  /**
4219
4270
  * Fetch parsed transaction details for a confirmed transaction
@@ -4261,7 +4312,8 @@ class Connection {
4261
4312
  /**
4262
4313
  * Fetch a list of all the confirmed signatures for transactions involving an address
4263
4314
  * within a specified slot range. Max range allowed is 10,000 slots.
4264
- * @deprecated Deprecated since v1.3. Use `Connection.getConfirmedSignaturesForAddress2()` instead.
4315
+ *
4316
+ * @deprecated Deprecated since v1.3. Please use {@link getConfirmedSignaturesForAddress2} instead.
4265
4317
  *
4266
4318
  * @param address queried address
4267
4319
  * @param startSlot start slot, inclusive