@solana/web3.js 1.49.0 → 1.51.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solana/web3.js",
3
- "version": "1.49.0",
3
+ "version": "1.51.0",
4
4
  "description": "Solana Javascript API",
5
5
  "keywords": [
6
6
  "api",
@@ -73,7 +73,7 @@
73
73
  "rpc-websockets": "^7.5.0",
74
74
  "secp256k1": "^4.0.2",
75
75
  "superstruct": "^0.14.2",
76
- "tweetnacl": "^1.0.0"
76
+ "tweetnacl": "^1.0.3"
77
77
  },
78
78
  "devDependencies": {
79
79
  "@babel/core": "^7.12.13",
package/src/connection.ts CHANGED
@@ -453,6 +453,14 @@ export type GetBlockConfig = {
453
453
  maxSupportedTransactionVersion?: number;
454
454
  };
455
455
 
456
+ /**
457
+ * Configuration object for changing `getStakeMinimumDelegation` query behavior
458
+ */
459
+ export type GetStakeMinimumDelegationConfig = {
460
+ /** The level of commitment desired */
461
+ commitment?: Commitment;
462
+ };
463
+
456
464
  /**
457
465
  * Configuration object for changing `getBlockHeight` query behavior
458
466
  */
@@ -796,6 +804,14 @@ export type TokenBalance = {
796
804
  */
797
805
  export type ParsedConfirmedTransactionMeta = ParsedTransactionMeta;
798
806
 
807
+ /**
808
+ * Collection of addresses loaded by a transaction using address table lookups
809
+ */
810
+ export type LoadedAddresses = {
811
+ writable: Array<PublicKey>;
812
+ readonly: Array<PublicKey>;
813
+ };
814
+
799
815
  /**
800
816
  * Metadata for a parsed transaction on the ledger
801
817
  */
@@ -816,6 +832,8 @@ export type ParsedTransactionMeta = {
816
832
  postTokenBalances?: Array<TokenBalance> | null;
817
833
  /** The error result of transaction processing */
818
834
  err: TransactionError | null;
835
+ /** The collection of addresses loaded using address lookup tables */
836
+ loadedAddresses?: LoadedAddresses;
819
837
  };
820
838
 
821
839
  export type CompiledInnerInstruction = {
@@ -1786,6 +1804,11 @@ const TokenBalanceResult = pick({
1786
1804
  uiTokenAmount: TokenAmountResult,
1787
1805
  });
1788
1806
 
1807
+ const LoadedAddressesResult = pick({
1808
+ writable: array(PublicKeyFromString),
1809
+ readonly: array(PublicKeyFromString),
1810
+ });
1811
+
1789
1812
  /**
1790
1813
  * @internal
1791
1814
  */
@@ -1813,6 +1836,7 @@ const ConfirmedTransactionMetaResult = pick({
1813
1836
  logMessages: optional(nullable(array(string()))),
1814
1837
  preTokenBalances: optional(nullable(array(TokenBalanceResult))),
1815
1838
  postTokenBalances: optional(nullable(array(TokenBalanceResult))),
1839
+ loadedAddresses: optional(LoadedAddressesResult),
1816
1840
  });
1817
1841
 
1818
1842
  /**
@@ -1836,6 +1860,7 @@ const ParsedConfirmedTransactionMetaResult = pick({
1836
1860
  logMessages: optional(nullable(array(string()))),
1837
1861
  preTokenBalances: optional(nullable(array(TokenBalanceResult))),
1838
1862
  postTokenBalances: optional(nullable(array(TokenBalanceResult))),
1863
+ loadedAddresses: optional(LoadedAddressesResult),
1839
1864
  });
1840
1865
 
1841
1866
  /**
@@ -3739,12 +3764,15 @@ export class Connection {
3739
3764
  */
3740
3765
  async getParsedTransaction(
3741
3766
  signature: TransactionSignature,
3742
- commitment?: Finality,
3767
+ commitmentOrConfig?: GetTransactionConfig | Finality,
3743
3768
  ): Promise<ParsedConfirmedTransaction | null> {
3769
+ const {commitment, config} =
3770
+ extractCommitmentFromConfig(commitmentOrConfig);
3744
3771
  const args = this._buildArgsAtLeastConfirmed(
3745
3772
  [signature],
3746
- commitment,
3773
+ commitment as Finality,
3747
3774
  'jsonParsed',
3775
+ config,
3748
3776
  );
3749
3777
  const unsafeRes = await this._rpcRequest('getTransaction', args);
3750
3778
  const res = create(unsafeRes, GetParsedTransactionRpcResult);
@@ -3759,13 +3787,16 @@ export class Connection {
3759
3787
  */
3760
3788
  async getParsedTransactions(
3761
3789
  signatures: TransactionSignature[],
3762
- commitment?: Finality,
3790
+ commitmentOrConfig?: GetTransactionConfig | Finality,
3763
3791
  ): Promise<(ParsedConfirmedTransaction | null)[]> {
3792
+ const {commitment, config} =
3793
+ extractCommitmentFromConfig(commitmentOrConfig);
3764
3794
  const batch = signatures.map(signature => {
3765
3795
  const args = this._buildArgsAtLeastConfirmed(
3766
3796
  [signature],
3767
- commitment,
3797
+ commitment as Finality,
3768
3798
  'jsonParsed',
3799
+ config,
3769
3800
  );
3770
3801
  return {
3771
3802
  methodName: 'getTransaction',
@@ -3791,10 +3822,17 @@ export class Connection {
3791
3822
  */
3792
3823
  async getTransactions(
3793
3824
  signatures: TransactionSignature[],
3794
- commitment?: Finality,
3825
+ commitmentOrConfig?: GetTransactionConfig | Finality,
3795
3826
  ): Promise<(TransactionResponse | null)[]> {
3827
+ const {commitment, config} =
3828
+ extractCommitmentFromConfig(commitmentOrConfig);
3796
3829
  const batch = signatures.map(signature => {
3797
- const args = this._buildArgsAtLeastConfirmed([signature], commitment);
3830
+ const args = this._buildArgsAtLeastConfirmed(
3831
+ [signature],
3832
+ commitment as Finality,
3833
+ undefined /* encoding */,
3834
+ config,
3835
+ );
3798
3836
  return {
3799
3837
  methodName: 'getTransaction',
3800
3838
  args,
@@ -4304,6 +4342,25 @@ export class Connection {
4304
4342
  }
4305
4343
  }
4306
4344
 
4345
+ /**
4346
+ * get the stake minimum delegation
4347
+ */
4348
+ async getStakeMinimumDelegation(
4349
+ config?: GetStakeMinimumDelegationConfig,
4350
+ ): Promise<RpcResponseAndContext<number>> {
4351
+ const {commitment, config: configArg} = extractCommitmentFromConfig(config);
4352
+ const args = this._buildArgs([], commitment, 'base64', configArg);
4353
+ const unsafeRes = await this._rpcRequest('getStakeMinimumDelegation', args);
4354
+ const res = create(unsafeRes, jsonRpcResultAndContext(number()));
4355
+ if ('error' in res) {
4356
+ throw new SolanaJSONRPCError(
4357
+ res.error,
4358
+ `failed to get stake minimum delegation`,
4359
+ );
4360
+ }
4361
+ return res.result;
4362
+ }
4363
+
4307
4364
  /**
4308
4365
  * Simulate a transaction
4309
4366
  */
@@ -4537,6 +4594,10 @@ export class Connection {
4537
4594
  _wsOnClose(code: number) {
4538
4595
  this._rpcWebSocketConnected = false;
4539
4596
  this._rpcWebSocketGeneration++;
4597
+ if (this._rpcWebSocketIdleTimeout) {
4598
+ clearTimeout(this._rpcWebSocketIdleTimeout);
4599
+ this._rpcWebSocketIdleTimeout = null;
4600
+ }
4540
4601
  if (this._rpcWebSocketHeartbeat) {
4541
4602
  clearInterval(this._rpcWebSocketHeartbeat);
4542
4603
  this._rpcWebSocketHeartbeat = null;