@solana/web3.js 1.44.3 → 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 +254 -127
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +253 -128
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +254 -127
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +180 -18
- package/lib/index.esm.js +253 -128
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +254 -127
- package/lib/index.iife.js.map +1 -1
- package/lib/index.iife.min.js +3 -3
- package/lib/index.iife.min.js.map +1 -1
- package/package.json +3 -3
- package/src/connection.ts +382 -173
- package/src/errors.ts +41 -0
- package/src/util/send-and-confirm-raw-transaction.ts +1 -0
- package/src/util/send-and-confirm-transaction.ts +1 -0
package/lib/index.browser.cjs.js
CHANGED
|
@@ -3104,7 +3104,8 @@ async function sendAndConfirmTransaction(connection, transaction, signers, optio
|
|
|
3104
3104
|
const sendOptions = options && {
|
|
3105
3105
|
skipPreflight: options.skipPreflight,
|
|
3106
3106
|
preflightCommitment: options.preflightCommitment || options.commitment,
|
|
3107
|
-
maxRetries: options.maxRetries
|
|
3107
|
+
maxRetries: options.maxRetries,
|
|
3108
|
+
minContextSlot: options.minContextSlot
|
|
3108
3109
|
};
|
|
3109
3110
|
const signature = await connection.sendTransaction(transaction, signers, sendOptions);
|
|
3110
3111
|
const status = transaction.recentBlockhash != null && transaction.lastValidBlockHeight != null ? (await connection.confirmTransaction({
|
|
@@ -4531,6 +4532,41 @@ class SendTransactionError extends Error {
|
|
|
4531
4532
|
this.logs = logs;
|
|
4532
4533
|
}
|
|
4533
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
|
+
|
|
4534
4570
|
}
|
|
4535
4571
|
|
|
4536
4572
|
var fetchImpl = globalThis.fetch;
|
|
@@ -4599,6 +4635,7 @@ function makeWebsocketUrl(endpoint) {
|
|
|
4599
4635
|
return url.toString();
|
|
4600
4636
|
}
|
|
4601
4637
|
|
|
4638
|
+
var _process$env$npm_pack;
|
|
4602
4639
|
const PublicKeyFromString = superstruct.coerce(superstruct.instance(PublicKey), superstruct.string(), value => new PublicKey(value));
|
|
4603
4640
|
const RawAccountDataResult = superstruct.tuple([superstruct.string(), superstruct.literal('base64')]);
|
|
4604
4641
|
const BufferFromRawAccountData = superstruct.coerce(superstruct.instance(buffer.Buffer), RawAccountDataResult, value => buffer.Buffer.from(value[0], 'base64'));
|
|
@@ -4615,9 +4652,32 @@ const BLOCKHASH_CACHE_TIMEOUT_MS = 30 * 1000;
|
|
|
4615
4652
|
* https://gist.github.com/steveluscher/c057eca81d479ef705cdb53162f9971d
|
|
4616
4653
|
*/
|
|
4617
4654
|
|
|
4655
|
+
/** @internal */
|
|
4656
|
+
function extractCommitmentFromConfig(commitmentOrConfig) {
|
|
4657
|
+
let commitment;
|
|
4658
|
+
let config;
|
|
4659
|
+
|
|
4660
|
+
if (typeof commitmentOrConfig === 'string') {
|
|
4661
|
+
commitment = commitmentOrConfig;
|
|
4662
|
+
} else if (commitmentOrConfig) {
|
|
4663
|
+
const {
|
|
4664
|
+
commitment: specifiedCommitment,
|
|
4665
|
+
...specifiedConfig
|
|
4666
|
+
} = commitmentOrConfig;
|
|
4667
|
+
commitment = specifiedCommitment;
|
|
4668
|
+
config = specifiedConfig;
|
|
4669
|
+
}
|
|
4670
|
+
|
|
4671
|
+
return {
|
|
4672
|
+
commitment,
|
|
4673
|
+
config
|
|
4674
|
+
};
|
|
4675
|
+
}
|
|
4618
4676
|
/**
|
|
4619
4677
|
* @internal
|
|
4620
4678
|
*/
|
|
4679
|
+
|
|
4680
|
+
|
|
4621
4681
|
function createRpcResult(result) {
|
|
4622
4682
|
return superstruct.union([superstruct.type({
|
|
4623
4683
|
jsonrpc: superstruct.literal('2.0'),
|
|
@@ -4809,7 +4869,7 @@ function createRpcClient(url, useHttps, httpHeaders, customFetch, fetchMiddlewar
|
|
|
4809
4869
|
agent,
|
|
4810
4870
|
headers: Object.assign({
|
|
4811
4871
|
'Content-Type': 'application/json'
|
|
4812
|
-
}, httpHeaders || {})
|
|
4872
|
+
}, httpHeaders || {}, COMMON_HTTP_HEADERS)
|
|
4813
4873
|
};
|
|
4814
4874
|
|
|
4815
4875
|
try {
|
|
@@ -5482,9 +5542,14 @@ const LogsNotificationResult = superstruct.type({
|
|
|
5482
5542
|
* Filter for log subscriptions.
|
|
5483
5543
|
*/
|
|
5484
5544
|
|
|
5545
|
+
/** @internal */
|
|
5546
|
+
const COMMON_HTTP_HEADERS = {
|
|
5547
|
+
'solana-client': `js/${(_process$env$npm_pack = "0.0.0-development") !== null && _process$env$npm_pack !== void 0 ? _process$env$npm_pack : 'UNKNOWN'}`
|
|
5548
|
+
};
|
|
5485
5549
|
/**
|
|
5486
5550
|
* A connection to a fullnode JSON RPC endpoint
|
|
5487
5551
|
*/
|
|
5552
|
+
|
|
5488
5553
|
class Connection {
|
|
5489
5554
|
/** @internal */
|
|
5490
5555
|
|
|
@@ -5649,14 +5714,22 @@ class Connection {
|
|
|
5649
5714
|
*/
|
|
5650
5715
|
|
|
5651
5716
|
|
|
5652
|
-
async getBalanceAndContext(publicKey,
|
|
5653
|
-
|
|
5717
|
+
async getBalanceAndContext(publicKey, commitmentOrConfig) {
|
|
5718
|
+
/** @internal */
|
|
5719
|
+
const {
|
|
5720
|
+
commitment,
|
|
5721
|
+
config
|
|
5722
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
5723
|
+
|
|
5724
|
+
const args = this._buildArgs([publicKey.toBase58()], commitment, undefined
|
|
5725
|
+
/* encoding */
|
|
5726
|
+
, config);
|
|
5654
5727
|
|
|
5655
5728
|
const unsafeRes = await this._rpcRequest('getBalance', args);
|
|
5656
5729
|
const res = superstruct.create(unsafeRes, jsonRpcResultAndContext(superstruct.number()));
|
|
5657
5730
|
|
|
5658
5731
|
if ('error' in res) {
|
|
5659
|
-
throw new
|
|
5732
|
+
throw new SolanaJSONRPCError(res.error, `failed to get balance for ${publicKey.toBase58()}`);
|
|
5660
5733
|
}
|
|
5661
5734
|
|
|
5662
5735
|
return res.result;
|
|
@@ -5666,8 +5739,8 @@ class Connection {
|
|
|
5666
5739
|
*/
|
|
5667
5740
|
|
|
5668
5741
|
|
|
5669
|
-
async getBalance(publicKey,
|
|
5670
|
-
return await this.getBalanceAndContext(publicKey,
|
|
5742
|
+
async getBalance(publicKey, commitmentOrConfig) {
|
|
5743
|
+
return await this.getBalanceAndContext(publicKey, commitmentOrConfig).then(x => x.value).catch(e => {
|
|
5671
5744
|
throw new Error('failed to get balance of account ' + publicKey.toBase58() + ': ' + e);
|
|
5672
5745
|
});
|
|
5673
5746
|
}
|
|
@@ -5681,7 +5754,7 @@ class Connection {
|
|
|
5681
5754
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.nullable(superstruct.number())));
|
|
5682
5755
|
|
|
5683
5756
|
if ('error' in res) {
|
|
5684
|
-
throw new
|
|
5757
|
+
throw new SolanaJSONRPCError(res.error, `failed to get block time for slot ${slot}`);
|
|
5685
5758
|
}
|
|
5686
5759
|
|
|
5687
5760
|
return res.result;
|
|
@@ -5697,7 +5770,7 @@ class Connection {
|
|
|
5697
5770
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.number()));
|
|
5698
5771
|
|
|
5699
5772
|
if ('error' in res) {
|
|
5700
|
-
throw new
|
|
5773
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get minimum ledger slot');
|
|
5701
5774
|
}
|
|
5702
5775
|
|
|
5703
5776
|
return res.result;
|
|
@@ -5712,7 +5785,7 @@ class Connection {
|
|
|
5712
5785
|
const res = superstruct.create(unsafeRes, SlotRpcResult);
|
|
5713
5786
|
|
|
5714
5787
|
if ('error' in res) {
|
|
5715
|
-
throw new
|
|
5788
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get first available block');
|
|
5716
5789
|
}
|
|
5717
5790
|
|
|
5718
5791
|
return res.result;
|
|
@@ -5743,7 +5816,7 @@ class Connection {
|
|
|
5743
5816
|
const res = superstruct.create(unsafeRes, GetSupplyRpcResult);
|
|
5744
5817
|
|
|
5745
5818
|
if ('error' in res) {
|
|
5746
|
-
throw new
|
|
5819
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get supply');
|
|
5747
5820
|
}
|
|
5748
5821
|
|
|
5749
5822
|
return res.result;
|
|
@@ -5760,7 +5833,7 @@ class Connection {
|
|
|
5760
5833
|
const res = superstruct.create(unsafeRes, jsonRpcResultAndContext(TokenAmountResult));
|
|
5761
5834
|
|
|
5762
5835
|
if ('error' in res) {
|
|
5763
|
-
throw new
|
|
5836
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get token supply');
|
|
5764
5837
|
}
|
|
5765
5838
|
|
|
5766
5839
|
return res.result;
|
|
@@ -5777,7 +5850,7 @@ class Connection {
|
|
|
5777
5850
|
const res = superstruct.create(unsafeRes, jsonRpcResultAndContext(TokenAmountResult));
|
|
5778
5851
|
|
|
5779
5852
|
if ('error' in res) {
|
|
5780
|
-
throw new
|
|
5853
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get token account balance');
|
|
5781
5854
|
}
|
|
5782
5855
|
|
|
5783
5856
|
return res.result;
|
|
@@ -5789,7 +5862,11 @@ class Connection {
|
|
|
5789
5862
|
*/
|
|
5790
5863
|
|
|
5791
5864
|
|
|
5792
|
-
async getTokenAccountsByOwner(ownerAddress, filter,
|
|
5865
|
+
async getTokenAccountsByOwner(ownerAddress, filter, commitmentOrConfig) {
|
|
5866
|
+
const {
|
|
5867
|
+
commitment,
|
|
5868
|
+
config
|
|
5869
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
5793
5870
|
let _args = [ownerAddress.toBase58()];
|
|
5794
5871
|
|
|
5795
5872
|
if ('mint' in filter) {
|
|
@@ -5802,13 +5879,13 @@ class Connection {
|
|
|
5802
5879
|
});
|
|
5803
5880
|
}
|
|
5804
5881
|
|
|
5805
|
-
const args = this._buildArgs(_args, commitment, 'base64');
|
|
5882
|
+
const args = this._buildArgs(_args, commitment, 'base64', config);
|
|
5806
5883
|
|
|
5807
5884
|
const unsafeRes = await this._rpcRequest('getTokenAccountsByOwner', args);
|
|
5808
5885
|
const res = superstruct.create(unsafeRes, GetTokenAccountsByOwner);
|
|
5809
5886
|
|
|
5810
5887
|
if ('error' in res) {
|
|
5811
|
-
throw new
|
|
5888
|
+
throw new SolanaJSONRPCError(res.error, `failed to get token accounts owned by account ${ownerAddress.toBase58()}`);
|
|
5812
5889
|
}
|
|
5813
5890
|
|
|
5814
5891
|
return res.result;
|
|
@@ -5839,7 +5916,7 @@ class Connection {
|
|
|
5839
5916
|
const res = superstruct.create(unsafeRes, GetParsedTokenAccountsByOwner);
|
|
5840
5917
|
|
|
5841
5918
|
if ('error' in res) {
|
|
5842
|
-
throw new
|
|
5919
|
+
throw new SolanaJSONRPCError(res.error, `failed to get token accounts owned by account ${ownerAddress.toBase58()}`);
|
|
5843
5920
|
}
|
|
5844
5921
|
|
|
5845
5922
|
return res.result;
|
|
@@ -5858,7 +5935,7 @@ class Connection {
|
|
|
5858
5935
|
const res = superstruct.create(unsafeRes, GetLargestAccountsRpcResult);
|
|
5859
5936
|
|
|
5860
5937
|
if ('error' in res) {
|
|
5861
|
-
throw new
|
|
5938
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get largest accounts');
|
|
5862
5939
|
}
|
|
5863
5940
|
|
|
5864
5941
|
return res.result;
|
|
@@ -5876,7 +5953,7 @@ class Connection {
|
|
|
5876
5953
|
const res = superstruct.create(unsafeRes, GetTokenLargestAccountsResult);
|
|
5877
5954
|
|
|
5878
5955
|
if ('error' in res) {
|
|
5879
|
-
throw new
|
|
5956
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get token largest accounts');
|
|
5880
5957
|
}
|
|
5881
5958
|
|
|
5882
5959
|
return res.result;
|
|
@@ -5886,14 +5963,19 @@ class Connection {
|
|
|
5886
5963
|
*/
|
|
5887
5964
|
|
|
5888
5965
|
|
|
5889
|
-
async getAccountInfoAndContext(publicKey,
|
|
5890
|
-
const
|
|
5966
|
+
async getAccountInfoAndContext(publicKey, commitmentOrConfig) {
|
|
5967
|
+
const {
|
|
5968
|
+
commitment,
|
|
5969
|
+
config
|
|
5970
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
5971
|
+
|
|
5972
|
+
const args = this._buildArgs([publicKey.toBase58()], commitment, 'base64', config);
|
|
5891
5973
|
|
|
5892
5974
|
const unsafeRes = await this._rpcRequest('getAccountInfo', args);
|
|
5893
5975
|
const res = superstruct.create(unsafeRes, jsonRpcResultAndContext(superstruct.nullable(AccountInfoResult)));
|
|
5894
5976
|
|
|
5895
5977
|
if ('error' in res) {
|
|
5896
|
-
throw new
|
|
5978
|
+
throw new SolanaJSONRPCError(res.error, `failed to get info about account ${publicKey.toBase58()}`);
|
|
5897
5979
|
}
|
|
5898
5980
|
|
|
5899
5981
|
return res.result;
|
|
@@ -5910,7 +5992,7 @@ class Connection {
|
|
|
5910
5992
|
const res = superstruct.create(unsafeRes, jsonRpcResultAndContext(superstruct.nullable(ParsedAccountInfoResult)));
|
|
5911
5993
|
|
|
5912
5994
|
if ('error' in res) {
|
|
5913
|
-
throw new
|
|
5995
|
+
throw new SolanaJSONRPCError(res.error, `failed to get info about account ${publicKey.toBase58()}`);
|
|
5914
5996
|
}
|
|
5915
5997
|
|
|
5916
5998
|
return res.result;
|
|
@@ -5920,9 +6002,9 @@ class Connection {
|
|
|
5920
6002
|
*/
|
|
5921
6003
|
|
|
5922
6004
|
|
|
5923
|
-
async getAccountInfo(publicKey,
|
|
6005
|
+
async getAccountInfo(publicKey, commitmentOrConfig) {
|
|
5924
6006
|
try {
|
|
5925
|
-
const res = await this.getAccountInfoAndContext(publicKey,
|
|
6007
|
+
const res = await this.getAccountInfoAndContext(publicKey, commitmentOrConfig);
|
|
5926
6008
|
return res.value;
|
|
5927
6009
|
} catch (e) {
|
|
5928
6010
|
throw new Error('failed to get info about account ' + publicKey.toBase58() + ': ' + e);
|
|
@@ -5933,16 +6015,20 @@ class Connection {
|
|
|
5933
6015
|
*/
|
|
5934
6016
|
|
|
5935
6017
|
|
|
5936
|
-
async getMultipleAccountsInfoAndContext(publicKeys,
|
|
6018
|
+
async getMultipleAccountsInfoAndContext(publicKeys, commitmentOrConfig) {
|
|
6019
|
+
const {
|
|
6020
|
+
commitment,
|
|
6021
|
+
config
|
|
6022
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
5937
6023
|
const keys = publicKeys.map(key => key.toBase58());
|
|
5938
6024
|
|
|
5939
|
-
const args = this._buildArgs([keys], commitment, 'base64');
|
|
6025
|
+
const args = this._buildArgs([keys], commitment, 'base64', config);
|
|
5940
6026
|
|
|
5941
6027
|
const unsafeRes = await this._rpcRequest('getMultipleAccounts', args);
|
|
5942
6028
|
const res = superstruct.create(unsafeRes, jsonRpcResultAndContext(superstruct.array(superstruct.nullable(AccountInfoResult))));
|
|
5943
6029
|
|
|
5944
6030
|
if ('error' in res) {
|
|
5945
|
-
throw new
|
|
6031
|
+
throw new SolanaJSONRPCError(res.error, `failed to get info for accounts ${keys}`);
|
|
5946
6032
|
}
|
|
5947
6033
|
|
|
5948
6034
|
return res.result;
|
|
@@ -5952,8 +6038,8 @@ class Connection {
|
|
|
5952
6038
|
*/
|
|
5953
6039
|
|
|
5954
6040
|
|
|
5955
|
-
async getMultipleAccountsInfo(publicKeys,
|
|
5956
|
-
const res = await this.getMultipleAccountsInfoAndContext(publicKeys,
|
|
6041
|
+
async getMultipleAccountsInfo(publicKeys, commitmentOrConfig) {
|
|
6042
|
+
const res = await this.getMultipleAccountsInfoAndContext(publicKeys, commitmentOrConfig);
|
|
5957
6043
|
return res.value;
|
|
5958
6044
|
}
|
|
5959
6045
|
/**
|
|
@@ -5961,16 +6047,23 @@ class Connection {
|
|
|
5961
6047
|
*/
|
|
5962
6048
|
|
|
5963
6049
|
|
|
5964
|
-
async getStakeActivation(publicKey,
|
|
5965
|
-
const
|
|
5966
|
-
|
|
5967
|
-
|
|
6050
|
+
async getStakeActivation(publicKey, commitmentOrConfig, epoch) {
|
|
6051
|
+
const {
|
|
6052
|
+
commitment,
|
|
6053
|
+
config
|
|
6054
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
6055
|
+
|
|
6056
|
+
const args = this._buildArgs([publicKey.toBase58()], commitment, undefined
|
|
6057
|
+
/* encoding */
|
|
6058
|
+
, { ...config,
|
|
6059
|
+
epoch: epoch != null ? epoch : config === null || config === void 0 ? void 0 : config.epoch
|
|
6060
|
+
});
|
|
5968
6061
|
|
|
5969
6062
|
const unsafeRes = await this._rpcRequest('getStakeActivation', args);
|
|
5970
6063
|
const res = superstruct.create(unsafeRes, jsonRpcResult(StakeActivationResult));
|
|
5971
6064
|
|
|
5972
6065
|
if ('error' in res) {
|
|
5973
|
-
throw new
|
|
6066
|
+
throw new SolanaJSONRPCError(res.error, `failed to get Stake Activation ${publicKey.toBase58()}`);
|
|
5974
6067
|
}
|
|
5975
6068
|
|
|
5976
6069
|
return res.result;
|
|
@@ -5983,34 +6076,22 @@ class Connection {
|
|
|
5983
6076
|
|
|
5984
6077
|
|
|
5985
6078
|
async getProgramAccounts(programId, configOrCommitment) {
|
|
5986
|
-
const
|
|
5987
|
-
|
|
5988
|
-
|
|
5989
|
-
|
|
5990
|
-
|
|
5991
|
-
|
|
5992
|
-
|
|
5993
|
-
|
|
5994
|
-
commitment = configOrCommitment.commitment;
|
|
5995
|
-
encoding = configOrCommitment.encoding;
|
|
5996
|
-
|
|
5997
|
-
if (configOrCommitment.dataSlice) {
|
|
5998
|
-
extra.dataSlice = configOrCommitment.dataSlice;
|
|
5999
|
-
}
|
|
6000
|
-
|
|
6001
|
-
if (configOrCommitment.filters) {
|
|
6002
|
-
extra.filters = configOrCommitment.filters;
|
|
6003
|
-
}
|
|
6004
|
-
}
|
|
6005
|
-
}
|
|
6079
|
+
const {
|
|
6080
|
+
commitment,
|
|
6081
|
+
config
|
|
6082
|
+
} = extractCommitmentFromConfig(configOrCommitment);
|
|
6083
|
+
const {
|
|
6084
|
+
encoding,
|
|
6085
|
+
...configWithoutEncoding
|
|
6086
|
+
} = config || {};
|
|
6006
6087
|
|
|
6007
|
-
const args = this._buildArgs([programId.toBase58()], commitment, encoding || 'base64',
|
|
6088
|
+
const args = this._buildArgs([programId.toBase58()], commitment, encoding || 'base64', configWithoutEncoding);
|
|
6008
6089
|
|
|
6009
6090
|
const unsafeRes = await this._rpcRequest('getProgramAccounts', args);
|
|
6010
6091
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.array(KeyedAccountInfoResult)));
|
|
6011
6092
|
|
|
6012
6093
|
if ('error' in res) {
|
|
6013
|
-
throw new
|
|
6094
|
+
throw new SolanaJSONRPCError(res.error, `failed to get accounts owned by program ${programId.toBase58()}`);
|
|
6014
6095
|
}
|
|
6015
6096
|
|
|
6016
6097
|
return res.result;
|
|
@@ -6023,28 +6104,18 @@ class Connection {
|
|
|
6023
6104
|
|
|
6024
6105
|
|
|
6025
6106
|
async getParsedProgramAccounts(programId, configOrCommitment) {
|
|
6026
|
-
const
|
|
6027
|
-
|
|
6028
|
-
|
|
6029
|
-
|
|
6030
|
-
if (typeof configOrCommitment === 'string') {
|
|
6031
|
-
commitment = configOrCommitment;
|
|
6032
|
-
} else {
|
|
6033
|
-
commitment = configOrCommitment.commitment;
|
|
6034
|
-
|
|
6035
|
-
if (configOrCommitment.filters) {
|
|
6036
|
-
extra.filters = configOrCommitment.filters;
|
|
6037
|
-
}
|
|
6038
|
-
}
|
|
6039
|
-
}
|
|
6107
|
+
const {
|
|
6108
|
+
commitment,
|
|
6109
|
+
config
|
|
6110
|
+
} = extractCommitmentFromConfig(configOrCommitment);
|
|
6040
6111
|
|
|
6041
|
-
const args = this._buildArgs([programId.toBase58()], commitment, 'jsonParsed',
|
|
6112
|
+
const args = this._buildArgs([programId.toBase58()], commitment, 'jsonParsed', config);
|
|
6042
6113
|
|
|
6043
6114
|
const unsafeRes = await this._rpcRequest('getProgramAccounts', args);
|
|
6044
6115
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.array(KeyedParsedAccountInfoResult)));
|
|
6045
6116
|
|
|
6046
6117
|
if ('error' in res) {
|
|
6047
|
-
throw new
|
|
6118
|
+
throw new SolanaJSONRPCError(res.error, `failed to get accounts owned by program ${programId.toBase58()}`);
|
|
6048
6119
|
}
|
|
6049
6120
|
|
|
6050
6121
|
return res.result;
|
|
@@ -6178,7 +6249,7 @@ class Connection {
|
|
|
6178
6249
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.array(ContactInfoResult)));
|
|
6179
6250
|
|
|
6180
6251
|
if ('error' in res) {
|
|
6181
|
-
throw new
|
|
6252
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get cluster nodes');
|
|
6182
6253
|
}
|
|
6183
6254
|
|
|
6184
6255
|
return res.result;
|
|
@@ -6195,7 +6266,7 @@ class Connection {
|
|
|
6195
6266
|
const res = superstruct.create(unsafeRes, GetVoteAccounts);
|
|
6196
6267
|
|
|
6197
6268
|
if ('error' in res) {
|
|
6198
|
-
throw new
|
|
6269
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get vote accounts');
|
|
6199
6270
|
}
|
|
6200
6271
|
|
|
6201
6272
|
return res.result;
|
|
@@ -6205,14 +6276,21 @@ class Connection {
|
|
|
6205
6276
|
*/
|
|
6206
6277
|
|
|
6207
6278
|
|
|
6208
|
-
async getSlot(
|
|
6209
|
-
const
|
|
6279
|
+
async getSlot(commitmentOrConfig) {
|
|
6280
|
+
const {
|
|
6281
|
+
commitment,
|
|
6282
|
+
config
|
|
6283
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
6284
|
+
|
|
6285
|
+
const args = this._buildArgs([], commitment, undefined
|
|
6286
|
+
/* encoding */
|
|
6287
|
+
, config);
|
|
6210
6288
|
|
|
6211
6289
|
const unsafeRes = await this._rpcRequest('getSlot', args);
|
|
6212
6290
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.number()));
|
|
6213
6291
|
|
|
6214
6292
|
if ('error' in res) {
|
|
6215
|
-
throw new
|
|
6293
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get slot');
|
|
6216
6294
|
}
|
|
6217
6295
|
|
|
6218
6296
|
return res.result;
|
|
@@ -6222,14 +6300,21 @@ class Connection {
|
|
|
6222
6300
|
*/
|
|
6223
6301
|
|
|
6224
6302
|
|
|
6225
|
-
async getSlotLeader(
|
|
6226
|
-
const
|
|
6303
|
+
async getSlotLeader(commitmentOrConfig) {
|
|
6304
|
+
const {
|
|
6305
|
+
commitment,
|
|
6306
|
+
config
|
|
6307
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
6308
|
+
|
|
6309
|
+
const args = this._buildArgs([], commitment, undefined
|
|
6310
|
+
/* encoding */
|
|
6311
|
+
, config);
|
|
6227
6312
|
|
|
6228
6313
|
const unsafeRes = await this._rpcRequest('getSlotLeader', args);
|
|
6229
6314
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.string()));
|
|
6230
6315
|
|
|
6231
6316
|
if ('error' in res) {
|
|
6232
|
-
throw new
|
|
6317
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get slot leader');
|
|
6233
6318
|
}
|
|
6234
6319
|
|
|
6235
6320
|
return res.result;
|
|
@@ -6248,7 +6333,7 @@ class Connection {
|
|
|
6248
6333
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.array(PublicKeyFromString)));
|
|
6249
6334
|
|
|
6250
6335
|
if ('error' in res) {
|
|
6251
|
-
throw new
|
|
6336
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get slot leaders');
|
|
6252
6337
|
}
|
|
6253
6338
|
|
|
6254
6339
|
return res.result;
|
|
@@ -6286,7 +6371,7 @@ class Connection {
|
|
|
6286
6371
|
const res = superstruct.create(unsafeRes, GetSignatureStatusesRpcResult);
|
|
6287
6372
|
|
|
6288
6373
|
if ('error' in res) {
|
|
6289
|
-
throw new
|
|
6374
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get signature status');
|
|
6290
6375
|
}
|
|
6291
6376
|
|
|
6292
6377
|
return res.result;
|
|
@@ -6296,14 +6381,21 @@ class Connection {
|
|
|
6296
6381
|
*/
|
|
6297
6382
|
|
|
6298
6383
|
|
|
6299
|
-
async getTransactionCount(
|
|
6300
|
-
const
|
|
6384
|
+
async getTransactionCount(commitmentOrConfig) {
|
|
6385
|
+
const {
|
|
6386
|
+
commitment,
|
|
6387
|
+
config
|
|
6388
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
6389
|
+
|
|
6390
|
+
const args = this._buildArgs([], commitment, undefined
|
|
6391
|
+
/* encoding */
|
|
6392
|
+
, config);
|
|
6301
6393
|
|
|
6302
6394
|
const unsafeRes = await this._rpcRequest('getTransactionCount', args);
|
|
6303
6395
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.number()));
|
|
6304
6396
|
|
|
6305
6397
|
if ('error' in res) {
|
|
6306
|
-
throw new
|
|
6398
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get transaction count');
|
|
6307
6399
|
}
|
|
6308
6400
|
|
|
6309
6401
|
return res.result;
|
|
@@ -6334,7 +6426,7 @@ class Connection {
|
|
|
6334
6426
|
const res = superstruct.create(unsafeRes, GetInflationGovernorRpcResult);
|
|
6335
6427
|
|
|
6336
6428
|
if ('error' in res) {
|
|
6337
|
-
throw new
|
|
6429
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get inflation');
|
|
6338
6430
|
}
|
|
6339
6431
|
|
|
6340
6432
|
return res.result;
|
|
@@ -6344,16 +6436,23 @@ class Connection {
|
|
|
6344
6436
|
*/
|
|
6345
6437
|
|
|
6346
6438
|
|
|
6347
|
-
async getInflationReward(addresses, epoch,
|
|
6348
|
-
const
|
|
6349
|
-
|
|
6439
|
+
async getInflationReward(addresses, epoch, commitmentOrConfig) {
|
|
6440
|
+
const {
|
|
6441
|
+
commitment,
|
|
6442
|
+
config
|
|
6443
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
6444
|
+
|
|
6445
|
+
const args = this._buildArgs([addresses.map(pubkey => pubkey.toBase58())], commitment, undefined
|
|
6446
|
+
/* encoding */
|
|
6447
|
+
, { ...config,
|
|
6448
|
+
epoch: epoch != null ? epoch : config === null || config === void 0 ? void 0 : config.epoch
|
|
6350
6449
|
});
|
|
6351
6450
|
|
|
6352
6451
|
const unsafeRes = await this._rpcRequest('getInflationReward', args);
|
|
6353
6452
|
const res = superstruct.create(unsafeRes, GetInflationRewardResult);
|
|
6354
6453
|
|
|
6355
6454
|
if ('error' in res) {
|
|
6356
|
-
throw new
|
|
6455
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get inflation reward');
|
|
6357
6456
|
}
|
|
6358
6457
|
|
|
6359
6458
|
return res.result;
|
|
@@ -6363,14 +6462,21 @@ class Connection {
|
|
|
6363
6462
|
*/
|
|
6364
6463
|
|
|
6365
6464
|
|
|
6366
|
-
async getEpochInfo(
|
|
6367
|
-
const
|
|
6465
|
+
async getEpochInfo(commitmentOrConfig) {
|
|
6466
|
+
const {
|
|
6467
|
+
commitment,
|
|
6468
|
+
config
|
|
6469
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
6470
|
+
|
|
6471
|
+
const args = this._buildArgs([], commitment, undefined
|
|
6472
|
+
/* encoding */
|
|
6473
|
+
, config);
|
|
6368
6474
|
|
|
6369
6475
|
const unsafeRes = await this._rpcRequest('getEpochInfo', args);
|
|
6370
6476
|
const res = superstruct.create(unsafeRes, GetEpochInfoRpcResult);
|
|
6371
6477
|
|
|
6372
6478
|
if ('error' in res) {
|
|
6373
|
-
throw new
|
|
6479
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get epoch info');
|
|
6374
6480
|
}
|
|
6375
6481
|
|
|
6376
6482
|
return res.result;
|
|
@@ -6385,7 +6491,7 @@ class Connection {
|
|
|
6385
6491
|
const res = superstruct.create(unsafeRes, GetEpochScheduleRpcResult);
|
|
6386
6492
|
|
|
6387
6493
|
if ('error' in res) {
|
|
6388
|
-
throw new
|
|
6494
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get epoch schedule');
|
|
6389
6495
|
}
|
|
6390
6496
|
|
|
6391
6497
|
const epochSchedule = res.result;
|
|
@@ -6402,7 +6508,7 @@ class Connection {
|
|
|
6402
6508
|
const res = superstruct.create(unsafeRes, GetLeaderScheduleRpcResult);
|
|
6403
6509
|
|
|
6404
6510
|
if ('error' in res) {
|
|
6405
|
-
throw new
|
|
6511
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get leader schedule');
|
|
6406
6512
|
}
|
|
6407
6513
|
|
|
6408
6514
|
return res.result;
|
|
@@ -6441,7 +6547,7 @@ class Connection {
|
|
|
6441
6547
|
const res = superstruct.create(unsafeRes, GetRecentBlockhashAndContextRpcResult);
|
|
6442
6548
|
|
|
6443
6549
|
if ('error' in res) {
|
|
6444
|
-
throw new
|
|
6550
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get recent blockhash');
|
|
6445
6551
|
}
|
|
6446
6552
|
|
|
6447
6553
|
return res.result;
|
|
@@ -6459,7 +6565,7 @@ class Connection {
|
|
|
6459
6565
|
const res = superstruct.create(unsafeRes, GetRecentPerformanceSamplesRpcResult);
|
|
6460
6566
|
|
|
6461
6567
|
if ('error' in res) {
|
|
6462
|
-
throw new
|
|
6568
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get recent performance samples');
|
|
6463
6569
|
}
|
|
6464
6570
|
|
|
6465
6571
|
return res.result;
|
|
@@ -6478,7 +6584,7 @@ class Connection {
|
|
|
6478
6584
|
const res = superstruct.create(unsafeRes, GetFeeCalculatorRpcResult);
|
|
6479
6585
|
|
|
6480
6586
|
if ('error' in res) {
|
|
6481
|
-
throw new
|
|
6587
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get fee calculator');
|
|
6482
6588
|
}
|
|
6483
6589
|
|
|
6484
6590
|
const {
|
|
@@ -6504,7 +6610,7 @@ class Connection {
|
|
|
6504
6610
|
const res = superstruct.create(unsafeRes, jsonRpcResultAndContext(superstruct.nullable(superstruct.number())));
|
|
6505
6611
|
|
|
6506
6612
|
if ('error' in res) {
|
|
6507
|
-
throw new
|
|
6613
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get slot');
|
|
6508
6614
|
}
|
|
6509
6615
|
|
|
6510
6616
|
if (res.result === null) {
|
|
@@ -6535,9 +6641,9 @@ class Connection {
|
|
|
6535
6641
|
*/
|
|
6536
6642
|
|
|
6537
6643
|
|
|
6538
|
-
async getLatestBlockhash(
|
|
6644
|
+
async getLatestBlockhash(commitmentOrConfig) {
|
|
6539
6645
|
try {
|
|
6540
|
-
const res = await this.getLatestBlockhashAndContext(
|
|
6646
|
+
const res = await this.getLatestBlockhashAndContext(commitmentOrConfig);
|
|
6541
6647
|
return res.value;
|
|
6542
6648
|
} catch (e) {
|
|
6543
6649
|
throw new Error('failed to get recent blockhash: ' + e);
|
|
@@ -6549,14 +6655,21 @@ class Connection {
|
|
|
6549
6655
|
*/
|
|
6550
6656
|
|
|
6551
6657
|
|
|
6552
|
-
async getLatestBlockhashAndContext(
|
|
6553
|
-
const
|
|
6658
|
+
async getLatestBlockhashAndContext(commitmentOrConfig) {
|
|
6659
|
+
const {
|
|
6660
|
+
commitment,
|
|
6661
|
+
config
|
|
6662
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
6663
|
+
|
|
6664
|
+
const args = this._buildArgs([], commitment, undefined
|
|
6665
|
+
/* encoding */
|
|
6666
|
+
, config);
|
|
6554
6667
|
|
|
6555
6668
|
const unsafeRes = await this._rpcRequest('getLatestBlockhash', args);
|
|
6556
6669
|
const res = superstruct.create(unsafeRes, GetLatestBlockhashRpcResult);
|
|
6557
6670
|
|
|
6558
6671
|
if ('error' in res) {
|
|
6559
|
-
throw new
|
|
6672
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get latest blockhash');
|
|
6560
6673
|
}
|
|
6561
6674
|
|
|
6562
6675
|
return res.result;
|
|
@@ -6571,7 +6684,7 @@ class Connection {
|
|
|
6571
6684
|
const res = superstruct.create(unsafeRes, jsonRpcResult(VersionResult));
|
|
6572
6685
|
|
|
6573
6686
|
if ('error' in res) {
|
|
6574
|
-
throw new
|
|
6687
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get version');
|
|
6575
6688
|
}
|
|
6576
6689
|
|
|
6577
6690
|
return res.result;
|
|
@@ -6586,7 +6699,7 @@ class Connection {
|
|
|
6586
6699
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.string()));
|
|
6587
6700
|
|
|
6588
6701
|
if ('error' in res) {
|
|
6589
|
-
throw new
|
|
6702
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get genesis hash');
|
|
6590
6703
|
}
|
|
6591
6704
|
|
|
6592
6705
|
return res.result;
|
|
@@ -6603,7 +6716,7 @@ class Connection {
|
|
|
6603
6716
|
const res = superstruct.create(unsafeRes, GetBlockRpcResult);
|
|
6604
6717
|
|
|
6605
6718
|
if ('error' in res) {
|
|
6606
|
-
throw new
|
|
6719
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get confirmed block');
|
|
6607
6720
|
}
|
|
6608
6721
|
|
|
6609
6722
|
const result = res.result;
|
|
@@ -6628,14 +6741,21 @@ class Connection {
|
|
|
6628
6741
|
*/
|
|
6629
6742
|
|
|
6630
6743
|
|
|
6631
|
-
async getBlockHeight(
|
|
6632
|
-
const
|
|
6744
|
+
async getBlockHeight(commitmentOrConfig) {
|
|
6745
|
+
const {
|
|
6746
|
+
commitment,
|
|
6747
|
+
config
|
|
6748
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
6749
|
+
|
|
6750
|
+
const args = this._buildArgs([], commitment, undefined
|
|
6751
|
+
/* encoding */
|
|
6752
|
+
, config);
|
|
6633
6753
|
|
|
6634
6754
|
const unsafeRes = await this._rpcRequest('getBlockHeight', args);
|
|
6635
6755
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.number()));
|
|
6636
6756
|
|
|
6637
6757
|
if ('error' in res) {
|
|
6638
|
-
throw new
|
|
6758
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get block height information');
|
|
6639
6759
|
}
|
|
6640
6760
|
|
|
6641
6761
|
return res.result;
|
|
@@ -6666,7 +6786,7 @@ class Connection {
|
|
|
6666
6786
|
const res = superstruct.create(unsafeRes, BlockProductionResponseStruct);
|
|
6667
6787
|
|
|
6668
6788
|
if ('error' in res) {
|
|
6669
|
-
throw new
|
|
6789
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get block production information');
|
|
6670
6790
|
}
|
|
6671
6791
|
|
|
6672
6792
|
return res.result;
|
|
@@ -6683,7 +6803,7 @@ class Connection {
|
|
|
6683
6803
|
const res = superstruct.create(unsafeRes, GetTransactionRpcResult);
|
|
6684
6804
|
|
|
6685
6805
|
if ('error' in res) {
|
|
6686
|
-
throw new
|
|
6806
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get transaction');
|
|
6687
6807
|
}
|
|
6688
6808
|
|
|
6689
6809
|
const result = res.result;
|
|
@@ -6706,7 +6826,7 @@ class Connection {
|
|
|
6706
6826
|
const res = superstruct.create(unsafeRes, GetParsedTransactionRpcResult);
|
|
6707
6827
|
|
|
6708
6828
|
if ('error' in res) {
|
|
6709
|
-
throw new
|
|
6829
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get transaction');
|
|
6710
6830
|
}
|
|
6711
6831
|
|
|
6712
6832
|
return res.result;
|
|
@@ -6730,7 +6850,7 @@ class Connection {
|
|
|
6730
6850
|
const res = superstruct.create(unsafeRes, GetParsedTransactionRpcResult);
|
|
6731
6851
|
|
|
6732
6852
|
if ('error' in res) {
|
|
6733
|
-
throw new
|
|
6853
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get transactions');
|
|
6734
6854
|
}
|
|
6735
6855
|
|
|
6736
6856
|
return res.result;
|
|
@@ -6757,7 +6877,7 @@ class Connection {
|
|
|
6757
6877
|
const res = superstruct.create(unsafeRes, GetTransactionRpcResult);
|
|
6758
6878
|
|
|
6759
6879
|
if ('error' in res) {
|
|
6760
|
-
throw new
|
|
6880
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get transactions');
|
|
6761
6881
|
}
|
|
6762
6882
|
|
|
6763
6883
|
const result = res.result;
|
|
@@ -6785,7 +6905,7 @@ class Connection {
|
|
|
6785
6905
|
const res = superstruct.create(unsafeRes, GetConfirmedBlockRpcResult);
|
|
6786
6906
|
|
|
6787
6907
|
if ('error' in res) {
|
|
6788
|
-
throw new
|
|
6908
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get confirmed block');
|
|
6789
6909
|
}
|
|
6790
6910
|
|
|
6791
6911
|
const result = res.result;
|
|
@@ -6832,7 +6952,7 @@ class Connection {
|
|
|
6832
6952
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.array(superstruct.number())));
|
|
6833
6953
|
|
|
6834
6954
|
if ('error' in res) {
|
|
6835
|
-
throw new
|
|
6955
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get blocks');
|
|
6836
6956
|
}
|
|
6837
6957
|
|
|
6838
6958
|
return res.result;
|
|
@@ -6852,7 +6972,7 @@ class Connection {
|
|
|
6852
6972
|
const res = superstruct.create(unsafeRes, GetBlockSignaturesRpcResult);
|
|
6853
6973
|
|
|
6854
6974
|
if ('error' in res) {
|
|
6855
|
-
throw new
|
|
6975
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get block');
|
|
6856
6976
|
}
|
|
6857
6977
|
|
|
6858
6978
|
const result = res.result;
|
|
@@ -6880,7 +7000,7 @@ class Connection {
|
|
|
6880
7000
|
const res = superstruct.create(unsafeRes, GetBlockSignaturesRpcResult);
|
|
6881
7001
|
|
|
6882
7002
|
if ('error' in res) {
|
|
6883
|
-
throw new
|
|
7003
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get confirmed block');
|
|
6884
7004
|
}
|
|
6885
7005
|
|
|
6886
7006
|
const result = res.result;
|
|
@@ -6905,7 +7025,7 @@ class Connection {
|
|
|
6905
7025
|
const res = superstruct.create(unsafeRes, GetTransactionRpcResult);
|
|
6906
7026
|
|
|
6907
7027
|
if ('error' in res) {
|
|
6908
|
-
throw new
|
|
7028
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get transaction');
|
|
6909
7029
|
}
|
|
6910
7030
|
|
|
6911
7031
|
const result = res.result;
|
|
@@ -6930,7 +7050,7 @@ class Connection {
|
|
|
6930
7050
|
const res = superstruct.create(unsafeRes, GetParsedTransactionRpcResult);
|
|
6931
7051
|
|
|
6932
7052
|
if ('error' in res) {
|
|
6933
|
-
throw new
|
|
7053
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get confirmed transaction');
|
|
6934
7054
|
}
|
|
6935
7055
|
|
|
6936
7056
|
return res.result;
|
|
@@ -6956,7 +7076,7 @@ class Connection {
|
|
|
6956
7076
|
const res = superstruct.create(unsafeRes, GetParsedTransactionRpcResult);
|
|
6957
7077
|
|
|
6958
7078
|
if ('error' in res) {
|
|
6959
|
-
throw new
|
|
7079
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get confirmed transactions');
|
|
6960
7080
|
}
|
|
6961
7081
|
|
|
6962
7082
|
return res.result;
|
|
@@ -7045,7 +7165,7 @@ class Connection {
|
|
|
7045
7165
|
const res = superstruct.create(unsafeRes, GetConfirmedSignaturesForAddress2RpcResult);
|
|
7046
7166
|
|
|
7047
7167
|
if ('error' in res) {
|
|
7048
|
-
throw new
|
|
7168
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get confirmed signatures for address');
|
|
7049
7169
|
}
|
|
7050
7170
|
|
|
7051
7171
|
return res.result;
|
|
@@ -7067,7 +7187,7 @@ class Connection {
|
|
|
7067
7187
|
const res = superstruct.create(unsafeRes, GetSignaturesForAddressRpcResult);
|
|
7068
7188
|
|
|
7069
7189
|
if ('error' in res) {
|
|
7070
|
-
throw new
|
|
7190
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get signatures for address');
|
|
7071
7191
|
}
|
|
7072
7192
|
|
|
7073
7193
|
return res.result;
|
|
@@ -7124,7 +7244,7 @@ class Connection {
|
|
|
7124
7244
|
const res = superstruct.create(unsafeRes, RequestAirdropRpcResult);
|
|
7125
7245
|
|
|
7126
7246
|
if ('error' in res) {
|
|
7127
|
-
throw new
|
|
7247
|
+
throw new SolanaJSONRPCError(res.error, `airdrop to ${to.toBase58()} failed`);
|
|
7128
7248
|
}
|
|
7129
7249
|
|
|
7130
7250
|
return res.result;
|
|
@@ -7358,6 +7478,10 @@ class Connection {
|
|
|
7358
7478
|
config.maxRetries = options.maxRetries;
|
|
7359
7479
|
}
|
|
7360
7480
|
|
|
7481
|
+
if (options && options.minContextSlot != null) {
|
|
7482
|
+
config.minContextSlot = options.minContextSlot;
|
|
7483
|
+
}
|
|
7484
|
+
|
|
7361
7485
|
if (skipPreflight) {
|
|
7362
7486
|
config.skipPreflight = skipPreflight;
|
|
7363
7487
|
}
|
|
@@ -9767,7 +9891,8 @@ async function sendAndConfirmRawTransaction(connection, rawTransaction, confirma
|
|
|
9767
9891
|
|
|
9768
9892
|
const sendOptions = options && {
|
|
9769
9893
|
skipPreflight: options.skipPreflight,
|
|
9770
|
-
preflightCommitment: options.preflightCommitment || options.commitment
|
|
9894
|
+
preflightCommitment: options.preflightCommitment || options.commitment,
|
|
9895
|
+
minContextSlot: options.minContextSlot
|
|
9771
9896
|
};
|
|
9772
9897
|
const signature = await connection.sendRawTransaction(rawTransaction, sendOptions);
|
|
9773
9898
|
const commitment = options && options.commitment;
|
|
@@ -9859,6 +9984,8 @@ exports.SYSVAR_SLOT_HISTORY_PUBKEY = SYSVAR_SLOT_HISTORY_PUBKEY;
|
|
|
9859
9984
|
exports.SYSVAR_STAKE_HISTORY_PUBKEY = SYSVAR_STAKE_HISTORY_PUBKEY;
|
|
9860
9985
|
exports.Secp256k1Program = Secp256k1Program;
|
|
9861
9986
|
exports.SendTransactionError = SendTransactionError;
|
|
9987
|
+
exports.SolanaJSONRPCError = SolanaJSONRPCError;
|
|
9988
|
+
exports.SolanaJSONRPCErrorCode = SolanaJSONRPCErrorCode;
|
|
9862
9989
|
exports.StakeAuthorizationLayout = StakeAuthorizationLayout;
|
|
9863
9990
|
exports.StakeInstruction = StakeInstruction;
|
|
9864
9991
|
exports.StakeProgram = StakeProgram;
|