@solana/web3.js 1.48.0 → 1.50.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
@@ -7096,8 +7096,15 @@ class Connection {
7096
7096
  */
7097
7097
 
7098
7098
 
7099
- async getBlock(slot, opts) {
7100
- const args = this._buildArgsAtLeastConfirmed([slot], opts && opts.commitment);
7099
+ async getBlock(slot, rawConfig) {
7100
+ const {
7101
+ commitment,
7102
+ config
7103
+ } = extractCommitmentFromConfig(rawConfig);
7104
+
7105
+ const args = this._buildArgsAtLeastConfirmed([slot], commitment, undefined
7106
+ /* encoding */
7107
+ , config);
7101
7108
 
7102
7109
  const unsafeRes = await this._rpcRequest('getBlock', args);
7103
7110
  const res = superstruct.create(unsafeRes, GetBlockRpcResult);
@@ -7183,8 +7190,15 @@ class Connection {
7183
7190
  */
7184
7191
 
7185
7192
 
7186
- async getTransaction(signature, opts) {
7187
- const args = this._buildArgsAtLeastConfirmed([signature], opts && opts.commitment);
7193
+ async getTransaction(signature, rawConfig) {
7194
+ const {
7195
+ commitment,
7196
+ config
7197
+ } = extractCommitmentFromConfig(rawConfig);
7198
+
7199
+ const args = this._buildArgsAtLeastConfirmed([signature], commitment, undefined
7200
+ /* encoding */
7201
+ , config);
7188
7202
 
7189
7203
  const unsafeRes = await this._rpcRequest('getTransaction', args);
7190
7204
  const res = superstruct.create(unsafeRes, GetTransactionRpcResult);
@@ -7206,8 +7220,13 @@ class Connection {
7206
7220
  */
7207
7221
 
7208
7222
 
7209
- async getParsedTransaction(signature, commitment) {
7210
- const args = this._buildArgsAtLeastConfirmed([signature], commitment, 'jsonParsed');
7223
+ async getParsedTransaction(signature, commitmentOrConfig) {
7224
+ const {
7225
+ commitment,
7226
+ config
7227
+ } = extractCommitmentFromConfig(commitmentOrConfig);
7228
+
7229
+ const args = this._buildArgsAtLeastConfirmed([signature], commitment, 'jsonParsed', config);
7211
7230
 
7212
7231
  const unsafeRes = await this._rpcRequest('getTransaction', args);
7213
7232
  const res = superstruct.create(unsafeRes, GetParsedTransactionRpcResult);
@@ -7223,9 +7242,13 @@ class Connection {
7223
7242
  */
7224
7243
 
7225
7244
 
7226
- async getParsedTransactions(signatures, commitment) {
7245
+ async getParsedTransactions(signatures, commitmentOrConfig) {
7246
+ const {
7247
+ commitment,
7248
+ config
7249
+ } = extractCommitmentFromConfig(commitmentOrConfig);
7227
7250
  const batch = signatures.map(signature => {
7228
- const args = this._buildArgsAtLeastConfirmed([signature], commitment, 'jsonParsed');
7251
+ const args = this._buildArgsAtLeastConfirmed([signature], commitment, 'jsonParsed', config);
7229
7252
 
7230
7253
  return {
7231
7254
  methodName: 'getTransaction',
@@ -7250,9 +7273,15 @@ class Connection {
7250
7273
  */
7251
7274
 
7252
7275
 
7253
- async getTransactions(signatures, commitment) {
7276
+ async getTransactions(signatures, commitmentOrConfig) {
7277
+ const {
7278
+ commitment,
7279
+ config
7280
+ } = extractCommitmentFromConfig(commitmentOrConfig);
7254
7281
  const batch = signatures.map(signature => {
7255
- const args = this._buildArgsAtLeastConfirmed([signature], commitment);
7282
+ const args = this._buildArgsAtLeastConfirmed([signature], commitment, undefined
7283
+ /* encoding */
7284
+ , config);
7256
7285
 
7257
7286
  return {
7258
7287
  methodName: 'getTransaction',
@@ -7694,6 +7723,28 @@ class Connection {
7694
7723
  this._pollingBlockhash = false;
7695
7724
  }
7696
7725
  }
7726
+ /**
7727
+ * get the stake minimum delegation
7728
+ */
7729
+
7730
+
7731
+ async getStakeMinimumDelegation(config) {
7732
+ const {
7733
+ commitment,
7734
+ config: configArg
7735
+ } = extractCommitmentFromConfig(config);
7736
+
7737
+ const args = this._buildArgs([], commitment, 'base64', configArg);
7738
+
7739
+ const unsafeRes = await this._rpcRequest('getStakeMinimumDelegation', args);
7740
+ const res = superstruct.create(unsafeRes, jsonRpcResultAndContext(superstruct.number()));
7741
+
7742
+ if ('error' in res) {
7743
+ throw new SolanaJSONRPCError(res.error, `failed to get stake minimum delegation`);
7744
+ }
7745
+
7746
+ return res.result;
7747
+ }
7697
7748
  /**
7698
7749
  * Simulate a transaction
7699
7750
  */
@@ -7925,6 +7976,11 @@ class Connection {
7925
7976
  this._rpcWebSocketConnected = false;
7926
7977
  this._rpcWebSocketGeneration++;
7927
7978
 
7979
+ if (this._rpcWebSocketIdleTimeout) {
7980
+ clearTimeout(this._rpcWebSocketIdleTimeout);
7981
+ this._rpcWebSocketIdleTimeout = null;
7982
+ }
7983
+
7928
7984
  if (this._rpcWebSocketHeartbeat) {
7929
7985
  clearInterval(this._rpcWebSocketHeartbeat);
7930
7986
  this._rpcWebSocketHeartbeat = null;