@solana/web3.js 1.55.0 → 1.56.2

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.
@@ -3208,6 +3208,28 @@ function notificationResultAndContext(value) {
3208
3208
  value
3209
3209
  });
3210
3210
  }
3211
+ /**
3212
+ * @internal
3213
+ */
3214
+
3215
+
3216
+ function versionedMessageFromResponse(version, response) {
3217
+ if (version === 0) {
3218
+ return new MessageV0({
3219
+ header: response.header,
3220
+ staticAccountKeys: response.accountKeys.map(accountKey => new PublicKey(accountKey)),
3221
+ recentBlockhash: response.recentBlockhash,
3222
+ compiledInstructions: response.instructions.map(ix => ({
3223
+ programIdIndex: ix.programIdIndex,
3224
+ accountKeyIndexes: ix.accounts,
3225
+ data: bs58.decode(ix.data)
3226
+ })),
3227
+ addressTableLookups: response.addressTableLookups
3228
+ });
3229
+ } else {
3230
+ return new Message(response);
3231
+ }
3232
+ }
3211
3233
  /**
3212
3234
  * The level of commitment desired when querying state
3213
3235
  * <pre>
@@ -3763,6 +3785,11 @@ const GetSignatureStatusesRpcResult = jsonRpcResultAndContext(array(nullable(Sig
3763
3785
  */
3764
3786
 
3765
3787
  const GetMinimumBalanceForRentExemptionRpcResult = jsonRpcResult(number());
3788
+ const AddressTableLookupStruct = type({
3789
+ accountKey: PublicKeyFromString,
3790
+ writableIndexes: array(number()),
3791
+ readonlyIndexes: array(number())
3792
+ });
3766
3793
  const ConfirmedTransactionResult = type({
3767
3794
  signatures: array(string()),
3768
3795
  message: type({
@@ -3777,7 +3804,8 @@ const ConfirmedTransactionResult = type({
3777
3804
  data: string(),
3778
3805
  programIdIndex: number()
3779
3806
  })),
3780
- recentBlockhash: string()
3807
+ recentBlockhash: string(),
3808
+ addressTableLookups: optional(array(AddressTableLookupStruct))
3781
3809
  })
3782
3810
  });
3783
3811
  const ParsedInstructionResult = type({
@@ -3820,7 +3848,8 @@ const ParsedConfirmedTransactionResult = type({
3820
3848
  writable: boolean()
3821
3849
  })),
3822
3850
  instructions: array(ParsedOrRawInstruction),
3823
- recentBlockhash: string()
3851
+ recentBlockhash: string(),
3852
+ addressTableLookups: optional(nullable(array(AddressTableLookupStruct)))
3824
3853
  })
3825
3854
  });
