@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.cjs.js
CHANGED
|
@@ -3131,7 +3131,8 @@ async function sendAndConfirmTransaction(connection, transaction, signers, optio
|
|
|
3131
3131
|
const sendOptions = options && {
|
|
3132
3132
|
skipPreflight: options.skipPreflight,
|
|
3133
3133
|
preflightCommitment: options.preflightCommitment || options.commitment,
|
|
3134
|
-
maxRetries: options.maxRetries
|
|
3134
|
+
maxRetries: options.maxRetries,
|
|
3135
|
+
minContextSlot: options.minContextSlot
|
|
3135
3136
|
};
|
|
3136
3137
|
const signature = await connection.sendTransaction(transaction, signers, sendOptions);
|
|
3137
3138
|
const status = transaction.recentBlockhash != null && transaction.lastValidBlockHeight != null ? (await connection.confirmTransaction({
|
|
@@ -4607,6 +4608,41 @@ class SendTransactionError extends Error {
|
|
|
4607
4608
|
this.logs = logs;
|
|
4608
4609
|
}
|
|
4609
4610
|
|
|
4611
|
+
} // Keep in sync with client/src/rpc_custom_errors.rs
|
|
4612
|
+
// Typescript `enums` thwart tree-shaking. See https://bargsten.org/jsts/enums/
|
|
4613
|
+
|
|
4614
|
+
const SolanaJSONRPCErrorCode = {
|
|
4615
|
+
JSON_RPC_SERVER_ERROR_BLOCK_CLEANED_UP: -32001,
|
|
4616
|
+
JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE: -32002,
|
|
4617
|
+
JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE: -32003,
|
|
4618
|
+
JSON_RPC_SERVER_ERROR_BLOCK_NOT_AVAILABLE: -32004,
|
|
4619
|
+
JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY: -32005,
|
|
4620
|
+
JSON_RPC_SERVER_ERROR_TRANSACTION_PRECOMPILE_VERIFICATION_FAILURE: -32006,
|
|
4621
|
+
JSON_RPC_SERVER_ERROR_SLOT_SKIPPED: -32007,
|
|
4622
|
+
JSON_RPC_SERVER_ERROR_NO_SNAPSHOT: -32008,
|
|
4623
|
+
JSON_RPC_SERVER_ERROR_LONG_TERM_STORAGE_SLOT_SKIPPED: -32009,
|
|
4624
|
+
JSON_RPC_SERVER_ERROR_KEY_EXCLUDED_FROM_SECONDARY_INDEX: -32010,
|
|
4625
|
+
JSON_RPC_SERVER_ERROR_TRANSACTION_HISTORY_NOT_AVAILABLE: -32011,
|
|
4626
|
+
JSON_RPC_SCAN_ERROR: -32012,
|
|
4627
|
+
JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_LEN_MISMATCH: -32013,
|
|
4628
|
+
JSON_RPC_SERVER_ERROR_BLOCK_STATUS_NOT_AVAILABLE_YET: -32014,
|
|
4629
|
+
JSON_RPC_SERVER_ERROR_UNSUPPORTED_TRANSACTION_VERSION: -32015,
|
|
4630
|
+
JSON_RPC_SERVER_ERROR_MIN_CONTEXT_SLOT_NOT_REACHED: -32016
|
|
4631
|
+
};
|
|
4632
|
+
class SolanaJSONRPCError extends Error {
|
|
4633
|
+
constructor({
|
|
4634
|
+
code,
|
|
4635
|
+
message,
|
|
4636
|
+
data
|
|
4637
|
+
}, customMessage) {
|
|
4638
|
+
super(customMessage != null ? `${customMessage}: ${message}` : message);
|
|
4639
|
+
this.code = void 0;
|
|
4640
|
+
this.data = void 0;
|
|
4641
|
+
this.code = code;
|
|
4642
|
+
this.data = data;
|
|
4643
|
+
this.name = 'SolanaJSONRPCError';
|
|
4644
|
+
}
|
|
4645
|
+
|
|
4610
4646
|
}
|
|
4611
4647
|
|
|
4612
4648
|
async function fetchImpl (input, init) {
|
|
@@ -4695,9 +4731,32 @@ const BLOCKHASH_CACHE_TIMEOUT_MS = 30 * 1000;
|
|
|
4695
4731
|
* https://gist.github.com/steveluscher/c057eca81d479ef705cdb53162f9971d
|
|
4696
4732
|
*/
|
|
4697
4733
|
|
|
4734
|
+
/** @internal */
|
|
4735
|
+
function extractCommitmentFromConfig(commitmentOrConfig) {
|
|
4736
|
+
let commitment;
|
|
4737
|
+
let config;
|
|
4738
|
+
|
|
4739
|
+
if (typeof commitmentOrConfig === 'string') {
|
|
4740
|
+
commitment = commitmentOrConfig;
|
|
4741
|
+
} else if (commitmentOrConfig) {
|
|
4742
|
+
const {
|
|
4743
|
+
commitment: specifiedCommitment,
|
|
4744
|
+
...specifiedConfig
|
|
4745
|
+
} = commitmentOrConfig;
|
|
4746
|
+
commitment = specifiedCommitment;
|
|
4747
|
+
config = specifiedConfig;
|
|
4748
|
+
}
|
|
4749
|
+
|
|
4750
|
+
return {
|
|
4751
|
+
commitment,
|
|
4752
|
+
config
|
|
4753
|
+
};
|
|
4754
|
+
}
|
|
4698
4755
|
/**
|
|
4699
4756
|
* @internal
|
|
4700
4757
|
*/
|
|
4758
|
+
|
|
4759
|
+
|
|
4701
4760
|
function createRpcResult(result) {
|
|
4702
4761
|
return superstruct.union([superstruct.type({
|
|
4703
4762
|
jsonrpc: superstruct.literal('2.0'),
|
|
@@ -5740,14 +5799,22 @@ class Connection {
|
|
|
5740
5799
|
*/
|
|
5741
5800
|
|
|
5742
5801
|
|
|
5743
|
-
async getBalanceAndContext(publicKey,
|
|
5744
|
-
|
|
5802
|
+
async getBalanceAndContext(publicKey, commitmentOrConfig) {
|
|
5803
|
+
/** @internal */
|
|
5804
|
+
const {
|
|
5805
|
+
commitment,
|
|
5806
|
+
config
|
|
5807
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
5808
|
+
|
|
5809
|
+
const args = this._buildArgs([publicKey.toBase58()], commitment, undefined
|
|
5810
|
+
/* encoding */
|
|
5811
|
+
, config);
|
|
5745
5812
|
|
|
5746
5813
|
const unsafeRes = await this._rpcRequest('getBalance', args);
|
|
5747
5814
|
const res = superstruct.create(unsafeRes, jsonRpcResultAndContext(superstruct.number()));
|
|
5748
5815
|
|
|
5749
5816
|
if ('error' in res) {
|
|
5750
|
-
throw new
|
|
5817
|
+
throw new SolanaJSONRPCError(res.error, `failed to get balance for ${publicKey.toBase58()}`);
|
|
5751
5818
|
}
|
|
5752
5819
|
|
|
5753
5820
|
return res.result;
|
|
@@ -5757,8 +5824,8 @@ class Connection {
|
|
|
5757
5824
|
*/
|
|
5758
5825
|
|
|
5759
5826
|
|
|
5760
|
-
async getBalance(publicKey,
|
|
5761
|
-
return await this.getBalanceAndContext(publicKey,
|
|
5827
|
+
async getBalance(publicKey, commitmentOrConfig) {
|
|
5828
|
+
return await this.getBalanceAndContext(publicKey, commitmentOrConfig).then(x => x.value).catch(e => {
|
|
5762
5829
|
throw new Error('failed to get balance of account ' + publicKey.toBase58() + ': ' + e);
|
|
5763
5830
|
});
|
|
5764
5831
|
}
|
|
@@ -5772,7 +5839,7 @@ class Connection {
|
|
|
5772
5839
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.nullable(superstruct.number())));
|
|
5773
5840
|
|
|
5774
5841
|
if ('error' in res) {
|
|
5775
|
-
throw new
|
|
5842
|
+
throw new SolanaJSONRPCError(res.error, `failed to get block time for slot ${slot}`);
|
|
5776
5843
|
}
|
|
5777
5844
|
|
|
5778
5845
|
return res.result;
|
|
@@ -5788,7 +5855,7 @@ class Connection {
|
|
|
5788
5855
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.number()));
|
|
5789
5856
|
|
|
5790
5857
|
if ('error' in res) {
|
|
5791
|
-
throw new
|
|
5858
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get minimum ledger slot');
|
|
5792
5859
|
}
|
|
5793
5860
|
|
|
5794
5861
|
return res.result;
|
|
@@ -5803,7 +5870,7 @@ class Connection {
|
|
|
5803
5870
|
const res = superstruct.create(unsafeRes, SlotRpcResult);
|
|
5804
5871
|
|
|
5805
5872
|
if ('error' in res) {
|
|
5806
|
-
throw new
|
|
5873
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get first available block');
|
|
5807
5874
|
}
|
|
5808
5875
|
|
|
5809
5876
|
return res.result;
|
|
@@ -5834,7 +5901,7 @@ class Connection {
|
|
|
5834
5901
|
const res = superstruct.create(unsafeRes, GetSupplyRpcResult);
|
|
5835
5902
|
|
|
5836
5903
|
if ('error' in res) {
|
|
5837
|
-
throw new
|
|
5904
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get supply');
|
|
5838
5905
|
}
|
|
5839
5906
|
|
|
5840
5907
|
return res.result;
|
|
@@ -5851,7 +5918,7 @@ class Connection {
|
|
|
5851
5918
|
const res = superstruct.create(unsafeRes, jsonRpcResultAndContext(TokenAmountResult));
|
|
5852
5919
|
|
|
5853
5920
|
if ('error' in res) {
|
|
5854
|
-
throw new
|
|
5921
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get token supply');
|
|
5855
5922
|
}
|
|
5856
5923
|
|
|
5857
5924
|
return res.result;
|
|
@@ -5868,7 +5935,7 @@ class Connection {
|
|
|
5868
5935
|
const res = superstruct.create(unsafeRes, jsonRpcResultAndContext(TokenAmountResult));
|
|
5869
5936
|
|
|
5870
5937
|
if ('error' in res) {
|
|
5871
|
-
throw new
|
|
5938
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get token account balance');
|
|
5872
5939
|
}
|
|
5873
5940
|
|
|
5874
5941
|
return res.result;
|
|
@@ -5880,7 +5947,11 @@ class Connection {
|
|
|
5880
5947
|
*/
|
|
5881
5948
|
|
|
5882
5949
|
|
|
5883
|
-
async getTokenAccountsByOwner(ownerAddress, filter,
|
|
5950
|
+
async getTokenAccountsByOwner(ownerAddress, filter, commitmentOrConfig) {
|
|
5951
|
+
const {
|
|
5952
|
+
commitment,
|
|
5953
|
+
config
|
|
5954
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
5884
5955
|
let _args = [ownerAddress.toBase58()];
|
|
5885
5956
|
|
|
5886
5957
|
if ('mint' in filter) {
|
|
@@ -5893,13 +5964,13 @@ class Connection {
|
|
|
5893
5964
|
});
|
|
5894
5965
|
}
|
|
5895
5966
|
|
|
5896
|
-
const args = this._buildArgs(_args, commitment, 'base64');
|
|
5967
|
+
const args = this._buildArgs(_args, commitment, 'base64', config);
|
|
5897
5968
|
|
|
5898
5969
|
const unsafeRes = await this._rpcRequest('getTokenAccountsByOwner', args);
|
|
5899
5970
|
const res = superstruct.create(unsafeRes, GetTokenAccountsByOwner);
|
|
5900
5971
|
|
|
5901
5972
|
if ('error' in res) {
|
|
5902
|
-
throw new
|
|
5973
|
+
throw new SolanaJSONRPCError(res.error, `failed to get token accounts owned by account ${ownerAddress.toBase58()}`);
|
|
5903
5974
|
}
|
|
5904
5975
|
|
|
5905
5976
|
return res.result;
|
|
@@ -5930,7 +6001,7 @@ class Connection {
|
|
|
5930
6001
|
const res = superstruct.create(unsafeRes, GetParsedTokenAccountsByOwner);
|
|
5931
6002
|
|
|
5932
6003
|
if ('error' in res) {
|
|
5933
|
-
throw new
|
|
6004
|
+
throw new SolanaJSONRPCError(res.error, `failed to get token accounts owned by account ${ownerAddress.toBase58()}`);
|
|
5934
6005
|
}
|
|
5935
6006
|
|
|
5936
6007
|
return res.result;
|
|
@@ -5949,7 +6020,7 @@ class Connection {
|
|
|
5949
6020
|
const res = superstruct.create(unsafeRes, GetLargestAccountsRpcResult);
|
|
5950
6021
|
|
|
5951
6022
|
if ('error' in res) {
|
|
5952
|
-
throw new
|
|
6023
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get largest accounts');
|
|
5953
6024
|
}
|
|
5954
6025
|
|
|
5955
6026
|
return res.result;
|
|
@@ -5967,7 +6038,7 @@ class Connection {
|
|
|
5967
6038
|
const res = superstruct.create(unsafeRes, GetTokenLargestAccountsResult);
|
|
5968
6039
|
|
|
5969
6040
|
if ('error' in res) {
|
|
5970
|
-
throw new
|
|
6041
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get token largest accounts');
|
|
5971
6042
|
}
|
|
5972
6043
|
|
|
5973
6044
|
return res.result;
|
|
@@ -5977,14 +6048,19 @@ class Connection {
|
|
|
5977
6048
|
*/
|
|
5978
6049
|
|
|
5979
6050
|
|
|
5980
|
-
async getAccountInfoAndContext(publicKey,
|
|
5981
|
-
const
|
|
6051
|
+
async getAccountInfoAndContext(publicKey, commitmentOrConfig) {
|
|
6052
|
+
const {
|
|
6053
|
+
commitment,
|
|
6054
|
+
config
|
|
6055
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
6056
|
+
|
|
6057
|
+
const args = this._buildArgs([publicKey.toBase58()], commitment, 'base64', config);
|
|
5982
6058
|
|
|
5983
6059
|
const unsafeRes = await this._rpcRequest('getAccountInfo', args);
|
|
5984
6060
|
const res = superstruct.create(unsafeRes, jsonRpcResultAndContext(superstruct.nullable(AccountInfoResult)));
|
|
5985
6061
|
|
|
5986
6062
|
if ('error' in res) {
|
|
5987
|
-
throw new
|
|
6063
|
+
throw new SolanaJSONRPCError(res.error, `failed to get info about account ${publicKey.toBase58()}`);
|
|
5988
6064
|
}
|
|
5989
6065
|
|
|
5990
6066
|
return res.result;
|
|
@@ -6001,7 +6077,7 @@ class Connection {
|
|
|
6001
6077
|
const res = superstruct.create(unsafeRes, jsonRpcResultAndContext(superstruct.nullable(ParsedAccountInfoResult)));
|
|
6002
6078
|
|
|
6003
6079
|
if ('error' in res) {
|
|
6004
|
-
throw new
|
|
6080
|
+
throw new SolanaJSONRPCError(res.error, `failed to get info about account ${publicKey.toBase58()}`);
|
|
6005
6081
|
}
|
|
6006
6082
|
|
|
6007
6083
|
return res.result;
|
|
@@ -6011,9 +6087,9 @@ class Connection {
|
|
|
6011
6087
|
*/
|
|
6012
6088
|
|
|
6013
6089
|
|
|
6014
|
-
async getAccountInfo(publicKey,
|
|
6090
|
+
async getAccountInfo(publicKey, commitmentOrConfig) {
|
|
6015
6091
|
try {
|
|
6016
|
-
const res = await this.getAccountInfoAndContext(publicKey,
|
|
6092
|
+
const res = await this.getAccountInfoAndContext(publicKey, commitmentOrConfig);
|
|
6017
6093
|
return res.value;
|
|
6018
6094
|
} catch (e) {
|
|
6019
6095
|
throw new Error('failed to get info about account ' + publicKey.toBase58() + ': ' + e);
|
|
@@ -6024,16 +6100,20 @@ class Connection {
|
|
|
6024
6100
|
*/
|
|
6025
6101
|
|
|
6026
6102
|
|
|
6027
|
-
async getMultipleAccountsInfoAndContext(publicKeys,
|
|
6103
|
+
async getMultipleAccountsInfoAndContext(publicKeys, commitmentOrConfig) {
|
|
6104
|
+
const {
|
|
6105
|
+
commitment,
|
|
6106
|
+
config
|
|
6107
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
6028
6108
|
const keys = publicKeys.map(key => key.toBase58());
|
|
6029
6109
|
|
|
6030
|
-
const args = this._buildArgs([keys], commitment, 'base64');
|
|
6110
|
+
const args = this._buildArgs([keys], commitment, 'base64', config);
|
|
6031
6111
|
|
|
6032
6112
|
const unsafeRes = await this._rpcRequest('getMultipleAccounts', args);
|
|
6033
6113
|
const res = superstruct.create(unsafeRes, jsonRpcResultAndContext(superstruct.array(superstruct.nullable(AccountInfoResult))));
|
|
6034
6114
|
|
|
6035
6115
|
if ('error' in res) {
|
|
6036
|
-
throw new
|
|
6116
|
+
throw new SolanaJSONRPCError(res.error, `failed to get info for accounts ${keys}`);
|
|
6037
6117
|
}
|
|
6038
6118
|
|
|
6039
6119
|
return res.result;
|
|
@@ -6043,8 +6123,8 @@ class Connection {
|
|
|
6043
6123
|
*/
|
|
6044
6124
|
|
|
6045
6125
|
|
|
6046
|
-
async getMultipleAccountsInfo(publicKeys,
|
|
6047
|
-
const res = await this.getMultipleAccountsInfoAndContext(publicKeys,
|
|
6126
|
+
async getMultipleAccountsInfo(publicKeys, commitmentOrConfig) {
|
|
6127
|
+
const res = await this.getMultipleAccountsInfoAndContext(publicKeys, commitmentOrConfig);
|
|
6048
6128
|
return res.value;
|
|
6049
6129
|
}
|
|
6050
6130
|
/**
|
|
@@ -6052,16 +6132,23 @@ class Connection {
|
|
|
6052
6132
|
*/
|
|
6053
6133
|
|
|
6054
6134
|
|
|
6055
|
-
async getStakeActivation(publicKey,
|
|
6056
|
-
const
|
|
6057
|
-
|
|
6058
|
-
|
|
6135
|
+
async getStakeActivation(publicKey, commitmentOrConfig, epoch) {
|
|
6136
|
+
const {
|
|
6137
|
+
commitment,
|
|
6138
|
+
config
|
|
6139
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
6140
|
+
|
|
6141
|
+
const args = this._buildArgs([publicKey.toBase58()], commitment, undefined
|
|
6142
|
+
/* encoding */
|
|
6143
|
+
, { ...config,
|
|
6144
|
+
epoch: epoch != null ? epoch : config === null || config === void 0 ? void 0 : config.epoch
|
|
6145
|
+
});
|
|
6059
6146
|
|
|
6060
6147
|
const unsafeRes = await this._rpcRequest('getStakeActivation', args);
|
|
6061
6148
|
const res = superstruct.create(unsafeRes, jsonRpcResult(StakeActivationResult));
|
|
6062
6149
|
|
|
6063
6150
|
if ('error' in res) {
|
|
6064
|
-
throw new
|
|
6151
|
+
throw new SolanaJSONRPCError(res.error, `failed to get Stake Activation ${publicKey.toBase58()}`);
|
|
6065
6152
|
}
|
|
6066
6153
|
|
|
6067
6154
|
return res.result;
|
|
@@ -6074,34 +6161,22 @@ class Connection {
|
|
|
6074
6161
|
|
|
6075
6162
|
|
|
6076
6163
|
async getProgramAccounts(programId, configOrCommitment) {
|
|
6077
|
-
const
|
|
6078
|
-
|
|
6079
|
-
|
|
6080
|
-
|
|
6081
|
-
|
|
6082
|
-
|
|
6083
|
-
|
|
6084
|
-
|
|
6085
|
-
commitment = configOrCommitment.commitment;
|
|
6086
|
-
encoding = configOrCommitment.encoding;
|
|
6087
|
-
|
|
6088
|
-
if (configOrCommitment.dataSlice) {
|
|
6089
|
-
extra.dataSlice = configOrCommitment.dataSlice;
|
|
6090
|
-
}
|
|
6091
|
-
|
|
6092
|
-
if (configOrCommitment.filters) {
|
|
6093
|
-
extra.filters = configOrCommitment.filters;
|
|
6094
|
-
}
|
|
6095
|
-
}
|
|
6096
|
-
}
|
|
6164
|
+
const {
|
|
6165
|
+
commitment,
|
|
6166
|
+
config
|
|
6167
|
+
} = extractCommitmentFromConfig(configOrCommitment);
|
|
6168
|
+
const {
|
|
6169
|
+
encoding,
|
|
6170
|
+
...configWithoutEncoding
|
|
6171
|
+
} = config || {};
|
|
6097
6172
|
|
|
6098
|
-
const args = this._buildArgs([programId.toBase58()], commitment, encoding || 'base64',
|
|
6173
|
+
const args = this._buildArgs([programId.toBase58()], commitment, encoding || 'base64', configWithoutEncoding);
|
|
6099
6174
|
|
|
6100
6175
|
const unsafeRes = await this._rpcRequest('getProgramAccounts', args);
|
|
6101
6176
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.array(KeyedAccountInfoResult)));
|
|
6102
6177
|
|
|
6103
6178
|
if ('error' in res) {
|
|
6104
|
-
throw new
|
|
6179
|
+
throw new SolanaJSONRPCError(res.error, `failed to get accounts owned by program ${programId.toBase58()}`);
|
|
6105
6180
|
}
|
|
6106
6181
|
|
|
6107
6182
|
return res.result;
|
|
@@ -6114,28 +6189,18 @@ class Connection {
|
|
|
6114
6189
|
|
|
6115
6190
|
|
|
6116
6191
|
async getParsedProgramAccounts(programId, configOrCommitment) {
|
|
6117
|
-
const
|
|
6118
|
-
|
|
6119
|
-
|
|
6120
|
-
|
|
6121
|
-
if (typeof configOrCommitment === 'string') {
|
|
6122
|
-
commitment = configOrCommitment;
|
|
6123
|
-
} else {
|
|
6124
|
-
commitment = configOrCommitment.commitment;
|
|
6125
|
-
|
|
6126
|
-
if (configOrCommitment.filters) {
|
|
6127
|
-
extra.filters = configOrCommitment.filters;
|
|
6128
|
-
}
|
|
6129
|
-
}
|
|
6130
|
-
}
|
|
6192
|
+
const {
|
|
6193
|
+
commitment,
|
|
6194
|
+
config
|
|
6195
|
+
} = extractCommitmentFromConfig(configOrCommitment);
|
|
6131
6196
|
|
|
6132
|
-
const args = this._buildArgs([programId.toBase58()], commitment, 'jsonParsed',
|
|
6197
|
+
const args = this._buildArgs([programId.toBase58()], commitment, 'jsonParsed', config);
|
|
6133
6198
|
|
|
6134
6199
|
const unsafeRes = await this._rpcRequest('getProgramAccounts', args);
|
|
6135
6200
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.array(KeyedParsedAccountInfoResult)));
|
|
6136
6201
|
|
|
6137
6202
|
if ('error' in res) {
|
|
6138
|
-
throw new
|
|
6203
|
+
throw new SolanaJSONRPCError(res.error, `failed to get accounts owned by program ${programId.toBase58()}`);
|
|
6139
6204
|
}
|
|
6140
6205
|
|
|
6141
6206
|
return res.result;
|
|
@@ -6269,7 +6334,7 @@ class Connection {
|
|
|
6269
6334
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.array(ContactInfoResult)));
|
|
6270
6335
|
|
|
6271
6336
|
if ('error' in res) {
|
|
6272
|
-
throw new
|
|
6337
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get cluster nodes');
|
|
6273
6338
|
}
|
|
6274
6339
|
|
|
6275
6340
|
return res.result;
|
|
@@ -6286,7 +6351,7 @@ class Connection {
|
|
|
6286
6351
|
const res = superstruct.create(unsafeRes, GetVoteAccounts);
|
|
6287
6352
|
|
|
6288
6353
|
if ('error' in res) {
|
|
6289
|
-
throw new
|
|
6354
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get vote accounts');
|
|
6290
6355
|
}
|
|
6291
6356
|
|
|
6292
6357
|
return res.result;
|
|
@@ -6296,14 +6361,21 @@ class Connection {
|
|
|
6296
6361
|
*/
|
|
6297
6362
|
|
|
6298
6363
|
|
|
6299
|
-
async getSlot(
|
|
6300
|
-
const
|
|
6364
|
+
async getSlot(commitmentOrConfig) {
|
|
6365
|
+
const {
|
|
6366
|
+
commitment,
|
|
6367
|
+
config
|
|
6368
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
6369
|
+
|
|
6370
|
+
const args = this._buildArgs([], commitment, undefined
|
|
6371
|
+
/* encoding */
|
|
6372
|
+
, config);
|
|
6301
6373
|
|
|
6302
6374
|
const unsafeRes = await this._rpcRequest('getSlot', args);
|
|
6303
6375
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.number()));
|
|
6304
6376
|
|
|
6305
6377
|
if ('error' in res) {
|
|
6306
|
-
throw new
|
|
6378
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get slot');
|
|
6307
6379
|
}
|
|
6308
6380
|
|
|
6309
6381
|
return res.result;
|
|
@@ -6313,14 +6385,21 @@ class Connection {
|
|
|
6313
6385
|
*/
|
|
6314
6386
|
|
|
6315
6387
|
|
|
6316
|
-
async getSlotLeader(
|
|
6317
|
-
const
|
|
6388
|
+
async getSlotLeader(commitmentOrConfig) {
|
|
6389
|
+
const {
|
|
6390
|
+
commitment,
|
|
6391
|
+
config
|
|
6392
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
6393
|
+
|
|
6394
|
+
const args = this._buildArgs([], commitment, undefined
|
|
6395
|
+
/* encoding */
|
|
6396
|
+
, config);
|
|
6318
6397
|
|
|
6319
6398
|
const unsafeRes = await this._rpcRequest('getSlotLeader', args);
|
|
6320
6399
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.string()));
|
|
6321
6400
|
|
|
6322
6401
|
if ('error' in res) {
|
|
6323
|
-
throw new
|
|
6402
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get slot leader');
|
|
6324
6403
|
}
|
|
6325
6404
|
|
|
6326
6405
|
return res.result;
|
|
@@ -6339,7 +6418,7 @@ class Connection {
|
|
|
6339
6418
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.array(PublicKeyFromString)));
|
|
6340
6419
|
|
|
6341
6420
|
if ('error' in res) {
|
|
6342
|
-
throw new
|
|
6421
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get slot leaders');
|
|
6343
6422
|
}
|
|
6344
6423
|
|
|
6345
6424
|
return res.result;
|
|
@@ -6377,7 +6456,7 @@ class Connection {
|
|
|
6377
6456
|
const res = superstruct.create(unsafeRes, GetSignatureStatusesRpcResult);
|
|
6378
6457
|
|
|
6379
6458
|
if ('error' in res) {
|
|
6380
|
-
throw new
|
|
6459
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get signature status');
|
|
6381
6460
|
}
|
|
6382
6461
|
|
|
6383
6462
|
return res.result;
|
|
@@ -6387,14 +6466,21 @@ class Connection {
|
|
|
6387
6466
|
*/
|
|
6388
6467
|
|
|
6389
6468
|
|
|
6390
|
-
async getTransactionCount(
|
|
6391
|
-
const
|
|
6469
|
+
async getTransactionCount(commitmentOrConfig) {
|
|
6470
|
+
const {
|
|
6471
|
+
commitment,
|
|
6472
|
+
config
|
|
6473
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
6474
|
+
|
|
6475
|
+
const args = this._buildArgs([], commitment, undefined
|
|
6476
|
+
/* encoding */
|
|
6477
|
+
, config);
|
|
6392
6478
|
|
|
6393
6479
|
const unsafeRes = await this._rpcRequest('getTransactionCount', args);
|
|
6394
6480
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.number()));
|
|
6395
6481
|
|
|
6396
6482
|
if ('error' in res) {
|
|
6397
|
-
throw new
|
|
6483
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get transaction count');
|
|
6398
6484
|
}
|
|
6399
6485
|
|
|
6400
6486
|
return res.result;
|
|
@@ -6425,7 +6511,7 @@ class Connection {
|
|
|
6425
6511
|
const res = superstruct.create(unsafeRes, GetInflationGovernorRpcResult);
|
|
6426
6512
|
|
|
6427
6513
|
if ('error' in res) {
|
|
6428
|
-
throw new
|
|
6514
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get inflation');
|
|
6429
6515
|
}
|
|
6430
6516
|
|
|
6431
6517
|
return res.result;
|
|
@@ -6435,16 +6521,23 @@ class Connection {
|
|
|
6435
6521
|
*/
|
|
6436
6522
|
|
|
6437
6523
|
|
|
6438
|
-
async getInflationReward(addresses, epoch,
|
|
6439
|
-
const
|
|
6440
|
-
|
|
6524
|
+
async getInflationReward(addresses, epoch, commitmentOrConfig) {
|
|
6525
|
+
const {
|
|
6526
|
+
commitment,
|
|
6527
|
+
config
|
|
6528
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
6529
|
+
|
|
6530
|
+
const args = this._buildArgs([addresses.map(pubkey => pubkey.toBase58())], commitment, undefined
|
|
6531
|
+
/* encoding */
|
|
6532
|
+
, { ...config,
|
|
6533
|
+
epoch: epoch != null ? epoch : config === null || config === void 0 ? void 0 : config.epoch
|
|
6441
6534
|
});
|
|
6442
6535
|
|
|
6443
6536
|
const unsafeRes = await this._rpcRequest('getInflationReward', args);
|
|
6444
6537
|
const res = superstruct.create(unsafeRes, GetInflationRewardResult);
|
|
6445
6538
|
|
|
6446
6539
|
if ('error' in res) {
|
|
6447
|
-
throw new
|
|
6540
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get inflation reward');
|
|
6448
6541
|
}
|
|
6449
6542
|
|
|
6450
6543
|
return res.result;
|
|
@@ -6454,14 +6547,21 @@ class Connection {
|
|
|
6454
6547
|
*/
|
|
6455
6548
|
|
|
6456
6549
|
|
|
6457
|
-
async getEpochInfo(
|
|
6458
|
-
const
|
|
6550
|
+
async getEpochInfo(commitmentOrConfig) {
|
|
6551
|
+
const {
|
|
6552
|
+
commitment,
|
|
6553
|
+
config
|
|
6554
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
6555
|
+
|
|
6556
|
+
const args = this._buildArgs([], commitment, undefined
|
|
6557
|
+
/* encoding */
|
|
6558
|
+
, config);
|
|
6459
6559
|
|
|
6460
6560
|
const unsafeRes = await this._rpcRequest('getEpochInfo', args);
|
|
6461
6561
|
const res = superstruct.create(unsafeRes, GetEpochInfoRpcResult);
|
|
6462
6562
|
|
|
6463
6563
|
if ('error' in res) {
|
|
6464
|
-
throw new
|
|
6564
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get epoch info');
|
|
6465
6565
|
}
|
|
6466
6566
|
|
|
6467
6567
|
return res.result;
|
|
@@ -6476,7 +6576,7 @@ class Connection {
|
|
|
6476
6576
|
const res = superstruct.create(unsafeRes, GetEpochScheduleRpcResult);
|
|
6477
6577
|
|
|
6478
6578
|
if ('error' in res) {
|
|
6479
|
-
throw new
|
|
6579
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get epoch schedule');
|
|
6480
6580
|
}
|
|
6481
6581
|
|
|
6482
6582
|
const epochSchedule = res.result;
|
|
@@ -6493,7 +6593,7 @@ class Connection {
|
|
|
6493
6593
|
const res = superstruct.create(unsafeRes, GetLeaderScheduleRpcResult);
|
|
6494
6594
|
|
|
6495
6595
|
if ('error' in res) {
|
|
6496
|
-
throw new
|
|
6596
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get leader schedule');
|
|
6497
6597
|
}
|
|
6498
6598
|
|
|
6499
6599
|
return res.result;
|
|
@@ -6532,7 +6632,7 @@ class Connection {
|
|
|
6532
6632
|
const res = superstruct.create(unsafeRes, GetRecentBlockhashAndContextRpcResult);
|
|
6533
6633
|
|
|
6534
6634
|
if ('error' in res) {
|
|
6535
|
-
throw new
|
|
6635
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get recent blockhash');
|
|
6536
6636
|
}
|
|
6537
6637
|
|
|
6538
6638
|
return res.result;
|
|
@@ -6550,7 +6650,7 @@ class Connection {
|
|
|
6550
6650
|
const res = superstruct.create(unsafeRes, GetRecentPerformanceSamplesRpcResult);
|
|
6551
6651
|
|
|
6552
6652
|
if ('error' in res) {
|
|
6553
|
-
throw new
|
|
6653
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get recent performance samples');
|
|
6554
6654
|
}
|
|
6555
6655
|
|
|
6556
6656
|
return res.result;
|
|
@@ -6569,7 +6669,7 @@ class Connection {
|
|
|
6569
6669
|
const res = superstruct.create(unsafeRes, GetFeeCalculatorRpcResult);
|
|
6570
6670
|
|
|
6571
6671
|
if ('error' in res) {
|
|
6572
|
-
throw new
|
|
6672
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get fee calculator');
|
|
6573
6673
|
}
|
|
6574
6674
|
|
|
6575
6675
|
const {
|
|
@@ -6595,7 +6695,7 @@ class Connection {
|
|
|
6595
6695
|
const res = superstruct.create(unsafeRes, jsonRpcResultAndContext(superstruct.nullable(superstruct.number())));
|
|
6596
6696
|
|
|
6597
6697
|
if ('error' in res) {
|
|
6598
|
-
throw new
|
|
6698
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get slot');
|
|
6599
6699
|
}
|
|
6600
6700
|
|
|
6601
6701
|
if (res.result === null) {
|
|
@@ -6626,9 +6726,9 @@ class Connection {
|
|
|
6626
6726
|
*/
|
|
6627
6727
|
|
|
6628
6728
|
|
|
6629
|
-
async getLatestBlockhash(
|
|
6729
|
+
async getLatestBlockhash(commitmentOrConfig) {
|
|
6630
6730
|
try {
|
|
6631
|
-
const res = await this.getLatestBlockhashAndContext(
|
|
6731
|
+
const res = await this.getLatestBlockhashAndContext(commitmentOrConfig);
|
|
6632
6732
|
return res.value;
|
|
6633
6733
|
} catch (e) {
|
|
6634
6734
|
throw new Error('failed to get recent blockhash: ' + e);
|
|
@@ -6640,14 +6740,21 @@ class Connection {
|
|
|
6640
6740
|
*/
|
|
6641
6741
|
|
|
6642
6742
|
|
|
6643
|
-
async getLatestBlockhashAndContext(
|
|
6644
|
-
const
|
|
6743
|
+
async getLatestBlockhashAndContext(commitmentOrConfig) {
|
|
6744
|
+
const {
|
|
6745
|
+
commitment,
|
|
6746
|
+
config
|
|
6747
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
6748
|
+
|
|
6749
|
+
const args = this._buildArgs([], commitment, undefined
|
|
6750
|
+
/* encoding */
|
|
6751
|
+
, config);
|
|
6645
6752
|
|
|
6646
6753
|
const unsafeRes = await this._rpcRequest('getLatestBlockhash', args);
|
|
6647
6754
|
const res = superstruct.create(unsafeRes, GetLatestBlockhashRpcResult);
|
|
6648
6755
|
|
|
6649
6756
|
if ('error' in res) {
|
|
6650
|
-
throw new
|
|
6757
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get latest blockhash');
|
|
6651
6758
|
}
|
|
6652
6759
|
|
|
6653
6760
|
return res.result;
|
|
@@ -6662,7 +6769,7 @@ class Connection {
|
|
|
6662
6769
|
const res = superstruct.create(unsafeRes, jsonRpcResult(VersionResult));
|
|
6663
6770
|
|
|
6664
6771
|
if ('error' in res) {
|
|
6665
|
-
throw new
|
|
6772
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get version');
|
|
6666
6773
|
}
|
|
6667
6774
|
|
|
6668
6775
|
return res.result;
|
|
@@ -6677,7 +6784,7 @@ class Connection {
|
|
|
6677
6784
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.string()));
|
|
6678
6785
|
|
|
6679
6786
|
if ('error' in res) {
|
|
6680
|
-
throw new
|
|
6787
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get genesis hash');
|
|
6681
6788
|
}
|
|
6682
6789
|
|
|
6683
6790
|
return res.result;
|
|
@@ -6694,7 +6801,7 @@ class Connection {
|
|
|
6694
6801
|
const res = superstruct.create(unsafeRes, GetBlockRpcResult);
|
|
6695
6802
|
|
|
6696
6803
|
if ('error' in res) {
|
|
6697
|
-
throw new
|
|
6804
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get confirmed block');
|
|
6698
6805
|
}
|
|
6699
6806
|
|
|
6700
6807
|
const result = res.result;
|
|
@@ -6719,14 +6826,21 @@ class Connection {
|
|
|
6719
6826
|
*/
|
|
6720
6827
|
|
|
6721
6828
|
|
|
6722
|
-
async getBlockHeight(
|
|
6723
|
-
const
|
|
6829
|
+
async getBlockHeight(commitmentOrConfig) {
|
|
6830
|
+
const {
|
|
6831
|
+
commitment,
|
|
6832
|
+
config
|
|
6833
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
6834
|
+
|
|
6835
|
+
const args = this._buildArgs([], commitment, undefined
|
|
6836
|
+
/* encoding */
|
|
6837
|
+
, config);
|
|
6724
6838
|
|
|
6725
6839
|
const unsafeRes = await this._rpcRequest('getBlockHeight', args);
|
|
6726
6840
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.number()));
|
|
6727
6841
|
|
|
6728
6842
|
if ('error' in res) {
|
|
6729
|
-
throw new
|
|
6843
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get block height information');
|
|
6730
6844
|
}
|
|
6731
6845
|
|
|
6732
6846
|
return res.result;
|
|
@@ -6757,7 +6871,7 @@ class Connection {
|
|
|
6757
6871
|
const res = superstruct.create(unsafeRes, BlockProductionResponseStruct);
|
|
6758
6872
|
|
|
6759
6873
|
if ('error' in res) {
|
|
6760
|
-
throw new
|
|
6874
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get block production information');
|
|
6761
6875
|
}
|
|
6762
6876
|
|
|
6763
6877
|
return res.result;
|
|
@@ -6774,7 +6888,7 @@ class Connection {
|
|
|
6774
6888
|
const res = superstruct.create(unsafeRes, GetTransactionRpcResult);
|
|
6775
6889
|
|
|
6776
6890
|
if ('error' in res) {
|
|
6777
|
-
throw new
|
|
6891
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get transaction');
|
|
6778
6892
|
}
|
|
6779
6893
|
|
|
6780
6894
|
const result = res.result;
|
|
@@ -6797,7 +6911,7 @@ class Connection {
|
|
|
6797
6911
|
const res = superstruct.create(unsafeRes, GetParsedTransactionRpcResult);
|
|
6798
6912
|
|
|
6799
6913
|
if ('error' in res) {
|
|
6800
|
-
throw new
|
|
6914
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get transaction');
|
|
6801
6915
|
}
|
|
6802
6916
|
|
|
6803
6917
|
return res.result;
|
|
@@ -6821,7 +6935,7 @@ class Connection {
|
|
|
6821
6935
|
const res = superstruct.create(unsafeRes, GetParsedTransactionRpcResult);
|
|
6822
6936
|
|
|
6823
6937
|
if ('error' in res) {
|
|
6824
|
-
throw new
|
|
6938
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get transactions');
|
|
6825
6939
|
}
|
|
6826
6940
|
|
|
6827
6941
|
return res.result;
|
|
@@ -6848,7 +6962,7 @@ class Connection {
|
|
|
6848
6962
|
const res = superstruct.create(unsafeRes, GetTransactionRpcResult);
|
|
6849
6963
|
|
|
6850
6964
|
if ('error' in res) {
|
|
6851
|
-
throw new
|
|
6965
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get transactions');
|
|
6852
6966
|
}
|
|
6853
6967
|
|
|
6854
6968
|
const result = res.result;
|
|
@@ -6876,7 +6990,7 @@ class Connection {
|
|
|
6876
6990
|
const res = superstruct.create(unsafeRes, GetConfirmedBlockRpcResult);
|
|
6877
6991
|
|
|
6878
6992
|
if ('error' in res) {
|
|
6879
|
-
throw new
|
|
6993
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get confirmed block');
|
|
6880
6994
|
}
|
|
6881
6995
|
|
|
6882
6996
|
const result = res.result;
|
|
@@ -6923,7 +7037,7 @@ class Connection {
|
|
|
6923
7037
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.array(superstruct.number())));
|
|
6924
7038
|
|
|
6925
7039
|
if ('error' in res) {
|
|
6926
|
-
throw new
|
|
7040
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get blocks');
|
|
6927
7041
|
}
|
|
6928
7042
|
|
|
6929
7043
|
return res.result;
|
|
@@ -6943,7 +7057,7 @@ class Connection {
|
|
|
6943
7057
|
const res = superstruct.create(unsafeRes, GetBlockSignaturesRpcResult);
|
|
6944
7058
|
|
|
6945
7059
|
if ('error' in res) {
|
|
6946
|
-
throw new
|
|
7060
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get block');
|
|
6947
7061
|
}
|
|
6948
7062
|
|
|
6949
7063
|
const result = res.result;
|
|
@@ -6971,7 +7085,7 @@ class Connection {
|
|
|
6971
7085
|
const res = superstruct.create(unsafeRes, GetBlockSignaturesRpcResult);
|
|
6972
7086
|
|
|
6973
7087
|
if ('error' in res) {
|
|
6974
|
-
throw new
|
|
7088
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get confirmed block');
|
|
6975
7089
|
}
|
|
6976
7090
|
|
|
6977
7091
|
const result = res.result;
|
|
@@ -6996,7 +7110,7 @@ class Connection {
|
|
|
6996
7110
|
const res = superstruct.create(unsafeRes, GetTransactionRpcResult);
|
|
6997
7111
|
|
|
6998
7112
|
if ('error' in res) {
|
|
6999
|
-
throw new
|
|
7113
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get transaction');
|
|
7000
7114
|
}
|
|
7001
7115
|
|
|
7002
7116
|
const result = res.result;
|
|
@@ -7021,7 +7135,7 @@ class Connection {
|
|
|
7021
7135
|
const res = superstruct.create(unsafeRes, GetParsedTransactionRpcResult);
|
|
7022
7136
|
|
|
7023
7137
|
if ('error' in res) {
|
|
7024
|
-
throw new
|
|
7138
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get confirmed transaction');
|
|
7025
7139
|
}
|
|
7026
7140
|
|
|
7027
7141
|
return res.result;
|
|
@@ -7047,7 +7161,7 @@ class Connection {
|
|
|
7047
7161
|
const res = superstruct.create(unsafeRes, GetParsedTransactionRpcResult);
|
|
7048
7162
|
|
|
7049
7163
|
if ('error' in res) {
|
|
7050
|
-
throw new
|
|
7164
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get confirmed transactions');
|
|
7051
7165
|
}
|
|
7052
7166
|
|
|
7053
7167
|
return res.result;
|
|
@@ -7136,7 +7250,7 @@ class Connection {
|
|
|
7136
7250
|
const res = superstruct.create(unsafeRes, GetConfirmedSignaturesForAddress2RpcResult);
|
|
7137
7251
|
|
|
7138
7252
|
if ('error' in res) {
|
|
7139
|
-
throw new
|
|
7253
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get confirmed signatures for address');
|
|
7140
7254
|
}
|
|
7141
7255
|
|
|
7142
7256
|
return res.result;
|
|
@@ -7158,7 +7272,7 @@ class Connection {
|
|
|
7158
7272
|
const res = superstruct.create(unsafeRes, GetSignaturesForAddressRpcResult);
|
|
7159
7273
|
|
|
7160
7274
|
if ('error' in res) {
|
|
7161
|
-
throw new
|
|
7275
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get signatures for address');
|
|
7162
7276
|
}
|
|
7163
7277
|
|
|
7164
7278
|
return res.result;
|
|
@@ -7215,7 +7329,7 @@ class Connection {
|
|
|
7215
7329
|
const res = superstruct.create(unsafeRes, RequestAirdropRpcResult);
|
|
7216
7330
|
|
|
7217
7331
|
if ('error' in res) {
|
|
7218
|
-
throw new
|
|
7332
|
+
throw new SolanaJSONRPCError(res.error, `airdrop to ${to.toBase58()} failed`);
|
|
7219
7333
|
}
|
|
7220
7334
|
|
|
7221
7335
|
return res.result;
|
|
@@ -7445,10 +7559,14 @@ class Connection {
|
|
|
7445
7559
|
const skipPreflight = options && options.skipPreflight;
|
|
7446
7560
|
const preflightCommitment = options && options.preflightCommitment || this.commitment;
|
|
7447
7561
|
|
|
7448
|
-
if (options && options.maxRetries) {
|
|
7562
|
+
if (options && options.maxRetries != null) {
|
|
7449
7563
|
config.maxRetries = options.maxRetries;
|
|
7450
7564
|
}
|
|
7451
7565
|
|
|
7566
|
+
if (options && options.minContextSlot != null) {
|
|
7567
|
+
config.minContextSlot = options.minContextSlot;
|
|
7568
|
+
}
|
|
7569
|
+
|
|
7452
7570
|
if (skipPreflight) {
|
|
7453
7571
|
config.skipPreflight = skipPreflight;
|
|
7454
7572
|
}
|
|
@@ -9858,7 +9976,8 @@ async function sendAndConfirmRawTransaction(connection, rawTransaction, confirma
|
|
|
9858
9976
|
|
|
9859
9977
|
const sendOptions = options && {
|
|
9860
9978
|
skipPreflight: options.skipPreflight,
|
|
9861
|
-
preflightCommitment: options.preflightCommitment || options.commitment
|
|
9979
|
+
preflightCommitment: options.preflightCommitment || options.commitment,
|
|
9980
|
+
minContextSlot: options.minContextSlot
|
|
9862
9981
|
};
|
|
9863
9982
|
const signature = await connection.sendRawTransaction(rawTransaction, sendOptions);
|
|
9864
9983
|
const commitment = options && options.commitment;
|
|
@@ -9950,6 +10069,8 @@ exports.SYSVAR_SLOT_HISTORY_PUBKEY = SYSVAR_SLOT_HISTORY_PUBKEY;
|
|
|
9950
10069
|
exports.SYSVAR_STAKE_HISTORY_PUBKEY = SYSVAR_STAKE_HISTORY_PUBKEY;
|
|
9951
10070
|
exports.Secp256k1Program = Secp256k1Program;
|
|
9952
10071
|
exports.SendTransactionError = SendTransactionError;
|
|
10072
|
+
exports.SolanaJSONRPCError = SolanaJSONRPCError;
|
|
10073
|
+
exports.SolanaJSONRPCErrorCode = SolanaJSONRPCErrorCode;
|
|
9953
10074
|
exports.StakeAuthorizationLayout = StakeAuthorizationLayout;
|
|
9954
10075
|
exports.StakeInstruction = StakeInstruction;
|
|
9955
10076
|
exports.StakeProgram = StakeProgram;
|