@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.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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
6601
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get recent blockhash');
|
|
6567
6602
|
}
|
|
6568
6603
|
|
|
6569
6604
|
return res.result;
|
|
@@ -6581,7 +6616,7 @@ class Connection {
|
|
|
6581
6616
|
const res = create(unsafeRes, GetRecentPerformanceSamplesRpcResult);
|
|
6582
6617
|
|
|
6583
6618
|
if ('error' in res) {
|
|
6584
|
-
throw new
|
|
6619
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get recent performance samples');
|
|
6585
6620
|
}
|
|
6586
6621
|
|
|
6587
6622
|
return res.result;
|
|
@@ -6600,7 +6635,7 @@ class Connection {
|
|
|
6600
6635
|
const res = create(unsafeRes, GetFeeCalculatorRpcResult);
|
|
6601
6636
|
|
|
6602
6637
|
if ('error' in res) {
|
|
6603
|
-
throw new
|
|
6638
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get fee calculator');
|
|
6604
6639
|
}
|
|
6605
6640
|
|
|
6606
6641
|
const {
|
|
@@ -6626,7 +6661,7 @@ class Connection {
|
|
|
6626
6661
|
const res = create(unsafeRes, jsonRpcResultAndContext(nullable(number())));
|
|
6627
6662
|
|
|
6628
6663
|
if ('error' in res) {
|
|
6629
|
-
throw new
|
|
6664
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get slot');
|
|
6630
6665
|
}
|
|
6631
6666
|
|
|
6632
6667
|
if (res.result === null) {
|
|
@@ -6685,7 +6720,7 @@ class Connection {
|
|
|
6685
6720
|
const res = create(unsafeRes, GetLatestBlockhashRpcResult);
|
|
6686
6721
|
|
|
6687
6722
|
if ('error' in res) {
|
|
6688
|
-
throw new
|
|
6723
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get latest blockhash');
|
|
6689
6724
|
}
|
|
6690
6725
|
|
|
6691
6726
|
return res.result;
|
|
@@ -6700,7 +6735,7 @@ class Connection {
|
|
|
6700
6735
|
const res = create(unsafeRes, jsonRpcResult(VersionResult));
|
|
6701
6736
|
|
|
6702
6737
|
if ('error' in res) {
|
|
6703
|
-
throw new
|
|
6738
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get version');
|
|
6704
6739
|
}
|
|
6705
6740
|
|
|
6706
6741
|
return res.result;
|
|
@@ -6715,7 +6750,7 @@ class Connection {
|
|
|
6715
6750
|
const res = create(unsafeRes, jsonRpcResult(string()));
|
|
6716
6751
|
|
|
6717
6752
|
if ('error' in res) {
|
|
6718
|
-
throw new
|
|
6753
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get genesis hash');
|
|
6719
6754
|
}
|
|
6720
6755
|
|
|
6721
6756
|
return res.result;
|
|
@@ -6732,7 +6767,7 @@ class Connection {
|
|
|
6732
6767
|
const res = create(unsafeRes, GetBlockRpcResult);
|
|
6733
6768
|
|
|
6734
6769
|
if ('error' in res) {
|
|
6735
|
-
throw new
|
|
6770
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get confirmed block');
|
|
6736
6771
|
}
|
|
6737
6772
|
|
|
6738
6773
|
const result = res.result;
|
|
@@ -6771,7 +6806,7 @@ class Connection {
|
|
|
6771
6806
|
const res = create(unsafeRes, jsonRpcResult(number()));
|
|
6772
6807
|
|
|
6773
6808
|
if ('error' in res) {
|
|
6774
|
-
throw new
|
|
6809
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get block height information');
|
|
6775
6810
|
}
|
|
6776
6811
|
|
|
6777
6812
|
return res.result;
|
|
@@ -6802,7 +6837,7 @@ class Connection {
|
|
|
6802
6837
|
const res = create(unsafeRes, BlockProductionResponseStruct);
|
|
6803
6838
|
|
|
6804
6839
|
if ('error' in res) {
|
|
6805
|
-
throw new
|
|
6840
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get block production information');
|
|
6806
6841
|
}
|
|
6807
6842
|
|
|
6808
6843
|
return res.result;
|
|
@@ -6819,7 +6854,7 @@ class Connection {
|
|
|
6819
6854
|
const res = create(unsafeRes, GetTransactionRpcResult);
|
|
6820
6855
|
|
|
6821
6856
|
if ('error' in res) {
|
|
6822
|
-
throw new
|
|
6857
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get transaction');
|
|
6823
6858
|
}
|
|
6824
6859
|
|
|
6825
6860
|
const result = res.result;
|
|
@@ -6842,7 +6877,7 @@ class Connection {
|
|
|
6842
6877
|
const res = create(unsafeRes, GetParsedTransactionRpcResult);
|
|
6843
6878
|
|
|
6844
6879
|
if ('error' in res) {
|
|
6845
|
-
throw new
|
|
6880
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get transaction');
|
|
6846
6881
|
}
|
|
6847
6882
|
|
|
6848
6883
|
return res.result;
|
|
@@ -6866,7 +6901,7 @@ class Connection {
|
|
|
6866
6901
|
const res = create(unsafeRes, GetParsedTransactionRpcResult);
|
|
6867
6902
|
|
|
6868
6903
|
if ('error' in res) {
|
|
6869
|
-
throw new
|
|
6904
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get transactions');
|
|
6870
6905
|
}
|
|
6871
6906
|
|
|
6872
6907
|
return res.result;
|
|
@@ -6893,7 +6928,7 @@ class Connection {
|
|
|
6893
6928
|
const res = create(unsafeRes, GetTransactionRpcResult);
|
|
6894
6929
|
|
|
6895
6930
|
if ('error' in res) {
|
|
6896
|
-
throw new
|
|
6931
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get transactions');
|
|
6897
6932
|
}
|
|
6898
6933
|
|
|
6899
6934
|
const result = res.result;
|
|
@@ -6921,7 +6956,7 @@ class Connection {
|
|
|
6921
6956
|
const res = create(unsafeRes, GetConfirmedBlockRpcResult);
|
|
6922
6957
|
|
|
6923
6958
|
if ('error' in res) {
|
|
6924
|
-
throw new
|
|
6959
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get confirmed block');
|
|
6925
6960
|
}
|
|
6926
6961
|
|
|
6927
6962
|
const result = res.result;
|
|
@@ -6968,7 +7003,7 @@ class Connection {
|
|
|
6968
7003
|
const res = create(unsafeRes, jsonRpcResult(array(number())));
|
|
6969
7004
|
|
|
6970
7005
|
if ('error' in res) {
|
|
6971
|
-
throw new
|
|
7006
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get blocks');
|
|
6972
7007
|
}
|
|
6973
7008
|
|
|
6974
7009
|
return res.result;
|
|
@@ -6988,7 +7023,7 @@ class Connection {
|
|
|
6988
7023
|
const res = create(unsafeRes, GetBlockSignaturesRpcResult);
|
|
6989
7024
|
|
|
6990
7025
|
if ('error' in res) {
|
|
6991
|
-
throw new
|
|
7026
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get block');
|
|
6992
7027
|
}
|
|
6993
7028
|
|
|
6994
7029
|
const result = res.result;
|
|
@@ -7016,7 +7051,7 @@ class Connection {
|
|
|
7016
7051
|
const res = create(unsafeRes, GetBlockSignaturesRpcResult);
|
|
7017
7052
|
|
|
7018
7053
|
if ('error' in res) {
|
|
7019
|
-
throw new
|
|
7054
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get confirmed block');
|
|
7020
7055
|
}
|
|
7021
7056
|
|
|
7022
7057
|
const result = res.result;
|
|
@@ -7041,7 +7076,7 @@ class Connection {
|
|
|
7041
7076
|
const res = create(unsafeRes, GetTransactionRpcResult);
|
|
7042
7077
|
|
|
7043
7078
|
if ('error' in res) {
|
|
7044
|
-
throw new
|
|
7079
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get transaction');
|
|
7045
7080
|
}
|
|
7046
7081
|
|
|
7047
7082
|
const result = res.result;
|
|
@@ -7066,7 +7101,7 @@ class Connection {
|
|
|
7066
7101
|
const res = create(unsafeRes, GetParsedTransactionRpcResult);
|
|
7067
7102
|
|
|
7068
7103
|
if ('error' in res) {
|
|
7069
|
-
throw new
|
|
7104
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get confirmed transaction');
|
|
7070
7105
|
}
|
|
7071
7106
|
|
|
7072
7107
|
return res.result;
|
|
@@ -7092,7 +7127,7 @@ class Connection {
|
|
|
7092
7127
|
const res = create(unsafeRes, GetParsedTransactionRpcResult);
|
|
7093
7128
|
|
|
7094
7129
|
if ('error' in res) {
|
|
7095
|
-
throw new
|
|
7130
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get confirmed transactions');
|
|
7096
7131
|
}
|
|
7097
7132
|
|
|
7098
7133
|
return res.result;
|
|
@@ -7181,7 +7216,7 @@ class Connection {
|
|
|
7181
7216
|
const res = create(unsafeRes, GetConfirmedSignaturesForAddress2RpcResult);
|
|
7182
7217
|
|
|
7183
7218
|
if ('error' in res) {
|
|
7184
|
-
throw new
|
|
7219
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get confirmed signatures for address');
|
|
7185
7220
|
}
|
|
7186
7221
|
|
|
7187
7222
|
return res.result;
|
|
@@ -7203,7 +7238,7 @@ class Connection {
|
|
|
7203
7238
|
const res = create(unsafeRes, GetSignaturesForAddressRpcResult);
|
|
7204
7239
|
|
|
7205
7240
|
if ('error' in res) {
|
|
7206
|
-
throw new
|
|
7241
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get signatures for address');
|
|
7207
7242
|
}
|
|
7208
7243
|
|
|
7209
7244
|
return res.result;
|
|
@@ -7260,7 +7295,7 @@ class Connection {
|
|
|
7260
7295
|
const res = create(unsafeRes, RequestAirdropRpcResult);
|
|
7261
7296
|
|
|
7262
7297
|
if ('error' in res) {
|
|
7263
|
-
throw new
|
|
7298
|
+
throw new SolanaJSONRPCError(res.error, `airdrop to ${to.toBase58()} failed`);
|
|
7264
7299
|
}
|
|
7265
7300
|
|
|
7266
7301
|
return res.result;
|
|
@@ -9960,5 +9995,5 @@ function clusterApiUrl(cluster, tls) {
|
|
|
9960
9995
|
|
|
9961
9996
|
const LAMPORTS_PER_SOL = 1000000000;
|
|
9962
9997
|
|
|
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 };
|
|
9998
|
+
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
9999
|
//# sourceMappingURL=index.esm.js.map
|