@solana/web3.js 1.46.0 → 1.47.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.
@@ -4501,6 +4501,41 @@ class SendTransactionError extends Error {
4501
4501
  this.logs = logs;
4502
4502
  }
4503
4503
 
4504
+ } // Keep in sync with client/src/rpc_custom_errors.rs
4505
+ // Typescript `enums` thwart tree-shaking. See https://bargsten.org/jsts/enums/
4506
+
4507
+ const SolanaJSONRPCErrorCode = {
4508
+ JSON_RPC_SERVER_ERROR_BLOCK_CLEANED_UP: -32001,
4509
+ JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE: -32002,
4510
+ JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE: -32003,
4511
+ JSON_RPC_SERVER_ERROR_BLOCK_NOT_AVAILABLE: -32004,
4512
+ JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY: -32005,
4513
+ JSON_RPC_SERVER_ERROR_TRANSACTION_PRECOMPILE_VERIFICATION_FAILURE: -32006,
4514
+ JSON_RPC_SERVER_ERROR_SLOT_SKIPPED: -32007,
4515
+ JSON_RPC_SERVER_ERROR_NO_SNAPSHOT: -32008,
4516
+ JSON_RPC_SERVER_ERROR_LONG_TERM_STORAGE_SLOT_SKIPPED: -32009,
4517
+ JSON_RPC_SERVER_ERROR_KEY_EXCLUDED_FROM_SECONDARY_INDEX: -32010,
4518
+ JSON_RPC_SERVER_ERROR_TRANSACTION_HISTORY_NOT_AVAILABLE: -32011,
4519
+ JSON_RPC_SCAN_ERROR: -32012,
4520
+ JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_LEN_MISMATCH: -32013,
4521
+ JSON_RPC_SERVER_ERROR_BLOCK_STATUS_NOT_AVAILABLE_YET: -32014,
4522
+ JSON_RPC_SERVER_ERROR_UNSUPPORTED_TRANSACTION_VERSION: -32015,
4523
+ JSON_RPC_SERVER_ERROR_MIN_CONTEXT_SLOT_NOT_REACHED: -32016
4524
+ };
4525
+ class SolanaJSONRPCError extends Error {
4526
+ constructor({
4527
+ code,
4528
+ message,
4529
+ data
4530
+ }, customMessage) {
4531
+ super(customMessage != null ? `${customMessage}: ${message}` : message);
4532
+ this.code = void 0;
4533
+ this.data = void 0;
4534
+ this.code = code;
4535
+ this.data = data;
4536
+ this.name = 'SolanaJSONRPCError';
4537
+ }
4538
+
4504
4539
  }
4505
4540
 
4506
4541
  var fetchImpl = globalThis.fetch;
