@solana/web3.js 1.45.0 → 1.47.1
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 +248 -127
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +247 -128
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +248 -127
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +178 -18
- package/lib/index.esm.js +247 -128
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +248 -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 +1 -1
- package/src/connection.ts +371 -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;
|
|
@@ -4616,9 +4652,32 @@ const BLOCKHASH_CACHE_TIMEOUT_MS = 30 * 1000;
|
|
|
4616
4652
|
* https://gist.github.com/steveluscher/c057eca81d479ef705cdb53162f9971d
|
|
4617
4653
|
*/
|
|
4618
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
|
+
}
|
|
4619
4676
|
/**
|
|
4620
4677
|
* @internal
|
|
4621
4678
|
*/
|
|
4679
|
+
|
|
4680
|
+
|
|
4622
4681
|
function createRpcResult(result) {
|
|
4623
4682
|
return superstruct.union([superstruct.type({
|
|
4624
4683
|
jsonrpc: superstruct.literal('2.0'),
|
|
@@ -5655,14 +5714,22 @@ class Connection {
|
|
|
5655
5714
|
*/
|
|
5656
5715
|
|
|
5657
5716
|
|
|
5658
|
-
async getBalanceAndContext(publicKey,
|
|
5659
|
-
|
|
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);
|
|
5660
5727
|
|
|
5661
5728
|
const unsafeRes = await this._rpcRequest('getBalance', args);
|
|
5662
5729
|
const res = superstruct.create(unsafeRes, jsonRpcResultAndContext(superstruct.number()));
|
|
5663
5730
|
|
|
5664
5731
|
if ('error' in res) {
|
|
5665
|
-
throw new
|
|
5732
|
+
throw new SolanaJSONRPCError(res.error, `failed to get balance for ${publicKey.toBase58()}`);
|
|
5666
5733
|
}
|
|
5667
5734
|
|
|
5668
5735
|
return res.result;
|
|
@@ -5672,8 +5739,8 @@ class Connection {
|
|
|
5672
5739
|
*/
|
|
5673
5740
|
|
|
5674
5741
|
|
|
5675
|
-
async getBalance(publicKey,
|
|
5676
|
-
return await this.getBalanceAndContext(publicKey,
|
|
5742
|
+
async getBalance(publicKey, commitmentOrConfig) {
|
|
5743
|
+
return await this.getBalanceAndContext(publicKey, commitmentOrConfig).then(x => x.value).catch(e => {
|
|
5677
5744
|
throw new Error('failed to get balance of account ' + publicKey.toBase58() + ': ' + e);
|
|
5678
5745
|
});
|
|
5679
5746
|
}
|
|
@@ -5687,7 +5754,7 @@ class Connection {
|
|
|
5687
5754
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.nullable(superstruct.number())));
|
|
5688
5755
|
|
|
5689
5756
|
if ('error' in res) {
|
|
5690
|
-
throw new
|
|
5757
|
+
throw new SolanaJSONRPCError(res.error, `failed to get block time for slot ${slot}`);
|
|
5691
5758
|
}
|
|
5692
5759
|
|
|
5693
5760
|
return res.result;
|
|
@@ -5703,7 +5770,7 @@ class Connection {
|
|
|
5703
5770
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.number()));
|
|
5704
5771
|
|
|
5705
5772
|
if ('error' in res) {
|
|
5706
|
-
throw new
|
|
5773
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get minimum ledger slot');
|
|
5707
5774
|
}
|
|
5708
5775
|
|
|
5709
5776
|
return res.result;
|
|
@@ -5718,7 +5785,7 @@ class Connection {
|
|
|
5718
5785
|
const res = superstruct.create(unsafeRes, SlotRpcResult);
|
|
5719
5786
|
|
|
5720
5787
|
if ('error' in res) {
|
|
5721
|
-
throw new
|
|
5788
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get first available block');
|
|
5722
5789
|
}
|
|
5723
5790
|
|
|
5724
5791
|
return res.result;
|
|
@@ -5749,7 +5816,7 @@ class Connection {
|
|
|
5749
5816
|
const res = superstruct.create(unsafeRes, GetSupplyRpcResult);
|
|
5750
5817
|
|
|
5751
5818
|
if ('error' in res) {
|
|
5752
|
-
throw new
|
|
5819
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get supply');
|
|
5753
5820
|
}
|
|
5754
5821
|
|
|
5755
5822
|
return res.result;
|
|
@@ -5766,7 +5833,7 @@ class Connection {
|
|
|
5766
5833
|
const res = superstruct.create(unsafeRes, jsonRpcResultAndContext(TokenAmountResult));
|
|
5767
5834
|
|
|
5768
5835
|
if ('error' in res) {
|
|
5769
|
-
throw new
|
|
5836
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get token supply');
|
|
5770
5837
|
}
|
|
5771
5838
|
|
|
5772
5839
|
return res.result;
|
|
@@ -5783,7 +5850,7 @@ class Connection {
|
|
|
5783
5850
|
const res = superstruct.create(unsafeRes, jsonRpcResultAndContext(TokenAmountResult));
|
|
5784
5851
|
|
|
5785
5852
|
if ('error' in res) {
|
|
5786
|
-
throw new
|
|
5853
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get token account balance');
|
|
5787
5854
|
}
|
|
5788
5855
|
|
|
5789
5856
|
return res.result;
|
|
@@ -5795,7 +5862,11 @@ class Connection {
|
|
|
5795
5862
|
*/
|
|
5796
5863
|
|
|
5797
5864
|
|
|
5798
|
-
async getTokenAccountsByOwner(ownerAddress, filter,
|
|
5865
|
+
async getTokenAccountsByOwner(ownerAddress, filter, commitmentOrConfig) {
|
|
5866
|
+
const {
|
|
5867
|
+
commitment,
|
|
5868
|
+
config
|
|
5869
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
5799
5870
|
let _args = [ownerAddress.toBase58()];
|
|
5800
5871
|
|
|
5801
5872
|
if ('mint' in filter) {
|
|
@@ -5808,13 +5879,13 @@ class Connection {
|
|
|
5808
5879
|
});
|
|
5809
5880
|
}
|
|
5810
5881
|
|
|
5811
|
-
const args = this._buildArgs(_args, commitment, 'base64');
|
|
5882
|
+
const args = this._buildArgs(_args, commitment, 'base64', config);
|
|
5812
5883
|
|
|
5813
5884
|
const unsafeRes = await this._rpcRequest('getTokenAccountsByOwner', args);
|
|
5814
5885
|
const res = superstruct.create(unsafeRes, GetTokenAccountsByOwner);
|
|
5815
5886
|
|
|
5816
5887
|
if ('error' in res) {
|
|
5817
|
-
throw new
|
|
5888
|
+
throw new SolanaJSONRPCError(res.error, `failed to get token accounts owned by account ${ownerAddress.toBase58()}`);
|
|
5818
5889
|
}
|
|
5819
5890
|
|
|
5820
5891
|
return res.result;
|
|
@@ -5845,7 +5916,7 @@ class Connection {
|
|
|
5845
5916
|
const res = superstruct.create(unsafeRes, GetParsedTokenAccountsByOwner);
|
|
5846
5917
|
|
|
5847
5918
|
if ('error' in res) {
|
|
5848
|
-
throw new
|
|
5919
|
+
throw new SolanaJSONRPCError(res.error, `failed to get token accounts owned by account ${ownerAddress.toBase58()}`);
|
|
5849
5920
|
}
|
|
5850
5921
|
|
|
5851
5922
|
return res.result;
|
|
@@ -5864,7 +5935,7 @@ class Connection {
|
|
|
5864
5935
|
const res = superstruct.create(unsafeRes, GetLargestAccountsRpcResult);
|
|
5865
5936
|
|
|
5866
5937
|
if ('error' in res) {
|
|
5867
|
-
throw new
|
|
5938
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get largest accounts');
|
|
5868
5939
|
}
|
|
5869
5940
|
|
|
5870
5941
|
return res.result;
|
|
@@ -5882,7 +5953,7 @@ class Connection {
|
|
|
5882
5953
|
const res = superstruct.create(unsafeRes, GetTokenLargestAccountsResult);
|
|
5883
5954
|
|
|
5884
5955
|
if ('error' in res) {
|
|
5885
|
-
throw new
|
|
5956
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get token largest accounts');
|
|
5886
5957
|
}
|
|
5887
5958
|
|
|
5888
5959
|
return res.result;
|
|
@@ -5892,14 +5963,19 @@ class Connection {
|
|
|
5892
5963
|
*/
|
|
5893
5964
|
|
|
5894
5965
|
|
|
5895
|
-
async getAccountInfoAndContext(publicKey,
|
|
5896
|
-
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);
|
|
5897
5973
|
|
|
5898
5974
|
const unsafeRes = await this._rpcRequest('getAccountInfo', args);
|
|
5899
5975
|
const res = superstruct.create(unsafeRes, jsonRpcResultAndContext(superstruct.nullable(AccountInfoResult)));
|
|
5900
5976
|
|
|
5901
5977
|
if ('error' in res) {
|
|
5902
|
-
throw new
|
|
5978
|
+
throw new SolanaJSONRPCError(res.error, `failed to get info about account ${publicKey.toBase58()}`);
|
|
5903
5979
|
}
|
|
5904
5980
|
|
|
5905
5981
|
return res.result;
|
|
@@ -5916,7 +5992,7 @@ class Connection {
|
|
|
5916
5992
|
const res = superstruct.create(unsafeRes, jsonRpcResultAndContext(superstruct.nullable(ParsedAccountInfoResult)));
|
|
5917
5993
|
|
|
5918
5994
|
if ('error' in res) {
|
|
5919
|
-
throw new
|
|
5995
|
+
throw new SolanaJSONRPCError(res.error, `failed to get info about account ${publicKey.toBase58()}`);
|
|
5920
5996
|
}
|
|
5921
5997
|
|
|
5922
5998
|
return res.result;
|
|
@@ -5926,9 +6002,9 @@ class Connection {
|
|
|
5926
6002
|
*/
|
|
5927
6003
|
|
|
5928
6004
|
|
|
5929
|
-
async getAccountInfo(publicKey,
|
|
6005
|
+
async getAccountInfo(publicKey, commitmentOrConfig) {
|
|
5930
6006
|
try {
|
|
5931
|
-
const res = await this.getAccountInfoAndContext(publicKey,
|
|
6007
|
+
const res = await this.getAccountInfoAndContext(publicKey, commitmentOrConfig);
|
|
5932
6008
|
return res.value;
|
|
5933
6009
|
} catch (e) {
|
|
5934
6010
|
throw new Error('failed to get info about account ' + publicKey.toBase58() + ': ' + e);
|
|
@@ -5939,16 +6015,20 @@ class Connection {
|
|
|
5939
6015
|
*/
|
|
5940
6016
|
|
|
5941
6017
|
|
|
5942
|
-
async getMultipleAccountsInfoAndContext(publicKeys,
|
|
6018
|
+
async getMultipleAccountsInfoAndContext(publicKeys, commitmentOrConfig) {
|
|
6019
|
+
const {
|
|
6020
|
+
commitment,
|
|
6021
|
+
config
|
|
6022
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
5943
6023
|
const keys = publicKeys.map(key => key.toBase58());
|
|
5944
6024
|
|
|
5945
|
-
const args = this._buildArgs([keys], commitment, 'base64');
|
|
6025
|
+
const args = this._buildArgs([keys], commitment, 'base64', config);
|
|
5946
6026
|
|
|
5947
6027
|
const unsafeRes = await this._rpcRequest('getMultipleAccounts', args);
|
|
5948
6028
|
const res = superstruct.create(unsafeRes, jsonRpcResultAndContext(superstruct.array(superstruct.nullable(AccountInfoResult))));
|
|
5949
6029
|
|
|
5950
6030
|
if ('error' in res) {
|
|
5951
|
-
throw new
|
|
6031
|
+
throw new SolanaJSONRPCError(res.error, `failed to get info for accounts ${keys}`);
|
|
5952
6032
|
}
|
|
5953
6033
|
|
|
5954
6034
|
return res.result;
|
|
@@ -5958,8 +6038,8 @@ class Connection {
|
|
|
5958
6038
|
*/
|
|
5959
6039
|
|
|
5960
6040
|
|
|
5961
|
-
async getMultipleAccountsInfo(publicKeys,
|
|
5962
|
-
const res = await this.getMultipleAccountsInfoAndContext(publicKeys,
|
|
6041
|
+
async getMultipleAccountsInfo(publicKeys, commitmentOrConfig) {
|
|
6042
|
+
const res = await this.getMultipleAccountsInfoAndContext(publicKeys, commitmentOrConfig);
|
|
5963
6043
|
return res.value;
|
|
5964
6044
|
}
|
|
5965
6045
|
/**
|
|
@@ -5967,16 +6047,23 @@ class Connection {
|
|
|
5967
6047
|
*/
|
|
5968
6048
|
|
|
5969
6049
|
|
|
5970
|
-
async getStakeActivation(publicKey,
|
|
5971
|
-
const
|
|
5972
|
-
|
|
5973
|
-
|
|
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
|
+
});
|
|
5974
6061
|
|
|
5975
6062
|
const unsafeRes = await this._rpcRequest('getStakeActivation', args);
|
|
5976
6063
|
const res = superstruct.create(unsafeRes, jsonRpcResult(StakeActivationResult));
|
|
5977
6064
|
|
|
5978
6065
|
if ('error' in res) {
|
|
5979
|
-
throw new
|
|
6066
|
+
throw new SolanaJSONRPCError(res.error, `failed to get Stake Activation ${publicKey.toBase58()}`);
|
|
5980
6067
|
}
|
|
5981
6068
|
|
|
5982
6069
|
return res.result;
|
|
@@ -5989,34 +6076,22 @@ class Connection {
|
|
|
5989
6076
|
|
|
5990
6077
|
|
|
5991
6078
|
async getProgramAccounts(programId, configOrCommitment) {
|
|
5992
|
-
const
|
|
5993
|
-
|
|
5994
|
-
|
|
5995
|
-
|
|
5996
|
-
|
|
5997
|
-
|
|
5998
|
-
|
|
5999
|
-
|
|
6000
|
-
commitment = configOrCommitment.commitment;
|
|
6001
|
-
encoding = configOrCommitment.encoding;
|
|
6002
|
-
|
|
6003
|
-
if (configOrCommitment.dataSlice) {
|
|
6004
|
-
extra.dataSlice = configOrCommitment.dataSlice;
|
|
6005
|
-
}
|
|
6006
|
-
|
|
6007
|
-
if (configOrCommitment.filters) {
|
|
6008
|
-
extra.filters = configOrCommitment.filters;
|
|
6009
|
-
}
|
|
6010
|
-
}
|
|
6011
|
-
}
|
|
6079
|
+
const {
|
|
6080
|
+
commitment,
|
|
6081
|
+
config
|
|
6082
|
+
} = extractCommitmentFromConfig(configOrCommitment);
|
|
6083
|
+
const {
|
|
6084
|
+
encoding,
|
|
6085
|
+
...configWithoutEncoding
|
|
6086
|
+
} = config || {};
|
|
6012
6087
|
|
|
6013
|
-
const args = this._buildArgs([programId.toBase58()], commitment, encoding || 'base64',
|
|
6088
|
+
const args = this._buildArgs([programId.toBase58()], commitment, encoding || 'base64', configWithoutEncoding);
|
|
6014
6089
|
|
|
6015
6090
|
const unsafeRes = await this._rpcRequest('getProgramAccounts', args);
|
|
6016
6091
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.array(KeyedAccountInfoResult)));
|
|
6017
6092
|
|
|
6018
6093
|
if ('error' in res) {
|
|
6019
|
-
throw new
|
|
6094
|
+
throw new SolanaJSONRPCError(res.error, `failed to get accounts owned by program ${programId.toBase58()}`);
|
|
6020
6095
|
}
|
|
6021
6096
|
|
|
6022
6097
|
return res.result;
|
|
@@ -6029,28 +6104,18 @@ class Connection {
|
|
|
6029
6104
|
|
|
6030
6105
|
|
|
6031
6106
|
async getParsedProgramAccounts(programId, configOrCommitment) {
|
|
6032
|
-
const
|
|
6033
|
-
|
|
6034
|
-
|
|
6035
|
-
|
|
6036
|
-
if (typeof configOrCommitment === 'string') {
|
|
6037
|
-
commitment = configOrCommitment;
|
|
6038
|
-
} else {
|
|
6039
|
-
commitment = configOrCommitment.commitment;
|
|
6040
|
-
|
|
6041
|
-
if (configOrCommitment.filters) {
|
|
6042
|
-
extra.filters = configOrCommitment.filters;
|
|
6043
|
-
}
|
|
6044
|
-
}
|
|
6045
|
-
}
|
|
6107
|
+
const {
|
|
6108
|
+
commitment,
|
|
6109
|
+
config
|
|
6110
|
+
} = extractCommitmentFromConfig(configOrCommitment);
|
|
6046
6111
|
|
|
6047
|
-
const args = this._buildArgs([programId.toBase58()], commitment, 'jsonParsed',
|
|
6112
|
+
const args = this._buildArgs([programId.toBase58()], commitment, 'jsonParsed', config);
|
|
6048
6113
|
|
|
6049
6114
|
const unsafeRes = await this._rpcRequest('getProgramAccounts', args);
|
|
6050
6115
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.array(KeyedParsedAccountInfoResult)));
|
|
6051
6116
|
|
|
6052
6117
|
if ('error' in res) {
|
|
6053
|
-
throw new
|
|
6118
|
+
throw new SolanaJSONRPCError(res.error, `failed to get accounts owned by program ${programId.toBase58()}`);
|
|
6054
6119
|
}
|
|
6055
6120
|
|
|
6056
6121
|
return res.result;
|
|
@@ -6184,7 +6249,7 @@ class Connection {
|
|
|
6184
6249
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.array(ContactInfoResult)));
|
|
6185
6250
|
|
|
6186
6251
|
if ('error' in res) {
|
|
6187
|
-
throw new
|
|
6252
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get cluster nodes');
|
|
6188
6253
|
}
|
|
6189
6254
|
|
|
6190
6255
|
return res.result;
|
|
@@ -6201,7 +6266,7 @@ class Connection {
|
|
|
6201
6266
|
const res = superstruct.create(unsafeRes, GetVoteAccounts);
|
|
6202
6267
|
|
|
6203
6268
|
if ('error' in res) {
|
|
6204
|
-
throw new
|
|
6269
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get vote accounts');
|
|
6205
6270
|
}
|
|
6206
6271
|
|
|
6207
6272
|
return res.result;
|
|
@@ -6211,14 +6276,21 @@ class Connection {
|
|
|
6211
6276
|
*/
|
|
6212
6277
|
|
|
6213
6278
|
|
|
6214
|
-
async getSlot(
|
|
6215
|
-
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);
|
|
6216
6288
|
|
|
6217
6289
|
const unsafeRes = await this._rpcRequest('getSlot', args);
|
|
6218
6290
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.number()));
|
|
6219
6291
|
|
|
6220
6292
|
if ('error' in res) {
|
|
6221
|
-
throw new
|
|
6293
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get slot');
|
|
6222
6294
|
}
|
|
6223
6295
|
|
|
6224
6296
|
return res.result;
|
|
@@ -6228,14 +6300,21 @@ class Connection {
|
|
|
6228
6300
|
*/
|
|
6229
6301
|
|
|
6230
6302
|
|
|
6231
|
-
async getSlotLeader(
|
|
6232
|
-
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);
|
|
6233
6312
|
|
|
6234
6313
|
const unsafeRes = await this._rpcRequest('getSlotLeader', args);
|
|
6235
6314
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.string()));
|
|
6236
6315
|
|
|
6237
6316
|
if ('error' in res) {
|
|
6238
|
-
throw new
|
|
6317
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get slot leader');
|
|
6239
6318
|
}
|
|
6240
6319
|
|
|
6241
6320
|
return res.result;
|
|
@@ -6254,7 +6333,7 @@ class Connection {
|
|
|
6254
6333
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.array(PublicKeyFromString)));
|
|
6255
6334
|
|
|
6256
6335
|
if ('error' in res) {
|
|
6257
|
-
throw new
|
|
6336
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get slot leaders');
|
|
6258
6337
|
}
|
|
6259
6338
|
|
|
6260
6339
|
return res.result;
|
|
@@ -6292,7 +6371,7 @@ class Connection {
|
|
|
6292
6371
|
const res = superstruct.create(unsafeRes, GetSignatureStatusesRpcResult);
|
|
6293
6372
|
|
|
6294
6373
|
if ('error' in res) {
|
|
6295
|
-
throw new
|
|
6374
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get signature status');
|
|
6296
6375
|
}
|
|
6297
6376
|
|
|
6298
6377
|
return res.result;
|
|
@@ -6302,14 +6381,21 @@ class Connection {
|
|
|
6302
6381
|
*/
|
|
6303
6382
|
|
|
6304
6383
|
|
|
6305
|
-
async getTransactionCount(
|
|
6306
|
-
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);
|
|
6307
6393
|
|
|
6308
6394
|
const unsafeRes = await this._rpcRequest('getTransactionCount', args);
|
|
6309
6395
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.number()));
|
|
6310
6396
|
|
|
6311
6397
|
if ('error' in res) {
|
|
6312
|
-
throw new
|
|
6398
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get transaction count');
|
|
6313
6399
|
}
|
|
6314
6400
|
|
|
6315
6401
|
return res.result;
|
|
@@ -6340,7 +6426,7 @@ class Connection {
|
|
|
6340
6426
|
const res = superstruct.create(unsafeRes, GetInflationGovernorRpcResult);
|
|
6341
6427
|
|
|
6342
6428
|
if ('error' in res) {
|
|
6343
|
-
throw new
|
|
6429
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get inflation');
|
|
6344
6430
|
}
|
|
6345
6431
|
|
|
6346
6432
|
return res.result;
|
|
@@ -6350,16 +6436,23 @@ class Connection {
|
|
|
6350
6436
|
*/
|
|
6351
6437
|
|
|
6352
6438
|
|
|
6353
|
-
async getInflationReward(addresses, epoch,
|
|
6354
|
-
const
|
|
6355
|
-
|
|
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
|
|
6356
6449
|
});
|
|
6357
6450
|
|
|
6358
6451
|
const unsafeRes = await this._rpcRequest('getInflationReward', args);
|
|
6359
6452
|
const res = superstruct.create(unsafeRes, GetInflationRewardResult);
|
|
6360
6453
|
|
|
6361
6454
|
if ('error' in res) {
|
|
6362
|
-
throw new
|
|
6455
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get inflation reward');
|
|
6363
6456
|
}
|
|
6364
6457
|
|
|
6365
6458
|
return res.result;
|
|
@@ -6369,14 +6462,21 @@ class Connection {
|
|
|
6369
6462
|
*/
|
|
6370
6463
|
|
|
6371
6464
|
|
|
6372
|
-
async getEpochInfo(
|
|
6373
|
-
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);
|
|
6374
6474
|
|
|
6375
6475
|
const unsafeRes = await this._rpcRequest('getEpochInfo', args);
|
|
6376
6476
|
const res = superstruct.create(unsafeRes, GetEpochInfoRpcResult);
|
|
6377
6477
|
|
|
6378
6478
|
if ('error' in res) {
|
|
6379
|
-
throw new
|
|
6479
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get epoch info');
|
|
6380
6480
|
}
|
|
6381
6481
|
|
|
6382
6482
|
return res.result;
|
|
@@ -6391,7 +6491,7 @@ class Connection {
|
|
|
6391
6491
|
const res = superstruct.create(unsafeRes, GetEpochScheduleRpcResult);
|
|
6392
6492
|
|
|
6393
6493
|
if ('error' in res) {
|
|
6394
|
-
throw new
|
|
6494
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get epoch schedule');
|
|
6395
6495
|
}
|
|
6396
6496
|
|
|
6397
6497
|
const epochSchedule = res.result;
|
|
@@ -6408,7 +6508,7 @@ class Connection {
|
|
|
6408
6508
|
const res = superstruct.create(unsafeRes, GetLeaderScheduleRpcResult);
|
|
6409
6509
|
|
|
6410
6510
|
if ('error' in res) {
|
|
6411
|
-
throw new
|
|
6511
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get leader schedule');
|
|
6412
6512
|
}
|
|
6413
6513
|
|
|
6414
6514
|
return res.result;
|
|
@@ -6447,7 +6547,7 @@ class Connection {
|
|
|
6447
6547
|
const res = superstruct.create(unsafeRes, GetRecentBlockhashAndContextRpcResult);
|
|
6448
6548
|
|
|
6449
6549
|
if ('error' in res) {
|
|
6450
|
-
throw new
|
|
6550
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get recent blockhash');
|
|
6451
6551
|
}
|
|
6452
6552
|
|
|
6453
6553
|
return res.result;
|
|
@@ -6465,7 +6565,7 @@ class Connection {
|
|
|
6465
6565
|
const res = superstruct.create(unsafeRes, GetRecentPerformanceSamplesRpcResult);
|
|
6466
6566
|
|
|
6467
6567
|
if ('error' in res) {
|
|
6468
|
-
throw new
|
|
6568
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get recent performance samples');
|
|
6469
6569
|
}
|
|
6470
6570
|
|
|
6471
6571
|
return res.result;
|
|
@@ -6484,7 +6584,7 @@ class Connection {
|
|
|
6484
6584
|
const res = superstruct.create(unsafeRes, GetFeeCalculatorRpcResult);
|
|
6485
6585
|
|
|
6486
6586
|
if ('error' in res) {
|
|
6487
|
-
throw new
|
|
6587
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get fee calculator');
|
|
6488
6588
|
}
|
|
6489
6589
|
|
|
6490
6590
|
const {
|
|
@@ -6510,7 +6610,7 @@ class Connection {
|
|
|
6510
6610
|
const res = superstruct.create(unsafeRes, jsonRpcResultAndContext(superstruct.nullable(superstruct.number())));
|
|
6511
6611
|
|
|
6512
6612
|
if ('error' in res) {
|
|
6513
|
-
throw new
|
|
6613
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get slot');
|
|
6514
6614
|
}
|
|
6515
6615
|
|
|
6516
6616
|
if (res.result === null) {
|
|
@@ -6541,9 +6641,9 @@ class Connection {
|
|
|
6541
6641
|
*/
|
|
6542
6642
|
|
|
6543
6643
|
|
|
6544
|
-
async getLatestBlockhash(
|
|
6644
|
+
async getLatestBlockhash(commitmentOrConfig) {
|
|
6545
6645
|
try {
|
|
6546
|
-
const res = await this.getLatestBlockhashAndContext(
|
|
6646
|
+
const res = await this.getLatestBlockhashAndContext(commitmentOrConfig);
|
|
6547
6647
|
return res.value;
|
|
6548
6648
|
} catch (e) {
|
|
6549
6649
|
throw new Error('failed to get recent blockhash: ' + e);
|
|
@@ -6555,14 +6655,21 @@ class Connection {
|
|
|
6555
6655
|
*/
|
|
6556
6656
|
|
|
6557
6657
|
|
|
6558
|
-
async getLatestBlockhashAndContext(
|
|
6559
|
-
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);
|
|
6560
6667
|
|
|
6561
6668
|
const unsafeRes = await this._rpcRequest('getLatestBlockhash', args);
|
|
6562
6669
|
const res = superstruct.create(unsafeRes, GetLatestBlockhashRpcResult);
|
|
6563
6670
|
|
|
6564
6671
|
if ('error' in res) {
|
|
6565
|
-
throw new
|
|
6672
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get latest blockhash');
|
|
6566
6673
|
}
|
|
6567
6674
|
|
|
6568
6675
|
return res.result;
|
|
@@ -6577,7 +6684,7 @@ class Connection {
|
|
|
6577
6684
|
const res = superstruct.create(unsafeRes, jsonRpcResult(VersionResult));
|
|
6578
6685
|
|
|
6579
6686
|
if ('error' in res) {
|
|
6580
|
-
throw new
|
|
6687
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get version');
|
|
6581
6688
|
}
|
|
6582
6689
|
|
|
6583
6690
|
return res.result;
|
|
@@ -6592,7 +6699,7 @@ class Connection {
|
|
|
6592
6699
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.string()));
|
|
6593
6700
|
|
|
6594
6701
|
if ('error' in res) {
|
|
6595
|
-
throw new
|
|
6702
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get genesis hash');
|
|
6596
6703
|
}
|
|
6597
6704
|
|
|
6598
6705
|
return res.result;
|
|
@@ -6609,7 +6716,7 @@ class Connection {
|
|
|
6609
6716
|
const res = superstruct.create(unsafeRes, GetBlockRpcResult);
|
|
6610
6717
|
|
|
6611
6718
|
if ('error' in res) {
|
|
6612
|
-
throw new
|
|
6719
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get confirmed block');
|
|
6613
6720
|
}
|
|
6614
6721
|
|
|
6615
6722
|
const result = res.result;
|
|
@@ -6634,14 +6741,21 @@ class Connection {
|
|
|
6634
6741
|
*/
|
|
6635
6742
|
|
|
6636
6743
|
|
|
6637
|
-
async getBlockHeight(
|
|
6638
|
-
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);
|
|
6639
6753
|
|
|
6640
6754
|
const unsafeRes = await this._rpcRequest('getBlockHeight', args);
|
|
6641
6755
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.number()));
|
|
6642
6756
|
|
|
6643
6757
|
if ('error' in res) {
|
|
6644
|
-
throw new
|
|
6758
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get block height information');
|
|
6645
6759
|
}
|
|
6646
6760
|
|
|
6647
6761
|
return res.result;
|
|
@@ -6672,7 +6786,7 @@ class Connection {
|
|
|
6672
6786
|
const res = superstruct.create(unsafeRes, BlockProductionResponseStruct);
|
|
6673
6787
|
|
|
6674
6788
|
if ('error' in res) {
|
|
6675
|
-
throw new
|
|
6789
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get block production information');
|
|
6676
6790
|
}
|
|
6677
6791
|
|
|
6678
6792
|
return res.result;
|
|
@@ -6689,7 +6803,7 @@ class Connection {
|
|
|
6689
6803
|
const res = superstruct.create(unsafeRes, GetTransactionRpcResult);
|
|
6690
6804
|
|
|
6691
6805
|
if ('error' in res) {
|
|
6692
|
-
throw new
|
|
6806
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get transaction');
|
|
6693
6807
|
}
|
|
6694
6808
|
|
|
6695
6809
|
const result = res.result;
|
|
@@ -6712,7 +6826,7 @@ class Connection {
|
|
|
6712
6826
|
const res = superstruct.create(unsafeRes, GetParsedTransactionRpcResult);
|
|
6713
6827
|
|
|
6714
6828
|
if ('error' in res) {
|
|
6715
|
-
throw new
|
|
6829
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get transaction');
|
|
6716
6830
|
}
|
|
6717
6831
|
|
|
6718
6832
|
return res.result;
|
|
@@ -6736,7 +6850,7 @@ class Connection {
|
|
|
6736
6850
|
const res = superstruct.create(unsafeRes, GetParsedTransactionRpcResult);
|
|
6737
6851
|
|
|
6738
6852
|
if ('error' in res) {
|
|
6739
|
-
throw new
|
|
6853
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get transactions');
|
|
6740
6854
|
}
|
|
6741
6855
|
|
|
6742
6856
|
return res.result;
|
|
@@ -6763,7 +6877,7 @@ class Connection {
|
|
|
6763
6877
|
const res = superstruct.create(unsafeRes, GetTransactionRpcResult);
|
|
6764
6878
|
|
|
6765
6879
|
if ('error' in res) {
|
|
6766
|
-
throw new
|
|
6880
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get transactions');
|
|
6767
6881
|
}
|
|
6768
6882
|
|
|
6769
6883
|
const result = res.result;
|
|
@@ -6791,7 +6905,7 @@ class Connection {
|
|
|
6791
6905
|
const res = superstruct.create(unsafeRes, GetConfirmedBlockRpcResult);
|
|
6792
6906
|
|
|
6793
6907
|
if ('error' in res) {
|
|
6794
|
-
throw new
|
|
6908
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get confirmed block');
|
|
6795
6909
|
}
|
|
6796
6910
|
|
|
6797
6911
|
const result = res.result;
|
|
@@ -6838,7 +6952,7 @@ class Connection {
|
|
|
6838
6952
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.array(superstruct.number())));
|
|
6839
6953
|
|
|
6840
6954
|
if ('error' in res) {
|
|
6841
|
-
throw new
|
|
6955
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get blocks');
|
|
6842
6956
|
}
|
|
6843
6957
|
|
|
6844
6958
|
return res.result;
|
|
@@ -6858,7 +6972,7 @@ class Connection {
|
|
|
6858
6972
|
const res = superstruct.create(unsafeRes, GetBlockSignaturesRpcResult);
|
|
6859
6973
|
|
|
6860
6974
|
if ('error' in res) {
|
|
6861
|
-
throw new
|
|
6975
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get block');
|
|
6862
6976
|
}
|
|
6863
6977
|
|
|
6864
6978
|
const result = res.result;
|
|
@@ -6886,7 +7000,7 @@ class Connection {
|
|
|
6886
7000
|
const res = superstruct.create(unsafeRes, GetBlockSignaturesRpcResult);
|
|
6887
7001
|
|
|
6888
7002
|
if ('error' in res) {
|
|
6889
|
-
throw new
|
|
7003
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get confirmed block');
|
|
6890
7004
|
}
|
|
6891
7005
|
|
|
6892
7006
|
const result = res.result;
|
|
@@ -6911,7 +7025,7 @@ class Connection {
|
|
|
6911
7025
|
const res = superstruct.create(unsafeRes, GetTransactionRpcResult);
|
|
6912
7026
|
|
|
6913
7027
|
if ('error' in res) {
|
|
6914
|
-
throw new
|
|
7028
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get transaction');
|
|
6915
7029
|
}
|
|
6916
7030
|
|
|
6917
7031
|
const result = res.result;
|
|
@@ -6936,7 +7050,7 @@ class Connection {
|
|
|
6936
7050
|
const res = superstruct.create(unsafeRes, GetParsedTransactionRpcResult);
|
|
6937
7051
|
|
|
6938
7052
|
if ('error' in res) {
|
|
6939
|
-
throw new
|
|
7053
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get confirmed transaction');
|
|
6940
7054
|
}
|
|
6941
7055
|
|
|
6942
7056
|
return res.result;
|
|
@@ -6962,7 +7076,7 @@ class Connection {
|
|
|
6962
7076
|
const res = superstruct.create(unsafeRes, GetParsedTransactionRpcResult);
|
|
6963
7077
|
|
|
6964
7078
|
if ('error' in res) {
|
|
6965
|
-
throw new
|
|
7079
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get confirmed transactions');
|
|
6966
7080
|
}
|
|
6967
7081
|
|
|
6968
7082
|
return res.result;
|
|
@@ -7051,7 +7165,7 @@ class Connection {
|
|
|
7051
7165
|
const res = superstruct.create(unsafeRes, GetConfirmedSignaturesForAddress2RpcResult);
|
|
7052
7166
|
|
|
7053
7167
|
if ('error' in res) {
|
|
7054
|
-
throw new
|
|
7168
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get confirmed signatures for address');
|
|
7055
7169
|
}
|
|
7056
7170
|
|
|
7057
7171
|
return res.result;
|
|
@@ -7073,7 +7187,7 @@ class Connection {
|
|
|
7073
7187
|
const res = superstruct.create(unsafeRes, GetSignaturesForAddressRpcResult);
|
|
7074
7188
|
|
|
7075
7189
|
if ('error' in res) {
|
|
7076
|
-
throw new
|
|
7190
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get signatures for address');
|
|
7077
7191
|
}
|
|
7078
7192
|
|
|
7079
7193
|
return res.result;
|
|
@@ -7130,7 +7244,7 @@ class Connection {
|
|
|
7130
7244
|
const res = superstruct.create(unsafeRes, RequestAirdropRpcResult);
|
|
7131
7245
|
|
|
7132
7246
|
if ('error' in res) {
|
|
7133
|
-
throw new
|
|
7247
|
+
throw new SolanaJSONRPCError(res.error, `airdrop to ${to.toBase58()} failed`);
|
|
7134
7248
|
}
|
|
7135
7249
|
|
|
7136
7250
|
return res.result;
|
|
@@ -7360,10 +7474,14 @@ class Connection {
|
|
|
7360
7474
|
const skipPreflight = options && options.skipPreflight;
|
|
7361
7475
|
const preflightCommitment = options && options.preflightCommitment || this.commitment;
|
|
7362
7476
|
|
|
7363
|
-
if (options && options.maxRetries) {
|
|
7477
|
+
if (options && options.maxRetries != null) {
|
|
7364
7478
|
config.maxRetries = options.maxRetries;
|
|
7365
7479
|
}
|
|
7366
7480
|
|
|
7481
|
+
if (options && options.minContextSlot != null) {
|
|
7482
|
+
config.minContextSlot = options.minContextSlot;
|
|
7483
|
+
}
|
|
7484
|
+
|
|
7367
7485
|
if (skipPreflight) {
|
|
7368
7486
|
config.skipPreflight = skipPreflight;
|
|
7369
7487
|
}
|
|
@@ -9773,7 +9891,8 @@ async function sendAndConfirmRawTransaction(connection, rawTransaction, confirma
|
|
|
9773
9891
|
|
|
9774
9892
|
const sendOptions = options && {
|
|
9775
9893
|
skipPreflight: options.skipPreflight,
|
|
9776
|
-
preflightCommitment: options.preflightCommitment || options.commitment
|
|
9894
|
+
preflightCommitment: options.preflightCommitment || options.commitment,
|
|
9895
|
+
minContextSlot: options.minContextSlot
|
|
9777
9896
|
};
|
|
9778
9897
|
const signature = await connection.sendRawTransaction(rawTransaction, sendOptions);
|
|
9779
9898
|
const commitment = options && options.commitment;
|
|
@@ -9865,6 +9984,8 @@ exports.SYSVAR_SLOT_HISTORY_PUBKEY = SYSVAR_SLOT_HISTORY_PUBKEY;
|
|
|
9865
9984
|
exports.SYSVAR_STAKE_HISTORY_PUBKEY = SYSVAR_STAKE_HISTORY_PUBKEY;
|
|
9866
9985
|
exports.Secp256k1Program = Secp256k1Program;
|
|
9867
9986
|
exports.SendTransactionError = SendTransactionError;
|
|
9987
|
+
exports.SolanaJSONRPCError = SolanaJSONRPCError;
|
|
9988
|
+
exports.SolanaJSONRPCErrorCode = SolanaJSONRPCErrorCode;
|
|
9868
9989
|
exports.StakeAuthorizationLayout = StakeAuthorizationLayout;
|
|
9869
9990
|
exports.StakeInstruction = StakeInstruction;
|
|
9870
9991
|
exports.StakeProgram = StakeProgram;
|