@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.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) {
|
|
@@ -4678,6 +4714,7 @@ function makeWebsocketUrl(endpoint) {
|
|
|
4678
4714
|
return url.toString();
|
|
4679
4715
|
}
|
|
4680
4716
|
|
|
4717
|
+
var _process$env$npm_pack;
|
|
4681
4718
|
const PublicKeyFromString = superstruct.coerce(superstruct.instance(PublicKey), superstruct.string(), value => new PublicKey(value));
|
|
4682
4719
|
const RawAccountDataResult = superstruct.tuple([superstruct.string(), superstruct.literal('base64')]);
|
|
4683
4720
|
const BufferFromRawAccountData = superstruct.coerce(superstruct.instance(buffer.Buffer), RawAccountDataResult, value => buffer.Buffer.from(value[0], 'base64'));
|
|
@@ -4694,9 +4731,32 @@ const BLOCKHASH_CACHE_TIMEOUT_MS = 30 * 1000;
|
|
|
4694
4731
|
* https://gist.github.com/steveluscher/c057eca81d479ef705cdb53162f9971d
|
|
4695
4732
|
*/
|
|
4696
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
|
+
}
|
|
4697
4755
|
/**
|
|
4698
4756
|
* @internal
|
|
4699
4757
|
*/
|
|
4758
|
+
|
|
4759
|
+
|
|
4700
4760
|
function createRpcResult(result) {
|
|
4701
4761
|
return superstruct.union([superstruct.type({
|
|
4702
4762
|
jsonrpc: superstruct.literal('2.0'),
|
|
@@ -4893,7 +4953,7 @@ function createRpcClient(url, useHttps, httpHeaders, customFetch, fetchMiddlewar
|
|
|
4893
4953
|
agent,
|
|
4894
4954
|
headers: Object.assign({
|
|
4895
4955
|
'Content-Type': 'application/json'
|
|
4896
|
-
}, httpHeaders || {})
|
|
4956
|
+
}, httpHeaders || {}, COMMON_HTTP_HEADERS)
|
|
4897
4957
|
};
|
|
4898
4958
|
|
|
4899
4959
|
try {
|
|
@@ -5567,9 +5627,14 @@ const LogsNotificationResult = superstruct.type({
|
|
|
5567
5627
|
* Filter for log subscriptions.
|
|
5568
5628
|
*/
|
|
5569
5629
|
|
|
5630
|
+
/** @internal */
|
|
5631
|
+
const COMMON_HTTP_HEADERS = {
|
|
5632
|
+
'solana-client': `js/${(_process$env$npm_pack = "0.0.0-development") !== null && _process$env$npm_pack !== void 0 ? _process$env$npm_pack : 'UNKNOWN'}`
|
|
5633
|
+
};
|
|
5570
5634
|
/**
|
|
5571
5635
|
* A connection to a fullnode JSON RPC endpoint
|
|
5572
5636
|
*/
|
|
5637
|
+
|
|
5573
5638
|
class Connection {
|
|
5574
5639
|
/** @internal */
|
|
5575
5640
|
|
|
@@ -5734,14 +5799,22 @@ class Connection {
|
|
|
5734
5799
|
*/
|
|
5735
5800
|
|
|
5736
5801
|
|
|
5737
|
-
async getBalanceAndContext(publicKey,
|
|
5738
|
-
|
|
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);
|
|
5739
5812
|
|
|
5740
5813
|
const unsafeRes = await this._rpcRequest('getBalance', args);
|
|
5741
5814
|
const res = superstruct.create(unsafeRes, jsonRpcResultAndContext(superstruct.number()));
|
|
5742
5815
|
|
|
5743
5816
|
if ('error' in res) {
|
|
5744
|
-
throw new
|
|
5817
|
+
throw new SolanaJSONRPCError(res.error, `failed to get balance for ${publicKey.toBase58()}`);
|
|
5745
5818
|
}
|
|
5746
5819
|
|
|
5747
5820
|
return res.result;
|
|
@@ -5751,8 +5824,8 @@ class Connection {
|
|
|
5751
5824
|
*/
|
|
5752
5825
|
|
|
5753
5826
|
|
|
5754
|
-
async getBalance(publicKey,
|
|
5755
|
-
return await this.getBalanceAndContext(publicKey,
|
|
5827
|
+
async getBalance(publicKey, commitmentOrConfig) {
|
|
5828
|
+
return await this.getBalanceAndContext(publicKey, commitmentOrConfig).then(x => x.value).catch(e => {
|
|
5756
5829
|
throw new Error('failed to get balance of account ' + publicKey.toBase58() + ': ' + e);
|
|
5757
5830
|
});
|
|
5758
5831
|
}
|
|
@@ -5766,7 +5839,7 @@ class Connection {
|
|
|
5766
5839
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.nullable(superstruct.number())));
|
|
5767
5840
|
|
|
5768
5841
|
if ('error' in res) {
|
|
5769
|
-
throw new
|
|
5842
|
+
throw new SolanaJSONRPCError(res.error, `failed to get block time for slot ${slot}`);
|
|
5770
5843
|
}
|
|
5771
5844
|
|
|
5772
5845
|
return res.result;
|
|
@@ -5782,7 +5855,7 @@ class Connection {
|
|
|
5782
5855
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.number()));
|
|
5783
5856
|
|
|
5784
5857
|
if ('error' in res) {
|
|
5785
|
-
throw new
|
|
5858
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get minimum ledger slot');
|
|
5786
5859
|
}
|
|
5787
5860
|
|
|
5788
5861
|
return res.result;
|
|
@@ -5797,7 +5870,7 @@ class Connection {
|
|
|
5797
5870
|
const res = superstruct.create(unsafeRes, SlotRpcResult);
|
|
5798
5871
|
|
|
5799
5872
|
if ('error' in res) {
|
|
5800
|
-
throw new
|
|
5873
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get first available block');
|
|
5801
5874
|
}
|
|
5802
5875
|
|
|
5803
5876
|
return res.result;
|
|
@@ -5828,7 +5901,7 @@ class Connection {
|
|
|
5828
5901
|
const res = superstruct.create(unsafeRes, GetSupplyRpcResult);
|
|
5829
5902
|
|
|
5830
5903
|
if ('error' in res) {
|
|
5831
|
-
throw new
|
|
5904
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get supply');
|
|
5832
5905
|
}
|
|
5833
5906
|
|
|
5834
5907
|
return res.result;
|
|
@@ -5845,7 +5918,7 @@ class Connection {
|
|
|
5845
5918
|
const res = superstruct.create(unsafeRes, jsonRpcResultAndContext(TokenAmountResult));
|
|
5846
5919
|
|
|
5847
5920
|
if ('error' in res) {
|
|
5848
|
-
throw new
|
|
5921
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get token supply');
|
|
5849
5922
|
}
|
|
5850
5923
|
|
|
5851
5924
|
return res.result;
|
|
@@ -5862,7 +5935,7 @@ class Connection {
|
|
|
5862
5935
|
const res = superstruct.create(unsafeRes, jsonRpcResultAndContext(TokenAmountResult));
|
|
5863
5936
|
|
|
5864
5937
|
if ('error' in res) {
|
|
5865
|
-
throw new
|
|
5938
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get token account balance');
|
|
5866
5939
|
}
|
|
5867
5940
|
|
|
5868
5941
|
return res.result;
|
|
@@ -5874,7 +5947,11 @@ class Connection {
|
|
|
5874
5947
|
*/
|
|
5875
5948
|
|
|
5876
5949
|
|
|
5877
|
-
async getTokenAccountsByOwner(ownerAddress, filter,
|
|
5950
|
+
async getTokenAccountsByOwner(ownerAddress, filter, commitmentOrConfig) {
|
|
5951
|
+
const {
|
|
5952
|
+
commitment,
|
|
5953
|
+
config
|
|
5954
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
5878
5955
|
let _args = [ownerAddress.toBase58()];
|
|
5879
5956
|
|
|
5880
5957
|
if ('mint' in filter) {
|
|
@@ -5887,13 +5964,13 @@ class Connection {
|
|
|
5887
5964
|
});
|
|
5888
5965
|
}
|
|
5889
5966
|
|
|
5890
|
-
const args = this._buildArgs(_args, commitment, 'base64');
|
|
5967
|
+
const args = this._buildArgs(_args, commitment, 'base64', config);
|
|
5891
5968
|
|
|
5892
5969
|
const unsafeRes = await this._rpcRequest('getTokenAccountsByOwner', args);
|
|
5893
5970
|
const res = superstruct.create(unsafeRes, GetTokenAccountsByOwner);
|
|
5894
5971
|
|
|
5895
5972
|
if ('error' in res) {
|
|
5896
|
-
throw new
|
|
5973
|
+
throw new SolanaJSONRPCError(res.error, `failed to get token accounts owned by account ${ownerAddress.toBase58()}`);
|
|
5897
5974
|
}
|
|
5898
5975
|
|
|
5899
5976
|
return res.result;
|
|
@@ -5924,7 +6001,7 @@ class Connection {
|
|
|
5924
6001
|
const res = superstruct.create(unsafeRes, GetParsedTokenAccountsByOwner);
|
|
5925
6002
|
|
|
5926
6003
|
if ('error' in res) {
|
|
5927
|
-
throw new
|
|
6004
|
+
throw new SolanaJSONRPCError(res.error, `failed to get token accounts owned by account ${ownerAddress.toBase58()}`);
|
|
5928
6005
|
}
|
|
5929
6006
|
|
|
5930
6007
|
return res.result;
|
|
@@ -5943,7 +6020,7 @@ class Connection {
|
|
|
5943
6020
|
const res = superstruct.create(unsafeRes, GetLargestAccountsRpcResult);
|
|
5944
6021
|
|
|
5945
6022
|
if ('error' in res) {
|
|
5946
|
-
throw new
|
|
6023
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get largest accounts');
|
|
5947
6024
|
}
|
|
5948
6025
|
|
|
5949
6026
|
return res.result;
|
|
@@ -5961,7 +6038,7 @@ class Connection {
|
|
|
5961
6038
|
const res = superstruct.create(unsafeRes, GetTokenLargestAccountsResult);
|
|
5962
6039
|
|
|
5963
6040
|
if ('error' in res) {
|
|
5964
|
-
throw new
|
|
6041
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get token largest accounts');
|
|
5965
6042
|
}
|
|
5966
6043
|
|
|
5967
6044
|
return res.result;
|
|
@@ -5971,14 +6048,19 @@ class Connection {
|
|
|
5971
6048
|
*/
|
|
5972
6049
|
|
|
5973
6050
|
|
|
5974
|
-
async getAccountInfoAndContext(publicKey,
|
|
5975
|
-
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);
|
|
5976
6058
|
|
|
5977
6059
|
const unsafeRes = await this._rpcRequest('getAccountInfo', args);
|
|
5978
6060
|
const res = superstruct.create(unsafeRes, jsonRpcResultAndContext(superstruct.nullable(AccountInfoResult)));
|
|
5979
6061
|
|
|
5980
6062
|
if ('error' in res) {
|
|
5981
|
-
throw new
|
|
6063
|
+
throw new SolanaJSONRPCError(res.error, `failed to get info about account ${publicKey.toBase58()}`);
|
|
5982
6064
|
}
|
|
5983
6065
|
|
|
5984
6066
|
return res.result;
|
|
@@ -5995,7 +6077,7 @@ class Connection {
|
|
|
5995
6077
|
const res = superstruct.create(unsafeRes, jsonRpcResultAndContext(superstruct.nullable(ParsedAccountInfoResult)));
|
|
5996
6078
|
|
|
5997
6079
|
if ('error' in res) {
|
|
5998
|
-
throw new
|
|
6080
|
+
throw new SolanaJSONRPCError(res.error, `failed to get info about account ${publicKey.toBase58()}`);
|
|
5999
6081
|
}
|
|
6000
6082
|
|
|
6001
6083
|
return res.result;
|
|
@@ -6005,9 +6087,9 @@ class Connection {
|
|
|
6005
6087
|
*/
|
|
6006
6088
|
|
|
6007
6089
|
|
|
6008
|
-
async getAccountInfo(publicKey,
|
|
6090
|
+
async getAccountInfo(publicKey, commitmentOrConfig) {
|
|
6009
6091
|
try {
|
|
6010
|
-
const res = await this.getAccountInfoAndContext(publicKey,
|
|
6092
|
+
const res = await this.getAccountInfoAndContext(publicKey, commitmentOrConfig);
|
|
6011
6093
|
return res.value;
|
|
6012
6094
|
} catch (e) {
|
|
6013
6095
|
throw new Error('failed to get info about account ' + publicKey.toBase58() + ': ' + e);
|
|
@@ -6018,16 +6100,20 @@ class Connection {
|
|
|
6018
6100
|
*/
|
|
6019
6101
|
|
|
6020
6102
|
|
|
6021
|
-
async getMultipleAccountsInfoAndContext(publicKeys,
|
|
6103
|
+
async getMultipleAccountsInfoAndContext(publicKeys, commitmentOrConfig) {
|
|
6104
|
+
const {
|
|
6105
|
+
commitment,
|
|
6106
|
+
config
|
|
6107
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
6022
6108
|
const keys = publicKeys.map(key => key.toBase58());
|
|
6023
6109
|
|
|
6024
|
-
const args = this._buildArgs([keys], commitment, 'base64');
|
|
6110
|
+
const args = this._buildArgs([keys], commitment, 'base64', config);
|
|
6025
6111
|
|
|
6026
6112
|
const unsafeRes = await this._rpcRequest('getMultipleAccounts', args);
|
|
6027
6113
|
const res = superstruct.create(unsafeRes, jsonRpcResultAndContext(superstruct.array(superstruct.nullable(AccountInfoResult))));
|
|
6028
6114
|
|
|
6029
6115
|
if ('error' in res) {
|
|
6030
|
-
throw new
|
|
6116
|
+
throw new SolanaJSONRPCError(res.error, `failed to get info for accounts ${keys}`);
|
|
6031
6117
|
}
|
|
6032
6118
|
|
|
6033
6119
|
return res.result;
|
|
@@ -6037,8 +6123,8 @@ class Connection {
|
|
|
6037
6123
|
*/
|
|
6038
6124
|
|
|
6039
6125
|
|
|
6040
|
-
async getMultipleAccountsInfo(publicKeys,
|
|
6041
|
-
const res = await this.getMultipleAccountsInfoAndContext(publicKeys,
|
|
6126
|
+
async getMultipleAccountsInfo(publicKeys, commitmentOrConfig) {
|
|
6127
|
+
const res = await this.getMultipleAccountsInfoAndContext(publicKeys, commitmentOrConfig);
|
|
6042
6128
|
return res.value;
|
|
6043
6129
|
}
|
|
6044
6130
|
/**
|
|
@@ -6046,16 +6132,23 @@ class Connection {
|
|
|
6046
6132
|
*/
|
|
6047
6133
|
|
|
6048
6134
|
|
|
6049
|
-
async getStakeActivation(publicKey,
|
|
6050
|
-
const
|
|
6051
|
-
|
|
6052
|
-
|
|
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
|
+
});
|
|
6053
6146
|
|
|
6054
6147
|
const unsafeRes = await this._rpcRequest('getStakeActivation', args);
|
|
6055
6148
|
const res = superstruct.create(unsafeRes, jsonRpcResult(StakeActivationResult));
|
|
6056
6149
|
|
|
6057
6150
|
if ('error' in res) {
|
|
6058
|
-
throw new
|
|
6151
|
+
throw new SolanaJSONRPCError(res.error, `failed to get Stake Activation ${publicKey.toBase58()}`);
|
|
6059
6152
|
}
|
|
6060
6153
|
|
|
6061
6154
|
return res.result;
|
|
@@ -6068,34 +6161,22 @@ class Connection {
|
|
|
6068
6161
|
|
|
6069
6162
|
|
|
6070
6163
|
async getProgramAccounts(programId, configOrCommitment) {
|
|
6071
|
-
const
|
|
6072
|
-
|
|
6073
|
-
|
|
6074
|
-
|
|
6075
|
-
|
|
6076
|
-
|
|
6077
|
-
|
|
6078
|
-
|
|
6079
|
-
commitment = configOrCommitment.commitment;
|
|
6080
|
-
encoding = configOrCommitment.encoding;
|
|
6081
|
-
|
|
6082
|
-
if (configOrCommitment.dataSlice) {
|
|
6083
|
-
extra.dataSlice = configOrCommitment.dataSlice;
|
|
6084
|
-
}
|
|
6085
|
-
|
|
6086
|
-
if (configOrCommitment.filters) {
|
|
6087
|
-
extra.filters = configOrCommitment.filters;
|
|
6088
|
-
}
|
|
6089
|
-
}
|
|
6090
|
-
}
|
|
6164
|
+
const {
|
|
6165
|
+
commitment,
|
|
6166
|
+
config
|
|
6167
|
+
} = extractCommitmentFromConfig(configOrCommitment);
|
|
6168
|
+
const {
|
|
6169
|
+
encoding,
|
|
6170
|
+
...configWithoutEncoding
|
|
6171
|
+
} = config || {};
|
|
6091
6172
|
|
|
6092
|
-
const args = this._buildArgs([programId.toBase58()], commitment, encoding || 'base64',
|
|
6173
|
+
const args = this._buildArgs([programId.toBase58()], commitment, encoding || 'base64', configWithoutEncoding);
|
|
6093
6174
|
|
|
6094
6175
|
const unsafeRes = await this._rpcRequest('getProgramAccounts', args);
|
|
6095
6176
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.array(KeyedAccountInfoResult)));
|
|
6096
6177
|
|
|
6097
6178
|
if ('error' in res) {
|
|
6098
|
-
throw new
|
|
6179
|
+
throw new SolanaJSONRPCError(res.error, `failed to get accounts owned by program ${programId.toBase58()}`);
|
|
6099
6180
|
}
|
|
6100
6181
|
|
|
6101
6182
|
return res.result;
|
|
@@ -6108,28 +6189,18 @@ class Connection {
|
|
|
6108
6189
|
|
|
6109
6190
|
|
|
6110
6191
|
async getParsedProgramAccounts(programId, configOrCommitment) {
|
|
6111
|
-
const
|
|
6112
|
-
|
|
6113
|
-
|
|
6114
|
-
|
|
6115
|
-
if (typeof configOrCommitment === 'string') {
|
|
6116
|
-
commitment = configOrCommitment;
|
|
6117
|
-
} else {
|
|
6118
|
-
commitment = configOrCommitment.commitment;
|
|
6119
|
-
|
|
6120
|
-
if (configOrCommitment.filters) {
|
|
6121
|
-
extra.filters = configOrCommitment.filters;
|
|
6122
|
-
}
|
|
6123
|
-
}
|
|
6124
|
-
}
|
|
6192
|
+
const {
|
|
6193
|
+
commitment,
|
|
6194
|
+
config
|
|
6195
|
+
} = extractCommitmentFromConfig(configOrCommitment);
|
|
6125
6196
|
|
|
6126
|
-
const args = this._buildArgs([programId.toBase58()], commitment, 'jsonParsed',
|
|
6197
|
+
const args = this._buildArgs([programId.toBase58()], commitment, 'jsonParsed', config);
|
|
6127
6198
|
|
|
6128
6199
|
const unsafeRes = await this._rpcRequest('getProgramAccounts', args);
|
|
6129
6200
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.array(KeyedParsedAccountInfoResult)));
|
|
6130
6201
|
|
|
6131
6202
|
if ('error' in res) {
|
|
6132
|
-
throw new
|
|
6203
|
+
throw new SolanaJSONRPCError(res.error, `failed to get accounts owned by program ${programId.toBase58()}`);
|
|
6133
6204
|
}
|
|
6134
6205
|
|
|
6135
6206
|
return res.result;
|
|
@@ -6263,7 +6334,7 @@ class Connection {
|
|
|
6263
6334
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.array(ContactInfoResult)));
|
|
6264
6335
|
|
|
6265
6336
|
if ('error' in res) {
|
|
6266
|
-
throw new
|
|
6337
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get cluster nodes');
|
|
6267
6338
|
}
|
|
6268
6339
|
|
|
6269
6340
|
return res.result;
|
|
@@ -6280,7 +6351,7 @@ class Connection {
|
|
|
6280
6351
|
const res = superstruct.create(unsafeRes, GetVoteAccounts);
|
|
6281
6352
|
|
|
6282
6353
|
if ('error' in res) {
|
|
6283
|
-
throw new
|
|
6354
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get vote accounts');
|
|
6284
6355
|
}
|
|
6285
6356
|
|
|
6286
6357
|
return res.result;
|
|
@@ -6290,14 +6361,21 @@ class Connection {
|
|
|
6290
6361
|
*/
|
|
6291
6362
|
|
|
6292
6363
|
|
|
6293
|
-
async getSlot(
|
|
6294
|
-
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);
|
|
6295
6373
|
|
|
6296
6374
|
const unsafeRes = await this._rpcRequest('getSlot', args);
|
|
6297
6375
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.number()));
|
|
6298
6376
|
|
|
6299
6377
|
if ('error' in res) {
|
|
6300
|
-
throw new
|
|
6378
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get slot');
|
|
6301
6379
|
}
|
|
6302
6380
|
|
|
6303
6381
|
return res.result;
|
|
@@ -6307,14 +6385,21 @@ class Connection {
|
|
|
6307
6385
|
*/
|
|
6308
6386
|
|
|
6309
6387
|
|
|
6310
|
-
async getSlotLeader(
|
|
6311
|
-
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);
|
|
6312
6397
|
|
|
6313
6398
|
const unsafeRes = await this._rpcRequest('getSlotLeader', args);
|
|
6314
6399
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.string()));
|
|
6315
6400
|
|
|
6316
6401
|
if ('error' in res) {
|
|
6317
|
-
throw new
|
|
6402
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get slot leader');
|
|
6318
6403
|
}
|
|
6319
6404
|
|
|
6320
6405
|
return res.result;
|
|
@@ -6333,7 +6418,7 @@ class Connection {
|
|
|
6333
6418
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.array(PublicKeyFromString)));
|
|
6334
6419
|
|
|
6335
6420
|
if ('error' in res) {
|
|
6336
|
-
throw new
|
|
6421
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get slot leaders');
|
|
6337
6422
|
}
|
|
6338
6423
|
|
|
6339
6424
|
return res.result;
|
|
@@ -6371,7 +6456,7 @@ class Connection {
|
|
|
6371
6456
|
const res = superstruct.create(unsafeRes, GetSignatureStatusesRpcResult);
|
|
6372
6457
|
|
|
6373
6458
|
if ('error' in res) {
|
|
6374
|
-
throw new
|
|
6459
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get signature status');
|
|
6375
6460
|
}
|
|
6376
6461
|
|
|
6377
6462
|
return res.result;
|
|
@@ -6381,14 +6466,21 @@ class Connection {
|
|
|
6381
6466
|
*/
|
|
6382
6467
|
|
|
6383
6468
|
|
|
6384
|
-
async getTransactionCount(
|
|
6385
|
-
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);
|
|
6386
6478
|
|
|
6387
6479
|
const unsafeRes = await this._rpcRequest('getTransactionCount', args);
|
|
6388
6480
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.number()));
|
|
6389
6481
|
|
|
6390
6482
|
if ('error' in res) {
|
|
6391
|
-
throw new
|
|
6483
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get transaction count');
|
|
6392
6484
|
}
|
|
6393
6485
|
|
|
6394
6486
|
return res.result;
|
|
@@ -6419,7 +6511,7 @@ class Connection {
|
|
|
6419
6511
|
const res = superstruct.create(unsafeRes, GetInflationGovernorRpcResult);
|
|
6420
6512
|
|
|
6421
6513
|
if ('error' in res) {
|
|
6422
|
-
throw new
|
|
6514
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get inflation');
|
|
6423
6515
|
}
|
|
6424
6516
|
|
|
6425
6517
|
return res.result;
|
|
@@ -6429,16 +6521,23 @@ class Connection {
|
|
|
6429
6521
|
*/
|
|
6430
6522
|
|
|
6431
6523
|
|
|
6432
|
-
async getInflationReward(addresses, epoch,
|
|
6433
|
-
const
|
|
6434
|
-
|
|
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
|
|
6435
6534
|
});
|
|
6436
6535
|
|
|
6437
6536
|
const unsafeRes = await this._rpcRequest('getInflationReward', args);
|
|
6438
6537
|
const res = superstruct.create(unsafeRes, GetInflationRewardResult);
|
|
6439
6538
|
|
|
6440
6539
|
if ('error' in res) {
|
|
6441
|
-
throw new
|
|
6540
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get inflation reward');
|
|
6442
6541
|
}
|
|
6443
6542
|
|
|
6444
6543
|
return res.result;
|
|
@@ -6448,14 +6547,21 @@ class Connection {
|
|
|
6448
6547
|
*/
|
|
6449
6548
|
|
|
6450
6549
|
|
|
6451
|
-
async getEpochInfo(
|
|
6452
|
-
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);
|
|
6453
6559
|
|
|
6454
6560
|
const unsafeRes = await this._rpcRequest('getEpochInfo', args);
|
|
6455
6561
|
const res = superstruct.create(unsafeRes, GetEpochInfoRpcResult);
|
|
6456
6562
|
|
|
6457
6563
|
if ('error' in res) {
|
|
6458
|
-
throw new
|
|
6564
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get epoch info');
|
|
6459
6565
|
}
|
|
6460
6566
|
|
|
6461
6567
|
return res.result;
|
|
@@ -6470,7 +6576,7 @@ class Connection {
|
|
|
6470
6576
|
const res = superstruct.create(unsafeRes, GetEpochScheduleRpcResult);
|
|
6471
6577
|
|
|
6472
6578
|
if ('error' in res) {
|
|
6473
|
-
throw new
|
|
6579
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get epoch schedule');
|
|
6474
6580
|
}
|
|
6475
6581
|
|
|
6476
6582
|
const epochSchedule = res.result;
|
|
@@ -6487,7 +6593,7 @@ class Connection {
|
|
|
6487
6593
|
const res = superstruct.create(unsafeRes, GetLeaderScheduleRpcResult);
|
|
6488
6594
|
|
|
6489
6595
|
if ('error' in res) {
|
|
6490
|
-
throw new
|
|
6596
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get leader schedule');
|
|
6491
6597
|
}
|
|
6492
6598
|
|
|
6493
6599
|
return res.result;
|
|
@@ -6526,7 +6632,7 @@ class Connection {
|
|
|
6526
6632
|
const res = superstruct.create(unsafeRes, GetRecentBlockhashAndContextRpcResult);
|
|
6527
6633
|
|
|
6528
6634
|
if ('error' in res) {
|
|
6529
|
-
throw new
|
|
6635
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get recent blockhash');
|
|
6530
6636
|
}
|
|
6531
6637
|
|
|
6532
6638
|
return res.result;
|
|
@@ -6544,7 +6650,7 @@ class Connection {
|
|
|
6544
6650
|
const res = superstruct.create(unsafeRes, GetRecentPerformanceSamplesRpcResult);
|
|
6545
6651
|
|
|
6546
6652
|
if ('error' in res) {
|
|
6547
|
-
throw new
|
|
6653
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get recent performance samples');
|
|
6548
6654
|
}
|
|
6549
6655
|
|
|
6550
6656
|
return res.result;
|
|
@@ -6563,7 +6669,7 @@ class Connection {
|
|
|
6563
6669
|
const res = superstruct.create(unsafeRes, GetFeeCalculatorRpcResult);
|
|
6564
6670
|
|
|
6565
6671
|
if ('error' in res) {
|
|
6566
|
-
throw new
|
|
6672
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get fee calculator');
|
|
6567
6673
|
}
|
|
6568
6674
|
|
|
6569
6675
|
const {
|
|
@@ -6589,7 +6695,7 @@ class Connection {
|
|
|
6589
6695
|
const res = superstruct.create(unsafeRes, jsonRpcResultAndContext(superstruct.nullable(superstruct.number())));
|
|
6590
6696
|
|
|
6591
6697
|
if ('error' in res) {
|
|
6592
|
-
throw new
|
|
6698
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get slot');
|
|
6593
6699
|
}
|
|
6594
6700
|
|
|
6595
6701
|
if (res.result === null) {
|
|
@@ -6620,9 +6726,9 @@ class Connection {
|
|
|
6620
6726
|
*/
|
|
6621
6727
|
|
|
6622
6728
|
|
|
6623
|
-
async getLatestBlockhash(
|
|
6729
|
+
async getLatestBlockhash(commitmentOrConfig) {
|
|
6624
6730
|
try {
|
|
6625
|
-
const res = await this.getLatestBlockhashAndContext(
|
|
6731
|
+
const res = await this.getLatestBlockhashAndContext(commitmentOrConfig);
|
|
6626
6732
|
return res.value;
|
|
6627
6733
|
} catch (e) {
|
|
6628
6734
|
throw new Error('failed to get recent blockhash: ' + e);
|
|
@@ -6634,14 +6740,21 @@ class Connection {
|
|
|
6634
6740
|
*/
|
|
6635
6741
|
|
|
6636
6742
|
|
|
6637
|
-
async getLatestBlockhashAndContext(
|
|
6638
|
-
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);
|
|
6639
6752
|
|
|
6640
6753
|
const unsafeRes = await this._rpcRequest('getLatestBlockhash', args);
|
|
6641
6754
|
const res = superstruct.create(unsafeRes, GetLatestBlockhashRpcResult);
|
|
6642
6755
|
|
|
6643
6756
|
if ('error' in res) {
|
|
6644
|
-
throw new
|
|
6757
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get latest blockhash');
|
|
6645
6758
|
}
|
|
6646
6759
|
|
|
6647
6760
|
return res.result;
|
|
@@ -6656,7 +6769,7 @@ class Connection {
|
|
|
6656
6769
|
const res = superstruct.create(unsafeRes, jsonRpcResult(VersionResult));
|
|
6657
6770
|
|
|
6658
6771
|
if ('error' in res) {
|
|
6659
|
-
throw new
|
|
6772
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get version');
|
|
6660
6773
|
}
|
|
6661
6774
|
|
|
6662
6775
|
return res.result;
|
|
@@ -6671,7 +6784,7 @@ class Connection {
|
|
|
6671
6784
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.string()));
|
|
6672
6785
|
|
|
6673
6786
|
if ('error' in res) {
|
|
6674
|
-
throw new
|
|
6787
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get genesis hash');
|
|
6675
6788
|
}
|
|
6676
6789
|
|
|
6677
6790
|
return res.result;
|
|
@@ -6688,7 +6801,7 @@ class Connection {
|
|
|
6688
6801
|
const res = superstruct.create(unsafeRes, GetBlockRpcResult);
|
|
6689
6802
|
|
|
6690
6803
|
if ('error' in res) {
|
|
6691
|
-
throw new
|
|
6804
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get confirmed block');
|
|
6692
6805
|
}
|
|
6693
6806
|
|
|
6694
6807
|
const result = res.result;
|
|
@@ -6713,14 +6826,21 @@ class Connection {
|
|
|
6713
6826
|
*/
|
|
6714
6827
|
|
|
6715
6828
|
|
|
6716
|
-
async getBlockHeight(
|
|
6717
|
-
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);
|
|
6718
6838
|
|
|
6719
6839
|
const unsafeRes = await this._rpcRequest('getBlockHeight', args);
|
|
6720
6840
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.number()));
|
|
6721
6841
|
|
|
6722
6842
|
if ('error' in res) {
|
|
6723
|
-
throw new
|
|
6843
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get block height information');
|
|
6724
6844
|
}
|
|
6725
6845
|
|
|
6726
6846
|
return res.result;
|
|
@@ -6751,7 +6871,7 @@ class Connection {
|
|
|
6751
6871
|
const res = superstruct.create(unsafeRes, BlockProductionResponseStruct);
|
|
6752
6872
|
|
|
6753
6873
|
if ('error' in res) {
|
|
6754
|
-
throw new
|
|
6874
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get block production information');
|
|
6755
6875
|
}
|
|
6756
6876
|
|
|
6757
6877
|
return res.result;
|
|
@@ -6768,7 +6888,7 @@ class Connection {
|
|
|
6768
6888
|
const res = superstruct.create(unsafeRes, GetTransactionRpcResult);
|
|
6769
6889
|
|
|
6770
6890
|
if ('error' in res) {
|
|
6771
|
-
throw new
|
|
6891
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get transaction');
|
|
6772
6892
|
}
|
|
6773
6893
|
|
|
6774
6894
|
const result = res.result;
|
|
@@ -6791,7 +6911,7 @@ class Connection {
|
|
|
6791
6911
|
const res = superstruct.create(unsafeRes, GetParsedTransactionRpcResult);
|
|
6792
6912
|
|
|
6793
6913
|
if ('error' in res) {
|
|
6794
|
-
throw new
|
|
6914
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get transaction');
|
|
6795
6915
|
}
|
|
6796
6916
|
|
|
6797
6917
|
return res.result;
|
|
@@ -6815,7 +6935,7 @@ class Connection {
|
|
|
6815
6935
|
const res = superstruct.create(unsafeRes, GetParsedTransactionRpcResult);
|
|
6816
6936
|
|
|
6817
6937
|
if ('error' in res) {
|
|
6818
|
-
throw new
|
|
6938
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get transactions');
|
|
6819
6939
|
}
|
|
6820
6940
|
|
|
6821
6941
|
return res.result;
|
|
@@ -6842,7 +6962,7 @@ class Connection {
|
|
|
6842
6962
|
const res = superstruct.create(unsafeRes, GetTransactionRpcResult);
|
|
6843
6963
|
|
|
6844
6964
|
if ('error' in res) {
|
|
6845
|
-
throw new
|
|
6965
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get transactions');
|
|
6846
6966
|
}
|
|
6847
6967
|
|
|
6848
6968
|
const result = res.result;
|
|
@@ -6870,7 +6990,7 @@ class Connection {
|
|
|
6870
6990
|
const res = superstruct.create(unsafeRes, GetConfirmedBlockRpcResult);
|
|
6871
6991
|
|
|
6872
6992
|
if ('error' in res) {
|
|
6873
|
-
throw new
|
|
6993
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get confirmed block');
|
|
6874
6994
|
}
|
|
6875
6995
|
|
|
6876
6996
|
const result = res.result;
|
|
@@ -6917,7 +7037,7 @@ class Connection {
|
|
|
6917
7037
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.array(superstruct.number())));
|
|
6918
7038
|
|
|
6919
7039
|
if ('error' in res) {
|
|
6920
|
-
throw new
|
|
7040
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get blocks');
|
|
6921
7041
|
}
|
|
6922
7042
|
|
|
6923
7043
|
return res.result;
|
|
@@ -6937,7 +7057,7 @@ class Connection {
|
|
|
6937
7057
|
const res = superstruct.create(unsafeRes, GetBlockSignaturesRpcResult);
|
|
6938
7058
|
|
|
6939
7059
|
if ('error' in res) {
|
|
6940
|
-
throw new
|
|
7060
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get block');
|
|
6941
7061
|
}
|
|
6942
7062
|
|
|
6943
7063
|
const result = res.result;
|
|
@@ -6965,7 +7085,7 @@ class Connection {
|
|
|
6965
7085
|
const res = superstruct.create(unsafeRes, GetBlockSignaturesRpcResult);
|
|
6966
7086
|
|
|
6967
7087
|
if ('error' in res) {
|
|
6968
|
-
throw new
|
|
7088
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get confirmed block');
|
|
6969
7089
|
}
|
|
6970
7090
|
|
|
6971
7091
|
const result = res.result;
|
|
@@ -6990,7 +7110,7 @@ class Connection {
|
|
|
6990
7110
|
const res = superstruct.create(unsafeRes, GetTransactionRpcResult);
|
|
6991
7111
|
|
|
6992
7112
|
if ('error' in res) {
|
|
6993
|
-
throw new
|
|
7113
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get transaction');
|
|
6994
7114
|
}
|
|
6995
7115
|
|
|
6996
7116
|
const result = res.result;
|
|
@@ -7015,7 +7135,7 @@ class Connection {
|
|
|
7015
7135
|
const res = superstruct.create(unsafeRes, GetParsedTransactionRpcResult);
|
|
7016
7136
|
|
|
7017
7137
|
if ('error' in res) {
|
|
7018
|
-
throw new
|
|
7138
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get confirmed transaction');
|
|
7019
7139
|
}
|
|
7020
7140
|
|
|
7021
7141
|
return res.result;
|
|
@@ -7041,7 +7161,7 @@ class Connection {
|
|
|
7041
7161
|
const res = superstruct.create(unsafeRes, GetParsedTransactionRpcResult);
|
|
7042
7162
|
|
|
7043
7163
|
if ('error' in res) {
|
|
7044
|
-
throw new
|
|
7164
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get confirmed transactions');
|
|
7045
7165
|
}
|
|
7046
7166
|
|
|
7047
7167
|
return res.result;
|
|
@@ -7130,7 +7250,7 @@ class Connection {
|
|
|
7130
7250
|
const res = superstruct.create(unsafeRes, GetConfirmedSignaturesForAddress2RpcResult);
|
|
7131
7251
|
|
|
7132
7252
|
if ('error' in res) {
|
|
7133
|
-
throw new
|
|
7253
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get confirmed signatures for address');
|
|
7134
7254
|
}
|
|
7135
7255
|
|
|
7136
7256
|
return res.result;
|
|
@@ -7152,7 +7272,7 @@ class Connection {
|
|
|
7152
7272
|
const res = superstruct.create(unsafeRes, GetSignaturesForAddressRpcResult);
|
|
7153
7273
|
|
|
7154
7274
|
if ('error' in res) {
|
|
7155
|
-
throw new
|
|
7275
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get signatures for address');
|
|
7156
7276
|
}
|
|
7157
7277
|
|
|
7158
7278
|
return res.result;
|
|
@@ -7209,7 +7329,7 @@ class Connection {
|
|
|
7209
7329
|
const res = superstruct.create(unsafeRes, RequestAirdropRpcResult);
|
|
7210
7330
|
|
|
7211
7331
|
if ('error' in res) {
|
|
7212
|
-
throw new
|
|
7332
|
+
throw new SolanaJSONRPCError(res.error, `airdrop to ${to.toBase58()} failed`);
|
|
7213
7333
|
}
|
|
7214
7334
|
|
|
7215
7335
|
return res.result;
|
|
@@ -7443,6 +7563,10 @@ class Connection {
|
|
|
7443
7563
|
config.maxRetries = options.maxRetries;
|
|
7444
7564
|
}
|
|
7445
7565
|
|
|
7566
|
+
if (options && options.minContextSlot != null) {
|
|
7567
|
+
config.minContextSlot = options.minContextSlot;
|
|
7568
|
+
}
|
|
7569
|
+
|
|
7446
7570
|
if (skipPreflight) {
|
|
7447
7571
|
config.skipPreflight = skipPreflight;
|
|
7448
7572
|
}
|
|
@@ -9852,7 +9976,8 @@ async function sendAndConfirmRawTransaction(connection, rawTransaction, confirma
|
|
|
9852
9976
|
|
|
9853
9977
|
const sendOptions = options && {
|
|
9854
9978
|
skipPreflight: options.skipPreflight,
|
|
9855
|
-
preflightCommitment: options.preflightCommitment || options.commitment
|
|
9979
|
+
preflightCommitment: options.preflightCommitment || options.commitment,
|
|
9980
|
+
minContextSlot: options.minContextSlot
|
|
9856
9981
|
};
|
|
9857
9982
|
const signature = await connection.sendRawTransaction(rawTransaction, sendOptions);
|
|
9858
9983
|
const commitment = options && options.commitment;
|
|
@@ -9944,6 +10069,8 @@ exports.SYSVAR_SLOT_HISTORY_PUBKEY = SYSVAR_SLOT_HISTORY_PUBKEY;
|
|
|
9944
10069
|
exports.SYSVAR_STAKE_HISTORY_PUBKEY = SYSVAR_STAKE_HISTORY_PUBKEY;
|
|
9945
10070
|
exports.Secp256k1Program = Secp256k1Program;
|
|
9946
10071
|
exports.SendTransactionError = SendTransactionError;
|
|
10072
|
+
exports.SolanaJSONRPCError = SolanaJSONRPCError;
|
|
10073
|
+
exports.SolanaJSONRPCErrorCode = SolanaJSONRPCErrorCode;
|
|
9947
10074
|
exports.StakeAuthorizationLayout = StakeAuthorizationLayout;
|
|
9948
10075
|
exports.StakeInstruction = StakeInstruction;
|
|
9949
10076
|
exports.StakeProgram = StakeProgram;
|