@solana/web3.js 1.46.0 → 1.47.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.
package/lib/index.d.ts CHANGED
@@ -3497,6 +3497,42 @@ declare module '@solana/web3.js' {
3497
3497
  logs: string[] | undefined;
3498
3498
  constructor(message: string, logs?: string[]);
3499
3499
  }
3500
+ export const SolanaJSONRPCErrorCode: {
3501
+ readonly JSON_RPC_SERVER_ERROR_BLOCK_CLEANED_UP: -32001;
3502
+ readonly JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE: -32002;
3503
+ readonly JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE: -32003;
3504
+ readonly JSON_RPC_SERVER_ERROR_BLOCK_NOT_AVAILABLE: -32004;
3505
+ readonly JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY: -32005;
3506
+ readonly JSON_RPC_SERVER_ERROR_TRANSACTION_PRECOMPILE_VERIFICATION_FAILURE: -32006;
3507
+ readonly JSON_RPC_SERVER_ERROR_SLOT_SKIPPED: -32007;
3508
+ readonly JSON_RPC_SERVER_ERROR_NO_SNAPSHOT: -32008;
3509
+ readonly JSON_RPC_SERVER_ERROR_LONG_TERM_STORAGE_SLOT_SKIPPED: -32009;
3510
+ readonly JSON_RPC_SERVER_ERROR_KEY_EXCLUDED_FROM_SECONDARY_INDEX: -32010;
3511
+ readonly JSON_RPC_SERVER_ERROR_TRANSACTION_HISTORY_NOT_AVAILABLE: -32011;
3512
+ readonly JSON_RPC_SCAN_ERROR: -32012;
3513
+ readonly JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_LEN_MISMATCH: -32013;
3514
+ readonly JSON_RPC_SERVER_ERROR_BLOCK_STATUS_NOT_AVAILABLE_YET: -32014;
3515
+ readonly JSON_RPC_SERVER_ERROR_UNSUPPORTED_TRANSACTION_VERSION: -32015;
3516
+ readonly JSON_RPC_SERVER_ERROR_MIN_CONTEXT_SLOT_NOT_REACHED: -32016;
3517
+ };
3518
+ export type SolanaJSONRPCErrorCodeEnum =
3519
+ typeof SolanaJSONRPCErrorCode[keyof typeof SolanaJSONRPCErrorCode];
3520
+ export class SolanaJSONRPCError extends Error {
3521
+ code: SolanaJSONRPCErrorCodeEnum | unknown;
3522
+ data?: any;
3523
+ constructor(
3524
+ {
3525
+ code,
3526
+ message,
3527
+ data,
3528
+ }: Readonly<{
3529
+ code: unknown;
3530
+ message: string;
3531
+ data?: any;
3532
+ }>,
3533
+ customMessage?: string,
3534
+ );
3535
+ }
3500
3536
 
