@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.
@@ -3239,6 +3239,28 @@ function notificationResultAndContext(value) {
3239
3239
  value
3240
3240
  });
3241
3241
  }
3242
+ /**
3243
+ * @internal
3244
+ */
3245
+
3246
+
3247
+ function versionedMessageFromResponse(version, response) {
3248
+ if (version === 0) {
3249
+ return new MessageV0({
3250
+ header: response.header,
3251
+ staticAccountKeys: response.accountKeys.map(accountKey => new PublicKey(accountKey)),
3252
+ recentBlockhash: response.recentBlockhash,
3253
+ compiledInstructions: response.instructions.map(ix => ({
3254
+ programIdIndex: ix.programIdIndex,
3255
+ accountKeyIndexes: ix.accounts,
3256
+ data: bs58__default["default"].decode(ix.data)
3257
+ })),
3258
+ addressTableLookups: response.addressTableLookups
3259
+ });
3260
+ } else {
3261
+ return new Message(response);
3262
+ }
3263
+ }
3242
3264
  /**
3243
3265
  * The level of commitment desired when querying state
3244
3266
  * <pre>
@@ -3794,6 +3816,11 @@ const GetSignatureStatusesRpcResult = jsonRpcResultAndContext(superstruct.array(
3794
3816
  */
3795
3817
 
3796
3818
  const GetMinimumBalanceForRentExemptionRpcResult = jsonRpcResult(superstruct.number());
3819
+ const AddressTableLookupStruct = superstruct.type({
3820
+ accountKey: PublicKeyFromString,
3821
+ writableIndexes: superstruct.array(superstruct.number()),
3822
+ readonlyIndexes: superstruct.array(superstruct.number())
3823
+ });
3797
3824
  const ConfirmedTransactionResult = superstruct.type({
3798
3825
  signatures: superstruct.array(superstruct.string()),
3799
3826
  message: superstruct.type({
@@ -3808,7 +3835,8 @@ const ConfirmedTransactionResult = superstruct.type({
3808
3835
  data: superstruct.string(),
3809
3836
  programIdIndex: superstruct.number()
3810
3837
  })),
3811
- recentBlockhash: superstruct.string()
3838
+ recentBlockhash: superstruct.string(),
3839
+ addressTableLookups: superstruct.optional(superstruct.array(AddressTableLookupStruct))
3812
3840
  })
3813
3841
  });
3814
3842
  const ParsedInstructionResult = superstruct.type({
@@ -3851,7 +3879,8 @@ const ParsedConfirmedTransactionResult = superstruct.type({
3851
3879
  writable: superstruct.boolean()
3852
3880
  })),
3853
3881
  instructions: superstruct.array(ParsedOrRawInstruction),
3854
- recentBlockhash: superstruct.string()
3882
+ recentBlockhash: superstruct.string(),
3883
+ addressTableLookups: superstruct.optional(superstruct.nullable(superstruct.array(AddressTableLookupStruct)))
3855
3884
  })
3856
3885
  });
