@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.
- package/lib/index.browser.cjs.js +90 -53
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +89 -54
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +90 -53
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +36 -0
- package/lib/index.esm.js +89 -54
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +90 -53
- package/lib/index.iife.js.map +1 -1
- package/lib/index.iife.min.js +2 -2
- package/lib/index.iife.min.js.map +1 -1
- package/package.json +1 -1
- package/src/connection.ts +101 -99
- package/src/errors.ts +41 -0
package/lib/index.cjs.js
CHANGED
|
@@ -4608,6 +4608,41 @@ class SendTransactionError extends Error {
|
|
|
4608
4608
|
this.logs = logs;
|
|
4609
4609
|
}
|
|
4610
4610
|
|
|
4611
|
+
} // Keep in sync with client/src/rpc_custom_errors.rs
|
|
4612
|
+
// Typescript `enums` thwart tree-shaking. See https://bargsten.org/jsts/enums/
|
|
4613
|
+
|
|
4614
|
+
const SolanaJSONRPCErrorCode = {
|
|
4615
|
+
JSON_RPC_SERVER_ERROR_BLOCK_CLEANED_UP: -32001,
|
|
4616
|
+
JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE: -32002,
|
|
4617
|
+
JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE: -32003,
|
|
4618
|
+
JSON_RPC_SERVER_ERROR_BLOCK_NOT_AVAILABLE: -32004,
|
|
4619
|
+
JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY: -32005,
|
|
4620
|
+
JSON_RPC_SERVER_ERROR_TRANSACTION_PRECOMPILE_VERIFICATION_FAILURE: -32006,
|
|
4621
|
+
JSON_RPC_SERVER_ERROR_SLOT_SKIPPED: -32007,
|
|
4622
|
+
JSON_RPC_SERVER_ERROR_NO_SNAPSHOT: -32008,
|
|
4623
|
+
JSON_RPC_SERVER_ERROR_LONG_TERM_STORAGE_SLOT_SKIPPED: -32009,
|
|
4624
|
+
JSON_RPC_SERVER_ERROR_KEY_EXCLUDED_FROM_SECONDARY_INDEX: -32010,
|
|
4625
|
+
JSON_RPC_SERVER_ERROR_TRANSACTION_HISTORY_NOT_AVAILABLE: -32011,
|
|
4626
|
+
JSON_RPC_SCAN_ERROR: -32012,
|
|
4627
|
+
JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_LEN_MISMATCH: -32013,
|
|
4628
|
+
JSON_RPC_SERVER_ERROR_BLOCK_STATUS_NOT_AVAILABLE_YET: -32014,
|
|
4629
|
+
JSON_RPC_SERVER_ERROR_UNSUPPORTED_TRANSACTION_VERSION: -32015,
|
|
4630
|
+
JSON_RPC_SERVER_ERROR_MIN_CONTEXT_SLOT_NOT_REACHED: -32016
|
|
4631
|
+
};
|
|
4632
|
+
class SolanaJSONRPCError extends Error {
|
|
4633
|
+
constructor({
|
|
4634
|
+
code,
|
|
4635
|
+
message,
|
|
4636
|
+
data
|
|
4637
|
+
}, customMessage) {
|
|
4638
|
+
super(customMessage != null ? `${customMessage}: ${message}` : message);
|
|
4639
|
+
this.code = void 0;
|
|
4640
|
+
this.data = void 0;
|
|
4641
|
+
this.code = code;
|
|
4642
|
+
this.data = data;
|
|
4643
|
+
this.name = 'SolanaJSONRPCError';
|
|
4644
|
+
}
|
|
4645
|
+
|
|
4611
4646
|
}
|
|
4612
4647
|
|
|
4613
4648
|
async function fetchImpl (input, init) {
|
|
@@ -5779,7 +5814,7 @@ class Connection {
|
|
|
5779
5814
|
const res = superstruct.create(unsafeRes, jsonRpcResultAndContext(superstruct.number()));
|
|
5780
5815
|
|
|
5781
5816
|
if ('error' in res) {
|
|
5782
|
-
throw new
|
|
5817
|
+
throw new SolanaJSONRPCError(res.error, `failed to get balance for ${publicKey.toBase58()}`);
|
|
5783
5818
|
}
|
|
5784
5819
|
|
|
5785
5820
|
return res.result;
|
|
@@ -5804,7 +5839,7 @@ class Connection {
|
|
|
5804
5839
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.nullable(superstruct.number())));
|
|
5805
5840
|
|
|
5806
5841
|
if ('error' in res) {
|
|
5807
|
-
throw new
|
|
5842
|
+
throw new SolanaJSONRPCError(res.error, `failed to get block time for slot ${slot}`);
|
|
5808
5843
|
}
|
|
5809
5844
|
|
|
5810
5845
|
return res.result;
|
|
@@ -5820,7 +5855,7 @@ class Connection {
|
|
|
5820
5855
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.number()));
|
|
5821
5856
|
|
|
5822
5857
|
if ('error' in res) {
|
|
5823
|
-
throw new
|
|
5858
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get minimum ledger slot');
|
|
5824
5859
|
}
|
|
5825
5860
|
|
|
5826
5861
|
return res.result;
|
|
@@ -5835,7 +5870,7 @@ class Connection {
|
|
|
5835
5870
|
const res = superstruct.create(unsafeRes, SlotRpcResult);
|
|
5836
5871
|
|
|
5837
5872
|
if ('error' in res) {
|
|
5838
|
-
throw new
|
|
5873
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get first available block');
|
|
5839
5874
|
}
|
|
5840
5875
|
|
|
5841
5876
|
return res.result;
|
|
@@ -5866,7 +5901,7 @@ class Connection {
|
|
|
5866
5901
|
const res = superstruct.create(unsafeRes, GetSupplyRpcResult);
|
|
5867
5902
|
|
|
5868
5903
|
if ('error' in res) {
|
|
5869
|
-
throw new
|
|
5904
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get supply');
|
|
5870
5905
|
}
|
|
5871
5906
|
|
|
5872
5907
|
return res.result;
|
|
@@ -5883,7 +5918,7 @@ class Connection {
|
|
|
5883
5918
|
const res = superstruct.create(unsafeRes, jsonRpcResultAndContext(TokenAmountResult));
|
|
5884
5919
|
|
|
5885
5920
|
if ('error' in res) {
|
|
5886
|
-
throw new
|
|
5921
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get token supply');
|
|
5887
5922
|
}
|
|
5888
5923
|
|
|
5889
5924
|
return res.result;
|
|
@@ -5900,7 +5935,7 @@ class Connection {
|
|
|
5900
5935
|
const res = superstruct.create(unsafeRes, jsonRpcResultAndContext(TokenAmountResult));
|
|
5901
5936
|
|
|
5902
5937
|
if ('error' in res) {
|
|
5903
|
-
throw new
|
|
5938
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get token account balance');
|
|
5904
5939
|
}
|
|
5905
5940
|
|
|
5906
5941
|
return res.result;
|
|
@@ -5935,7 +5970,7 @@ class Connection {
|
|
|
5935
5970
|
const res = superstruct.create(unsafeRes, GetTokenAccountsByOwner);
|
|
5936
5971
|
|
|
5937
5972
|
if ('error' in res) {
|
|
5938
|
-
throw new
|
|
5973
|
+
throw new SolanaJSONRPCError(res.error, `failed to get token accounts owned by account ${ownerAddress.toBase58()}`);
|
|
5939
5974
|
}
|
|
5940
5975
|
|
|
5941
5976
|
return res.result;
|
|
@@ -5966,7 +6001,7 @@ class Connection {
|
|
|
5966
6001
|
const res = superstruct.create(unsafeRes, GetParsedTokenAccountsByOwner);
|
|
5967
6002
|
|
|
5968
6003
|
if ('error' in res) {
|
|
5969
|
-
throw new
|
|
6004
|
+
throw new SolanaJSONRPCError(res.error, `failed to get token accounts owned by account ${ownerAddress.toBase58()}`);
|
|
5970
6005
|
}
|
|
5971
6006
|
|
|
5972
6007
|
return res.result;
|
|
@@ -5985,7 +6020,7 @@ class Connection {
|
|
|
5985
6020
|
const res = superstruct.create(unsafeRes, GetLargestAccountsRpcResult);
|
|
5986
6021
|
|
|
5987
6022
|
if ('error' in res) {
|
|
5988
|
-
throw new
|
|
6023
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get largest accounts');
|
|
5989
6024
|
}
|
|
5990
6025
|
|
|
5991
6026
|
return res.result;
|
|
@@ -6003,7 +6038,7 @@ class Connection {
|
|
|
6003
6038
|
const res = superstruct.create(unsafeRes, GetTokenLargestAccountsResult);
|
|
6004
6039
|
|
|
6005
6040
|
if ('error' in res) {
|
|
6006
|
-
throw new
|
|
6041
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get token largest accounts');
|
|
6007
6042
|
}
|
|
6008
6043
|
|
|
6009
6044
|
return res.result;
|
|
@@ -6025,7 +6060,7 @@ class Connection {
|
|
|
6025
6060
|
const res = superstruct.create(unsafeRes, jsonRpcResultAndContext(superstruct.nullable(AccountInfoResult)));
|
|
6026
6061
|
|
|
6027
6062
|
if ('error' in res) {
|
|
6028
|
-
throw new
|
|
6063
|
+
throw new SolanaJSONRPCError(res.error, `failed to get info about account ${publicKey.toBase58()}`);
|
|
6029
6064
|
}
|
|
6030
6065
|
|
|
6031
6066
|
return res.result;
|
|
@@ -6042,7 +6077,7 @@ class Connection {
|
|
|
6042
6077
|
const res = superstruct.create(unsafeRes, jsonRpcResultAndContext(superstruct.nullable(ParsedAccountInfoResult)));
|
|
6043
6078
|
|
|
6044
6079
|
if ('error' in res) {
|
|
6045
|
-
throw new
|
|
6080
|
+
throw new SolanaJSONRPCError(res.error, `failed to get info about account ${publicKey.toBase58()}`);
|
|
6046
6081
|
}
|
|
6047
6082
|
|
|
6048
6083
|
return res.result;
|
|
@@ -6078,7 +6113,7 @@ class Connection {
|
|
|
6078
6113
|
const res = superstruct.create(unsafeRes, jsonRpcResultAndContext(superstruct.array(superstruct.nullable(AccountInfoResult))));
|
|
6079
6114
|
|
|
6080
6115
|
if ('error' in res) {
|
|
6081
|
-
throw new
|
|
6116
|
+
throw new SolanaJSONRPCError(res.error, `failed to get info for accounts ${keys}`);
|
|
6082
6117
|
}
|
|
6083
6118
|
|
|
6084
6119
|
return res.result;
|
|
@@ -6113,7 +6148,7 @@ class Connection {
|
|
|
6113
6148
|
const res = superstruct.create(unsafeRes, jsonRpcResult(StakeActivationResult));
|
|
6114
6149
|
|
|
6115
6150
|
if ('error' in res) {
|
|
6116
|
-
throw new
|
|
6151
|
+
throw new SolanaJSONRPCError(res.error, `failed to get Stake Activation ${publicKey.toBase58()}`);
|
|
6117
6152
|
}
|
|
6118
6153
|
|
|
6119
6154
|
return res.result;
|
|
@@ -6141,7 +6176,7 @@ class Connection {
|
|
|
6141
6176
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.array(KeyedAccountInfoResult)));
|
|
6142
6177
|
|
|
6143
6178
|
if ('error' in res) {
|
|
6144
|
-
throw new
|
|
6179
|
+
throw new SolanaJSONRPCError(res.error, `failed to get accounts owned by program ${programId.toBase58()}`);
|
|
6145
6180
|
}
|
|
6146
6181
|
|
|
6147
6182
|
return res.result;
|
|
@@ -6165,7 +6200,7 @@ class Connection {
|
|
|
6165
6200
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.array(KeyedParsedAccountInfoResult)));
|
|
6166
6201
|
|
|
6167
6202
|
if ('error' in res) {
|
|
6168
|
-
throw new
|
|
6203
|
+
throw new SolanaJSONRPCError(res.error, `failed to get accounts owned by program ${programId.toBase58()}`);
|
|
6169
6204
|
}
|
|
6170
6205
|
|
|
6171
6206
|
return res.result;
|
|
@@ -6299,7 +6334,7 @@ class Connection {
|
|
|
6299
6334
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.array(ContactInfoResult)));
|
|
6300
6335
|
|
|
6301
6336
|
if ('error' in res) {
|
|
6302
|
-
throw new
|
|
6337
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get cluster nodes');
|
|
6303
6338
|
}
|
|
6304
6339
|
|
|
6305
6340
|
return res.result;
|
|
@@ -6316,7 +6351,7 @@ class Connection {
|
|
|
6316
6351
|
const res = superstruct.create(unsafeRes, GetVoteAccounts);
|
|
6317
6352
|
|
|
6318
6353
|
if ('error' in res) {
|
|
6319
|
-
throw new
|
|
6354
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get vote accounts');
|
|
6320
6355
|
}
|
|
6321
6356
|
|
|
6322
6357
|
return res.result;
|
|
@@ -6340,7 +6375,7 @@ class Connection {
|
|
|
6340
6375
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.number()));
|
|
6341
6376
|
|
|
6342
6377
|
if ('error' in res) {
|
|
6343
|
-
throw new
|
|
6378
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get slot');
|
|
6344
6379
|
}
|
|
6345
6380
|
|
|
6346
6381
|
return res.result;
|
|
@@ -6364,7 +6399,7 @@ class Connection {
|
|
|
6364
6399
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.string()));
|
|
6365
6400
|
|
|
6366
6401
|
if ('error' in res) {
|
|
6367
|
-
throw new
|
|
6402
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get slot leader');
|
|
6368
6403
|
}
|
|
6369
6404
|
|
|
6370
6405
|
return res.result;
|
|
@@ -6383,7 +6418,7 @@ class Connection {
|
|
|
6383
6418
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.array(PublicKeyFromString)));
|
|
6384
6419
|
|
|
6385
6420
|
if ('error' in res) {
|
|
6386
|
-
throw new
|
|
6421
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get slot leaders');
|
|
6387
6422
|
}
|
|
6388
6423
|
|
|
6389
6424
|
return res.result;
|
|
@@ -6421,7 +6456,7 @@ class Connection {
|
|
|
6421
6456
|
const res = superstruct.create(unsafeRes, GetSignatureStatusesRpcResult);
|
|
6422
6457
|
|
|
6423
6458
|
if ('error' in res) {
|
|
6424
|
-
throw new
|
|
6459
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get signature status');
|
|
6425
6460
|
}
|
|
6426
6461
|
|
|
6427
6462
|
return res.result;
|
|
@@ -6445,7 +6480,7 @@ class Connection {
|
|
|
6445
6480
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.number()));
|
|
6446
6481
|
|
|
6447
6482
|
if ('error' in res) {
|
|
6448
|
-
throw new
|
|
6483
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get transaction count');
|
|
6449
6484
|
}
|
|
6450
6485
|
|
|
6451
6486
|
return res.result;
|
|
@@ -6476,7 +6511,7 @@ class Connection {
|
|
|
6476
6511
|
const res = superstruct.create(unsafeRes, GetInflationGovernorRpcResult);
|
|
6477
6512
|
|
|
6478
6513
|
if ('error' in res) {
|
|
6479
|
-
throw new
|
|
6514
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get inflation');
|
|
6480
6515
|
}
|
|
6481
6516
|
|
|
6482
6517
|
return res.result;
|
|
@@ -6502,7 +6537,7 @@ class Connection {
|
|
|
6502
6537
|
const res = superstruct.create(unsafeRes, GetInflationRewardResult);
|
|
6503
6538
|
|
|
6504
6539
|
if ('error' in res) {
|
|
6505
|
-
throw new
|
|
6540
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get inflation reward');
|
|
6506
6541
|
}
|
|
6507
6542
|
|
|
6508
6543
|
return res.result;
|
|
@@ -6526,7 +6561,7 @@ class Connection {
|
|
|
6526
6561
|
const res = superstruct.create(unsafeRes, GetEpochInfoRpcResult);
|
|
6527
6562
|
|
|
6528
6563
|
if ('error' in res) {
|
|
6529
|
-
throw new
|
|
6564
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get epoch info');
|
|
6530
6565
|
}
|
|
6531
6566
|
|
|
6532
6567
|
return res.result;
|
|
@@ -6541,7 +6576,7 @@ class Connection {
|
|
|
6541
6576
|
const res = superstruct.create(unsafeRes, GetEpochScheduleRpcResult);
|
|
6542
6577
|
|
|
6543
6578
|
if ('error' in res) {
|
|
6544
|
-
throw new
|
|
6579
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get epoch schedule');
|
|
6545
6580
|
}
|
|
6546
6581
|
|
|
6547
6582
|
const epochSchedule = res.result;
|
|
@@ -6558,7 +6593,7 @@ class Connection {
|
|
|
6558
6593
|
const res = superstruct.create(unsafeRes, GetLeaderScheduleRpcResult);
|
|
6559
6594
|
|
|
6560
6595
|
if ('error' in res) {
|
|
6561
|
-
throw new
|
|
6596
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get leader schedule');
|
|
6562
6597
|
}
|
|
6563
6598
|
|
|
6564
6599
|
return res.result;
|
|
@@ -6597,7 +6632,7 @@ class Connection {
|
|
|
6597
6632
|
const res = superstruct.create(unsafeRes, GetRecentBlockhashAndContextRpcResult);
|
|
6598
6633
|
|
|
6599
6634
|
if ('error' in res) {
|
|
6600
|
-
throw new
|
|
6635
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get recent blockhash');
|
|
6601
6636
|
}
|
|
6602
6637
|
|
|
6603
6638
|
return res.result;
|
|
@@ -6615,7 +6650,7 @@ class Connection {
|
|
|
6615
6650
|
const res = superstruct.create(unsafeRes, GetRecentPerformanceSamplesRpcResult);
|
|
6616
6651
|
|
|
6617
6652
|
if ('error' in res) {
|
|
6618
|
-
throw new
|
|
6653
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get recent performance samples');
|
|
6619
6654
|
}
|
|
6620
6655
|
|
|
6621
6656
|
return res.result;
|
|
@@ -6634,7 +6669,7 @@ class Connection {
|
|
|
6634
6669
|
const res = superstruct.create(unsafeRes, GetFeeCalculatorRpcResult);
|
|
6635
6670
|
|
|
6636
6671
|
if ('error' in res) {
|
|
6637
|
-
throw new
|
|
6672
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get fee calculator');
|
|
6638
6673
|
}
|
|
6639
6674
|
|
|
6640
6675
|
const {
|
|
@@ -6660,7 +6695,7 @@ class Connection {
|
|
|
6660
6695
|
const res = superstruct.create(unsafeRes, jsonRpcResultAndContext(superstruct.nullable(superstruct.number())));
|
|
6661
6696
|
|
|
6662
6697
|
if ('error' in res) {
|
|
6663
|
-
throw new
|
|
6698
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get slot');
|
|
6664
6699
|
}
|
|
6665
6700
|
|
|
6666
6701
|
if (res.result === null) {
|
|
@@ -6719,7 +6754,7 @@ class Connection {
|
|
|
6719
6754
|
const res = superstruct.create(unsafeRes, GetLatestBlockhashRpcResult);
|
|
6720
6755
|
|
|
6721
6756
|
if ('error' in res) {
|
|
6722
|
-
throw new
|
|
6757
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get latest blockhash');
|
|
6723
6758
|
}
|
|
6724
6759
|
|
|
6725
6760
|
return res.result;
|
|
@@ -6734,7 +6769,7 @@ class Connection {
|
|
|
6734
6769
|
const res = superstruct.create(unsafeRes, jsonRpcResult(VersionResult));
|
|
6735
6770
|
|
|
6736
6771
|
if ('error' in res) {
|
|
6737
|
-
throw new
|
|
6772
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get version');
|
|
6738
6773
|
}
|
|
6739
6774
|
|
|
6740
6775
|
return res.result;
|
|
@@ -6749,7 +6784,7 @@ class Connection {
|
|
|
6749
6784
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.string()));
|
|
6750
6785
|
|
|
6751
6786
|
if ('error' in res) {
|
|
6752
|
-
throw new
|
|
6787
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get genesis hash');
|
|
6753
6788
|
}
|
|
6754
6789
|
|
|
6755
6790
|
return res.result;
|
|
@@ -6766,7 +6801,7 @@ class Connection {
|
|
|
6766
6801
|
const res = superstruct.create(unsafeRes, GetBlockRpcResult);
|
|
6767
6802
|
|
|
6768
6803
|
if ('error' in res) {
|
|
6769
|
-
throw new
|
|
6804
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get confirmed block');
|
|
6770
6805
|
}
|
|
6771
6806
|
|
|
6772
6807
|
const result = res.result;
|
|
@@ -6805,7 +6840,7 @@ class Connection {
|
|
|
6805
6840
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.number()));
|
|
6806
6841
|
|
|
6807
6842
|
if ('error' in res) {
|
|
6808
|
-
throw new
|
|
6843
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get block height information');
|
|
6809
6844
|
}
|
|
6810
6845
|
|
|
6811
6846
|
return res.result;
|
|
@@ -6836,7 +6871,7 @@ class Connection {
|
|
|
6836
6871
|
const res = superstruct.create(unsafeRes, BlockProductionResponseStruct);
|
|
6837
6872
|
|
|
6838
6873
|
if ('error' in res) {
|
|
6839
|
-
throw new
|
|
6874
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get block production information');
|
|
6840
6875
|
}
|
|
6841
6876
|
|
|
6842
6877
|
return res.result;
|
|
@@ -6853,7 +6888,7 @@ class Connection {
|
|
|
6853
6888
|
const res = superstruct.create(unsafeRes, GetTransactionRpcResult);
|
|
6854
6889
|
|
|
6855
6890
|
if ('error' in res) {
|
|
6856
|
-
throw new
|
|
6891
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get transaction');
|
|
6857
6892
|
}
|
|
6858
6893
|
|
|
6859
6894
|
const result = res.result;
|
|
@@ -6876,7 +6911,7 @@ class Connection {
|
|
|
6876
6911
|
const res = superstruct.create(unsafeRes, GetParsedTransactionRpcResult);
|
|
6877
6912
|
|
|
6878
6913
|
if ('error' in res) {
|
|
6879
|
-
throw new
|
|
6914
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get transaction');
|
|
6880
6915
|
}
|
|
6881
6916
|
|
|
6882
6917
|
return res.result;
|
|
@@ -6900,7 +6935,7 @@ class Connection {
|
|
|
6900
6935
|
const res = superstruct.create(unsafeRes, GetParsedTransactionRpcResult);
|
|
6901
6936
|
|
|
6902
6937
|
if ('error' in res) {
|
|
6903
|
-
throw new
|
|
6938
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get transactions');
|
|
6904
6939
|
}
|
|
6905
6940
|
|
|
6906
6941
|
return res.result;
|
|
@@ -6927,7 +6962,7 @@ class Connection {
|
|
|
6927
6962
|
const res = superstruct.create(unsafeRes, GetTransactionRpcResult);
|
|
6928
6963
|
|
|
6929
6964
|
if ('error' in res) {
|
|
6930
|
-
throw new
|
|
6965
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get transactions');
|
|
6931
6966
|
}
|
|
6932
6967
|
|
|
6933
6968
|
const result = res.result;
|
|
@@ -6955,7 +6990,7 @@ class Connection {
|
|
|
6955
6990
|
const res = superstruct.create(unsafeRes, GetConfirmedBlockRpcResult);
|
|
6956
6991
|
|
|
6957
6992
|
if ('error' in res) {
|
|
6958
|
-
throw new
|
|
6993
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get confirmed block');
|
|
6959
6994
|
}
|
|
6960
6995
|
|
|
6961
6996
|
const result = res.result;
|
|
@@ -7002,7 +7037,7 @@ class Connection {
|
|
|
7002
7037
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.array(superstruct.number())));
|
|
7003
7038
|
|
|
7004
7039
|
if ('error' in res) {
|
|
7005
|
-
throw new
|
|
7040
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get blocks');
|
|
7006
7041
|
}
|
|
7007
7042
|
|
|
7008
7043
|
return res.result;
|
|
@@ -7022,7 +7057,7 @@ class Connection {
|
|
|
7022
7057
|
const res = superstruct.create(unsafeRes, GetBlockSignaturesRpcResult);
|
|
7023
7058
|
|
|
7024
7059
|
if ('error' in res) {
|
|
7025
|
-
throw new
|
|
7060
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get block');
|
|
7026
7061
|
}
|
|
7027
7062
|
|
|
7028
7063
|
const result = res.result;
|
|
@@ -7050,7 +7085,7 @@ class Connection {
|
|
|
7050
7085
|
const res = superstruct.create(unsafeRes, GetBlockSignaturesRpcResult);
|
|
7051
7086
|
|
|
7052
7087
|
if ('error' in res) {
|
|
7053
|
-
throw new
|
|
7088
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get confirmed block');
|
|
7054
7089
|
}
|
|
7055
7090
|
|
|
7056
7091
|
const result = res.result;
|
|
@@ -7075,7 +7110,7 @@ class Connection {
|
|
|
7075
7110
|
const res = superstruct.create(unsafeRes, GetTransactionRpcResult);
|
|
7076
7111
|
|
|
7077
7112
|
if ('error' in res) {
|
|
7078
|
-
throw new
|
|
7113
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get transaction');
|
|
7079
7114
|
}
|
|
7080
7115
|
|
|
7081
7116
|
const result = res.result;
|
|
@@ -7100,7 +7135,7 @@ class Connection {
|
|
|
7100
7135
|
const res = superstruct.create(unsafeRes, GetParsedTransactionRpcResult);
|
|
7101
7136
|
|
|
7102
7137
|
if ('error' in res) {
|
|
7103
|
-
throw new
|
|
7138
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get confirmed transaction');
|
|
7104
7139
|
}
|
|
7105
7140
|
|
|
7106
7141
|
return res.result;
|
|
@@ -7126,7 +7161,7 @@ class Connection {
|
|
|
7126
7161
|
const res = superstruct.create(unsafeRes, GetParsedTransactionRpcResult);
|
|
7127
7162
|
|
|
7128
7163
|
if ('error' in res) {
|
|
7129
|
-
throw new
|
|
7164
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get confirmed transactions');
|
|
7130
7165
|
}
|
|
7131
7166
|
|
|
7132
7167
|
return res.result;
|
|
@@ -7215,7 +7250,7 @@ class Connection {
|
|
|
7215
7250
|
const res = superstruct.create(unsafeRes, GetConfirmedSignaturesForAddress2RpcResult);
|
|
7216
7251
|
|
|
7217
7252
|
if ('error' in res) {
|
|
7218
|
-
throw new
|
|
7253
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get confirmed signatures for address');
|
|
7219
7254
|
}
|
|
7220
7255
|
|
|
7221
7256
|
return res.result;
|
|
@@ -7237,7 +7272,7 @@ class Connection {
|
|
|
7237
7272
|
const res = superstruct.create(unsafeRes, GetSignaturesForAddressRpcResult);
|
|
7238
7273
|
|
|
7239
7274
|
if ('error' in res) {
|
|
7240
|
-
throw new
|
|
7275
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get signatures for address');
|
|
7241
7276
|
}
|
|
7242
7277
|
|
|
7243
7278
|
return res.result;
|
|
@@ -7294,7 +7329,7 @@ class Connection {
|
|
|
7294
7329
|
const res = superstruct.create(unsafeRes, RequestAirdropRpcResult);
|
|
7295
7330
|
|
|
7296
7331
|
if ('error' in res) {
|
|
7297
|
-
throw new
|
|
7332
|
+
throw new SolanaJSONRPCError(res.error, `airdrop to ${to.toBase58()} failed`);
|
|
7298
7333
|
}
|
|
7299
7334
|
|
|
7300
7335
|
return res.result;
|
|
@@ -10034,6 +10069,8 @@ exports.SYSVAR_SLOT_HISTORY_PUBKEY = SYSVAR_SLOT_HISTORY_PUBKEY;
|
|
|
10034
10069
|
exports.SYSVAR_STAKE_HISTORY_PUBKEY = SYSVAR_STAKE_HISTORY_PUBKEY;
|
|
10035
10070
|
exports.Secp256k1Program = Secp256k1Program;
|
|
10036
10071
|
exports.SendTransactionError = SendTransactionError;
|
|
10072
|
+
exports.SolanaJSONRPCError = SolanaJSONRPCError;
|
|
10073
|
+
exports.SolanaJSONRPCErrorCode = SolanaJSONRPCErrorCode;
|
|
10037
10074
|
exports.StakeAuthorizationLayout = StakeAuthorizationLayout;
|
|
10038
10075
|
exports.StakeInstruction = StakeInstruction;
|
|
10039
10076
|
exports.StakeProgram = StakeProgram;
|