3826
3855
  const TokenBalanceResult = type({
@@ -3853,7 +3882,8 @@ const ConfirmedTransactionMetaResult = type({
3853
3882
  logMessages: optional(nullable(array(string()))),
3854
3883
  preTokenBalances: optional(nullable(array(TokenBalanceResult))),
3855
3884
  postTokenBalances: optional(nullable(array(TokenBalanceResult))),
3856
- loadedAddresses: optional(LoadedAddressesResult)
3885
+ loadedAddresses: optional(LoadedAddressesResult),
3886
+ computeUnitsConsumed: optional(number())
3857
3887
  });
3858
3888
  /**
3859
3889
  * @internal
@@ -3871,8 +3901,10 @@ const ParsedConfirmedTransactionMetaResult = type({
3871
3901
  logMessages: optional(nullable(array(string()))),
3872
3902
  preTokenBalances: optional(nullable(array(TokenBalanceResult))),
3873
3903
  postTokenBalances: optional(nullable(array(TokenBalanceResult))),
3874
- loadedAddresses: optional(LoadedAddressesResult)
3904
+ loadedAddresses: optional(LoadedAddressesResult),
3905
+ computeUnitsConsumed: optional(number())
3875
3906
  });
3907
+ const TransactionVersionStruct = union([literal(0), literal('legacy')]);
3876
3908
  /**
3877
3909
  * Expected JSON RPC response for the "getBlock" message
3878
3910
  */
@@ -3883,7 +3915,8 @@ const GetBlockRpcResult = jsonRpcResult(nullable(type({
3883
3915
  parentSlot: number(),
3884
3916
  transactions: array(type({
3885
3917
  transaction: ConfirmedTransactionResult,
3886
- meta: nullable(ConfirmedTransactionMetaResult)
3918
+ meta: nullable(ConfirmedTransactionMetaResult),
3919
+ version: optional(TransactionVersionStruct)
3887
3920
  })),
3888
3921
  rewards: optional(array(type({
3889
3922
  pubkey: string(),
@@ -3935,7 +3968,8 @@ const GetTransactionRpcResult = jsonRpcResult(nullable(type({
3935
3968
  slot: number(),
3936
3969
  meta: ConfirmedTransactionMetaResult,
3937
3970
  blockTime: optional(nullable(number())),
3938
- transaction: ConfirmedTransactionResult
3971
+ transaction: ConfirmedTransactionResult,
3972
+ version: optional(TransactionVersionStruct)
3939
3973
  })));
3940
3974
  /**
3941
3975
  * Expected parsed JSON RPC response for the "getTransaction" message
@@ -3945,7 +3979,8 @@ const GetParsedTransactionRpcResult = jsonRpcResult(nullable(type({
3945
3979
  slot: number(),
3946
3980
  transaction: ParsedConfirmedTransactionResult,
3947
3981
  meta: nullable(ParsedConfirmedTransactionMetaResult),
3948
- blockTime: optional(nullable(number()))
3982
+ blockTime: optional(nullable(number())),
3983
+ version: optional(TransactionVersionStruct)
3949
3984
  })));
3950
3985
  /**
3951
3986
  * Expected JSON RPC response for the "getRecentBlockhash" message
@@ -5188,9 +5223,16 @@ class Connection {
5188
5223
  }
5189
5224
  /**
5190
5225
  * Fetch a processed block from the cluster.
5226
+ *
5227
+ * @deprecated Instead, call `getBlock` using a `GetVersionedBlockConfig` by
5228
+ * setting the `maxSupportedTransactionVersion` property.
5191
5229
  */
5192
5230
 
5193
5231
 
5232
+ /**
5233
+ * Fetch a processed block from the cluster.
5234
+ */
5235
+ // eslint-disable-next-line no-dupe-class-members
5194
5236
  async getBlock(slot, rawConfig) {
5195
5237
  const {
5196
5238
  commitment,
@@ -5213,16 +5255,15 @@ class Connection {
5213
5255
  return { ...result,
5214
5256
  transactions: result.transactions.map(({
5215
5257
  transaction,
5216
- meta
5217
- }) => {
5218
- const message = new Message(transaction.message);
5219
- return {
5220
- meta,
5221
- transaction: { ...transaction,
5222
- message
5223
- }
5224
- };
5225
- })
5258
+ meta,
5259
+ version
5260
+ }) => ({
5261
+ meta,
5262
+ transaction: { ...transaction,
5263
+ message: versionedMessageFromResponse(version, transaction.message)
5264
+ },
5265
+ version
5266
+ }))
5226
5267
  };
5227
5268
  }
5228
5269
  /*
@@ -5282,9 +5323,17 @@ class Connection {
5282
5323
  }
5283
5324
  /**
5284
5325
  * Fetch a confirmed or finalized transaction from the cluster.
5326
+ *
5327
+ * @deprecated Instead, call `getTransaction` using a
5328
+ * `GetVersionedTransactionConfig` by setting the
5329
+ * `maxSupportedTransactionVersion` property.
5285
5330
  */
5286
5331
 
5287
5332
 
5333
+ /**
5334
+ * Fetch a confirmed or finalized transaction from the cluster.
5335
+ */
5336
+ // eslint-disable-next-line no-dupe-class-members
5288
5337
  async getTransaction(signature, rawConfig) {
5289
5338
  const {
5290
5339
  commitment,
@@ -5306,7 +5355,7 @@ class Connection {
5306
5355
  if (!result) return result;
5307
5356
  return { ...result,
5308
5357
  transaction: { ...result.transaction,
5309
- message: new Message(result.transaction.message)
5358
+ message: versionedMessageFromResponse(result.version, result.transaction.message)
5310
5359
  }
5311
5360
  };
5312
5361
  }
@@ -5365,9 +5414,19 @@ class Connection {
5365
5414
  /**
5366
5415
  * Fetch transaction details for a batch of confirmed transactions.
5367
5416
  * Similar to {@link getParsedTransactions} but returns a {@link TransactionResponse}.
5417
+ *
5418
+ * @deprecated Instead, call `getTransactions` using a
5419
+ * `GetVersionedTransactionConfig` by setting the
5420
+ * `maxSupportedTransactionVersion` property.
5368
5421
  */
5369
5422
 
5370
5423
 
5424
+ /**
5425
+ * Fetch transaction details for a batch of confirmed transactions.
5426
+ * Similar to {@link getParsedTransactions} but returns a {@link
5427
+ * VersionedTransactionResponse}.
5428
+ */
5429
+ // eslint-disable-next-line no-dupe-class-members
5371
5430
  async getTransactions(signatures, commitmentOrConfig) {
5372
5431
  const {
5373
5432
  commitment,
@@ -5395,7 +5454,7 @@ class Connection {
5395
5454
  if (!result) return result;
5396
5455
  return { ...result,
5397
5456
  transaction: { ...result.transaction,
5398
- message: new Message(result.transaction.message)
5457
+ message: versionedMessageFromResponse(result.version, result.transaction.message)
5399
5458
  }
5400
5459
  };
5401
5460
  });