@solana/web3.js 1.45.1 → 1.46.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 +158 -74
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +158 -74
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +158 -74
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +142 -18
- package/lib/index.esm.js +158 -74
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +158 -74
- 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 +269 -73
- 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
|
@@ -3160,7 +3160,8 @@ async function sendAndConfirmTransaction(connection, transaction, signers, optio
|
|
|
3160
3160
|
const sendOptions = options && {
|
|
3161
3161
|
skipPreflight: options.skipPreflight,
|
|
3162
3162
|
preflightCommitment: options.preflightCommitment || options.commitment,
|
|
3163
|
-
maxRetries: options.maxRetries
|
|
3163
|
+
maxRetries: options.maxRetries,
|
|
3164
|
+
minContextSlot: options.minContextSlot
|
|
3164
3165
|
};
|
|
3165
3166
|
const signature = await connection.sendTransaction(transaction, signers, sendOptions);
|
|
3166
3167
|
const status = transaction.recentBlockhash != null && transaction.lastValidBlockHeight != null ? (await connection.confirmTransaction({
|
|
@@ -4724,9 +4725,32 @@ const BLOCKHASH_CACHE_TIMEOUT_MS = 30 * 1000;
|
|
|
4724
4725
|
* https://gist.github.com/steveluscher/c057eca81d479ef705cdb53162f9971d
|
|
4725
4726
|
*/
|
|
4726
4727
|
|
|
4728
|
+
/** @internal */
|
|
4729
|
+
function extractCommitmentFromConfig(commitmentOrConfig) {
|
|
4730
|
+
let commitment;
|
|
4731
|
+
let config;
|
|
4732
|
+
|
|
4733
|
+
if (typeof commitmentOrConfig === 'string') {
|
|
4734
|
+
commitment = commitmentOrConfig;
|
|
4735
|
+
} else if (commitmentOrConfig) {
|
|
4736
|
+
const {
|
|
4737
|
+
commitment: specifiedCommitment,
|
|
4738
|
+
...specifiedConfig
|
|
4739
|
+
} = commitmentOrConfig;
|
|
4740
|
+
commitment = specifiedCommitment;
|
|
4741
|
+
config = specifiedConfig;
|
|
4742
|
+
}
|
|
4743
|
+
|
|
4744
|
+
return {
|
|
4745
|
+
commitment,
|
|
4746
|
+
config
|
|
4747
|
+
};
|
|
4748
|
+
}
|
|
4727
4749
|
/**
|
|
4728
4750
|
* @internal
|
|
4729
4751
|
*/
|
|
4752
|
+
|
|
4753
|
+
|
|
4730
4754
|
function createRpcResult(result) {
|
|
4731
4755
|
return superstruct.union([superstruct.type({
|
|
4732
4756
|
jsonrpc: superstruct.literal('2.0'),
|
|
@@ -5599,7 +5623,7 @@ const LogsNotificationResult = superstruct.type({
|
|
|
5599
5623
|
|
|
5600
5624
|
/** @internal */
|
|
5601
5625
|
const COMMON_HTTP_HEADERS = {
|
|
5602
|
-
'solana-client': `js/${(_process$env$npm_pack = "1.
|
|
5626
|
+
'solana-client': `js/${(_process$env$npm_pack = "1.46.1") !== null && _process$env$npm_pack !== void 0 ? _process$env$npm_pack : 'UNKNOWN'}`
|
|
5603
5627
|
};
|
|
5604
5628
|
/**
|
|
5605
5629
|
* A connection to a fullnode JSON RPC endpoint
|
|
@@ -5769,8 +5793,16 @@ class Connection {
|
|
|
5769
5793
|
*/
|
|
5770
5794
|
|
|
5771
5795
|
|
|
5772
|
-
async getBalanceAndContext(publicKey,
|
|
5773
|
-
|
|
5796
|
+
async getBalanceAndContext(publicKey, commitmentOrConfig) {
|
|
5797
|
+
/** @internal */
|
|
5798
|
+
const {
|
|
5799
|
+
commitment,
|
|
5800
|
+
config
|
|
5801
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
5802
|
+
|
|
5803
|
+
const args = this._buildArgs([publicKey.toBase58()], commitment, undefined
|
|
5804
|
+
/* encoding */
|
|
5805
|
+
, config);
|
|
5774
5806
|
|
|
5775
5807
|
const unsafeRes = await this._rpcRequest('getBalance', args);
|
|
5776
5808
|
const res = superstruct.create(unsafeRes, jsonRpcResultAndContext(superstruct.number()));
|
|
@@ -5786,8 +5818,8 @@ class Connection {
|
|
|
5786
5818
|
*/
|
|
5787
5819
|
|
|
5788
5820
|
|
|
5789
|
-
async getBalance(publicKey,
|
|
5790
|
-
return await this.getBalanceAndContext(publicKey,
|
|
5821
|
+
async getBalance(publicKey, commitmentOrConfig) {
|
|
5822
|
+
return await this.getBalanceAndContext(publicKey, commitmentOrConfig).then(x => x.value).catch(e => {
|
|
5791
5823
|
throw new Error('failed to get balance of account ' + publicKey.toBase58() + ': ' + e);
|
|
5792
5824
|
});
|
|
5793
5825
|
}
|
|
@@ -5909,7 +5941,11 @@ class Connection {
|
|
|
5909
5941
|
*/
|
|
5910
5942
|
|
|
5911
5943
|
|
|
5912
|
-
async getTokenAccountsByOwner(ownerAddress, filter,
|
|
5944
|
+
async getTokenAccountsByOwner(ownerAddress, filter, commitmentOrConfig) {
|
|
5945
|
+
const {
|
|
5946
|
+
commitment,
|
|
5947
|
+
config
|
|
5948
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
5913
5949
|
let _args = [ownerAddress.toBase58()];
|
|
5914
5950
|
|
|
5915
5951
|
if ('mint' in filter) {
|
|
@@ -5922,7 +5958,7 @@ class Connection {
|
|
|
5922
5958
|
});
|
|
5923
5959
|
}
|
|
5924
5960
|
|
|
5925
|
-
const args = this._buildArgs(_args, commitment, 'base64');
|
|
5961
|
+
const args = this._buildArgs(_args, commitment, 'base64', config);
|
|
5926
5962
|
|
|
5927
5963
|
const unsafeRes = await this._rpcRequest('getTokenAccountsByOwner', args);
|
|
5928
5964
|
const res = superstruct.create(unsafeRes, GetTokenAccountsByOwner);
|
|
@@ -6006,8 +6042,13 @@ class Connection {
|
|
|
6006
6042
|
*/
|
|
6007
6043
|
|
|
6008
6044
|
|
|
6009
|
-
async getAccountInfoAndContext(publicKey,
|
|
6010
|
-
const
|
|
6045
|
+
async getAccountInfoAndContext(publicKey, commitmentOrConfig) {
|
|
6046
|
+
const {
|
|
6047
|
+
commitment,
|
|
6048
|
+
config
|
|
6049
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
6050
|
+
|
|
6051
|
+
const args = this._buildArgs([publicKey.toBase58()], commitment, 'base64', config);
|
|
6011
6052
|
|
|
6012
6053
|
const unsafeRes = await this._rpcRequest('getAccountInfo', args);
|
|
6013
6054
|
const res = superstruct.create(unsafeRes, jsonRpcResultAndContext(superstruct.nullable(AccountInfoResult)));
|
|
@@ -6040,9 +6081,9 @@ class Connection {
|
|
|
6040
6081
|
*/
|
|
6041
6082
|
|
|
6042
6083
|
|
|
6043
|
-
async getAccountInfo(publicKey,
|
|
6084
|
+
async getAccountInfo(publicKey, commitmentOrConfig) {
|
|
6044
6085
|
try {
|
|
6045
|
-
const res = await this.getAccountInfoAndContext(publicKey,
|
|
6086
|
+
const res = await this.getAccountInfoAndContext(publicKey, commitmentOrConfig);
|
|
6046
6087
|
return res.value;
|
|
6047
6088
|
} catch (e) {
|
|
6048
6089
|
throw new Error('failed to get info about account ' + publicKey.toBase58() + ': ' + e);
|
|
@@ -6053,10 +6094,14 @@ class Connection {
|
|
|
6053
6094
|
*/
|
|
6054
6095
|
|
|
6055
6096
|
|
|
6056
|
-
async getMultipleAccountsInfoAndContext(publicKeys,
|
|
6097
|
+
async getMultipleAccountsInfoAndContext(publicKeys, commitmentOrConfig) {
|
|
6098
|
+
const {
|
|
6099
|
+
commitment,
|
|
6100
|
+
config
|
|
6101
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
6057
6102
|
const keys = publicKeys.map(key => key.toBase58());
|
|
6058
6103
|
|
|
6059
|
-
const args = this._buildArgs([keys], commitment, 'base64');
|
|
6104
|
+
const args = this._buildArgs([keys], commitment, 'base64', config);
|
|
6060
6105
|
|
|
6061
6106
|
const unsafeRes = await this._rpcRequest('getMultipleAccounts', args);
|
|
6062
6107
|
const res = superstruct.create(unsafeRes, jsonRpcResultAndContext(superstruct.array(superstruct.nullable(AccountInfoResult))));
|
|
@@ -6072,8 +6117,8 @@ class Connection {
|
|
|
6072
6117
|
*/
|
|
6073
6118
|
|
|
6074
6119
|
|
|
6075
|
-
async getMultipleAccountsInfo(publicKeys,
|
|
6076
|
-
const res = await this.getMultipleAccountsInfoAndContext(publicKeys,
|
|
6120
|
+
async getMultipleAccountsInfo(publicKeys, commitmentOrConfig) {
|
|
6121
|
+
const res = await this.getMultipleAccountsInfoAndContext(publicKeys, commitmentOrConfig);
|
|
6077
6122
|
return res.value;
|
|
6078
6123
|
}
|
|
6079
6124
|
/**
|
|
@@ -6081,10 +6126,17 @@ class Connection {
|
|
|
6081
6126
|
*/
|
|
6082
6127
|
|
|
6083
6128
|
|
|
6084
|
-
async getStakeActivation(publicKey,
|
|
6085
|
-
const
|
|
6086
|
-
|
|
6087
|
-
|
|
6129
|
+
async getStakeActivation(publicKey, commitmentOrConfig, epoch) {
|
|
6130
|
+
const {
|
|
6131
|
+
commitment,
|
|
6132
|
+
config
|
|
6133
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
6134
|
+
|
|
6135
|
+
const args = this._buildArgs([publicKey.toBase58()], commitment, undefined
|
|
6136
|
+
/* encoding */
|
|
6137
|
+
, { ...config,
|
|
6138
|
+
epoch: epoch != null ? epoch : config === null || config === void 0 ? void 0 : config.epoch
|
|
6139
|
+
});
|
|
6088
6140
|
|
|
6089
6141
|
const unsafeRes = await this._rpcRequest('getStakeActivation', args);
|
|
6090
6142
|
const res = superstruct.create(unsafeRes, jsonRpcResult(StakeActivationResult));
|
|
@@ -6103,28 +6155,16 @@ class Connection {
|
|
|
6103
6155
|
|
|
6104
6156
|
|
|
6105
6157
|
async getProgramAccounts(programId, configOrCommitment) {
|
|
6106
|
-
const
|
|
6107
|
-
|
|
6108
|
-
|
|
6109
|
-
|
|
6110
|
-
|
|
6111
|
-
|
|
6112
|
-
|
|
6113
|
-
|
|
6114
|
-
commitment = configOrCommitment.commitment;
|
|
6115
|
-
encoding = configOrCommitment.encoding;
|
|
6116
|
-
|
|
6117
|
-
if (configOrCommitment.dataSlice) {
|
|
6118
|
-
extra.dataSlice = configOrCommitment.dataSlice;
|
|
6119
|
-
}
|
|
6120
|
-
|
|
6121
|
-
if (configOrCommitment.filters) {
|
|
6122
|
-
extra.filters = configOrCommitment.filters;
|
|
6123
|
-
}
|
|
6124
|
-
}
|
|
6125
|
-
}
|
|
6158
|
+
const {
|
|
6159
|
+
commitment,
|
|
6160
|
+
config
|
|
6161
|
+
} = extractCommitmentFromConfig(configOrCommitment);
|
|
6162
|
+
const {
|
|
6163
|
+
encoding,
|
|
6164
|
+
...configWithoutEncoding
|
|
6165
|
+
} = config || {};
|
|
6126
6166
|
|
|
6127
|
-
const args = this._buildArgs([programId.toBase58()], commitment, encoding || 'base64',
|
|
6167
|
+
const args = this._buildArgs([programId.toBase58()], commitment, encoding || 'base64', configWithoutEncoding);
|
|
6128
6168
|
|
|
6129
6169
|
const unsafeRes = await this._rpcRequest('getProgramAccounts', args);
|
|
6130
6170
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.array(KeyedAccountInfoResult)));
|
|
@@ -6143,22 +6183,12 @@ class Connection {
|
|
|
6143
6183
|
|
|
6144
6184
|
|
|
6145
6185
|
async getParsedProgramAccounts(programId, configOrCommitment) {
|
|
6146
|
-
const
|
|
6147
|
-
|
|
6148
|
-
|
|
6149
|
-
|
|
6150
|
-
if (typeof configOrCommitment === 'string') {
|
|
6151
|
-
commitment = configOrCommitment;
|
|
6152
|
-
} else {
|
|
6153
|
-
commitment = configOrCommitment.commitment;
|
|
6154
|
-
|
|
6155
|
-
if (configOrCommitment.filters) {
|
|
6156
|
-
extra.filters = configOrCommitment.filters;
|
|
6157
|
-
}
|
|
6158
|
-
}
|
|
6159
|
-
}
|
|
6186
|
+
const {
|
|
6187
|
+
commitment,
|
|
6188
|
+
config
|
|
6189
|
+
} = extractCommitmentFromConfig(configOrCommitment);
|
|
6160
6190
|
|
|
6161
|
-
const args = this._buildArgs([programId.toBase58()], commitment, 'jsonParsed',
|
|
6191
|
+
const args = this._buildArgs([programId.toBase58()], commitment, 'jsonParsed', config);
|
|
6162
6192
|
|
|
6163
6193
|
const unsafeRes = await this._rpcRequest('getProgramAccounts', args);
|
|
6164
6194
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.array(KeyedParsedAccountInfoResult)));
|
|
@@ -6325,8 +6355,15 @@ class Connection {
|
|
|
6325
6355
|
*/
|
|
6326
6356
|
|
|
6327
6357
|
|
|
6328
|
-
async getSlot(
|
|
6329
|
-
const
|
|
6358
|
+
async getSlot(commitmentOrConfig) {
|
|
6359
|
+
const {
|
|
6360
|
+
commitment,
|
|
6361
|
+
config
|
|
6362
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
6363
|
+
|
|
6364
|
+
const args = this._buildArgs([], commitment, undefined
|
|
6365
|
+
/* encoding */
|
|
6366
|
+
, config);
|
|
6330
6367
|
|
|
6331
6368
|
const unsafeRes = await this._rpcRequest('getSlot', args);
|
|
6332
6369
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.number()));
|
|
@@ -6342,8 +6379,15 @@ class Connection {
|
|
|
6342
6379
|
*/
|
|
6343
6380
|
|
|
6344
6381
|
|
|
6345
|
-
async getSlotLeader(
|
|
6346
|
-
const
|
|
6382
|
+
async getSlotLeader(commitmentOrConfig) {
|
|
6383
|
+
const {
|
|
6384
|
+
commitment,
|
|
6385
|
+
config
|
|
6386
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
6387
|
+
|
|
6388
|
+
const args = this._buildArgs([], commitment, undefined
|
|
6389
|
+
/* encoding */
|
|
6390
|
+
, config);
|
|
6347
6391
|
|
|
6348
6392
|
const unsafeRes = await this._rpcRequest('getSlotLeader', args);
|
|
6349
6393
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.string()));
|
|
@@ -6416,8 +6460,15 @@ class Connection {
|
|
|
6416
6460
|
*/
|
|
6417
6461
|
|
|
6418
6462
|
|
|
6419
|
-
async getTransactionCount(
|
|
6420
|
-
const
|
|
6463
|
+
async getTransactionCount(commitmentOrConfig) {
|
|
6464
|
+
const {
|
|
6465
|
+
commitment,
|
|
6466
|
+
config
|
|
6467
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
6468
|
+
|
|
6469
|
+
const args = this._buildArgs([], commitment, undefined
|
|
6470
|
+
/* encoding */
|
|
6471
|
+
, config);
|
|
6421
6472
|
|
|
6422
6473
|
const unsafeRes = await this._rpcRequest('getTransactionCount', args);
|
|
6423
6474
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.number()));
|
|
@@ -6464,9 +6515,16 @@ class Connection {
|
|
|
6464
6515
|
*/
|
|
6465
6516
|
|
|
6466
6517
|
|
|
6467
|
-
async getInflationReward(addresses, epoch,
|
|
6468
|
-
const
|
|
6469
|
-
|
|
6518
|
+
async getInflationReward(addresses, epoch, commitmentOrConfig) {
|
|
6519
|
+
const {
|
|
6520
|
+
commitment,
|
|
6521
|
+
config
|
|
6522
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
6523
|
+
|
|
6524
|
+
const args = this._buildArgs([addresses.map(pubkey => pubkey.toBase58())], commitment, undefined
|
|
6525
|
+
/* encoding */
|
|
6526
|
+
, { ...config,
|
|
6527
|
+
epoch: epoch != null ? epoch : config === null || config === void 0 ? void 0 : config.epoch
|
|
6470
6528
|
});
|
|
6471
6529
|
|
|
6472
6530
|
const unsafeRes = await this._rpcRequest('getInflationReward', args);
|
|
@@ -6483,8 +6541,15 @@ class Connection {
|
|
|
6483
6541
|
*/
|
|
6484
6542
|
|
|
6485
6543
|
|
|
6486
|
-
async getEpochInfo(
|
|
6487
|
-
const
|
|
6544
|
+
async getEpochInfo(commitmentOrConfig) {
|
|
6545
|
+
const {
|
|
6546
|
+
commitment,
|
|
6547
|
+
config
|
|
6548
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
6549
|
+
|
|
6550
|
+
const args = this._buildArgs([], commitment, undefined
|
|
6551
|
+
/* encoding */
|
|
6552
|
+
, config);
|
|
6488
6553
|
|
|
6489
6554
|
const unsafeRes = await this._rpcRequest('getEpochInfo', args);
|
|
6490
6555
|
const res = superstruct.create(unsafeRes, GetEpochInfoRpcResult);
|
|
@@ -6655,9 +6720,9 @@ class Connection {
|
|
|
6655
6720
|
*/
|
|
6656
6721
|
|
|
6657
6722
|
|
|
6658
|
-
async getLatestBlockhash(
|
|
6723
|
+
async getLatestBlockhash(commitmentOrConfig) {
|
|
6659
6724
|
try {
|
|
6660
|
-
const res = await this.getLatestBlockhashAndContext(
|
|
6725
|
+
const res = await this.getLatestBlockhashAndContext(commitmentOrConfig);
|
|
6661
6726
|
return res.value;
|
|
6662
6727
|
} catch (e) {
|
|
6663
6728
|
throw new Error('failed to get recent blockhash: ' + e);
|
|
@@ -6669,8 +6734,15 @@ class Connection {
|
|
|
6669
6734
|
*/
|
|
6670
6735
|
|
|
6671
6736
|
|
|
6672
|
-
async getLatestBlockhashAndContext(
|
|
6673
|
-
const
|
|
6737
|
+
async getLatestBlockhashAndContext(commitmentOrConfig) {
|
|
6738
|
+
const {
|
|
6739
|
+
commitment,
|
|
6740
|
+
config
|
|
6741
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
6742
|
+
|
|
6743
|
+
const args = this._buildArgs([], commitment, undefined
|
|
6744
|
+
/* encoding */
|
|
6745
|
+
, config);
|
|
6674
6746
|
|
|
6675
6747
|
const unsafeRes = await this._rpcRequest('getLatestBlockhash', args);
|
|
6676
6748
|
const res = superstruct.create(unsafeRes, GetLatestBlockhashRpcResult);
|
|
@@ -6748,8 +6820,15 @@ class Connection {
|
|
|
6748
6820
|
*/
|
|
6749
6821
|
|
|
6750
6822
|
|
|
6751
|
-
async getBlockHeight(
|
|
6752
|
-
const
|
|
6823
|
+
async getBlockHeight(commitmentOrConfig) {
|
|
6824
|
+
const {
|
|
6825
|
+
commitment,
|
|
6826
|
+
config
|
|
6827
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
6828
|
+
|
|
6829
|
+
const args = this._buildArgs([], commitment, undefined
|
|
6830
|
+
/* encoding */
|
|
6831
|
+
, config);
|
|
6753
6832
|
|
|
6754
6833
|
const unsafeRes = await this._rpcRequest('getBlockHeight', args);
|
|
6755
6834
|
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.number()));
|
|
@@ -7478,6 +7557,10 @@ class Connection {
|
|
|
7478
7557
|
config.maxRetries = options.maxRetries;
|
|
7479
7558
|
}
|
|
7480
7559
|
|
|
7560
|
+
if (options && options.minContextSlot != null) {
|
|
7561
|
+
config.minContextSlot = options.minContextSlot;
|
|
7562
|
+
}
|
|
7563
|
+
|
|
7481
7564
|
if (skipPreflight) {
|
|
7482
7565
|
config.skipPreflight = skipPreflight;
|
|
7483
7566
|
}
|
|
@@ -9885,7 +9968,8 @@ async function sendAndConfirmRawTransaction(connection, rawTransaction, confirma
|
|
|
9885
9968
|
|
|
9886
9969
|
const sendOptions = options && {
|
|
9887
9970
|
skipPreflight: options.skipPreflight,
|
|
9888
|
-
preflightCommitment: options.preflightCommitment || options.commitment
|
|
9971
|
+
preflightCommitment: options.preflightCommitment || options.commitment,
|
|
9972
|
+
minContextSlot: options.minContextSlot
|
|
9889
9973
|
};
|
|
9890
9974
|
const signature = await connection.sendRawTransaction(rawTransaction, sendOptions);
|
|
9891
9975
|
const commitment = options && options.commitment;
|