@solana/web3.js 1.2.8 → 1.3.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.
@@ -4640,11 +4640,6 @@ const StakeActivationResult = type({
4640
4640
  active: number(),
4641
4641
  inactive: number()
4642
4642
  });
4643
- /**
4644
- * Expected JSON RPC response for the "getConfirmedSignaturesForAddress" message
4645
- */
4646
-
4647
- const GetConfirmedSignaturesForAddressRpcResult = jsonRpcResult(array(string()));
4648
4643
  /**
4649
4644
  * Expected JSON RPC response for the "getConfirmedSignaturesForAddress2" message
4650
4645
  */
@@ -4889,6 +4884,17 @@ const GetConfirmedBlockRpcResult = jsonRpcResult(nullable(type({
4889
4884
  }))),
4890
4885
  blockTime: nullable(number())
4891
4886
  })));
4887
+ /**
4888
+ * Expected JSON RPC response for the "getConfirmedBlockSignatures" message
4889
+ */
4890
+
4891
+ const GetConfirmedBlockSignaturesRpcResult = jsonRpcResult(nullable(type({
4892
+ blockhash: string(),
4893
+ previousBlockhash: string(),
4894
+ parentSlot: number(),
4895
+ signatures: array(string()),
4896
+ blockTime: nullable(number())
4897
+ })));
4892
4898
  /**
4893
4899
  * Expected JSON RPC response for the "getConfirmedTransaction" message
4894
4900
  */
@@ -5651,20 +5657,21 @@ class Connection {
5651
5657
  }
5652
5658
  /**
5653
5659
  * Fetch the current total currency supply of the cluster in lamports
5660
+ * @deprecated Deprecated since v1.2.8. Use `Connection.getSupply()` instead.
5654
5661
  */
5655
5662
 
5656
5663
 
5657
5664
  async getTotalSupply(commitment) {
5658
5665
  const args = this._buildArgs([], commitment);
5659
5666
 
5660
- const unsafeRes = await this._rpcRequest('getTotalSupply', args);
5661
- const res = create(unsafeRes, jsonRpcResult(number()));
5667
+ const unsafeRes = await this._rpcRequest('getSupply', args);
5668
+ const res = create(unsafeRes, GetSupplyRpcResult);
5662
5669
 
5663
5670
  if ('error' in res) {
5664
5671
  throw new Error('failed to get total supply: ' + res.error.message);
5665
5672
  }
5666
5673
 
5667
- return res.result;
5674
+ return res.result.value.total;
5668
5675
  }
5669
5676
  /**
5670
5677
  * Fetch the cluster InflationGovernor parameters
@@ -5861,6 +5868,30 @@ class Connection {
5861
5868
 
5862
5869
  return result;
5863
5870
  }
5871
+ /**
5872
+ * Fetch a list of Signatures from the cluster for a confirmed block, excluding rewards
5873
+ */
5874
+
5875
+
5876
+ async getConfirmedBlockSignatures(slot) {
5877
+ const unsafeRes = await this._rpcRequest('getConfirmedBlock', [slot, {
5878
+ transactionDetails: 'signatures',
5879
+ rewards: false
5880
+ }]);
5881
+ const res = create(unsafeRes, GetConfirmedBlockSignaturesRpcResult);
5882
+
5883
+ if ('error' in res) {
5884
+ throw new Error('failed to get confirmed block: ' + res.error.message);
5885
+ }
5886
+
5887
+ const result = res.result;
5888
+
5889
+ if (!result) {
5890
+ throw new Error('Confirmed block ' + slot + ' not found');
5891
+ }
5892
+
5893
+ return result;
5894
+ }
5864
5895
  /**
5865
5896
  * Fetch a transaction details for a confirmed transaction
5866
5897
  */
@@ -5918,6 +5949,7 @@ class Connection {
5918
5949
  /**
5919
5950
  * Fetch a list of all the confirmed signatures for transactions involving an address
5920
5951
  * within a specified slot range. Max range allowed is 10,000 slots.
5952
+ * @deprecated Deprecated since v1.3. Use `Connection.getConfirmedSignaturesForAddress2()` instead.
5921
5953
  *
5922
5954
  * @param address queried address
5923
5955
  * @param startSlot start slot, inclusive
@@ -5926,14 +5958,57 @@ class Connection {
5926
5958
 
5927
5959
 
5928
5960
  async getConfirmedSignaturesForAddress(address, startSlot, endSlot) {
5929
- const unsafeRes = await this._rpcRequest('getConfirmedSignaturesForAddress', [address.toBase58(), startSlot, endSlot]);
5930
- const res = create(unsafeRes, GetConfirmedSignaturesForAddressRpcResult);
5961
+ let options = {};
5962
+ let firstAvailableBlock = await this.getFirstAvailableBlock();
5931
5963
 
5932
- if ('error' in res) {
5933
- throw new Error('failed to get confirmed signatures for address: ' + res.error.message);
5964
+ while (!('until' in options)) {
5965
+ startSlot--;
5966
+
5967
+ if (startSlot <= 0 || startSlot < firstAvailableBlock) {
5968
+ break;
5969
+ }
5970
+
5971
+ try {
5972
+ const block = await this.getConfirmedBlockSignatures(startSlot);
5973
+
5974
+ if (block.signatures.length > 0) {
5975
+ options.until = block.signatures[block.signatures.length - 1].toString();
5976
+ }
5977
+ } catch (err) {
5978
+ if (err.message.includes('skipped')) {
5979
+ continue;
5980
+ } else {
5981
+ throw err;
5982
+ }
5983
+ }
5934
5984
  }
5935
5985
 
5936
- return res.result;
5986
+ let highestConfirmedRoot = await this.getSlot('finalized');
5987
+
5988
+ while (!('before' in options)) {
5989
+ endSlot++;
5990
+
5991
+ if (endSlot > highestConfirmedRoot) {
5992
+ break;
5993
+ }
5994
+
5995
+ try {
5996
+ const block = await this.getConfirmedBlockSignatures(endSlot);
5997
+
5998
+ if (block.signatures.length > 0) {
5999
+ options.before = block.signatures[block.signatures.length - 1].toString();
6000
+ }
6001
+ } catch (err) {
6002
+ if (err.message.includes('skipped')) {
6003
+ continue;
6004
+ } else {
6005
+ throw err;
6006
+ }
6007
+ }
6008
+ }
6009
+
6010
+ const confirmedSignatureInfo = await this.getConfirmedSignaturesForAddress2(address, options);
6011
+ return confirmedSignatureInfo.map(info => info.signature);
5937
6012
  }
5938
6013
  /**
5939
6014
  * Returns confirmed signatures for transactions involving an