@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.browser.cjs.js
CHANGED
|
@@ -4532,6 +4532,41 @@ class SendTransactionError extends Error {
|
|
|
4532
4532
|
this.logs = logs;
|
|
4533
4533
|
}
|
|
4534
4534
|
|
|
4535
|
+
} // Keep in sync with client/src/rpc_custom_errors.rs
|
|
4536
|
+
// Typescript `enums` thwart tree-shaking. See https://bargsten.org/jsts/enums/
|
|
4537
|
+
|
|
4538
|
+
const SolanaJSONRPCErrorCode = {
|
|
4539
|
+
JSON_RPC_SERVER_ERROR_BLOCK_CLEANED_UP: -32001,
|
|
4540
|
+
JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE: -32002,
|
|
4541
|
+
JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE: -32003,
|
|
4542
|
+
JSON_RPC_SERVER_ERROR_BLOCK_NOT_AVAILABLE: -32004,
|
|
4543
|
+
JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY: -32005,
|
|
4544
|
+
JSON_RPC_SERVER_ERROR_TRANSACTION_PRECOMPILE_VERIFICATION_FAILURE: -32006,
|
|
4545
|
+
JSON_RPC_SERVER_ERROR_SLOT_SKIPPED: -32007,
|
|
4546
|
+
JSON_RPC_SERVER_ERROR_NO_SNAPSHOT: -32008,
|
|
4547
|
+
JSON_RPC_SERVER_ERROR_LONG_TERM_STORAGE_SLOT_SKIPPED: -32009,
|
|
4548
|
+
JSON_RPC_SERVER_ERROR_KEY_EXCLUDED_FROM_SECONDARY_INDEX: -32010,
|
|
4549
|
+
JSON_RPC_SERVER_ERROR_TRANSACTION_HISTORY_NOT_AVAILABLE: -32011,
|
|
4550
|
+
JSON_RPC_SCAN_ERROR: -32012,
|
|
4551
|
+
JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_LEN_MISMATCH: -32013,
|
|
4552
|
+
JSON_RPC_SERVER_ERROR_BLOCK_STATUS_NOT_AVAILABLE_YET: -32014,
|
|
4553
|
+
JSON_RPC_SERVER_ERROR_UNSUPPORTED_TRANSACTION_VERSION: -32015,
|
|
4554
|
+
JSON_RPC_SERVER_ERROR_MIN_CONTEXT_SLOT_NOT_REACHED: -32016
|
|
4555
|
+
};
|
|
4556
|
+
class SolanaJSONRPCError extends Error {
|
|
4557
|
+
constructor({
|
|
4558
|
+
code,
|
|
4559
|
+
message,
|
|
4560
|
+
data
|
|
4561
|
+
}, customMessage) {
|
|
4562
|
+
super(customMessage != null ? `${customMessage}: ${message}` : message);
|
|
4563
|
+
this.code = void 0;
|
|
4564
|
+
this.data = void 0;
|
|
4565
|
+
this.code = code;
|
|
4566
|
+
this.data = data;
|
|
4567
|
+
this.name = 'SolanaJSONRPCError';
|
|
4568
|
+
}
|
|
4569
|
+
|
|
4535
4570
|
}
|
|
4536
4571
|
|
|
4537
4572
|
var fetchImpl = globalThis.fetch;
|
|
@@ -5694,7 +5729,7 @@ class Connection {
|
|
|
5694
5729
|
const res = superstruct.create(unsafeRes, jsonRpcResultAndContext(superstruct.number()));
|
|
5695
5730
|
|
|
5696
5731
|
if ('error' in res) {
|
|
5697
|
-
throw new
|
|
5732
|
+
throw new SolanaJSONRPCError(res.error, `failed to get balance for ${publicKey.toBase58()}`);
|
|
5698
5733
|
}
|
|
5699
5734
|
|
|
5700
5735
|
return res.result;
|
|
@@ -5719,7 +5754,7 @@ class Connection {
|
|
|
5719
5754
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.nullable(superstruct.number())));
|
|
5720
5755
|
|
|
5721
5756
|
if ('error' in res) {
|
|
5722
|
-
throw new
|
|
5757
|
+
throw new SolanaJSONRPCError(res.error, `failed to get block time for slot ${slot}`);
|
|
5723
5758
|
}
|
|
5724
5759
|
|
|
5725
5760
|
return res.result;
|
|
@@ -5735,7 +5770,7 @@ class Connection {
|
|
|
5735
5770
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.number()));
|
|
5736
5771
|
|
|
5737
5772
|
if ('error' in res) {
|
|
5738
|
-
throw new
|
|
5773
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get minimum ledger slot');
|
|
5739
5774
|
}
|
|
5740
5775
|
|
|
5741
5776
|
return res.result;
|
|
@@ -5750,7 +5785,7 @@ class Connection {
|
|
|
5750
5785
|
const res = superstruct.create(unsafeRes, SlotRpcResult);
|
|
5751
5786
|
|
|
5752
5787
|
if ('error' in res) {
|
|
5753
|
-
throw new
|
|
5788
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get first available block');
|
|
5754
5789
|
}
|
|
5755
5790
|
|
|
5756
5791
|
return res.result;
|
|
@@ -5781,7 +5816,7 @@ class Connection {
|
|
|
5781
5816
|
const res = superstruct.create(unsafeRes, GetSupplyRpcResult);
|
|
5782
5817
|
|
|
5783
5818
|
if ('error' in res) {
|
|
5784
|
-
throw new
|
|
5819
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get supply');
|
|
5785
5820
|
}
|
|
5786
5821
|
|
|
5787
5822
|
return res.result;
|
|
@@ -5798,7 +5833,7 @@ class Connection {
|
|
|
5798
5833
|
const res = superstruct.create(unsafeRes, jsonRpcResultAndContext(TokenAmountResult));
|
|
5799
5834
|
|
|
5800
5835
|
if ('error' in res) {
|
|
5801
|
-
throw new
|
|
5836
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get token supply');
|
|
5802
5837
|
}
|
|
5803
5838
|
|
|
5804
5839
|
return res.result;
|
|
@@ -5815,7 +5850,7 @@ class Connection {
|
|
|
5815
5850
|
const res = superstruct.create(unsafeRes, jsonRpcResultAndContext(TokenAmountResult));
|
|
5816
5851
|
|
|
5817
5852
|
if ('error' in res) {
|
|
5818
|
-
throw new
|
|
5853
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get token account balance');
|
|
5819
5854
|
}
|
|
5820
5855
|
|
|
5821
5856
|
return res.result;
|
|
@@ -5850,7 +5885,7 @@ class Connection {
|
|
|
5850
5885
|
const res = superstruct.create(unsafeRes, GetTokenAccountsByOwner);
|
|
5851
5886
|
|
|
5852
5887
|
if ('error' in res) {
|
|
5853
|
-
throw new
|
|
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;
|
|
@@ -5881,7 +5916,7 @@ class Connection {
|
|
|
5881
5916
|
const res = superstruct.create(unsafeRes, GetParsedTokenAccountsByOwner);
|
|
5882
5917
|
|
|
5883
5918
|
if ('error' in res) {
|
|
5884
|
-
throw new
|
|
5919
|
+
throw new SolanaJSONRPCError(res.error, `failed to get token accounts owned by account ${ownerAddress.toBase58()}`);
|
|
5885
5920
|
}
|
|
5886
5921
|
|
|
5887
5922
|
return res.result;
|
|
@@ -5900,7 +5935,7 @@ class Connection {
|
|
|
5900
5935
|
const res = superstruct.create(unsafeRes, GetLargestAccountsRpcResult);
|
|
5901
5936
|
|
|
5902
5937
|
if ('error' in res) {
|
|
5903
|
-
throw new
|
|
5938
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get largest accounts');
|
|
5904
5939
|
}
|
|
5905
5940
|
|
|
5906
5941
|
return res.result;
|
|
@@ -5918,7 +5953,7 @@ class Connection {
|
|
|
5918
5953
|
const res = superstruct.create(unsafeRes, GetTokenLargestAccountsResult);
|
|
5919
5954
|
|
|
5920
5955
|
if ('error' in res) {
|
|
5921
|
-
throw new
|
|
5956
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get token largest accounts');
|
|
5922
5957
|
}
|
|
5923
5958
|
|
|
5924
5959
|
return res.result;
|
|
@@ -5940,7 +5975,7 @@ class Connection {
|
|
|
5940
5975
|
const res = superstruct.create(unsafeRes, jsonRpcResultAndContext(superstruct.nullable(AccountInfoResult)));
|
|
5941
5976
|
|
|
5942
5977
|
if ('error' in res) {
|
|
5943
|
-
throw new
|
|
5978
|
+
throw new SolanaJSONRPCError(res.error, `failed to get info about account ${publicKey.toBase58()}`);
|
|
5944
5979
|
}
|
|
5945
5980
|
|
|
5946
5981
|
return res.result;
|
|
@@ -5957,7 +5992,7 @@ class Connection {
|
|
|
5957
5992
|
const res = superstruct.create(unsafeRes, jsonRpcResultAndContext(superstruct.nullable(ParsedAccountInfoResult)));
|
|
5958
5993
|
|
|
5959
5994
|
if ('error' in res) {
|
|
5960
|
-
throw new
|
|
5995
|
+
throw new SolanaJSONRPCError(res.error, `failed to get info about account ${publicKey.toBase58()}`);
|
|
5961
5996
|
}
|
|
5962
5997
|
|
|
5963
5998
|
return res.result;
|
|
@@ -5993,7 +6028,7 @@ class Connection {
|
|
|
5993
6028
|
const res = superstruct.create(unsafeRes, jsonRpcResultAndContext(superstruct.array(superstruct.nullable(AccountInfoResult))));
|
|
5994
6029
|
|
|
5995
6030
|
if ('error' in res) {
|
|
5996
|
-
throw new
|
|
6031
|
+
throw new SolanaJSONRPCError(res.error, `failed to get info for accounts ${keys}`);
|
|
5997
6032
|
}
|
|
5998
6033
|
|
|
5999
6034
|
return res.result;
|
|
@@ -6028,7 +6063,7 @@ class Connection {
|
|
|
6028
6063
|
const res = superstruct.create(unsafeRes, jsonRpcResult(StakeActivationResult));
|
|
6029
6064
|
|
|
6030
6065
|
if ('error' in res) {
|
|
6031
|
-
throw new
|
|
6066
|
+
throw new SolanaJSONRPCError(res.error, `failed to get Stake Activation ${publicKey.toBase58()}`);
|
|
6032
6067
|
}
|
|
6033
6068
|
|
|
6034
6069
|
return res.result;
|
|
@@ -6056,7 +6091,7 @@ class Connection {
|
|
|
6056
6091
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.array(KeyedAccountInfoResult)));
|
|
6057
6092
|
|
|
6058
6093
|
if ('error' in res) {
|
|
6059
|
-
throw new
|
|
6094
|
+
throw new SolanaJSONRPCError(res.error, `failed to get accounts owned by program ${programId.toBase58()}`);
|
|
6060
6095
|
}
|
|
6061
6096
|
|
|
6062
6097
|
return res.result;
|
|
@@ -6080,7 +6115,7 @@ class Connection {
|
|
|
6080
6115
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.array(KeyedParsedAccountInfoResult)));
|
|
6081
6116
|
|
|
6082
6117
|
if ('error' in res) {
|
|
6083
|
-
throw new
|
|
6118
|
+
throw new SolanaJSONRPCError(res.error, `failed to get accounts owned by program ${programId.toBase58()}`);
|
|
6084
6119
|
}
|
|
6085
6120
|
|
|
6086
6121
|
return res.result;
|
|
@@ -6214,7 +6249,7 @@ class Connection {
|
|
|
6214
6249
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.array(ContactInfoResult)));
|
|
6215
6250
|
|
|
6216
6251
|
if ('error' in res) {
|
|
6217
|
-
throw new
|
|
6252
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get cluster nodes');
|
|
6218
6253
|
}
|
|
6219
6254
|
|
|
6220
6255
|
return res.result;
|
|
@@ -6231,7 +6266,7 @@ class Connection {
|
|
|
6231
6266
|
const res = superstruct.create(unsafeRes, GetVoteAccounts);
|
|
6232
6267
|
|
|
6233
6268
|
if ('error' in res) {
|
|
6234
|
-
throw new
|
|
6269
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get vote accounts');
|
|
6235
6270
|
}
|
|
6236
6271
|
|
|
6237
6272
|
return res.result;
|
|
@@ -6255,7 +6290,7 @@ class Connection {
|
|
|
6255
6290
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.number()));
|
|
6256
6291
|
|
|
6257
6292
|
if ('error' in res) {
|
|
6258
|
-
throw new
|
|
6293
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get slot');
|
|
6259
6294
|
}
|
|
6260
6295
|
|
|
6261
6296
|
return res.result;
|
|
@@ -6279,7 +6314,7 @@ class Connection {
|
|
|
6279
6314
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.string()));
|
|
6280
6315
|
|
|
6281
6316
|
if ('error' in res) {
|
|
6282
|
-
throw new
|
|
6317
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get slot leader');
|
|
6283
6318
|
}
|
|
6284
6319
|
|
|
6285
6320
|
return res.result;
|
|
@@ -6298,7 +6333,7 @@ class Connection {
|
|
|
6298
6333
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.array(PublicKeyFromString)));
|
|
6299
6334
|
|
|
6300
6335
|
if ('error' in res) {
|
|
6301
|
-
throw new
|
|
6336
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get slot leaders');
|
|
6302
6337
|
}
|
|
6303
6338
|
|
|
6304
6339
|
return res.result;
|
|
@@ -6336,7 +6371,7 @@ class Connection {
|
|
|
6336
6371
|
const res = superstruct.create(unsafeRes, GetSignatureStatusesRpcResult);
|
|
6337
6372
|
|
|
6338
6373
|
if ('error' in res) {
|
|
6339
|
-
throw new
|
|
6374
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get signature status');
|
|
6340
6375
|
}
|
|
6341
6376
|
|
|
6342
6377
|
return res.result;
|
|
@@ -6360,7 +6395,7 @@ class Connection {
|
|
|
6360
6395
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.number()));
|
|
6361
6396
|
|
|
6362
6397
|
if ('error' in res) {
|
|
6363
|
-
throw new
|
|
6398
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get transaction count');
|
|
6364
6399
|
}
|
|
6365
6400
|
|
|
6366
6401
|
return res.result;
|
|
@@ -6391,7 +6426,7 @@ class Connection {
|
|
|
6391
6426
|
const res = superstruct.create(unsafeRes, GetInflationGovernorRpcResult);
|
|
6392
6427
|
|
|
6393
6428
|
if ('error' in res) {
|
|
6394
|
-
throw new
|
|
6429
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get inflation');
|
|
6395
6430
|
}
|
|
6396
6431
|
|
|
6397
6432
|
return res.result;
|
|
@@ -6417,7 +6452,7 @@ class Connection {
|
|
|
6417
6452
|
const res = superstruct.create(unsafeRes, GetInflationRewardResult);
|
|
6418
6453
|
|
|
6419
6454
|
if ('error' in res) {
|
|
6420
|
-
throw new
|
|
6455
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get inflation reward');
|
|
6421
6456
|
}
|
|
6422
6457
|
|
|
6423
6458
|
return res.result;
|
|
@@ -6441,7 +6476,7 @@ class Connection {
|
|
|
6441
6476
|
const res = superstruct.create(unsafeRes, GetEpochInfoRpcResult);
|
|
6442
6477
|
|
|
6443
6478
|
if ('error' in res) {
|
|
6444
|
-
throw new
|
|
6479
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get epoch info');
|
|
6445
6480
|
}
|
|
6446
6481
|
|
|
6447
6482
|
return res.result;
|
|
@@ -6456,7 +6491,7 @@ class Connection {
|
|
|
6456
6491
|
const res = superstruct.create(unsafeRes, GetEpochScheduleRpcResult);
|
|
6457
6492
|
|
|
6458
6493
|
if ('error' in res) {
|
|
6459
|
-
throw new
|
|
6494
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get epoch schedule');
|
|
6460
6495
|
}
|
|
6461
6496
|
|
|
6462
6497
|
const epochSchedule = res.result;
|
|
@@ -6473,7 +6508,7 @@ class Connection {
|
|
|
6473
6508
|
const res = superstruct.create(unsafeRes, GetLeaderScheduleRpcResult);
|
|
6474
6509
|
|
|
6475
6510
|
if ('error' in res) {
|
|
6476
|
-
throw new
|
|
6511
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get leader schedule');
|
|
6477
6512
|
}
|
|
6478
6513
|
|
|
6479
6514
|
return res.result;
|
|
@@ -6512,7 +6547,7 @@ class Connection {
|
|
|
6512
6547
|
const res = superstruct.create(unsafeRes, GetRecentBlockhashAndContextRpcResult);
|
|
6513
6548
|
|
|
6514
6549
|
if ('error' in res) {
|
|
6515
|
-
throw new
|
|
6550
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get recent blockhash');
|
|
6516
6551
|
}
|
|
6517
6552
|
|
|
6518
6553
|
return res.result;
|
|
@@ -6530,7 +6565,7 @@ class Connection {
|
|
|
6530
6565
|
const res = superstruct.create(unsafeRes, GetRecentPerformanceSamplesRpcResult);
|
|
6531
6566
|
|
|
6532
6567
|
if ('error' in res) {
|
|
6533
|
-
throw new
|
|
6568
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get recent performance samples');
|
|
6534
6569
|
}
|
|
6535
6570
|
|
|
6536
6571
|
return res.result;
|
|
@@ -6549,7 +6584,7 @@ class Connection {
|
|
|
6549
6584
|
const res = superstruct.create(unsafeRes, GetFeeCalculatorRpcResult);
|
|
6550
6585
|
|
|
6551
6586
|
if ('error' in res) {
|
|
6552
|
-
throw new
|
|
6587
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get fee calculator');
|
|
6553
6588
|
}
|
|
6554
6589
|
|
|
6555
6590
|
const {
|
|
@@ -6575,7 +6610,7 @@ class Connection {
|
|
|
6575
6610
|
const res = superstruct.create(unsafeRes, jsonRpcResultAndContext(superstruct.nullable(superstruct.number())));
|
|
6576
6611
|
|
|
6577
6612
|
if ('error' in res) {
|
|
6578
|
-
throw new
|
|
6613
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get slot');
|
|
6579
6614
|
}
|
|
6580
6615
|
|
|
6581
6616
|
if (res.result === null) {
|
|
@@ -6634,7 +6669,7 @@ class Connection {
|
|
|
6634
6669
|
const res = superstruct.create(unsafeRes, GetLatestBlockhashRpcResult);
|
|
6635
6670
|
|
|
6636
6671
|
if ('error' in res) {
|
|
6637
|
-
throw new
|
|
6672
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get latest blockhash');
|
|
6638
6673
|
}
|
|
6639
6674
|
|
|
6640
6675
|
return res.result;
|
|
@@ -6649,7 +6684,7 @@ class Connection {
|
|
|
6649
6684
|
const res = superstruct.create(unsafeRes, jsonRpcResult(VersionResult));
|
|
6650
6685
|
|
|
6651
6686
|
if ('error' in res) {
|
|
6652
|
-
throw new
|
|
6687
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get version');
|
|
6653
6688
|
}
|
|
6654
6689
|
|
|
6655
6690
|
return res.result;
|
|
@@ -6664,7 +6699,7 @@ class Connection {
|
|
|
6664
6699
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.string()));
|
|
6665
6700
|
|
|
6666
6701
|
if ('error' in res) {
|
|
6667
|
-
throw new
|
|
6702
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get genesis hash');
|
|
6668
6703
|
}
|
|
6669
6704
|
|
|
6670
6705
|
return res.result;
|
|
@@ -6681,7 +6716,7 @@ class Connection {
|
|
|
6681
6716
|
const res = superstruct.create(unsafeRes, GetBlockRpcResult);
|
|
6682
6717
|
|
|
6683
6718
|
if ('error' in res) {
|
|
6684
|
-
throw new
|
|
6719
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get confirmed block');
|
|
6685
6720
|
}
|
|
6686
6721
|
|
|
6687
6722
|
const result = res.result;
|
|
@@ -6720,7 +6755,7 @@ class Connection {
|
|
|
6720
6755
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.number()));
|
|
6721
6756
|
|
|
6722
6757
|
if ('error' in res) {
|
|
6723
|
-
throw new
|
|
6758
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get block height information');
|
|
6724
6759
|
}
|
|
6725
6760
|
|
|
6726
6761
|
return res.result;
|
|
@@ -6751,7 +6786,7 @@ class Connection {
|
|
|
6751
6786
|
const res = superstruct.create(unsafeRes, BlockProductionResponseStruct);
|
|
6752
6787
|
|
|
6753
6788
|
if ('error' in res) {
|
|
6754
|
-
throw new
|
|
6789
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get block production information');
|
|
6755
6790
|
}
|
|
6756
6791
|
|
|
6757
6792
|
return res.result;
|
|
@@ -6768,7 +6803,7 @@ class Connection {
|
|
|
6768
6803
|
const res = superstruct.create(unsafeRes, GetTransactionRpcResult);
|
|
6769
6804
|
|
|
6770
6805
|
if ('error' in res) {
|
|
6771
|
-
throw new
|
|
6806
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get transaction');
|
|
6772
6807
|
}
|
|
6773
6808
|
|
|
6774
6809
|
const result = res.result;
|
|
@@ -6791,7 +6826,7 @@ class Connection {
|
|
|
6791
6826
|
const res = superstruct.create(unsafeRes, GetParsedTransactionRpcResult);
|
|
6792
6827
|
|
|
6793
6828
|
if ('error' in res) {
|
|
6794
|
-
throw new
|
|
6829
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get transaction');
|
|
6795
6830
|
}
|
|
6796
6831
|
|
|
6797
6832
|
return res.result;
|
|
@@ -6815,7 +6850,7 @@ class Connection {
|
|
|
6815
6850
|
const res = superstruct.create(unsafeRes, GetParsedTransactionRpcResult);
|
|
6816
6851
|
|
|
6817
6852
|
if ('error' in res) {
|
|
6818
|
-
throw new
|
|
6853
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get transactions');
|
|
6819
6854
|
}
|
|
6820
6855
|
|
|
6821
6856
|
return res.result;
|
|
@@ -6842,7 +6877,7 @@ class Connection {
|
|
|
6842
6877
|
const res = superstruct.create(unsafeRes, GetTransactionRpcResult);
|
|
6843
6878
|
|
|
6844
6879
|
if ('error' in res) {
|
|
6845
|
-
throw new
|
|
6880
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get transactions');
|
|
6846
6881
|
}
|
|
6847
6882
|
|
|
6848
6883
|
const result = res.result;
|
|
@@ -6870,7 +6905,7 @@ class Connection {
|
|
|
6870
6905
|
const res = superstruct.create(unsafeRes, GetConfirmedBlockRpcResult);
|
|
6871
6906
|
|
|
6872
6907
|
if ('error' in res) {
|
|
6873
|
-
throw new
|
|
6908
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get confirmed block');
|
|
6874
6909
|
}
|
|
6875
6910
|
|
|
6876
6911
|
const result = res.result;
|
|
@@ -6917,7 +6952,7 @@ class Connection {
|
|
|
6917
6952
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.array(superstruct.number())));
|
|
6918
6953
|
|
|
6919
6954
|
if ('error' in res) {
|
|
6920
|
-
throw new
|
|
6955
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get blocks');
|
|
6921
6956
|
}
|
|
6922
6957
|
|
|
6923
6958
|
return res.result;
|
|
@@ -6937,7 +6972,7 @@ class Connection {
|
|
|
6937
6972
|
const res = superstruct.create(unsafeRes, GetBlockSignaturesRpcResult);
|
|
6938
6973
|
|
|
6939
6974
|
if ('error' in res) {
|
|
6940
|
-
throw new
|
|
6975
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get block');
|
|
6941
6976
|
}
|
|
6942
6977
|
|
|
6943
6978
|
const result = res.result;
|
|
@@ -6965,7 +7000,7 @@ class Connection {
|
|
|
6965
7000
|
const res = superstruct.create(unsafeRes, GetBlockSignaturesRpcResult);
|
|
6966
7001
|
|
|
6967
7002
|
if ('error' in res) {
|
|
6968
|
-
throw new
|
|
7003
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get confirmed block');
|
|
6969
7004
|
}
|
|
6970
7005
|
|
|
6971
7006
|
const result = res.result;
|
|
@@ -6990,7 +7025,7 @@ class Connection {
|
|
|
6990
7025
|
const res = superstruct.create(unsafeRes, GetTransactionRpcResult);
|
|
6991
7026
|
|
|
6992
7027
|
if ('error' in res) {
|
|
6993
|
-
throw new
|
|
7028
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get transaction');
|
|
6994
7029
|
}
|
|
6995
7030
|
|
|
6996
7031
|
const result = res.result;
|
|
@@ -7015,7 +7050,7 @@ class Connection {
|
|
|
7015
7050
|
const res = superstruct.create(unsafeRes, GetParsedTransactionRpcResult);
|
|
7016
7051
|
|
|
7017
7052
|
if ('error' in res) {
|
|
7018
|
-
throw new
|
|
7053
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get confirmed transaction');
|
|
7019
7054
|
}
|
|
7020
7055
|
|
|
7021
7056
|
return res.result;
|
|
@@ -7041,7 +7076,7 @@ class Connection {
|
|
|
7041
7076
|
const res = superstruct.create(unsafeRes, GetParsedTransactionRpcResult);
|
|
7042
7077
|
|
|
7043
7078
|
if ('error' in res) {
|
|
7044
|
-
throw new
|
|
7079
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get confirmed transactions');
|
|
7045
7080
|
}
|
|
7046
7081
|
|
|
7047
7082
|
return res.result;
|
|
@@ -7130,7 +7165,7 @@ class Connection {
|
|
|
7130
7165
|
const res = superstruct.create(unsafeRes, GetConfirmedSignaturesForAddress2RpcResult);
|
|
7131
7166
|
|
|
7132
7167
|
if ('error' in res) {
|
|
7133
|
-
throw new
|
|
7168
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get confirmed signatures for address');
|
|
7134
7169
|
}
|
|
7135
7170
|
|
|
7136
7171
|
return res.result;
|
|
@@ -7152,7 +7187,7 @@ class Connection {
|
|
|
7152
7187
|
const res = superstruct.create(unsafeRes, GetSignaturesForAddressRpcResult);
|
|
7153
7188
|
|
|
7154
7189
|
if ('error' in res) {
|
|
7155
|
-
throw new
|
|
7190
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get signatures for address');
|
|
7156
7191
|
}
|
|
7157
7192
|
|
|
7158
7193
|
return res.result;
|
|
@@ -7209,7 +7244,7 @@ class Connection {
|
|
|
7209
7244
|
const res = superstruct.create(unsafeRes, RequestAirdropRpcResult);
|
|
7210
7245
|
|
|
7211
7246
|
if ('error' in res) {
|
|
7212
|
-
throw new
|
|
7247
|
+
throw new SolanaJSONRPCError(res.error, `airdrop to ${to.toBase58()} failed`);
|
|
7213
7248
|
}
|
|
7214
7249
|
|
|
7215
7250
|
return res.result;
|
|
@@ -9949,6 +9984,8 @@ exports.SYSVAR_SLOT_HISTORY_PUBKEY = SYSVAR_SLOT_HISTORY_PUBKEY;
|
|
|
9949
9984
|
exports.SYSVAR_STAKE_HISTORY_PUBKEY = SYSVAR_STAKE_HISTORY_PUBKEY;
|
|
9950
9985
|
exports.Secp256k1Program = Secp256k1Program;
|
|
9951
9986
|
exports.SendTransactionError = SendTransactionError;
|
|
9987
|
+
exports.SolanaJSONRPCError = SolanaJSONRPCError;
|
|
9988
|
+
exports.SolanaJSONRPCErrorCode = SolanaJSONRPCErrorCode;
|
|
9952
9989
|
exports.StakeAuthorizationLayout = StakeAuthorizationLayout;
|
|
9953
9990
|
exports.StakeInstruction = StakeInstruction;
|
|
9954
9991
|
exports.StakeProgram = StakeProgram;
|