3857
3886
  const TokenBalanceResult = superstruct.type({
@@ -3884,7 +3913,8 @@ const ConfirmedTransactionMetaResult = superstruct.type({
3884
3913
  logMessages: superstruct.optional(superstruct.nullable(superstruct.array(superstruct.string()))),
3885
3914
  preTokenBalances: superstruct.optional(superstruct.nullable(superstruct.array(TokenBalanceResult))),
3886
3915
  postTokenBalances: superstruct.optional(superstruct.nullable(superstruct.array(TokenBalanceResult))),
3887
- loadedAddresses: superstruct.optional(LoadedAddressesResult)
3916
+ loadedAddresses: superstruct.optional(LoadedAddressesResult),
3917
+ computeUnitsConsumed: superstruct.optional(superstruct.number())
3888
3918
  });
3889
3919
  /**
3890
3920
  * @internal
@@ -3902,8 +3932,10 @@ const ParsedConfirmedTransactionMetaResult = superstruct.type({
3902
3932
  logMessages: superstruct.optional(superstruct.nullable(superstruct.array(superstruct.string()))),
3903
3933
  preTokenBalances: superstruct.optional(superstruct.nullable(superstruct.array(TokenBalanceResult))),
3904
3934
  postTokenBalances: superstruct.optional(superstruct.nullable(superstruct.array(TokenBalanceResult))),
3905
- loadedAddresses: superstruct.optional(LoadedAddressesResult)
3935
+ loadedAddresses: superstruct.optional(LoadedAddressesResult),
3936
+ computeUnitsConsumed: superstruct.optional(superstruct.number())
3906
3937
  });
3938
+ const TransactionVersionStruct = superstruct.union([superstruct.literal(0), superstruct.literal('legacy')]);
3907
3939
  /**
3908
3940
  * Expected JSON RPC response for the "getBlock" message
3909
3941
  */
@@ -3914,7 +3946,8 @@ const GetBlockRpcResult = jsonRpcResult(superstruct.nullable(superstruct.type({
3914
3946
  parentSlot: superstruct.number(),
3915
3947
  transactions: superstruct.array(superstruct.type({
3916
3948
  transaction: ConfirmedTransactionResult,
3917
- meta: superstruct.nullable(ConfirmedTransactionMetaResult)
3949
+ meta: superstruct.nullable(ConfirmedTransactionMetaResult),
3950
+ version: superstruct.optional(TransactionVersionStruct)
3918
3951
  })),
3919
3952
  rewards: superstruct.optional(superstruct.array(superstruct.type({
3920
3953
  pubkey: superstruct.string(),
@@ -3966,7 +3999,8 @@ const GetTransactionRpcResult = jsonRpcResult(superstruct.nullable(superstruct.t
3966
3999
  slot: superstruct.number(),
3967
4000
  meta: ConfirmedTransactionMetaResult,
3968
4001
  blockTime: superstruct.optional(superstruct.nullable(superstruct.number())),
3969
- transaction: ConfirmedTransactionResult
4002
+ transaction: ConfirmedTransactionResult,
4003
+ version: superstruct.optional(TransactionVersionStruct)
3970
4004
  })));
3971
4005
  /**
3972
4006
  * Expected parsed JSON RPC response for the "getTransaction" message
@@ -3976,7 +4010,8 @@ const GetParsedTransactionRpcResult = jsonRpcResult(superstruct.nullable(superst
3976
4010
  slot: superstruct.number(),
3977
4011
  transaction: ParsedConfirmedTransactionResult,
3978
4012
  meta: superstruct.nullable(ParsedConfirmedTransactionMetaResult),
3979
- blockTime: superstruct.optional(superstruct.nullable(superstruct.number()))
4013
+ blockTime: superstruct.optional(superstruct.nullable(superstruct.number())),
4014
+ version: superstruct.optional(TransactionVersionStruct)
3980
4015
  })));
3981
4016
  /**
3982
4017
  * Expected JSON RPC response for the "getRecentBlockhash" message
@@ -5219,9 +5254,16 @@ class Connection {
5219
5254
  }
5220
5255
  /**
5221
5256
  * Fetch a processed block from the cluster.
5257
+ *
5258
+ * @deprecated Instead, call `getBlock` using a `GetVersionedBlockConfig` by
5259
+ * setting the `maxSupportedTransactionVersion` property.
5222
5260
  */
5223
5261
 
5224
5262
 
5263
+ /**
5264
+ * Fetch a processed block from the cluster.
5265
+ */
5266
+ // eslint-disable-next-line no-dupe-class-members
5225
5267
  async getBlock(slot, rawConfig) {
5226
5268
  const {
5227
5269
  commitment,
@@ -5244,16 +5286,15 @@ class Connection {
5244
5286
  return { ...result,
5245
5287
  transactions: result.transactions.map(({
5246
5288
  transaction,
5247
- meta
5248
- }) => {
5249
- const message = new Message(transaction.message);
5250
- return {
5251
- meta,
5252
- transaction: { ...transaction,
5253
- message
5254
- }
5255
- };
5256
- })
5289
+ meta,
5290
+ version
5291
+ }) => ({
5292
+ meta,
5293
+ transaction: { ...transaction,
5294
+ message: versionedMessageFromResponse(version, transaction.message)
5295
+ },
5296
+ version
5297
+ }))
5257
5298
  };
5258
5299
  }
5259
5300
  /*
@@ -5313,9 +5354,17 @@ class Connection {
5313
5354
  }
5314
5355
  /**
5315
5356
  * Fetch a confirmed or finalized transaction from the cluster.
5357
+ *
5358
+ * @deprecated Instead, call `getTransaction` using a
5359
+ * `GetVersionedTransactionConfig` by setting the
5360
+ * `maxSupportedTransactionVersion` property.
5316
5361
  */
5317
5362
 
5318
5363
 
5364
+ /**
5365
+ * Fetch a confirmed or finalized transaction from the cluster.
5366
+ */
5367
+ // eslint-disable-next-line no-dupe-class-members
5319
5368
  async getTransaction(signature, rawConfig) {
5320
5369
  const {
5321
5370
  commitment,
@@ -5337,7 +5386,7 @@ class Connection {
5337
5386
  if (!result) return result;
5338
5387
  return { ...result,
5339
5388
  transaction: { ...result.transaction,
5340
- message: new Message(result.transaction.message)
5389
+ message: versionedMessageFromResponse(result.version, result.transaction.message)
5341
5390
  }
5342
5391
  };
5343
5392
  }
@@ -5396,9 +5445,19 @@ class Connection {
5396
5445
  /**
5397
5446
  * Fetch transaction details for a batch of confirmed transactions.
5398
5447
  * Similar to {@link getParsedTransactions} but returns a {@link TransactionResponse}.
5448
+ *
5449
+ * @deprecated Instead, call `getTransactions` using a
5450
+ * `GetVersionedTransactionConfig` by setting the
5451
+ * `maxSupportedTransactionVersion` property.
5399
5452
  */
5400
5453
 
5401
5454
 
5455
+ /**
5456
+ * Fetch transaction details for a batch of confirmed transactions.
5457
+ * Similar to {@link getParsedTransactions} but returns a {@link
5458
+ * VersionedTransactionResponse}.
5459
+ */
5460
+ // eslint-disable-next-line no-dupe-class-members
5402
5461
  async getTransactions(signatures, commitmentOrConfig) {
5403
5462
  const {
5404
5463
  commitment,
@@ -5426,7 +5485,7 @@ class Connection {
5426
5485
  if (!result) return result;
5427
5486
  return { ...result,
5428
5487
  transaction: { ...result.transaction,
5429
- message: new Message(result.transaction.message)
5488
+ message: versionedMessageFromResponse(result.version, result.transaction.message)
5430
5489
  }
5431
5490
  };
5432
5491
  });