@solana/web3.js 1.45.0 → 1.47.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.iife.js CHANGED
@@ -14764,7 +14764,8 @@ var solanaWeb3 = (function (exports) {
14764
14764
  const sendOptions = options && {
14765
14765
  skipPreflight: options.skipPreflight,
14766
14766
  preflightCommitment: options.preflightCommitment || options.commitment,
14767
- maxRetries: options.maxRetries
14767
+ maxRetries: options.maxRetries,
14768
+ minContextSlot: options.minContextSlot
14768
14769
  };
14769
14770
  const signature = await connection.sendTransaction(transaction, signers, sendOptions);
14770
14771
  const status = transaction.recentBlockhash != null && transaction.lastValidBlockHeight != null ? (await connection.confirmTransaction({
@@ -19356,6 +19357,41 @@ var solanaWeb3 = (function (exports) {
19356
19357
  this.logs = logs;
19357
19358
  }
19358
19359
 
19360
+ } // Keep in sync with client/src/rpc_custom_errors.rs
19361
+ // Typescript `enums` thwart tree-shaking. See https://bargsten.org/jsts/enums/
19362
+
19363
+ const SolanaJSONRPCErrorCode = {
19364
+ JSON_RPC_SERVER_ERROR_BLOCK_CLEANED_UP: -32001,
19365
+ JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE: -32002,
19366
+ JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE: -32003,
19367
+ JSON_RPC_SERVER_ERROR_BLOCK_NOT_AVAILABLE: -32004,
19368
+ JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY: -32005,
19369
+ JSON_RPC_SERVER_ERROR_TRANSACTION_PRECOMPILE_VERIFICATION_FAILURE: -32006,
19370
+ JSON_RPC_SERVER_ERROR_SLOT_SKIPPED: -32007,
19371
+ JSON_RPC_SERVER_ERROR_NO_SNAPSHOT: -32008,
19372
+ JSON_RPC_SERVER_ERROR_LONG_TERM_STORAGE_SLOT_SKIPPED: -32009,
19373
+ JSON_RPC_SERVER_ERROR_KEY_EXCLUDED_FROM_SECONDARY_INDEX: -32010,
19374
+ JSON_RPC_SERVER_ERROR_TRANSACTION_HISTORY_NOT_AVAILABLE: -32011,
19375
+ JSON_RPC_SCAN_ERROR: -32012,
19376
+ JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_LEN_MISMATCH: -32013,
19377
+ JSON_RPC_SERVER_ERROR_BLOCK_STATUS_NOT_AVAILABLE_YET: -32014,
19378
+ JSON_RPC_SERVER_ERROR_UNSUPPORTED_TRANSACTION_VERSION: -32015,
19379
+ JSON_RPC_SERVER_ERROR_MIN_CONTEXT_SLOT_NOT_REACHED: -32016
19380
+ };
19381
+ class SolanaJSONRPCError extends Error {
19382
+ constructor({
19383
+ code,
19384
+ message,
19385
+ data
19386
+ }, customMessage) {
19387
+ super(customMessage != null ? `${customMessage}: ${message}` : message);
19388
+ this.code = void 0;
19389
+ this.data = void 0;
19390
+ this.code = code;
19391
+ this.data = data;
19392
+ this.name = 'SolanaJSONRPCError';
19393
+ }
19394
+
19359
19395
  }
19360
19396
 
19361
19397
  var fetchImpl = globalThis.fetch;
@@ -19441,9 +19477,32 @@ var solanaWeb3 = (function (exports) {
19441
19477
  * https://gist.github.com/steveluscher/c057eca81d479ef705cdb53162f9971d
19442
19478
  */
19443
19479
 
19480
+ /** @internal */
19481
+ function extractCommitmentFromConfig(commitmentOrConfig) {
19482
+ let commitment;
19483
+ let config;
19484
+
19485
+ if (typeof commitmentOrConfig === 'string') {
19486
+ commitment = commitmentOrConfig;
19487
+ } else if (commitmentOrConfig) {
19488
+ const {
19489
+ commitment: specifiedCommitment,
19490
+ ...specifiedConfig
19491
+ } = commitmentOrConfig;
19492
+ commitment = specifiedCommitment;
19493
+ config = specifiedConfig;
19494
+ }
19495
+
19496
+ return {
19497
+ commitment,
19498
+ config
19499
+ };
19500
+ }
19444
19501
  /**
19445
19502
  * @internal
19446
19503
  */
19504
+
19505
+
19447
19506
  function createRpcResult(result) {
19448
19507
  return union([type({
19449
19508
  jsonrpc: literal('2.0'),
@@ -20480,14 +20539,22 @@ var solanaWeb3 = (function (exports) {
20480
20539
  */
20481
20540
 
20482
20541
 
20483
- async getBalanceAndContext(publicKey, commitment) {
20484
- const args = this._buildArgs([publicKey.toBase58()], commitment);
20542
+ async getBalanceAndContext(publicKey, commitmentOrConfig) {
20543
+ /** @internal */
20544
+ const {
20545
+ commitment,
20546
+ config
20547
+ } = extractCommitmentFromConfig(commitmentOrConfig);
20548
+
20549
+ const args = this._buildArgs([publicKey.toBase58()], commitment, undefined
20550
+ /* encoding */
20551
+ , config);
20485
20552
 
20486
20553
  const unsafeRes = await this._rpcRequest('getBalance', args);
20487
20554
  const res = create(unsafeRes, jsonRpcResultAndContext(number()));
20488
20555
 
20489
20556
  if ('error' in res) {
20490
- throw new Error('failed to get balance for ' + publicKey.toBase58() + ': ' + res.error.message);
20557
+ throw new SolanaJSONRPCError(res.error, `failed to get balance for ${publicKey.toBase58()}`);
20491
20558
  }
20492
20559
 
20493
20560
  return res.result;
@@ -20497,8 +20564,8 @@ var solanaWeb3 = (function (exports) {
20497
20564
  */
20498
20565
 
20499
20566
 
20500
- async getBalance(publicKey, commitment) {
20501
- return await this.getBalanceAndContext(publicKey, commitment).then(x => x.value).catch(e => {
20567
+ async getBalance(publicKey, commitmentOrConfig) {
20568
+ return await this.getBalanceAndContext(publicKey, commitmentOrConfig).then(x => x.value).catch(e => {
20502
20569
  throw new Error('failed to get balance of account ' + publicKey.toBase58() + ': ' + e);
20503
20570
  });
20504
20571
  }
@@ -20512,7 +20579,7 @@ var solanaWeb3 = (function (exports) {
20512
20579
  const res = create(unsafeRes, jsonRpcResult(nullable(number())));
20513
20580
 
20514
20581
  if ('error' in res) {
20515
- throw new Error('failed to get block time for slot ' + slot + ': ' + res.error.message);
20582
+ throw new SolanaJSONRPCError(res.error, `failed to get block time for slot ${slot}`);
20516
20583
  }
20517
20584
 
20518
20585
  return res.result;
@@ -20528,7 +20595,7 @@ var solanaWeb3 = (function (exports) {
20528
20595
  const res = create(unsafeRes, jsonRpcResult(number()));
20529
20596
 
20530
20597
  if ('error' in res) {
20531
- throw new Error('failed to get minimum ledger slot: ' + res.error.message);
20598
+ throw new SolanaJSONRPCError(res.error, 'failed to get minimum ledger slot');
20532
20599
  }
20533
20600
 
20534
20601
  return res.result;
@@ -20543,7 +20610,7 @@ var solanaWeb3 = (function (exports) {
20543
20610
  const res = create(unsafeRes, SlotRpcResult);
20544
20611
 
20545
20612
  if ('error' in res) {
20546
- throw new Error('failed to get first available block: ' + res.error.message);
20613
+ throw new SolanaJSONRPCError(res.error, 'failed to get first available block');
20547
20614
  }
20548
20615
 
20549
20616
  return res.result;
@@ -20574,7 +20641,7 @@ var solanaWeb3 = (function (exports) {
20574
20641
  const res = create(unsafeRes, GetSupplyRpcResult);
20575
20642
 
20576
20643
  if ('error' in res) {
20577
- throw new Error('failed to get supply: ' + res.error.message);
20644
+ throw new SolanaJSONRPCError(res.error, 'failed to get supply');
20578
20645
  }
20579
20646
 
20580
20647
  return res.result;
@@ -20591,7 +20658,7 @@ var solanaWeb3 = (function (exports) {
20591
20658
  const res = create(unsafeRes, jsonRpcResultAndContext(TokenAmountResult));
20592
20659
 
20593
20660
  if ('error' in res) {
20594
- throw new Error('failed to get token supply: ' + res.error.message);
20661
+ throw new SolanaJSONRPCError(res.error, 'failed to get token supply');
20595
20662
  }
20596
20663
 
20597
20664
  return res.result;
@@ -20608,7 +20675,7 @@ var solanaWeb3 = (function (exports) {
20608
20675
  const res = create(unsafeRes, jsonRpcResultAndContext(TokenAmountResult));
20609
20676
 
20610
20677
  if ('error' in res) {
20611
- throw new Error('failed to get token account balance: ' + res.error.message);
20678
+ throw new SolanaJSONRPCError(res.error, 'failed to get token account balance');
20612
20679
  }
20613
20680
 
20614
20681
  return res.result;
@@ -20620,7 +20687,11 @@ var solanaWeb3 = (function (exports) {
20620
20687
  */
20621
20688
 
20622
20689
 
20623
- async getTokenAccountsByOwner(ownerAddress, filter, commitment) {
20690
+ async getTokenAccountsByOwner(ownerAddress, filter, commitmentOrConfig) {
20691
+ const {
20692
+ commitment,
20693
+ config
20694
+ } = extractCommitmentFromConfig(commitmentOrConfig);
20624
20695
  let _args = [ownerAddress.toBase58()];
20625
20696
 
20626
20697
  if ('mint' in filter) {
@@ -20633,13 +20704,13 @@ var solanaWeb3 = (function (exports) {
20633
20704
  });
20634
20705
  }
20635
20706
 
20636
- const args = this._buildArgs(_args, commitment, 'base64');
20707
+ const args = this._buildArgs(_args, commitment, 'base64', config);
20637
20708
 
20638
20709
  const unsafeRes = await this._rpcRequest('getTokenAccountsByOwner', args);
20639
20710
  const res = create(unsafeRes, GetTokenAccountsByOwner);
20640
20711
 
20641
20712
  if ('error' in res) {
20642
- throw new Error('failed to get token accounts owned by account ' + ownerAddress.toBase58() + ': ' + res.error.message);
20713
+ throw new SolanaJSONRPCError(res.error, `failed to get token accounts owned by account ${ownerAddress.toBase58()}`);
20643
20714
  }
20644
20715
 
20645
20716
  return res.result;
@@ -20670,7 +20741,7 @@ var solanaWeb3 = (function (exports) {
20670
20741
  const res = create(unsafeRes, GetParsedTokenAccountsByOwner);
20671
20742
 
20672
20743
  if ('error' in res) {
20673
- throw new Error('failed to get token accounts owned by account ' + ownerAddress.toBase58() + ': ' + res.error.message);
20744
+ throw new SolanaJSONRPCError(res.error, `failed to get token accounts owned by account ${ownerAddress.toBase58()}`);
20674
20745
  }
20675
20746
 
20676
20747
  return res.result;
@@ -20689,7 +20760,7 @@ var solanaWeb3 = (function (exports) {
20689
20760
  const res = create(unsafeRes, GetLargestAccountsRpcResult);
20690
20761
 
20691
20762
  if ('error' in res) {
20692
- throw new Error('failed to get largest accounts: ' + res.error.message);
20763
+ throw new SolanaJSONRPCError(res.error, 'failed to get largest accounts');
20693
20764
  }
20694
20765
 
20695
20766
  return res.result;
@@ -20707,7 +20778,7 @@ var solanaWeb3 = (function (exports) {
20707
20778
  const res = create(unsafeRes, GetTokenLargestAccountsResult);
20708
20779
 
20709
20780
  if ('error' in res) {
20710
- throw new Error('failed to get token largest accounts: ' + res.error.message);
20781
+ throw new SolanaJSONRPCError(res.error, 'failed to get token largest accounts');
20711
20782
  }
20712
20783
 
20713
20784
  return res.result;
@@ -20717,14 +20788,19 @@ var solanaWeb3 = (function (exports) {
20717
20788
  */
20718
20789
 
20719
20790
 
20720
- async getAccountInfoAndContext(publicKey, commitment) {
20721
- const args = this._buildArgs([publicKey.toBase58()], commitment, 'base64');
20791
+ async getAccountInfoAndContext(publicKey, commitmentOrConfig) {
20792
+ const {
20793
+ commitment,
20794
+ config
20795
+ } = extractCommitmentFromConfig(commitmentOrConfig);
20796
+
20797
+ const args = this._buildArgs([publicKey.toBase58()], commitment, 'base64', config);
20722
20798
 
20723
20799
  const unsafeRes = await this._rpcRequest('getAccountInfo', args);
20724
20800
  const res = create(unsafeRes, jsonRpcResultAndContext(nullable(AccountInfoResult)));
20725
20801
 
20726
20802
  if ('error' in res) {
20727
- throw new Error('failed to get info about account ' + publicKey.toBase58() + ': ' + res.error.message);
20803
+ throw new SolanaJSONRPCError(res.error, `failed to get info about account ${publicKey.toBase58()}`);
20728
20804
  }
20729
20805
 
20730
20806
  return res.result;
@@ -20741,7 +20817,7 @@ var solanaWeb3 = (function (exports) {
20741
20817
  const res = create(unsafeRes, jsonRpcResultAndContext(nullable(ParsedAccountInfoResult)));
20742
20818
 
20743
20819
  if ('error' in res) {
20744
- throw new Error('failed to get info about account ' + publicKey.toBase58() + ': ' + res.error.message);
20820
+ throw new SolanaJSONRPCError(res.error, `failed to get info about account ${publicKey.toBase58()}`);
20745
20821
  }
20746
20822
 
20747
20823
  return res.result;
@@ -20751,9 +20827,9 @@ var solanaWeb3 = (function (exports) {
20751
20827
  */
20752
20828
 
20753
20829
 
20754
- async getAccountInfo(publicKey, commitment) {
20830
+ async getAccountInfo(publicKey, commitmentOrConfig) {
20755
20831
  try {
20756
- const res = await this.getAccountInfoAndContext(publicKey, commitment);
20832
+ const res = await this.getAccountInfoAndContext(publicKey, commitmentOrConfig);
20757
20833
  return res.value;
20758
20834
  } catch (e) {
20759
20835
  throw new Error('failed to get info about account ' + publicKey.toBase58() + ': ' + e);
@@ -20764,16 +20840,20 @@ var solanaWeb3 = (function (exports) {
20764
20840
  */
20765
20841
 
20766
20842
 
20767
- async getMultipleAccountsInfoAndContext(publicKeys, commitment) {
20843
+ async getMultipleAccountsInfoAndContext(publicKeys, commitmentOrConfig) {
20844
+ const {
20845
+ commitment,
20846
+ config
20847
+ } = extractCommitmentFromConfig(commitmentOrConfig);
20768
20848
  const keys = publicKeys.map(key => key.toBase58());
20769
20849
 
20770
- const args = this._buildArgs([keys], commitment, 'base64');
20850
+ const args = this._buildArgs([keys], commitment, 'base64', config);
20771
20851
 
20772
20852
  const unsafeRes = await this._rpcRequest('getMultipleAccounts', args);
20773
20853
  const res = create(unsafeRes, jsonRpcResultAndContext(array(nullable(AccountInfoResult))));
20774
20854
 
20775
20855
  if ('error' in res) {
20776
- throw new Error('failed to get info for accounts ' + keys + ': ' + res.error.message);
20856
+ throw new SolanaJSONRPCError(res.error, `failed to get info for accounts ${keys}`);
20777
20857
  }
20778
20858
 
20779
20859
  return res.result;
@@ -20783,8 +20863,8 @@ var solanaWeb3 = (function (exports) {
20783
20863
  */
20784
20864
 
20785
20865
 
20786
- async getMultipleAccountsInfo(publicKeys, commitment) {
20787
- const res = await this.getMultipleAccountsInfoAndContext(publicKeys, commitment);
20866
+ async getMultipleAccountsInfo(publicKeys, commitmentOrConfig) {
20867
+ const res = await this.getMultipleAccountsInfoAndContext(publicKeys, commitmentOrConfig);
20788
20868
  return res.value;
20789
20869
  }
20790
20870
  /**
@@ -20792,16 +20872,23 @@ var solanaWeb3 = (function (exports) {
20792
20872
  */
20793
20873
 
20794
20874
 
20795
- async getStakeActivation(publicKey, commitment, epoch) {
20796
- const args = this._buildArgs([publicKey.toBase58()], commitment, undefined, epoch !== undefined ? {
20797
- epoch
20798
- } : undefined);
20875
+ async getStakeActivation(publicKey, commitmentOrConfig, epoch) {
20876
+ const {
20877
+ commitment,
20878
+ config
20879
+ } = extractCommitmentFromConfig(commitmentOrConfig);
20880
+
20881
+ const args = this._buildArgs([publicKey.toBase58()], commitment, undefined
20882
+ /* encoding */
20883
+ , { ...config,
20884
+ epoch: epoch != null ? epoch : config === null || config === void 0 ? void 0 : config.epoch
20885
+ });
20799
20886
 
20800
20887
  const unsafeRes = await this._rpcRequest('getStakeActivation', args);
20801
20888
  const res = create(unsafeRes, jsonRpcResult(StakeActivationResult));
20802
20889
 
20803
20890
  if ('error' in res) {
20804
- throw new Error(`failed to get Stake Activation ${publicKey.toBase58()}: ${res.error.message}`);
20891
+ throw new SolanaJSONRPCError(res.error, `failed to get Stake Activation ${publicKey.toBase58()}`);
20805
20892
  }
20806
20893
 
20807
20894
  return res.result;
@@ -20814,34 +20901,22 @@ var solanaWeb3 = (function (exports) {
20814
20901
 
20815
20902
 
20816
20903
  async getProgramAccounts(programId, configOrCommitment) {
20817
- const extra = {};
20818
- let commitment;
20819
- let encoding;
20820
-
20821
- if (configOrCommitment) {
20822
- if (typeof configOrCommitment === 'string') {
20823
- commitment = configOrCommitment;
20824
- } else {
20825
- commitment = configOrCommitment.commitment;
20826
- encoding = configOrCommitment.encoding;
20827
-
20828
- if (configOrCommitment.dataSlice) {
20829
- extra.dataSlice = configOrCommitment.dataSlice;
20830
- }
20831
-
20832
- if (configOrCommitment.filters) {
20833
- extra.filters = configOrCommitment.filters;
20834
- }
20835
- }
20836
- }
20904
+ const {
20905
+ commitment,
20906
+ config
20907
+ } = extractCommitmentFromConfig(configOrCommitment);
20908
+ const {
20909
+ encoding,
20910
+ ...configWithoutEncoding
20911
+ } = config || {};
20837
20912
 
20838
- const args = this._buildArgs([programId.toBase58()], commitment, encoding || 'base64', extra);
20913
+ const args = this._buildArgs([programId.toBase58()], commitment, encoding || 'base64', configWithoutEncoding);
20839
20914
 
20840
20915
  const unsafeRes = await this._rpcRequest('getProgramAccounts', args);
20841
20916
  const res = create(unsafeRes, jsonRpcResult(array(KeyedAccountInfoResult)));
20842
20917
 
20843
20918
  if ('error' in res) {
20844
- throw new Error('failed to get accounts owned by program ' + programId.toBase58() + ': ' + res.error.message);
20919
+ throw new SolanaJSONRPCError(res.error, `failed to get accounts owned by program ${programId.toBase58()}`);
20845
20920
  }
20846
20921
 
20847
20922
  return res.result;
@@ -20854,28 +20929,18 @@ var solanaWeb3 = (function (exports) {
20854
20929
 
20855
20930
 
20856
20931
  async getParsedProgramAccounts(programId, configOrCommitment) {
20857
- const extra = {};
20858
- let commitment;
20859
-
20860
- if (configOrCommitment) {
20861
- if (typeof configOrCommitment === 'string') {
20862
- commitment = configOrCommitment;
20863
- } else {
20864
- commitment = configOrCommitment.commitment;
20865
-
20866
- if (configOrCommitment.filters) {
20867
- extra.filters = configOrCommitment.filters;
20868
- }
20869
- }
20870
- }
20932
+ const {
20933
+ commitment,
20934
+ config
20935
+ } = extractCommitmentFromConfig(configOrCommitment);
20871
20936
 
20872
- const args = this._buildArgs([programId.toBase58()], commitment, 'jsonParsed', extra);
20937
+ const args = this._buildArgs([programId.toBase58()], commitment, 'jsonParsed', config);
20873
20938
 
20874
20939
  const unsafeRes = await this._rpcRequest('getProgramAccounts', args);
20875
20940
  const res = create(unsafeRes, jsonRpcResult(array(KeyedParsedAccountInfoResult)));
20876
20941
 
20877
20942
  if ('error' in res) {
20878
- throw new Error('failed to get accounts owned by program ' + programId.toBase58() + ': ' + res.error.message);
20943
+ throw new SolanaJSONRPCError(res.error, `failed to get accounts owned by program ${programId.toBase58()}`);
20879
20944
  }
20880
20945
 
20881
20946
  return res.result;
@@ -21009,7 +21074,7 @@ var solanaWeb3 = (function (exports) {
21009
21074
  const res = create(unsafeRes, jsonRpcResult(array(ContactInfoResult)));
21010
21075
 
21011
21076
  if ('error' in res) {
21012
- throw new Error('failed to get cluster nodes: ' + res.error.message);
21077
+ throw new SolanaJSONRPCError(res.error, 'failed to get cluster nodes');
21013
21078
  }
21014
21079
 
21015
21080
  return res.result;
@@ -21026,7 +21091,7 @@ var solanaWeb3 = (function (exports) {
21026
21091
  const res = create(unsafeRes, GetVoteAccounts);
21027
21092
 
21028
21093
  if ('error' in res) {
21029
- throw new Error('failed to get vote accounts: ' + res.error.message);
21094
+ throw new SolanaJSONRPCError(res.error, 'failed to get vote accounts');
21030
21095
  }
21031
21096
 
21032
21097
  return res.result;
@@ -21036,14 +21101,21 @@ var solanaWeb3 = (function (exports) {
21036
21101
  */
21037
21102
 
21038
21103
 
21039
- async getSlot(commitment) {
21040
- const args = this._buildArgs([], commitment);
21104
+ async getSlot(commitmentOrConfig) {
21105
+ const {
21106
+ commitment,
21107
+ config
21108
+ } = extractCommitmentFromConfig(commitmentOrConfig);
21109
+
21110
+ const args = this._buildArgs([], commitment, undefined
21111
+ /* encoding */
21112
+ , config);
21041
21113
 
21042
21114
  const unsafeRes = await this._rpcRequest('getSlot', args);
21043
21115
  const res = create(unsafeRes, jsonRpcResult(number()));
21044
21116
 
21045
21117
  if ('error' in res) {
21046
- throw new Error('failed to get slot: ' + res.error.message);
21118
+ throw new SolanaJSONRPCError(res.error, 'failed to get slot');
21047
21119
  }
21048
21120
 
21049
21121
  return res.result;
@@ -21053,14 +21125,21 @@ var solanaWeb3 = (function (exports) {
21053
21125
  */
21054
21126
 
21055
21127
 
21056
- async getSlotLeader(commitment) {
21057
- const args = this._buildArgs([], commitment);
21128
+ async getSlotLeader(commitmentOrConfig) {
21129
+ const {
21130
+ commitment,
21131
+ config
21132
+ } = extractCommitmentFromConfig(commitmentOrConfig);
21133
+
21134
+ const args = this._buildArgs([], commitment, undefined
21135
+ /* encoding */
21136
+ , config);
21058
21137
 
21059
21138
  const unsafeRes = await this._rpcRequest('getSlotLeader', args);
21060
21139
  const res = create(unsafeRes, jsonRpcResult(string()));
21061
21140
 
21062
21141
  if ('error' in res) {
21063
- throw new Error('failed to get slot leader: ' + res.error.message);
21142
+ throw new SolanaJSONRPCError(res.error, 'failed to get slot leader');
21064
21143
  }
21065
21144
 
21066
21145
  return res.result;
@@ -21079,7 +21158,7 @@ var solanaWeb3 = (function (exports) {
21079
21158
  const res = create(unsafeRes, jsonRpcResult(array(PublicKeyFromString)));
21080
21159
 
21081
21160
  if ('error' in res) {
21082
- throw new Error('failed to get slot leaders: ' + res.error.message);
21161
+ throw new SolanaJSONRPCError(res.error, 'failed to get slot leaders');
21083
21162
  }
21084
21163
 
21085
21164
  return res.result;
@@ -21117,7 +21196,7 @@ var solanaWeb3 = (function (exports) {
21117
21196
  const res = create(unsafeRes, GetSignatureStatusesRpcResult);
21118
21197
 
21119
21198
  if ('error' in res) {
21120
- throw new Error('failed to get signature status: ' + res.error.message);
21199
+ throw new SolanaJSONRPCError(res.error, 'failed to get signature status');
21121
21200
  }
21122
21201
 
21123
21202
  return res.result;
@@ -21127,14 +21206,21 @@ var solanaWeb3 = (function (exports) {
21127
21206
  */
21128
21207
 
21129
21208
 
21130
- async getTransactionCount(commitment) {
21131
- const args = this._buildArgs([], commitment);
21209
+ async getTransactionCount(commitmentOrConfig) {
21210
+ const {
21211
+ commitment,
21212
+ config
21213
+ } = extractCommitmentFromConfig(commitmentOrConfig);
21214
+
21215
+ const args = this._buildArgs([], commitment, undefined
21216
+ /* encoding */
21217
+ , config);
21132
21218
 
21133
21219
  const unsafeRes = await this._rpcRequest('getTransactionCount', args);
21134
21220
  const res = create(unsafeRes, jsonRpcResult(number()));
21135
21221
 
21136
21222
  if ('error' in res) {
21137
- throw new Error('failed to get transaction count: ' + res.error.message);
21223
+ throw new SolanaJSONRPCError(res.error, 'failed to get transaction count');
21138
21224
  }
21139
21225
 
21140
21226
  return res.result;
@@ -21165,7 +21251,7 @@ var solanaWeb3 = (function (exports) {
21165
21251
  const res = create(unsafeRes, GetInflationGovernorRpcResult);
21166
21252
 
21167
21253
  if ('error' in res) {
21168
- throw new Error('failed to get inflation: ' + res.error.message);
21254
+ throw new SolanaJSONRPCError(res.error, 'failed to get inflation');
21169
21255
  }
21170
21256
 
21171
21257
  return res.result;
@@ -21175,16 +21261,23 @@ var solanaWeb3 = (function (exports) {
21175
21261
  */
21176
21262
 
21177
21263
 
21178
- async getInflationReward(addresses, epoch, commitment) {
21179
- const args = this._buildArgs([addresses.map(pubkey => pubkey.toBase58())], commitment, undefined, {
21180
- epoch
21264
+ async getInflationReward(addresses, epoch, commitmentOrConfig) {
21265
+ const {
21266
+ commitment,
21267
+ config
21268
+ } = extractCommitmentFromConfig(commitmentOrConfig);
21269
+
21270
+ const args = this._buildArgs([addresses.map(pubkey => pubkey.toBase58())], commitment, undefined
21271
+ /* encoding */
21272
+ , { ...config,
21273
+ epoch: epoch != null ? epoch : config === null || config === void 0 ? void 0 : config.epoch
21181
21274
  });
21182
21275
 
21183
21276
  const unsafeRes = await this._rpcRequest('getInflationReward', args);
21184
21277
  const res = create(unsafeRes, GetInflationRewardResult);
21185
21278
 
21186
21279
  if ('error' in res) {
21187
- throw new Error('failed to get inflation reward: ' + res.error.message);
21280
+ throw new SolanaJSONRPCError(res.error, 'failed to get inflation reward');
21188
21281
  }
21189
21282
 
21190
21283
  return res.result;
@@ -21194,14 +21287,21 @@ var solanaWeb3 = (function (exports) {
21194
21287
  */
21195
21288
 
21196
21289
 
21197
- async getEpochInfo(commitment) {
21198
- const args = this._buildArgs([], commitment);
21290
+ async getEpochInfo(commitmentOrConfig) {
21291
+ const {
21292
+ commitment,
21293
+ config
21294
+ } = extractCommitmentFromConfig(commitmentOrConfig);
21295
+
21296
+ const args = this._buildArgs([], commitment, undefined
21297
+ /* encoding */
21298
+ , config);
21199
21299
 
21200
21300
  const unsafeRes = await this._rpcRequest('getEpochInfo', args);
21201
21301
  const res = create(unsafeRes, GetEpochInfoRpcResult);
21202
21302
 
21203
21303
  if ('error' in res) {
21204
- throw new Error('failed to get epoch info: ' + res.error.message);
21304
+ throw new SolanaJSONRPCError(res.error, 'failed to get epoch info');
21205
21305
  }
21206
21306
 
21207
21307
  return res.result;
@@ -21216,7 +21316,7 @@ var solanaWeb3 = (function (exports) {
21216
21316
  const res = create(unsafeRes, GetEpochScheduleRpcResult);
21217
21317
 
21218
21318
  if ('error' in res) {
21219
- throw new Error('failed to get epoch schedule: ' + res.error.message);
21319
+ throw new SolanaJSONRPCError(res.error, 'failed to get epoch schedule');
21220
21320
  }
21221
21321
 
21222
21322
  const epochSchedule = res.result;
@@ -21233,7 +21333,7 @@ var solanaWeb3 = (function (exports) {
21233
21333
  const res = create(unsafeRes, GetLeaderScheduleRpcResult);
21234
21334
 
21235
21335
  if ('error' in res) {
21236
- throw new Error('failed to get leader schedule: ' + res.error.message);
21336
+ throw new SolanaJSONRPCError(res.error, 'failed to get leader schedule');
21237
21337
  }
21238
21338
 
21239
21339
  return res.result;
@@ -21272,7 +21372,7 @@ var solanaWeb3 = (function (exports) {
21272
21372
  const res = create(unsafeRes, GetRecentBlockhashAndContextRpcResult);
21273
21373
 
21274
21374
  if ('error' in res) {
21275
- throw new Error('failed to get recent blockhash: ' + res.error.message);
21375
+ throw new SolanaJSONRPCError(res.error, 'failed to get recent blockhash');
21276
21376
  }
21277
21377
 
21278
21378
  return res.result;
@@ -21290,7 +21390,7 @@ var solanaWeb3 = (function (exports) {
21290
21390
  const res = create(unsafeRes, GetRecentPerformanceSamplesRpcResult);
21291
21391
 
21292
21392
  if ('error' in res) {
21293
- throw new Error('failed to get recent performance samples: ' + res.error.message);
21393
+ throw new SolanaJSONRPCError(res.error, 'failed to get recent performance samples');
21294
21394
  }
21295
21395
 
21296
21396
  return res.result;
@@ -21309,7 +21409,7 @@ var solanaWeb3 = (function (exports) {
21309
21409
  const res = create(unsafeRes, GetFeeCalculatorRpcResult);
21310
21410
 
21311
21411
  if ('error' in res) {
21312
- throw new Error('failed to get fee calculator: ' + res.error.message);
21412
+ throw new SolanaJSONRPCError(res.error, 'failed to get fee calculator');
21313
21413
  }
21314
21414
 
21315
21415
  const {
@@ -21335,7 +21435,7 @@ var solanaWeb3 = (function (exports) {
21335
21435
  const res = create(unsafeRes, jsonRpcResultAndContext(nullable(number())));
21336
21436
 
21337
21437
  if ('error' in res) {
21338
- throw new Error('failed to get slot: ' + res.error.message);
21438
+ throw new SolanaJSONRPCError(res.error, 'failed to get slot');
21339
21439
  }
21340
21440
 
21341
21441
  if (res.result === null) {
@@ -21366,9 +21466,9 @@ var solanaWeb3 = (function (exports) {
21366
21466
  */
21367
21467
 
21368
21468
 
21369
- async getLatestBlockhash(commitment) {
21469
+ async getLatestBlockhash(commitmentOrConfig) {
21370
21470
  try {
21371
- const res = await this.getLatestBlockhashAndContext(commitment);
21471
+ const res = await this.getLatestBlockhashAndContext(commitmentOrConfig);
21372
21472
  return res.value;
21373
21473
  } catch (e) {
21374
21474
  throw new Error('failed to get recent blockhash: ' + e);
@@ -21380,14 +21480,21 @@ var solanaWeb3 = (function (exports) {
21380
21480
  */
21381
21481
 
21382
21482
 
21383
- async getLatestBlockhashAndContext(commitment) {
21384
- const args = this._buildArgs([], commitment);
21483
+ async getLatestBlockhashAndContext(commitmentOrConfig) {
21484
+ const {
21485
+ commitment,
21486
+ config
21487
+ } = extractCommitmentFromConfig(commitmentOrConfig);
21488
+
21489
+ const args = this._buildArgs([], commitment, undefined
21490
+ /* encoding */
21491
+ , config);
21385
21492
 
21386
21493
  const unsafeRes = await this._rpcRequest('getLatestBlockhash', args);
21387
21494
  const res = create(unsafeRes, GetLatestBlockhashRpcResult);
21388
21495
 
21389
21496
  if ('error' in res) {
21390
- throw new Error('failed to get latest blockhash: ' + res.error.message);
21497
+ throw new SolanaJSONRPCError(res.error, 'failed to get latest blockhash');
21391
21498
  }
21392
21499
 
21393
21500
  return res.result;
@@ -21402,7 +21509,7 @@ var solanaWeb3 = (function (exports) {
21402
21509
  const res = create(unsafeRes, jsonRpcResult(VersionResult));
21403
21510
 
21404
21511
  if ('error' in res) {
21405
- throw new Error('failed to get version: ' + res.error.message);
21512
+ throw new SolanaJSONRPCError(res.error, 'failed to get version');
21406
21513
  }
21407
21514
 
21408
21515
  return res.result;
@@ -21417,7 +21524,7 @@ var solanaWeb3 = (function (exports) {
21417
21524
  const res = create(unsafeRes, jsonRpcResult(string()));
21418
21525
 
21419
21526
  if ('error' in res) {
21420
- throw new Error('failed to get genesis hash: ' + res.error.message);
21527
+ throw new SolanaJSONRPCError(res.error, 'failed to get genesis hash');
21421
21528
  }
21422
21529
 
21423
21530
  return res.result;
@@ -21434,7 +21541,7 @@ var solanaWeb3 = (function (exports) {
21434
21541
  const res = create(unsafeRes, GetBlockRpcResult);
21435
21542
 
21436
21543
  if ('error' in res) {
21437
- throw new Error('failed to get confirmed block: ' + res.error.message);
21544
+ throw new SolanaJSONRPCError(res.error, 'failed to get confirmed block');
21438
21545
  }
21439
21546
 
21440
21547
  const result = res.result;
@@ -21459,14 +21566,21 @@ var solanaWeb3 = (function (exports) {
21459
21566
  */
21460
21567
 
21461
21568
 
21462
- async getBlockHeight(commitment) {
21463
- const args = this._buildArgs([], commitment);
21569
+ async getBlockHeight(commitmentOrConfig) {
21570
+ const {
21571
+ commitment,
21572
+ config
21573
+ } = extractCommitmentFromConfig(commitmentOrConfig);
21574
+
21575
+ const args = this._buildArgs([], commitment, undefined
21576
+ /* encoding */
21577
+ , config);
21464
21578
 
21465
21579
  const unsafeRes = await this._rpcRequest('getBlockHeight', args);
21466
21580
  const res = create(unsafeRes, jsonRpcResult(number()));
21467
21581
 
21468
21582
  if ('error' in res) {
21469
- throw new Error('failed to get block height information: ' + res.error.message);
21583
+ throw new SolanaJSONRPCError(res.error, 'failed to get block height information');
21470
21584
  }
21471
21585
 
21472
21586
  return res.result;
@@ -21497,7 +21611,7 @@ var solanaWeb3 = (function (exports) {
21497
21611
  const res = create(unsafeRes, BlockProductionResponseStruct);
21498
21612
 
21499
21613
  if ('error' in res) {
21500
- throw new Error('failed to get block production information: ' + res.error.message);
21614
+ throw new SolanaJSONRPCError(res.error, 'failed to get block production information');
21501
21615
  }
21502
21616
 
21503
21617
  return res.result;
@@ -21514,7 +21628,7 @@ var solanaWeb3 = (function (exports) {
21514
21628
  const res = create(unsafeRes, GetTransactionRpcResult);
21515
21629
 
21516
21630
  if ('error' in res) {
21517
- throw new Error('failed to get transaction: ' + res.error.message);
21631
+ throw new SolanaJSONRPCError(res.error, 'failed to get transaction');
21518
21632
  }
21519
21633
 
21520
21634
  const result = res.result;
@@ -21537,7 +21651,7 @@ var solanaWeb3 = (function (exports) {
21537
21651
  const res = create(unsafeRes, GetParsedTransactionRpcResult);
21538
21652
 
21539
21653
  if ('error' in res) {
21540
- throw new Error('failed to get transaction: ' + res.error.message);
21654
+ throw new SolanaJSONRPCError(res.error, 'failed to get transaction');
21541
21655
  }
21542
21656
 
21543
21657
  return res.result;
@@ -21561,7 +21675,7 @@ var solanaWeb3 = (function (exports) {
21561
21675
  const res = create(unsafeRes, GetParsedTransactionRpcResult);
21562
21676
 
21563
21677
  if ('error' in res) {
21564
- throw new Error('failed to get transactions: ' + res.error.message);
21678
+ throw new SolanaJSONRPCError(res.error, 'failed to get transactions');
21565
21679
  }
21566
21680
 
21567
21681
  return res.result;
@@ -21588,7 +21702,7 @@ var solanaWeb3 = (function (exports) {
21588
21702
  const res = create(unsafeRes, GetTransactionRpcResult);
21589
21703
 
21590
21704
  if ('error' in res) {
21591
- throw new Error('failed to get transactions: ' + res.error.message);
21705
+ throw new SolanaJSONRPCError(res.error, 'failed to get transactions');
21592
21706
  }
21593
21707
 
21594
21708
  const result = res.result;
@@ -21616,7 +21730,7 @@ var solanaWeb3 = (function (exports) {
21616
21730
  const res = create(unsafeRes, GetConfirmedBlockRpcResult);
21617
21731
 
21618
21732
  if ('error' in res) {
21619
- throw new Error('failed to get confirmed block: ' + res.error.message);
21733
+ throw new SolanaJSONRPCError(res.error, 'failed to get confirmed block');
21620
21734
  }
21621
21735
 
21622
21736
  const result = res.result;
@@ -21663,7 +21777,7 @@ var solanaWeb3 = (function (exports) {
21663
21777
  const res = create(unsafeRes, jsonRpcResult(array(number())));
21664
21778
 
21665
21779
  if ('error' in res) {
21666
- throw new Error('failed to get blocks: ' + res.error.message);
21780
+ throw new SolanaJSONRPCError(res.error, 'failed to get blocks');
21667
21781
  }
21668
21782
 
21669
21783
  return res.result;
@@ -21683,7 +21797,7 @@ var solanaWeb3 = (function (exports) {
21683
21797
  const res = create(unsafeRes, GetBlockSignaturesRpcResult);
21684
21798
 
21685
21799
  if ('error' in res) {
21686
- throw new Error('failed to get block: ' + res.error.message);
21800
+ throw new SolanaJSONRPCError(res.error, 'failed to get block');
21687
21801
  }
21688
21802
 
21689
21803
  const result = res.result;
@@ -21711,7 +21825,7 @@ var solanaWeb3 = (function (exports) {
21711
21825
  const res = create(unsafeRes, GetBlockSignaturesRpcResult);
21712
21826
 
21713
21827
  if ('error' in res) {
21714
- throw new Error('failed to get confirmed block: ' + res.error.message);
21828
+ throw new SolanaJSONRPCError(res.error, 'failed to get confirmed block');
21715
21829
  }
21716
21830
 
21717
21831
  const result = res.result;
@@ -21736,7 +21850,7 @@ var solanaWeb3 = (function (exports) {
21736
21850
  const res = create(unsafeRes, GetTransactionRpcResult);
21737
21851
 
21738
21852
  if ('error' in res) {
21739
- throw new Error('failed to get transaction: ' + res.error.message);
21853
+ throw new SolanaJSONRPCError(res.error, 'failed to get transaction');
21740
21854
  }
21741
21855
 
21742
21856
  const result = res.result;
@@ -21761,7 +21875,7 @@ var solanaWeb3 = (function (exports) {
21761
21875
  const res = create(unsafeRes, GetParsedTransactionRpcResult);
21762
21876
 
21763
21877
  if ('error' in res) {
21764
- throw new Error('failed to get confirmed transaction: ' + res.error.message);
21878
+ throw new SolanaJSONRPCError(res.error, 'failed to get confirmed transaction');
21765
21879
  }
21766
21880
 
21767
21881
  return res.result;
@@ -21787,7 +21901,7 @@ var solanaWeb3 = (function (exports) {
21787
21901
  const res = create(unsafeRes, GetParsedTransactionRpcResult);
21788
21902
 
21789
21903
  if ('error' in res) {
21790
- throw new Error('failed to get confirmed transactions: ' + res.error.message);
21904
+ throw new SolanaJSONRPCError(res.error, 'failed to get confirmed transactions');
21791
21905
  }
21792
21906
 
21793
21907
  return res.result;
@@ -21876,7 +21990,7 @@ var solanaWeb3 = (function (exports) {
21876
21990
  const res = create(unsafeRes, GetConfirmedSignaturesForAddress2RpcResult);
21877
21991
 
21878
21992
  if ('error' in res) {
21879
- throw new Error('failed to get confirmed signatures for address: ' + res.error.message);
21993
+ throw new SolanaJSONRPCError(res.error, 'failed to get confirmed signatures for address');
21880
21994
  }
21881
21995
 
21882
21996
  return res.result;
@@ -21898,7 +22012,7 @@ var solanaWeb3 = (function (exports) {
21898
22012
  const res = create(unsafeRes, GetSignaturesForAddressRpcResult);
21899
22013
 
21900
22014
  if ('error' in res) {
21901
- throw new Error('failed to get signatures for address: ' + res.error.message);
22015
+ throw new SolanaJSONRPCError(res.error, 'failed to get signatures for address');
21902
22016
  }
21903
22017
 
21904
22018
  return res.result;
@@ -21955,7 +22069,7 @@ var solanaWeb3 = (function (exports) {
21955
22069
  const res = create(unsafeRes, RequestAirdropRpcResult);
21956
22070
 
21957
22071
  if ('error' in res) {
21958
- throw new Error('airdrop to ' + to.toBase58() + ' failed: ' + res.error.message);
22072
+ throw new SolanaJSONRPCError(res.error, `airdrop to ${to.toBase58()} failed`);
21959
22073
  }
21960
22074
 
21961
22075
  return res.result;
@@ -22185,10 +22299,14 @@ var solanaWeb3 = (function (exports) {
22185
22299
  const skipPreflight = options && options.skipPreflight;
22186
22300
  const preflightCommitment = options && options.preflightCommitment || this.commitment;
22187
22301
 
22188
- if (options && options.maxRetries) {
22302
+ if (options && options.maxRetries != null) {
22189
22303
  config.maxRetries = options.maxRetries;
22190
22304
  }
22191
22305
 
22306
+ if (options && options.minContextSlot != null) {
22307
+ config.minContextSlot = options.minContextSlot;
22308
+ }
22309
+
22192
22310
  if (skipPreflight) {
22193
22311
  config.skipPreflight = skipPreflight;
22194
22312
  }
@@ -30191,7 +30309,8 @@ var solanaWeb3 = (function (exports) {
30191
30309
 
30192
30310
  const sendOptions = options && {
30193
30311
  skipPreflight: options.skipPreflight,
30194
- preflightCommitment: options.preflightCommitment || options.commitment
30312
+ preflightCommitment: options.preflightCommitment || options.commitment,
30313
+ minContextSlot: options.minContextSlot
30195
30314
  };
30196
30315
  const signature = await connection.sendRawTransaction(rawTransaction, sendOptions);
30197
30316
  const commitment = options && options.commitment;
@@ -30283,6 +30402,8 @@ var solanaWeb3 = (function (exports) {
30283
30402
  exports.SYSVAR_STAKE_HISTORY_PUBKEY = SYSVAR_STAKE_HISTORY_PUBKEY;
30284
30403
  exports.Secp256k1Program = Secp256k1Program;
30285
30404
  exports.SendTransactionError = SendTransactionError;
30405
+ exports.SolanaJSONRPCError = SolanaJSONRPCError;
30406
+ exports.SolanaJSONRPCErrorCode = SolanaJSONRPCErrorCode;
30286
30407
  exports.StakeAuthorizationLayout = StakeAuthorizationLayout;
30287
30408
  exports.StakeInstruction = StakeInstruction;
30288
30409
  exports.StakeProgram = StakeProgram;