@@ -5663,7 +5698,7 @@ class Connection {
5663
5698
  const res = create(unsafeRes, jsonRpcResultAndContext(number()));
5664
5699
 
5665
5700
  if ('error' in res) {
5666
- throw new Error('failed to get balance for ' + publicKey.toBase58() + ': ' + res.error.message);
5701
+ throw new SolanaJSONRPCError(res.error, `failed to get balance for ${publicKey.toBase58()}`);
5667
5702
  }
5668
5703
 
5669
5704
  return res.result;
@@ -5688,7 +5723,7 @@ class Connection {
5688
5723
  const res = create(unsafeRes, jsonRpcResult(nullable(number())));
5689
5724
 
5690
5725
  if ('error' in res) {
5691
- throw new Error('failed to get block time for slot ' + slot + ': ' + res.error.message);
5726
+ throw new SolanaJSONRPCError(res.error, `failed to get block time for slot ${slot}`);
5692
5727
  }
5693
5728
 
5694
5729
  return res.result;
@@ -5704,7 +5739,7 @@ class Connection {
5704
5739
  const res = create(unsafeRes, jsonRpcResult(number()));
5705
5740
 
5706
5741
  if ('error' in res) {
5707
- throw new Error('failed to get minimum ledger slot: ' + res.error.message);
5742
+ throw new SolanaJSONRPCError(res.error, 'failed to get minimum ledger slot');
5708
5743
  }
5709
5744
 
5710
5745
  return res.result;
@@ -5719,7 +5754,7 @@ class Connection {
5719
5754
  const res = create(unsafeRes, SlotRpcResult);
5720
5755
 
5721
5756
  if ('error' in res) {
5722
- throw new Error('failed to get first available block: ' + res.error.message);
5757
+ throw new SolanaJSONRPCError(res.error, 'failed to get first available block');
5723
5758
  }
5724
5759
 
5725
5760
  return res.result;
@@ -5750,7 +5785,7 @@ class Connection {
5750
5785
  const res = create(unsafeRes, GetSupplyRpcResult);
5751
5786
 
5752
5787
  if ('error' in res) {
5753
- throw new Error('failed to get supply: ' + res.error.message);
5788
+ throw new SolanaJSONRPCError(res.error, 'failed to get supply');
5754
5789
  }
5755
5790
 
5756
5791
  return res.result;
@@ -5767,7 +5802,7 @@ class Connection {
5767
5802
  const res = create(unsafeRes, jsonRpcResultAndContext(TokenAmountResult));
5768
5803
 
5769
5804
  if ('error' in res) {
5770
- throw new Error('failed to get token supply: ' + res.error.message);
5805
+ throw new SolanaJSONRPCError(res.error, 'failed to get token supply');
5771
5806
  }
5772
5807
 
5773
5808
  return res.result;
@@ -5784,7 +5819,7 @@ class Connection {
5784
5819
  const res = create(unsafeRes, jsonRpcResultAndContext(TokenAmountResult));
5785
5820
 
5786
5821
  if ('error' in res) {
5787
- throw new Error('failed to get token account balance: ' + res.error.message);
5822
+ throw new SolanaJSONRPCError(res.error, 'failed to get token account balance');
5788
5823
  }
5789
5824
 
5790
5825
  return res.result;
@@ -5819,7 +5854,7 @@ class Connection {
5819
5854
  const res = create(unsafeRes, GetTokenAccountsByOwner);
5820
5855
 
5821
5856
  if ('error' in res) {
5822
- throw new Error('failed to get token accounts owned by account ' + ownerAddress.toBase58() + ': ' + res.error.message);
5857
+ throw new SolanaJSONRPCError(res.error, `failed to get token accounts owned by account ${ownerAddress.toBase58()}`);
5823
5858
  }
5824
5859
 
5825
5860
  return res.result;
@@ -5850,7 +5885,7 @@ class Connection {
5850
5885
  const res = create(unsafeRes, GetParsedTokenAccountsByOwner);
5851
5886
 
5852
5887
  if ('error' in res) {
5853
- throw new Error('failed to get token accounts owned by account ' + ownerAddress.toBase58() + ': ' + res.error.message);
5888
+ throw new SolanaJSONRPCError(res.error, `failed to get token accounts owned by account ${ownerAddress.toBase58()}`);
5854
5889
  }
5855
5890
 
5856
5891
  return res.result;
@@ -5869,7 +5904,7 @@ class Connection {
5869
5904
  const res = create(unsafeRes, GetLargestAccountsRpcResult);
5870
5905
 
5871
5906
  if ('error' in res) {
5872
- throw new Error('failed to get largest accounts: ' + res.error.message);
5907
+ throw new SolanaJSONRPCError(res.error, 'failed to get largest accounts');
5873
5908
  }
5874
5909
 
5875
5910
  return res.result;
@@ -5887,7 +5922,7 @@ class Connection {
5887
5922
  const res = create(unsafeRes, GetTokenLargestAccountsResult);
5888
5923
 
5889
5924
  if ('error' in res) {
5890
- throw new Error('failed to get token largest accounts: ' + res.error.message);
5925
+ throw new SolanaJSONRPCError(res.error, 'failed to get token largest accounts');
5891
5926
  }
5892
5927
 
5893
5928
  return res.result;
@@ -5909,7 +5944,7 @@ class Connection {
5909
5944
  const res = create(unsafeRes, jsonRpcResultAndContext(nullable(AccountInfoResult)));
5910
5945
 
5911
5946
  if ('error' in res) {
5912
- throw new Error('failed to get info about account ' + publicKey.toBase58() + ': ' + res.error.message);
5947
+ throw new SolanaJSONRPCError(res.error, `failed to get info about account ${publicKey.toBase58()}`);
5913
5948
  }
5914
5949
 
5915
5950
  return res.result;
@@ -5926,7 +5961,7 @@ class Connection {
5926
5961
  const res = create(unsafeRes, jsonRpcResultAndContext(nullable(ParsedAccountInfoResult)));
5927
5962
 
5928
5963
  if ('error' in res) {
5929
- throw new Error('failed to get info about account ' + publicKey.toBase58() + ': ' + res.error.message);
5964
+ throw new SolanaJSONRPCError(res.error, `failed to get info about account ${publicKey.toBase58()}`);
5930
5965
  }
5931
5966
 
5932
5967
  return res.result;
@@ -5962,7 +5997,7 @@ class Connection {
5962
5997
  const res = create(unsafeRes, jsonRpcResultAndContext(array(nullable(AccountInfoResult))));
5963
5998
 
5964
5999
  if ('error' in res) {
5965
- throw new Error('failed to get info for accounts ' + keys + ': ' + res.error.message);
6000
+ throw new SolanaJSONRPCError(res.error, `failed to get info for accounts ${keys}`);
5966
6001
  }
5967
6002
 
5968
6003
  return res.result;
@@ -5997,7 +6032,7 @@ class Connection {
5997
6032
  const res = create(unsafeRes, jsonRpcResult(StakeActivationResult));
5998
6033
 
5999
6034
  if ('error' in res) {
6000
- throw new Error(`failed to get Stake Activation ${publicKey.toBase58()}: ${res.error.message}`);
6035
+ throw new SolanaJSONRPCError(res.error, `failed to get Stake Activation ${publicKey.toBase58()}`);
6001
6036
  }
6002
6037
 
6003
6038
  return res.result;
@@ -6025,7 +6060,7 @@ class Connection {
6025
6060
  const res = create(unsafeRes, jsonRpcResult(array(KeyedAccountInfoResult)));
6026
6061
 
6027
6062
  if ('error' in res) {
6028
- throw new Error('failed to get accounts owned by program ' + programId.toBase58() + ': ' + res.error.message);
6063
+ throw new SolanaJSONRPCError(res.error, `failed to get accounts owned by program ${programId.toBase58()}`);
6029
6064
  }
6030
6065
 
6031
6066
  return res.result;
@@ -6049,7 +6084,7 @@ class Connection {
6049
6084
  const res = create(unsafeRes, jsonRpcResult(array(KeyedParsedAccountInfoResult)));
6050
6085
 
6051
6086
  if ('error' in res) {
6052
- throw new Error('failed to get accounts owned by program ' + programId.toBase58() + ': ' + res.error.message);
6087
+ throw new SolanaJSONRPCError(res.error, `failed to get accounts owned by program ${programId.toBase58()}`);
6053
6088
  }
6054
6089
 
6055
6090
  return res.result;
@@ -6183,7 +6218,7 @@ class Connection {
6183
6218
  const res = create(unsafeRes, jsonRpcResult(array(ContactInfoResult)));
6184
6219
 
6185
6220
  if ('error' in res) {
6186
- throw new Error('failed to get cluster nodes: ' + res.error.message);
6221
+ throw new SolanaJSONRPCError(res.error, 'failed to get cluster nodes');
6187
6222
  }
6188
6223
 
6189
6224
  return res.result;
@@ -6200,7 +6235,7 @@ class Connection {
6200
6235
  const res = create(unsafeRes, GetVoteAccounts);
6201
6236
 
6202
6237
  if ('error' in res) {
6203
- throw new Error('failed to get vote accounts: ' + res.error.message);
6238
+ throw new SolanaJSONRPCError(res.error, 'failed to get vote accounts');
6204
6239
  }
6205
6240
 
6206
6241
  return res.result;
@@ -6224,7 +6259,7 @@ class Connection {
6224
6259
  const res = create(unsafeRes, jsonRpcResult(number()));
6225
6260
 
6226
6261
  if ('error' in res) {
6227
- throw new Error('failed to get slot: ' + res.error.message);
6262
+ throw new SolanaJSONRPCError(res.error, 'failed to get slot');
6228
6263
  }
6229
6264
 
6230
6265
  return res.result;
@@ -6248,7 +6283,7 @@ class Connection {
6248
6283
  const res = create(unsafeRes, jsonRpcResult(string()));
6249
6284
 
6250
6285
  if ('error' in res) {
6251
- throw new Error('failed to get slot leader: ' + res.error.message);
6286
+ throw new SolanaJSONRPCError(res.error, 'failed to get slot leader');
6252
6287
  }
6253
6288
 
6254
6289
  return res.result;
@@ -6267,7 +6302,7 @@ class Connection {
6267
6302
  const res = create(unsafeRes, jsonRpcResult(array(PublicKeyFromString)));
6268
6303
 
6269
6304
  if ('error' in res) {
6270
- throw new Error('failed to get slot leaders: ' + res.error.message);
6305
+ throw new SolanaJSONRPCError(res.error, 'failed to get slot leaders');
6271
6306
  }
6272
6307
 
6273
6308
  return res.result;
@@ -6305,7 +6340,7 @@ class Connection {
6305
6340
  const res = create(unsafeRes, GetSignatureStatusesRpcResult);
6306
6341
 
6307
6342
  if ('error' in res) {
6308
- throw new Error('failed to get signature status: ' + res.error.message);
6343
+ throw new SolanaJSONRPCError(res.error, 'failed to get signature status');
6309
6344
  }
6310
6345
 
6311
6346
  return res.result;
@@ -6329,7 +6364,7 @@ class Connection {
6329
6364
  const res = create(unsafeRes, jsonRpcResult(number()));
6330
6365
 
6331
6366
  if ('error' in res) {
6332
- throw new Error('failed to get transaction count: ' + res.error.message);
6367
+ throw new SolanaJSONRPCError(res.error, 'failed to get transaction count');
6333
6368
  }
6334
6369
 
6335
6370
  return res.result;
@@ -6360,7 +6395,7 @@ class Connection {
6360
6395
  const res = create(unsafeRes, GetInflationGovernorRpcResult);
6361
6396
 
6362
6397
  if ('error' in res) {
6363
- throw new Error('failed to get inflation: ' + res.error.message);
6398
+ throw new SolanaJSONRPCError(res.error, 'failed to get inflation');
6364
6399
  }
6365
6400
 
6366
6401
  return res.result;
@@ -6386,7 +6421,7 @@ class Connection {
6386
6421
  const res = create(unsafeRes, GetInflationRewardResult);
6387
6422
 
6388
6423
  if ('error' in res) {
6389
- throw new Error('failed to get inflation reward: ' + res.error.message);
6424
+ throw new SolanaJSONRPCError(res.error, 'failed to get inflation reward');
6390
6425
  }
6391
6426
 
6392
6427
  return res.result;
@@ -6410,7 +6445,7 @@ class Connection {
6410
6445
  const res = create(unsafeRes, GetEpochInfoRpcResult);
6411
6446
 
6412
6447
  if ('error' in res) {
6413
- throw new Error('failed to get epoch info: ' + res.error.message);
6448
+ throw new SolanaJSONRPCError(res.error, 'failed to get epoch info');
6414
6449
  }
6415
6450
 
6416
6451
  return res.result;
@@ -6425,7 +6460,7 @@ class Connection {
6425
6460
  const res = create(unsafeRes, GetEpochScheduleRpcResult);
6426
6461
 
6427
6462
  if ('error' in res) {
6428
- throw new Error('failed to get epoch schedule: ' + res.error.message);
6463
+ throw new SolanaJSONRPCError(res.error, 'failed to get epoch schedule');
6429
6464
  }
6430
6465
 
6431
6466
  const epochSchedule = res.result;
@@ -6442,7 +6477,7 @@ class Connection {
6442
6477
  const res = create(unsafeRes, GetLeaderScheduleRpcResult);
6443
6478
 
6444
6479
  if ('error' in res) {
6445
- throw new Error('failed to get leader schedule: ' + res.error.message);
6480
+ throw new SolanaJSONRPCError(res.error, 'failed to get leader schedule');
6446
6481
  }
6447
6482
 
6448
6483
  return res.result;
@@ -6481,7 +6516,7 @@ class Connection {
6481
6516
  const res = create(unsafeRes, GetRecentBlockhashAndContextRpcResult);
6482
6517
 
6483
6518
  if ('error' in res) {
6484
- throw new Error('failed to get recent blockhash: ' + res.error.message);
6519
+ throw new SolanaJSONRPCError(res.error, 'failed to get recent blockhash');
6485
6520
  }
6486
6521
 
6487
6522
  return res.result;
@@ -6499,7 +6534,7 @@ class Connection {
6499
6534
  const res = create(unsafeRes, GetRecentPerformanceSamplesRpcResult);
6500
6535
 
6501
6536
  if ('error' in res) {
6502
- throw new Error('failed to get recent performance samples: ' + res.error.message);
6537
+ throw new SolanaJSONRPCError(res.error, 'failed to get recent performance samples');
6503
6538
  }
6504
6539
 
6505
6540
  return res.result;
@@ -6518,7 +6553,7 @@ class Connection {
6518
6553
  const res = create(unsafeRes, GetFeeCalculatorRpcResult);
6519
6554
 
6520
6555
  if ('error' in res) {
6521
- throw new Error('failed to get fee calculator: ' + res.error.message);
6556
+ throw new SolanaJSONRPCError(res.error, 'failed to get fee calculator');
6522
6557
  }
6523
6558
 
6524
6559
  const {
@@ -6544,7 +6579,7 @@ class Connection {
6544
6579
  const res = create(unsafeRes, jsonRpcResultAndContext(nullable(number())));
6545
6580
 
6546
6581
  if ('error' in res) {
6547
- throw new Error('failed to get slot: ' + res.error.message);
6582
+ throw new SolanaJSONRPCError(res.error, 'failed to get slot');
6548
6583
  }
6549
6584
 
6550
6585
  if (res.result === null) {
@@ -6603,7 +6638,7 @@ class Connection {
6603
6638
  const res = create(unsafeRes, GetLatestBlockhashRpcResult);
6604
6639
 
6605
6640
  if ('error' in res) {
6606
- throw new Error('failed to get latest blockhash: ' + res.error.message);
6641
+ throw new SolanaJSONRPCError(res.error, 'failed to get latest blockhash');
6607
6642
  }
6608
6643
 
6609
6644
  return res.result;
@@ -6618,7 +6653,7 @@ class Connection {
6618
6653
  const res = create(unsafeRes, jsonRpcResult(VersionResult));
6619
6654
 
6620
6655
  if ('error' in res) {
6621
- throw new Error('failed to get version: ' + res.error.message);
6656
+ throw new SolanaJSONRPCError(res.error, 'failed to get version');
6622
6657
  }
6623
6658
 
6624
6659
  return res.result;
@@ -6633,7 +6668,7 @@ class Connection {
6633
6668
  const res = create(unsafeRes, jsonRpcResult(string()));
6634
6669
 
6635
6670
  if ('error' in res) {
6636
- throw new Error('failed to get genesis hash: ' + res.error.message);
6671
+ throw new SolanaJSONRPCError(res.error, 'failed to get genesis hash');
6637
6672
  }
6638
6673
 
6639
6674
  return res.result;
@@ -6650,7 +6685,7 @@ class Connection {
6650
6685
  const res = create(unsafeRes, GetBlockRpcResult);
6651
6686
 
6652
6687
  if ('error' in res) {
6653
- throw new Error('failed to get confirmed block: ' + res.error.message);
6688
+ throw new SolanaJSONRPCError(res.error, 'failed to get confirmed block');
6654
6689
  }
6655
6690
 
6656
6691
  const result = res.result;
@@ -6689,7 +6724,7 @@ class Connection {
6689
6724
  const res = create(unsafeRes, jsonRpcResult(number()));
6690
6725
 
6691
6726
  if ('error' in res) {
6692
- throw new Error('failed to get block height information: ' + res.error.message);
6727
+ throw new SolanaJSONRPCError(res.error, 'failed to get block height information');
6693
6728
  }
6694
6729
 
6695
6730
  return res.result;
@@ -6720,7 +6755,7 @@ class Connection {
6720
6755
  const res = create(unsafeRes, BlockProductionResponseStruct);
6721
6756
 
6722
6757
  if ('error' in res) {
6723
- throw new Error('failed to get block production information: ' + res.error.message);
6758
+ throw new SolanaJSONRPCError(res.error, 'failed to get block production information');
6724
6759
  }
6725
6760
 
6726
6761
  return res.result;
@@ -6737,7 +6772,7 @@ class Connection {
6737
6772
  const res = create(unsafeRes, GetTransactionRpcResult);
6738
6773
 
6739
6774
  if ('error' in res) {
6740
- throw new Error('failed to get transaction: ' + res.error.message);
6775
+ throw new SolanaJSONRPCError(res.error, 'failed to get transaction');
6741
6776
  }
6742
6777
 
6743
6778
  const result = res.result;
@@ -6760,7 +6795,7 @@ class Connection {
6760
6795
  const res = create(unsafeRes, GetParsedTransactionRpcResult);
6761
6796
 
6762
6797
  if ('error' in res) {
6763
- throw new Error('failed to get transaction: ' + res.error.message);
6798
+ throw new SolanaJSONRPCError(res.error, 'failed to get transaction');
6764
6799
  }
6765
6800
 
6766
6801
  return res.result;
@@ -6784,7 +6819,7 @@ class Connection {
6784
6819
  const res = create(unsafeRes, GetParsedTransactionRpcResult);
6785
6820
 
6786
6821
  if ('error' in res) {
6787
- throw new Error('failed to get transactions: ' + res.error.message);
6822
+ throw new SolanaJSONRPCError(res.error, 'failed to get transactions');
6788
6823
  }
6789
6824
 
6790
6825
  return res.result;
@@ -6811,7 +6846,7 @@ class Connection {
6811
6846
  const res = create(unsafeRes, GetTransactionRpcResult);
6812
6847
 
6813
6848
  if ('error' in res) {
6814
- throw new Error('failed to get transactions: ' + res.error.message);
6849
+ throw new SolanaJSONRPCError(res.error, 'failed to get transactions');
6815
6850
  }
6816
6851
 
6817
6852
  const result = res.result;
@@ -6839,7 +6874,7 @@ class Connection {
6839
6874
  const res = create(unsafeRes, GetConfirmedBlockRpcResult);
6840
6875
 
6841
6876
  if ('error' in res) {
6842
- throw new Error('failed to get confirmed block: ' + res.error.message);
6877
+ throw new SolanaJSONRPCError(res.error, 'failed to get confirmed block');
6843
6878
  }
6844
6879
 
6845
6880
  const result = res.result;
@@ -6886,7 +6921,7 @@ class Connection {
6886
6921
  const res = create(unsafeRes, jsonRpcResult(array(number())));
6887
6922
 
6888
6923
  if ('error' in res) {
6889
- throw new Error('failed to get blocks: ' + res.error.message);
6924
+ throw new SolanaJSONRPCError(res.error, 'failed to get blocks');
6890
6925
  }
6891
6926
 
6892
6927
  return res.result;
@@ -6906,7 +6941,7 @@ class Connection {
6906
6941
  const res = create(unsafeRes, GetBlockSignaturesRpcResult);
6907
6942
 
6908
6943
  if ('error' in res) {
6909
- throw new Error('failed to get block: ' + res.error.message);
6944
+ throw new SolanaJSONRPCError(res.error, 'failed to get block');
6910
6945
  }
6911
6946
 
6912
6947
  const result = res.result;
@@ -6934,7 +6969,7 @@ class Connection {
6934
6969
  const res = create(unsafeRes, GetBlockSignaturesRpcResult);
6935
6970
 
6936
6971
  if ('error' in res) {
6937
- throw new Error('failed to get confirmed block: ' + res.error.message);
6972
+ throw new SolanaJSONRPCError(res.error, 'failed to get confirmed block');
6938
6973
  }
6939
6974
 
6940
6975
  const result = res.result;
@@ -6959,7 +6994,7 @@ class Connection {
6959
6994
  const res = create(unsafeRes, GetTransactionRpcResult);
6960
6995
 
6961
6996
  if ('error' in res) {
6962
- throw new Error('failed to get transaction: ' + res.error.message);
6997
+ throw new SolanaJSONRPCError(res.error, 'failed to get transaction');
6963
6998
  }
6964
6999
 
6965
7000
  const result = res.result;
@@ -6984,7 +7019,7 @@ class Connection {
6984
7019
  const res = create(unsafeRes, GetParsedTransactionRpcResult);
6985
7020
 
6986
7021
  if ('error' in res) {
6987
- throw new Error('failed to get confirmed transaction: ' + res.error.message);
7022
+ throw new SolanaJSONRPCError(res.error, 'failed to get confirmed transaction');
6988
7023
  }
6989
7024
 
6990
7025
  return res.result;
@@ -7010,7 +7045,7 @@ class Connection {
7010
7045
  const res = create(unsafeRes, GetParsedTransactionRpcResult);
7011
7046
 
7012
7047
  if ('error' in res) {
7013
- throw new Error('failed to get confirmed transactions: ' + res.error.message);
7048
+ throw new SolanaJSONRPCError(res.error, 'failed to get confirmed transactions');
7014
7049
  }
7015
7050
 
7016
7051
  return res.result;
@@ -7099,7 +7134,7 @@ class Connection {
7099
7134
  const res = create(unsafeRes, GetConfirmedSignaturesForAddress2RpcResult);
7100
7135
 
7101
7136
  if ('error' in res) {
7102
- throw new Error('failed to get confirmed signatures for address: ' + res.error.message);
7137
+ throw new SolanaJSONRPCError(res.error, 'failed to get confirmed signatures for address');
7103
7138
  }
7104
7139
 
7105
7140
  return res.result;
@@ -7121,7 +7156,7 @@ class Connection {
7121
7156
  const res = create(unsafeRes, GetSignaturesForAddressRpcResult);
7122
7157
 
7123
7158
  if ('error' in res) {
7124
- throw new Error('failed to get signatures for address: ' + res.error.message);
7159
+ throw new SolanaJSONRPCError(res.error, 'failed to get signatures for address');
7125
7160
  }
7126
7161
 
7127
7162
  return res.result;
@@ -7178,7 +7213,7 @@ class Connection {
7178
7213
  const res = create(unsafeRes, RequestAirdropRpcResult);
7179
7214
 
7180
7215
  if ('error' in res) {
7181
- throw new Error('airdrop to ' + to.toBase58() + ' failed: ' + res.error.message);
7216
+ throw new SolanaJSONRPCError(res.error, `airdrop to ${to.toBase58()} failed`);
7182
7217
  }
7183
7218
 
7184
7219
  return res.result;
@@ -9878,5 +9913,5 @@ function clusterApiUrl(cluster, tls) {
9878
9913
 
9879
9914
  const LAMPORTS_PER_SOL = 1000000000;
9880
9915
 
9881
- 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 };
9916
+ 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 };
9882
9917
  //# sourceMappingURL=index.browser.esm.js.map