3501
3537
  /**
3502
3538
  * Sign, send and confirm a transaction.
package/lib/index.esm.js CHANGED
@@ -4574,6 +4574,41 @@ class SendTransactionError extends Error {
4574
4574
  this.logs = logs;
4575
4575
  }
4576
4576
 
4577
+ } // Keep in sync with client/src/rpc_custom_errors.rs
4578
+ // Typescript `enums` thwart tree-shaking. See https://bargsten.org/jsts/enums/
4579
+
4580
+ const SolanaJSONRPCErrorCode = {
4581
+ JSON_RPC_SERVER_ERROR_BLOCK_CLEANED_UP: -32001,
4582
+ JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE: -32002,
4583
+ JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE: -32003,
4584
+ JSON_RPC_SERVER_ERROR_BLOCK_NOT_AVAILABLE: -32004,
4585
+ JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY: -32005,
4586
+ JSON_RPC_SERVER_ERROR_TRANSACTION_PRECOMPILE_VERIFICATION_FAILURE: -32006,
4587
+ JSON_RPC_SERVER_ERROR_SLOT_SKIPPED: -32007,
4588
+ JSON_RPC_SERVER_ERROR_NO_SNAPSHOT: -32008,
4589
+ JSON_RPC_SERVER_ERROR_LONG_TERM_STORAGE_SLOT_SKIPPED: -32009,
4590
+ JSON_RPC_SERVER_ERROR_KEY_EXCLUDED_FROM_SECONDARY_INDEX: -32010,
4591
+ JSON_RPC_SERVER_ERROR_TRANSACTION_HISTORY_NOT_AVAILABLE: -32011,
4592
+ JSON_RPC_SCAN_ERROR: -32012,
4593
+ JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_LEN_MISMATCH: -32013,
4594
+ JSON_RPC_SERVER_ERROR_BLOCK_STATUS_NOT_AVAILABLE_YET: -32014,
4595
+ JSON_RPC_SERVER_ERROR_UNSUPPORTED_TRANSACTION_VERSION: -32015,
4596
+ JSON_RPC_SERVER_ERROR_MIN_CONTEXT_SLOT_NOT_REACHED: -32016
4597
+ };
4598
+ class SolanaJSONRPCError extends Error {
4599
+ constructor({
4600
+ code,
4601
+ message,
4602
+ data
4603
+ }, customMessage) {
4604
+ super(customMessage != null ? `${customMessage}: ${message}` : message);
4605
+ this.code = void 0;
4606
+ this.data = void 0;
4607
+ this.code = code;
4608
+ this.data = data;
4609
+ this.name = 'SolanaJSONRPCError';
4610
+ }
4611
+
4577
4612
  }
4578
4613
 
4579
4614
  async function fetchImpl (input, init) {
@@ -5745,7 +5780,7 @@ class Connection {
5745
5780
  const res = create(unsafeRes, jsonRpcResultAndContext(number()));
5746
5781
 
5747
5782
  if ('error' in res) {
5748
- throw new Error('failed to get balance for ' + publicKey.toBase58() + ': ' + res.error.message);
5783
+ throw new SolanaJSONRPCError(res.error, `failed to get balance for ${publicKey.toBase58()}`);
5749
5784
  }
5750
5785
 
5751
5786
  return res.result;
@@ -5770,7 +5805,7 @@ class Connection {
5770
5805
  const res = create(unsafeRes, jsonRpcResult(nullable(number())));
5771
5806
 
5772
5807
  if ('error' in res) {
5773
- throw new Error('failed to get block time for slot ' + slot + ': ' + res.error.message);
5808
+ throw new SolanaJSONRPCError(res.error, `failed to get block time for slot ${slot}`);
5774
5809
  }
5775
5810
 
5776
5811
  return res.result;
@@ -5786,7 +5821,7 @@ class Connection {
5786
5821
  const res = create(unsafeRes, jsonRpcResult(number()));
5787
5822
 
5788
5823
  if ('error' in res) {
5789
- throw new Error('failed to get minimum ledger slot: ' + res.error.message);
5824
+ throw new SolanaJSONRPCError(res.error, 'failed to get minimum ledger slot');
5790
5825
  }
5791
5826
 
5792
5827
  return res.result;
@@ -5801,7 +5836,7 @@ class Connection {
5801
5836
  const res = create(unsafeRes, SlotRpcResult);
5802
5837
 
5803
5838
  if ('error' in res) {
5804
- throw new Error('failed to get first available block: ' + res.error.message);
5839
+ throw new SolanaJSONRPCError(res.error, 'failed to get first available block');
5805
5840
  }
5806
5841
 
5807
5842
  return res.result;
@@ -5832,7 +5867,7 @@ class Connection {
5832
5867
  const res = create(unsafeRes, GetSupplyRpcResult);
5833
5868
 
5834
5869
  if ('error' in res) {
5835
- throw new Error('failed to get supply: ' + res.error.message);
5870
+ throw new SolanaJSONRPCError(res.error, 'failed to get supply');
5836
5871
  }
5837
5872
 
5838
5873
  return res.result;
@@ -5849,7 +5884,7 @@ class Connection {
5849
5884
  const res = create(unsafeRes, jsonRpcResultAndContext(TokenAmountResult));
5850
5885
 
5851
5886
  if ('error' in res) {
5852
- throw new Error('failed to get token supply: ' + res.error.message);
5887
+ throw new SolanaJSONRPCError(res.error, 'failed to get token supply');
5853
5888
  }
5854
5889
 
5855
5890
  return res.result;
@@ -5866,7 +5901,7 @@ class Connection {
5866
5901
  const res = create(unsafeRes, jsonRpcResultAndContext(TokenAmountResult));
5867
5902
 
5868
5903
  if ('error' in res) {
5869
- throw new Error('failed to get token account balance: ' + res.error.message);
5904
+ throw new SolanaJSONRPCError(res.error, 'failed to get token account balance');
5870
5905
  }
5871
5906
 
5872
5907
  return res.result;
@@ -5901,7 +5936,7 @@ class Connection {
5901
5936
  const res = create(unsafeRes, GetTokenAccountsByOwner);
5902
5937
 
5903
5938
  if ('error' in res) {
5904
- throw new Error('failed to get token accounts owned by account ' + ownerAddress.toBase58() + ': ' + res.error.message);
5939
+ throw new SolanaJSONRPCError(res.error, `failed to get token accounts owned by account ${ownerAddress.toBase58()}`);
5905
5940
  }
5906
5941
 
5907
5942
  return res.result;
@@ -5932,7 +5967,7 @@ class Connection {
5932
5967
  const res = create(unsafeRes, GetParsedTokenAccountsByOwner);
5933
5968
 
5934
5969
  if ('error' in res) {
5935
- throw new Error('failed to get token accounts owned by account ' + ownerAddress.toBase58() + ': ' + res.error.message);
5970
+ throw new SolanaJSONRPCError(res.error, `failed to get token accounts owned by account ${ownerAddress.toBase58()}`);
5936
5971
  }
5937
5972
 
5938
5973
  return res.result;
@@ -5951,7 +5986,7 @@ class Connection {
5951
5986
  const res = create(unsafeRes, GetLargestAccountsRpcResult);
5952
5987
 
5953
5988
  if ('error' in res) {
5954
- throw new Error('failed to get largest accounts: ' + res.error.message);
5989
+ throw new SolanaJSONRPCError(res.error, 'failed to get largest accounts');
5955
5990
  }
5956
5991
 
5957
5992
  return res.result;
@@ -5969,7 +6004,7 @@ class Connection {
5969
6004
  const res = create(unsafeRes, GetTokenLargestAccountsResult);
5970
6005
 
5971
6006
  if ('error' in res) {
5972
- throw new Error('failed to get token largest accounts: ' + res.error.message);
6007
+ throw new SolanaJSONRPCError(res.error, 'failed to get token largest accounts');
5973
6008
  }
5974
6009
 
5975
6010
  return res.result;
@@ -5991,7 +6026,7 @@ class Connection {
5991
6026
  const res = create(unsafeRes, jsonRpcResultAndContext(nullable(AccountInfoResult)));
5992
6027
 
5993
6028
  if ('error' in res) {
5994
- throw new Error('failed to get info about account ' + publicKey.toBase58() + ': ' + res.error.message);
6029
+ throw new SolanaJSONRPCError(res.error, `failed to get info about account ${publicKey.toBase58()}`);
5995
6030
  }
5996
6031
 
5997
6032
  return res.result;
@@ -6008,7 +6043,7 @@ class Connection {
6008
6043
  const res = create(unsafeRes, jsonRpcResultAndContext(nullable(ParsedAccountInfoResult)));
6009
6044
 
6010
6045
  if ('error' in res) {
6011
- throw new Error('failed to get info about account ' + publicKey.toBase58() + ': ' + res.error.message);
6046
+ throw new SolanaJSONRPCError(res.error, `failed to get info about account ${publicKey.toBase58()}`);
6012
6047
  }
6013
6048
 
6014
6049
  return res.result;
@@ -6044,7 +6079,7 @@ class Connection {
6044
6079
  const res = create(unsafeRes, jsonRpcResultAndContext(array(nullable(AccountInfoResult))));
6045
6080
 
6046
6081
  if ('error' in res) {
6047
- throw new Error('failed to get info for accounts ' + keys + ': ' + res.error.message);
6082
+ throw new SolanaJSONRPCError(res.error, `failed to get info for accounts ${keys}`);
6048
6083
  }
6049
6084
 
6050
6085
  return res.result;
@@ -6079,7 +6114,7 @@ class Connection {
6079
6114
  const res = create(unsafeRes, jsonRpcResult(StakeActivationResult));
6080
6115
 
6081
6116
  if ('error' in res) {
6082
- throw new Error(`failed to get Stake Activation ${publicKey.toBase58()}: ${res.error.message}`);
6117
+ throw new SolanaJSONRPCError(res.error, `failed to get Stake Activation ${publicKey.toBase58()}`);
6083
6118
  }
6084
6119
 
6085
6120
  return res.result;
@@ -6107,7 +6142,7 @@ class Connection {
6107
6142
  const res = create(unsafeRes, jsonRpcResult(array(KeyedAccountInfoResult)));
6108
6143
 
6109
6144
  if ('error' in res) {
6110
- throw new Error('failed to get accounts owned by program ' + programId.toBase58() + ': ' + res.error.message);
6145
+ throw new SolanaJSONRPCError(res.error, `failed to get accounts owned by program ${programId.toBase58()}`);
6111
6146
  }
6112
6147
 
6113
6148
  return res.result;
@@ -6131,7 +6166,7 @@ class Connection {
6131
6166
  const res = create(unsafeRes, jsonRpcResult(array(KeyedParsedAccountInfoResult)));
6132
6167
 
6133
6168
  if ('error' in res) {
6134
- throw new Error('failed to get accounts owned by program ' + programId.toBase58() + ': ' + res.error.message);
6169
+ throw new SolanaJSONRPCError(res.error, `failed to get accounts owned by program ${programId.toBase58()}`);
6135
6170
  }
6136
6171
 
6137
6172
  return res.result;
@@ -6265,7 +6300,7 @@ class Connection {
6265
6300
  const res = create(unsafeRes, jsonRpcResult(array(ContactInfoResult)));
6266
6301
 
6267
6302
  if ('error' in res) {
6268
- throw new Error('failed to get cluster nodes: ' + res.error.message);
6303
+ throw new SolanaJSONRPCError(res.error, 'failed to get cluster nodes');
6269
6304
  }
6270
6305
 
6271
6306
  return res.result;
@@ -6282,7 +6317,7 @@ class Connection {
6282
6317
  const res = create(unsafeRes, GetVoteAccounts);
6283
6318
 
6284
6319
  if ('error' in res) {
6285
- throw new Error('failed to get vote accounts: ' + res.error.message);
6320
+ throw new SolanaJSONRPCError(res.error, 'failed to get vote accounts');
6286
6321
  }
6287
6322
 
6288
6323
  return res.result;
@@ -6306,7 +6341,7 @@ class Connection {
6306
6341
  const res = create(unsafeRes, jsonRpcResult(number()));
6307
6342
 
6308
6343
  if ('error' in res) {
6309
- throw new Error('failed to get slot: ' + res.error.message);
6344
+ throw new SolanaJSONRPCError(res.error, 'failed to get slot');
6310
6345
  }
6311
6346
 
6312
6347
  return res.result;
@@ -6330,7 +6365,7 @@ class Connection {
6330
6365
  const res = create(unsafeRes, jsonRpcResult(string()));
6331
6366
 
6332
6367
  if ('error' in res) {
6333
- throw new Error('failed to get slot leader: ' + res.error.message);
6368
+ throw new SolanaJSONRPCError(res.error, 'failed to get slot leader');
6334
6369
  }
6335
6370
 
6336
6371
  return res.result;
@@ -6349,7 +6384,7 @@ class Connection {
6349
6384
  const res = create(unsafeRes, jsonRpcResult(array(PublicKeyFromString)));
6350
6385
 
6351
6386
  if ('error' in res) {
6352
- throw new Error('failed to get slot leaders: ' + res.error.message);
6387
+ throw new SolanaJSONRPCError(res.error, 'failed to get slot leaders');
6353
6388
  }
6354
6389
 
6355
6390
  return res.result;
@@ -6387,7 +6422,7 @@ class Connection {
6387
6422
  const res = create(unsafeRes, GetSignatureStatusesRpcResult);
6388
6423
 
6389
6424
  if ('error' in res) {
6390
- throw new Error('failed to get signature status: ' + res.error.message);
6425
+ throw new SolanaJSONRPCError(res.error, 'failed to get signature status');
6391
6426
  }
6392
6427
 
6393
6428
  return res.result;
@@ -6411,7 +6446,7 @@ class Connection {
6411
6446
  const res = create(unsafeRes, jsonRpcResult(number()));
6412
6447
 
6413
6448
  if ('error' in res) {
6414
- throw new Error('failed to get transaction count: ' + res.error.message);
6449
+ throw new SolanaJSONRPCError(res.error, 'failed to get transaction count');
6415
6450
  }
6416
6451
 
6417
6452
  return res.result;
@@ -6442,7 +6477,7 @@ class Connection {
6442
6477
  const res = create(unsafeRes, GetInflationGovernorRpcResult);
6443
6478
 
6444
6479
  if ('error' in res) {
6445
- throw new Error('failed to get inflation: ' + res.error.message);
6480
+ throw new SolanaJSONRPCError(res.error, 'failed to get inflation');
6446
6481
  }
6447
6482
 
6448
6483
  return res.result;
@@ -6468,7 +6503,7 @@ class Connection {
6468
6503
  const res = create(unsafeRes, GetInflationRewardResult);
6469
6504
 
6470
6505
  if ('error' in res) {
6471
- throw new Error('failed to get inflation reward: ' + res.error.message);
6506
+ throw new SolanaJSONRPCError(res.error, 'failed to get inflation reward');
6472
6507
  }
6473
6508
 
6474
6509
  return res.result;
@@ -6492,7 +6527,7 @@ class Connection {
6492
6527
  const res = create(unsafeRes, GetEpochInfoRpcResult);
6493
6528
 
6494
6529
  if ('error' in res) {
6495
- throw new Error('failed to get epoch info: ' + res.error.message);
6530
+ throw new SolanaJSONRPCError(res.error, 'failed to get epoch info');
6496
6531
  }
6497
6532
 
6498
6533
  return res.result;
@@ -6507,7 +6542,7 @@ class Connection {
6507
6542
  const res = create(unsafeRes, GetEpochScheduleRpcResult);
6508
6543
 
6509
6544
  if ('error' in res) {
6510
- throw new Error('failed to get epoch schedule: ' + res.error.message);
6545
+ throw new SolanaJSONRPCError(res.error, 'failed to get epoch schedule');
6511
6546
  }
6512
6547
 
6513
6548
  const epochSchedule = res.result;
@@ -6524,7 +6559,7 @@ class Connection {
6524
6559
  const res = create(unsafeRes, GetLeaderScheduleRpcResult);
6525
6560
 
6526
6561
  if ('error' in res) {
6527
- throw new Error('failed to get leader schedule: ' + res.error.message);
6562
+ throw new SolanaJSONRPCError(res.error, 'failed to get leader schedule');
6528
6563
  }
6529
6564
 
6530
6565
  return res.result;
@@ -6563,7 +6598,7 @@ class Connection {
6563
6598
  const res = create(unsafeRes, GetRecentBlockhashAndContextRpcResult);
6564
6599
 
6565
6600
  if ('error' in res) {
6566
- throw new Error('failed to get recent blockhash: ' + res.error.message);
6601
+ throw new SolanaJSONRPCError(res.error, 'failed to get recent blockhash');
6567
6602
  }
6568
6603
 
6569
6604
  return res.result;
@@ -6575,13 +6610,11 @@ class Connection {
6575
6610
 
6576
6611
 
6577
6612
  async getRecentPerformanceSamples(limit) {
6578
- const args = this._buildArgs(limit ? [limit] : []);
6579
-
6580
- const unsafeRes = await this._rpcRequest('getRecentPerformanceSamples', args);
6613
+ const unsafeRes = await this._rpcRequest('getRecentPerformanceSamples', limit ? [limit] : []);
6581
6614
  const res = create(unsafeRes, GetRecentPerformanceSamplesRpcResult);
6582
6615
 
6583
6616
  if ('error' in res) {
6584
- throw new Error('failed to get recent performance samples: ' + res.error.message);
6617
+ throw new SolanaJSONRPCError(res.error, 'failed to get recent performance samples');
6585
6618
  }
6586
6619
 
6587
6620
  return res.result;
@@ -6600,7 +6633,7 @@ class Connection {
6600
6633
  const res = create(unsafeRes, GetFeeCalculatorRpcResult);
6601
6634
 
6602
6635
  if ('error' in res) {
6603
- throw new Error('failed to get fee calculator: ' + res.error.message);
6636
+ throw new SolanaJSONRPCError(res.error, 'failed to get fee calculator');
6604
6637
  }
6605
6638
 
6606
6639
  const {
@@ -6626,7 +6659,7 @@ class Connection {
6626
6659
  const res = create(unsafeRes, jsonRpcResultAndContext(nullable(number())));
6627
6660
 
6628
6661
  if ('error' in res) {
6629
- throw new Error('failed to get slot: ' + res.error.message);
6662
+ throw new SolanaJSONRPCError(res.error, 'failed to get slot');
6630
6663
  }
6631
6664
 
6632
6665
  if (res.result === null) {
@@ -6685,7 +6718,7 @@ class Connection {
6685
6718
  const res = create(unsafeRes, GetLatestBlockhashRpcResult);
6686
6719
 
6687
6720
  if ('error' in res) {
6688
- throw new Error('failed to get latest blockhash: ' + res.error.message);
6721
+ throw new SolanaJSONRPCError(res.error, 'failed to get latest blockhash');
6689
6722
  }
6690
6723
 
6691
6724
  return res.result;
@@ -6700,7 +6733,7 @@ class Connection {
6700
6733
  const res = create(unsafeRes, jsonRpcResult(VersionResult));
6701
6734
 
6702
6735
  if ('error' in res) {
6703
- throw new Error('failed to get version: ' + res.error.message);
6736
+ throw new SolanaJSONRPCError(res.error, 'failed to get version');
6704
6737
  }
6705
6738
 
6706
6739
  return res.result;
@@ -6715,7 +6748,7 @@ class Connection {
6715
6748
  const res = create(unsafeRes, jsonRpcResult(string()));
6716
6749
 
6717
6750
  if ('error' in res) {
6718
- throw new Error('failed to get genesis hash: ' + res.error.message);
6751
+ throw new SolanaJSONRPCError(res.error, 'failed to get genesis hash');
6719
6752
  }
6720
6753
 
6721
6754
  return res.result;
@@ -6732,7 +6765,7 @@ class Connection {
6732
6765
  const res = create(unsafeRes, GetBlockRpcResult);
6733
6766
 
6734
6767
  if ('error' in res) {
6735
- throw new Error('failed to get confirmed block: ' + res.error.message);
6768
+ throw new SolanaJSONRPCError(res.error, 'failed to get confirmed block');
6736
6769
  }
6737
6770
 
6738
6771
  const result = res.result;
@@ -6771,7 +6804,7 @@ class Connection {
6771
6804
  const res = create(unsafeRes, jsonRpcResult(number()));
6772
6805
 
6773
6806
  if ('error' in res) {
6774
- throw new Error('failed to get block height information: ' + res.error.message);
6807
+ throw new SolanaJSONRPCError(res.error, 'failed to get block height information');
6775
6808
  }
6776
6809
 
6777
6810
  return res.result;
@@ -6802,7 +6835,7 @@ class Connection {
6802
6835
  const res = create(unsafeRes, BlockProductionResponseStruct);
6803
6836
 
6804
6837
  if ('error' in res) {
6805
- throw new Error('failed to get block production information: ' + res.error.message);
6838
+ throw new SolanaJSONRPCError(res.error, 'failed to get block production information');
6806
6839
  }
6807
6840
 
6808
6841
  return res.result;
@@ -6819,7 +6852,7 @@ class Connection {
6819
6852
  const res = create(unsafeRes, GetTransactionRpcResult);
6820
6853
 
6821
6854
  if ('error' in res) {
6822
- throw new Error('failed to get transaction: ' + res.error.message);
6855
+ throw new SolanaJSONRPCError(res.error, 'failed to get transaction');
6823
6856
  }
6824
6857
 
6825
6858
  const result = res.result;
@@ -6842,7 +6875,7 @@ class Connection {
6842
6875
  const res = create(unsafeRes, GetParsedTransactionRpcResult);
6843
6876
 
6844
6877
  if ('error' in res) {
6845
- throw new Error('failed to get transaction: ' + res.error.message);
6878
+ throw new SolanaJSONRPCError(res.error, 'failed to get transaction');
6846
6879
  }
6847
6880
 
6848
6881
  return res.result;
@@ -6866,7 +6899,7 @@ class Connection {
6866
6899
  const res = create(unsafeRes, GetParsedTransactionRpcResult);
6867
6900
 
6868
6901
  if ('error' in res) {
6869
- throw new Error('failed to get transactions: ' + res.error.message);
6902
+ throw new SolanaJSONRPCError(res.error, 'failed to get transactions');
6870
6903
  }
6871
6904
 
6872
6905
  return res.result;
@@ -6893,7 +6926,7 @@ class Connection {
6893
6926
  const res = create(unsafeRes, GetTransactionRpcResult);
6894
6927
 
6895
6928
  if ('error' in res) {
6896
- throw new Error('failed to get transactions: ' + res.error.message);
6929
+ throw new SolanaJSONRPCError(res.error, 'failed to get transactions');
6897
6930
  }
6898
6931
 
6899
6932
  const result = res.result;
@@ -6921,7 +6954,7 @@ class Connection {
6921
6954
  const res = create(unsafeRes, GetConfirmedBlockRpcResult);
6922
6955
 
6923
6956
  if ('error' in res) {
6924
- throw new Error('failed to get confirmed block: ' + res.error.message);
6957
+ throw new SolanaJSONRPCError(res.error, 'failed to get confirmed block');
6925
6958
  }
6926
6959
 
6927
6960
  const result = res.result;
@@ -6968,7 +7001,7 @@ class Connection {
6968
7001
  const res = create(unsafeRes, jsonRpcResult(array(number())));
6969
7002
 
6970
7003
  if ('error' in res) {
6971
- throw new Error('failed to get blocks: ' + res.error.message);
7004
+ throw new SolanaJSONRPCError(res.error, 'failed to get blocks');
6972
7005
  }
6973
7006
 
6974
7007
  return res.result;
@@ -6988,7 +7021,7 @@ class Connection {
6988
7021
  const res = create(unsafeRes, GetBlockSignaturesRpcResult);
6989
7022
 
6990
7023
  if ('error' in res) {
6991
- throw new Error('failed to get block: ' + res.error.message);
7024
+ throw new SolanaJSONRPCError(res.error, 'failed to get block');
6992
7025
  }
6993
7026
 
6994
7027
  const result = res.result;
@@ -7016,7 +7049,7 @@ class Connection {
7016
7049
  const res = create(unsafeRes, GetBlockSignaturesRpcResult);
7017
7050
 
7018
7051
  if ('error' in res) {
7019
- throw new Error('failed to get confirmed block: ' + res.error.message);
7052
+ throw new SolanaJSONRPCError(res.error, 'failed to get confirmed block');
7020
7053
  }
7021
7054
 
7022
7055
  const result = res.result;
@@ -7041,7 +7074,7 @@ class Connection {
7041
7074
  const res = create(unsafeRes, GetTransactionRpcResult);
7042
7075
 
7043
7076
  if ('error' in res) {
7044
- throw new Error('failed to get transaction: ' + res.error.message);
7077
+ throw new SolanaJSONRPCError(res.error, 'failed to get transaction');
7045
7078
  }
7046
7079
 
7047
7080
  const result = res.result;
@@ -7066,7 +7099,7 @@ class Connection {
7066
7099
  const res = create(unsafeRes, GetParsedTransactionRpcResult);
7067
7100
 
7068
7101
  if ('error' in res) {
7069
- throw new Error('failed to get confirmed transaction: ' + res.error.message);
7102
+ throw new SolanaJSONRPCError(res.error, 'failed to get confirmed transaction');
7070
7103
  }
7071
7104
 
7072
7105
  return res.result;
@@ -7092,7 +7125,7 @@ class Connection {
7092
7125
  const res = create(unsafeRes, GetParsedTransactionRpcResult);
7093
7126
 
7094
7127
  if ('error' in res) {
7095
- throw new Error('failed to get confirmed transactions: ' + res.error.message);
7128
+ throw new SolanaJSONRPCError(res.error, 'failed to get confirmed transactions');
7096
7129
  }
7097
7130
 
7098
7131
  return res.result;
@@ -7181,7 +7214,7 @@ class Connection {
7181
7214
  const res = create(unsafeRes, GetConfirmedSignaturesForAddress2RpcResult);
7182
7215
 
7183
7216
  if ('error' in res) {
7184
- throw new Error('failed to get confirmed signatures for address: ' + res.error.message);
7217
+ throw new SolanaJSONRPCError(res.error, 'failed to get confirmed signatures for address');
7185
7218
  }
7186
7219
 
7187
7220
  return res.result;
@@ -7203,7 +7236,7 @@ class Connection {
7203
7236
  const res = create(unsafeRes, GetSignaturesForAddressRpcResult);
7204
7237
 
7205
7238
  if ('error' in res) {
7206
- throw new Error('failed to get signatures for address: ' + res.error.message);
7239
+ throw new SolanaJSONRPCError(res.error, 'failed to get signatures for address');
7207
7240
  }
7208
7241
 
7209
7242
  return res.result;
@@ -7260,7 +7293,7 @@ class Connection {
7260
7293
  const res = create(unsafeRes, RequestAirdropRpcResult);
7261
7294
 
7262
7295
  if ('error' in res) {
7263
- throw new Error('airdrop to ' + to.toBase58() + ' failed: ' + res.error.message);
7296
+ throw new SolanaJSONRPCError(res.error, `airdrop to ${to.toBase58()} failed`);
7264
7297
  }
7265
7298
 
7266
7299
  return res.result;
@@ -7490,7 +7523,7 @@ class Connection {
7490
7523
  const skipPreflight = options && options.skipPreflight;
7491
7524
  const preflightCommitment = options && options.preflightCommitment || this.commitment;
7492
7525
 
7493
- if (options && options.maxRetries) {
7526
+ if (options && options.maxRetries != null) {
7494
7527
  config.maxRetries = options.maxRetries;
7495
7528
  }
7496
7529
 
@@ -9960,5 +9993,5 @@ function clusterApiUrl(cluster, tls) {
9960
9993
 
9961
9994
  const LAMPORTS_PER_SOL = 1000000000;
9962
9995
 
9963
- export { Account, Authorized, BLOCKHASH_CACHE_TIMEOUT_MS, BPF_LOADER_DEPRECATED_PROGRAM_ID, BPF_LOADER_PROGRAM_ID, BpfLoader, COMPUTE_BUDGET_INSTRUCTION_LAYOUTS, ComputeBudgetInstruction, ComputeBudgetProgram, Connection, Ed25519Program, Enum, EpochSchedule, FeeCalculatorLayout, Keypair, LAMPORTS_PER_SOL, Loader, Lockup, MAX_SEED_LENGTH, Message, NONCE_ACCOUNT_LENGTH, NonceAccount, PACKET_DATA_SIZE, PublicKey, SIGNATURE_LENGTH_IN_BYTES, SOLANA_SCHEMA, STAKE_CONFIG_ID, STAKE_INSTRUCTION_LAYOUTS, SYSTEM_INSTRUCTION_LAYOUTS, SYSVAR_CLOCK_PUBKEY, SYSVAR_EPOCH_SCHEDULE_PUBKEY, SYSVAR_INSTRUCTIONS_PUBKEY, SYSVAR_RECENT_BLOCKHASHES_PUBKEY, SYSVAR_RENT_PUBKEY, SYSVAR_REWARDS_PUBKEY, SYSVAR_SLOT_HASHES_PUBKEY, SYSVAR_SLOT_HISTORY_PUBKEY, SYSVAR_STAKE_HISTORY_PUBKEY, Secp256k1Program, SendTransactionError, StakeAuthorizationLayout, StakeInstruction, StakeProgram, Struct, SystemInstruction, SystemProgram, Transaction, TransactionExpiredBlockheightExceededError, TransactionExpiredTimeoutError, TransactionInstruction, TransactionStatus, VALIDATOR_INFO_KEY, VOTE_PROGRAM_ID, ValidatorInfo, VoteAccount, VoteAuthorizationLayout, VoteInit, VoteInstruction, VoteProgram, clusterApiUrl, sendAndConfirmRawTransaction, sendAndConfirmTransaction };
9996
+ export { Account, Authorized, BLOCKHASH_CACHE_TIMEOUT_MS, BPF_LOADER_DEPRECATED_PROGRAM_ID, BPF_LOADER_PROGRAM_ID, BpfLoader, COMPUTE_BUDGET_INSTRUCTION_LAYOUTS, ComputeBudgetInstruction, ComputeBudgetProgram, Connection, Ed25519Program, Enum, EpochSchedule, FeeCalculatorLayout, Keypair, LAMPORTS_PER_SOL, Loader, Lockup, MAX_SEED_LENGTH, Message, NONCE_ACCOUNT_LENGTH, NonceAccount, PACKET_DATA_SIZE, PublicKey, SIGNATURE_LENGTH_IN_BYTES, SOLANA_SCHEMA, STAKE_CONFIG_ID, STAKE_INSTRUCTION_LAYOUTS, SYSTEM_INSTRUCTION_LAYOUTS, SYSVAR_CLOCK_PUBKEY, SYSVAR_EPOCH_SCHEDULE_PUBKEY, SYSVAR_INSTRUCTIONS_PUBKEY, SYSVAR_RECENT_BLOCKHASHES_PUBKEY, SYSVAR_RENT_PUBKEY, SYSVAR_REWARDS_PUBKEY, SYSVAR_SLOT_HASHES_PUBKEY, SYSVAR_SLOT_HISTORY_PUBKEY, SYSVAR_STAKE_HISTORY_PUBKEY, Secp256k1Program, SendTransactionError, SolanaJSONRPCError, SolanaJSONRPCErrorCode, StakeAuthorizationLayout, StakeInstruction, StakeProgram, Struct, SystemInstruction, SystemProgram, Transaction, TransactionExpiredBlockheightExceededError, TransactionExpiredTimeoutError, TransactionInstruction, TransactionStatus, VALIDATOR_INFO_KEY, VOTE_PROGRAM_ID, ValidatorInfo, VoteAccount, VoteAuthorizationLayout, VoteInit, VoteInstruction, VoteProgram, clusterApiUrl, sendAndConfirmRawTransaction, sendAndConfirmTransaction };
9964
9997
  //# sourceMappingURL=index.esm.js.map