@solana/web3.js 1.44.2 → 1.46.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 +184 -91
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +184 -91
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +184 -91
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +144 -18
- package/lib/index.esm.js +184 -91
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +184 -91
- 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 +283 -76
- package/src/transaction.ts +19 -12
- package/src/util/send-and-confirm-raw-transaction.ts +1 -0
- package/src/util/send-and-confirm-transaction.ts +1 -0
package/lib/index.browser.esm.js
CHANGED
|
@@ -2510,24 +2510,27 @@ class Transaction {
|
|
|
2510
2510
|
return this._message;
|
|
2511
2511
|
}
|
|
2512
2512
|
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
} = this;
|
|
2513
|
+
let recentBlockhash;
|
|
2514
|
+
let instructions;
|
|
2516
2515
|
|
|
2517
|
-
if (
|
|
2518
|
-
|
|
2519
|
-
this.instructions.unshift(nonceInfo.nonceInstruction);
|
|
2520
|
-
}
|
|
2516
|
+
if (this.nonceInfo) {
|
|
2517
|
+
recentBlockhash = this.nonceInfo.nonce;
|
|
2521
2518
|
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2519
|
+
if (this.instructions[0] != this.nonceInfo.nonceInstruction) {
|
|
2520
|
+
instructions = [this.nonceInfo.nonceInstruction, ...this.instructions];
|
|
2521
|
+
} else {
|
|
2522
|
+
instructions = this.instructions;
|
|
2523
|
+
}
|
|
2524
|
+
} else {
|
|
2525
|
+
recentBlockhash = this.recentBlockhash;
|
|
2526
|
+
instructions = this.instructions;
|
|
2527
|
+
}
|
|
2525
2528
|
|
|
2526
2529
|
if (!recentBlockhash) {
|
|
2527
2530
|
throw new Error('Transaction recentBlockhash required');
|
|
2528
2531
|
}
|
|
2529
2532
|
|
|
2530
|
-
if (
|
|
2533
|
+
if (instructions.length < 1) {
|
|
2531
2534
|
console.warn('No instructions provided');
|
|
2532
2535
|
}
|
|
2533
2536
|
|
|
@@ -2542,15 +2545,15 @@ class Transaction {
|
|
|
2542
2545
|
throw new Error('Transaction fee payer required');
|
|
2543
2546
|
}
|
|
2544
2547
|
|
|
2545
|
-
for (let i = 0; i <
|
|
2546
|
-
if (
|
|
2548
|
+
for (let i = 0; i < instructions.length; i++) {
|
|
2549
|
+
if (instructions[i].programId === undefined) {
|
|
2547
2550
|
throw new Error(`Transaction instruction index ${i} has undefined program id`);
|
|
2548
2551
|
}
|
|
2549
2552
|
}
|
|
2550
2553
|
|
|
2551
2554
|
const programIds = [];
|
|
2552
2555
|
const accountMetas = [];
|
|
2553
|
-
|
|
2556
|
+
instructions.forEach(instruction => {
|
|
2554
2557
|
instruction.keys.forEach(accountMeta => {
|
|
2555
2558
|
accountMetas.push({ ...accountMeta
|
|
2556
2559
|
});
|
|
@@ -2660,7 +2663,7 @@ class Transaction {
|
|
|
2660
2663
|
}
|
|
2661
2664
|
});
|
|
2662
2665
|
const accountKeys = signedKeys.concat(unsignedKeys);
|
|
2663
|
-
const
|
|
2666
|
+
const compiledInstructions = instructions.map(instruction => {
|
|
2664
2667
|
const {
|
|
2665
2668
|
data,
|
|
2666
2669
|
programId
|
|
@@ -2671,7 +2674,7 @@ class Transaction {
|
|
|
2671
2674
|
data: bs58.encode(data)
|
|
2672
2675
|
};
|
|
2673
2676
|
});
|
|
2674
|
-
|
|
2677
|
+
compiledInstructions.forEach(instruction => {
|
|
2675
2678
|
assert(instruction.programIdIndex >= 0);
|
|
2676
2679
|
instruction.accounts.forEach(keyIndex => assert(keyIndex >= 0));
|
|
2677
2680
|
});
|
|
@@ -2683,7 +2686,7 @@ class Transaction {
|
|
|
2683
2686
|
},
|
|
2684
2687
|
accountKeys,
|
|
2685
2688
|
recentBlockhash,
|
|
2686
|
-
instructions
|
|
2689
|
+
instructions: compiledInstructions
|
|
2687
2690
|
});
|
|
2688
2691
|
}
|
|
2689
2692
|
/**
|
|
@@ -3070,7 +3073,8 @@ async function sendAndConfirmTransaction(connection, transaction, signers, optio
|
|
|
3070
3073
|
const sendOptions = options && {
|
|
3071
3074
|
skipPreflight: options.skipPreflight,
|
|
3072
3075
|
preflightCommitment: options.preflightCommitment || options.commitment,
|
|
3073
|
-
maxRetries: options.maxRetries
|
|
3076
|
+
maxRetries: options.maxRetries,
|
|
3077
|
+
minContextSlot: options.minContextSlot
|
|
3074
3078
|
};
|
|
3075
3079
|
const signature = await connection.sendTransaction(transaction, signers, sendOptions);
|
|
3076
3080
|
const status = transaction.recentBlockhash != null && transaction.lastValidBlockHeight != null ? (await connection.confirmTransaction({
|
|
@@ -4565,6 +4569,7 @@ function makeWebsocketUrl(endpoint) {
|
|
|
4565
4569
|
return url.toString();
|
|
4566
4570
|
}
|
|
4567
4571
|
|
|
4572
|
+
var _process$env$npm_pack;
|
|
4568
4573
|
const PublicKeyFromString = coerce(instance(PublicKey), string(), value => new PublicKey(value));
|
|
4569
4574
|
const RawAccountDataResult = tuple([string(), literal('base64')]);
|
|
4570
4575
|
const BufferFromRawAccountData = coerce(instance(Buffer), RawAccountDataResult, value => Buffer.from(value[0], 'base64'));
|
|
@@ -4581,9 +4586,32 @@ const BLOCKHASH_CACHE_TIMEOUT_MS = 30 * 1000;
|
|
|
4581
4586
|
* https://gist.github.com/steveluscher/c057eca81d479ef705cdb53162f9971d
|
|
4582
4587
|
*/
|
|
4583
4588
|
|
|
4589
|
+
/** @internal */
|
|
4590
|
+
function extractCommitmentFromConfig(commitmentOrConfig) {
|
|
4591
|
+
let commitment;
|
|
4592
|
+
let config;
|
|
4593
|
+
|
|
4594
|
+
if (typeof commitmentOrConfig === 'string') {
|
|
4595
|
+
commitment = commitmentOrConfig;
|
|
4596
|
+
} else if (commitmentOrConfig) {
|
|
4597
|
+
const {
|
|
4598
|
+
commitment: specifiedCommitment,
|
|
4599
|
+
...specifiedConfig
|
|
4600
|
+
} = commitmentOrConfig;
|
|
4601
|
+
commitment = specifiedCommitment;
|
|
4602
|
+
config = specifiedConfig;
|
|
4603
|
+
}
|
|
4604
|
+
|
|
4605
|
+
return {
|
|
4606
|
+
commitment,
|
|
4607
|
+
config
|
|
4608
|
+
};
|
|
4609
|
+
}
|
|
4584
4610
|
/**
|
|
4585
4611
|
* @internal
|
|
4586
4612
|
*/
|
|
4613
|
+
|
|
4614
|
+
|
|
4587
4615
|
function createRpcResult(result) {
|
|
4588
4616
|
return union([type({
|
|
4589
4617
|
jsonrpc: literal('2.0'),
|
|
@@ -4775,7 +4803,7 @@ function createRpcClient(url, useHttps, httpHeaders, customFetch, fetchMiddlewar
|
|
|
4775
4803
|
agent,
|
|
4776
4804
|
headers: Object.assign({
|
|
4777
4805
|
'Content-Type': 'application/json'
|
|
4778
|
-
}, httpHeaders || {})
|
|
4806
|
+
}, httpHeaders || {}, COMMON_HTTP_HEADERS)
|
|
4779
4807
|
};
|
|
4780
4808
|
|
|
4781
4809
|
try {
|
|
@@ -5448,9 +5476,14 @@ const LogsNotificationResult = type({
|
|
|
5448
5476
|
* Filter for log subscriptions.
|
|
5449
5477
|
*/
|
|
5450
5478
|
|
|
5479
|
+
/** @internal */
|
|
5480
|
+
const COMMON_HTTP_HEADERS = {
|
|
5481
|
+
'solana-client': `js/${(_process$env$npm_pack = "0.0.0-development") !== null && _process$env$npm_pack !== void 0 ? _process$env$npm_pack : 'UNKNOWN'}`
|
|
5482
|
+
};
|
|
5451
5483
|
/**
|
|
5452
5484
|
* A connection to a fullnode JSON RPC endpoint
|
|
5453
5485
|
*/
|
|
5486
|
+
|
|
5454
5487
|
class Connection {
|
|
5455
5488
|
/** @internal */
|
|
5456
5489
|
|
|
@@ -5615,8 +5648,16 @@ class Connection {
|
|
|
5615
5648
|
*/
|
|
5616
5649
|
|
|
5617
5650
|
|
|
5618
|
-
async getBalanceAndContext(publicKey,
|
|
5619
|
-
|
|
5651
|
+
async getBalanceAndContext(publicKey, commitmentOrConfig) {
|
|
5652
|
+
/** @internal */
|
|
5653
|
+
const {
|
|
5654
|
+
commitment,
|
|
5655
|
+
config
|
|
5656
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
5657
|
+
|
|
5658
|
+
const args = this._buildArgs([publicKey.toBase58()], commitment, undefined
|
|
5659
|
+
/* encoding */
|
|
5660
|
+
, config);
|
|
5620
5661
|
|
|
5621
5662
|
const unsafeRes = await this._rpcRequest('getBalance', args);
|
|
5622
5663
|
const res = create(unsafeRes, jsonRpcResultAndContext(number()));
|
|
@@ -5632,8 +5673,8 @@ class Connection {
|
|
|
5632
5673
|
*/
|
|
5633
5674
|
|
|
5634
5675
|
|
|
5635
|
-
async getBalance(publicKey,
|
|
5636
|
-
return await this.getBalanceAndContext(publicKey,
|
|
5676
|
+
async getBalance(publicKey, commitmentOrConfig) {
|
|
5677
|
+
return await this.getBalanceAndContext(publicKey, commitmentOrConfig).then(x => x.value).catch(e => {
|
|
5637
5678
|
throw new Error('failed to get balance of account ' + publicKey.toBase58() + ': ' + e);
|
|
5638
5679
|
});
|
|
5639
5680
|
}
|
|
@@ -5755,7 +5796,11 @@ class Connection {
|
|
|
5755
5796
|
*/
|
|
5756
5797
|
|
|
5757
5798
|
|
|
5758
|
-
async getTokenAccountsByOwner(ownerAddress, filter,
|
|
5799
|
+
async getTokenAccountsByOwner(ownerAddress, filter, commitmentOrConfig) {
|
|
5800
|
+
const {
|
|
5801
|
+
commitment,
|
|
5802
|
+
config
|
|
5803
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
5759
5804
|
let _args = [ownerAddress.toBase58()];
|
|
5760
5805
|
|
|
5761
5806
|
if ('mint' in filter) {
|
|
@@ -5768,7 +5813,7 @@ class Connection {
|
|
|
5768
5813
|
});
|
|
5769
5814
|
}
|
|
5770
5815
|
|
|
5771
|
-
const args = this._buildArgs(_args, commitment, 'base64');
|
|
5816
|
+
const args = this._buildArgs(_args, commitment, 'base64', config);
|
|
5772
5817
|
|
|
5773
5818
|
const unsafeRes = await this._rpcRequest('getTokenAccountsByOwner', args);
|
|
5774
5819
|
const res = create(unsafeRes, GetTokenAccountsByOwner);
|
|
@@ -5852,8 +5897,13 @@ class Connection {
|
|
|
5852
5897
|
*/
|
|
5853
5898
|
|
|
5854
5899
|
|
|
5855
|
-
async getAccountInfoAndContext(publicKey,
|
|
5856
|
-
const
|
|
5900
|
+
async getAccountInfoAndContext(publicKey, commitmentOrConfig) {
|
|
5901
|
+
const {
|
|
5902
|
+
commitment,
|
|
5903
|
+
config
|
|
5904
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
5905
|
+
|
|
5906
|
+
const args = this._buildArgs([publicKey.toBase58()], commitment, 'base64', config);
|
|
5857
5907
|
|
|
5858
5908
|
const unsafeRes = await this._rpcRequest('getAccountInfo', args);
|
|
5859
5909
|
const res = create(unsafeRes, jsonRpcResultAndContext(nullable(AccountInfoResult)));
|
|
@@ -5886,9 +5936,9 @@ class Connection {
|
|
|
5886
5936
|
*/
|
|
5887
5937
|
|
|
5888
5938
|
|
|
5889
|
-
async getAccountInfo(publicKey,
|
|
5939
|
+
async getAccountInfo(publicKey, commitmentOrConfig) {
|
|
5890
5940
|
try {
|
|
5891
|
-
const res = await this.getAccountInfoAndContext(publicKey,
|
|
5941
|
+
const res = await this.getAccountInfoAndContext(publicKey, commitmentOrConfig);
|
|
5892
5942
|
return res.value;
|
|
5893
5943
|
} catch (e) {
|
|
5894
5944
|
throw new Error('failed to get info about account ' + publicKey.toBase58() + ': ' + e);
|
|
@@ -5899,10 +5949,14 @@ class Connection {
|
|
|
5899
5949
|
*/
|
|
5900
5950
|
|
|
5901
5951
|
|
|
5902
|
-
async getMultipleAccountsInfoAndContext(publicKeys,
|
|
5952
|
+
async getMultipleAccountsInfoAndContext(publicKeys, commitmentOrConfig) {
|
|
5953
|
+
const {
|
|
5954
|
+
commitment,
|
|
5955
|
+
config
|
|
5956
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
5903
5957
|
const keys = publicKeys.map(key => key.toBase58());
|
|
5904
5958
|
|
|
5905
|
-
const args = this._buildArgs([keys], commitment, 'base64');
|
|
5959
|
+
const args = this._buildArgs([keys], commitment, 'base64', config);
|
|
5906
5960
|
|
|
5907
5961
|
const unsafeRes = await this._rpcRequest('getMultipleAccounts', args);
|
|
5908
5962
|
const res = create(unsafeRes, jsonRpcResultAndContext(array(nullable(AccountInfoResult))));
|
|
@@ -5918,8 +5972,8 @@ class Connection {
|
|
|
5918
5972
|
*/
|
|
5919
5973
|
|
|
5920
5974
|
|
|
5921
|
-
async getMultipleAccountsInfo(publicKeys,
|
|
5922
|
-
const res = await this.getMultipleAccountsInfoAndContext(publicKeys,
|
|
5975
|
+
async getMultipleAccountsInfo(publicKeys, commitmentOrConfig) {
|
|
5976
|
+
const res = await this.getMultipleAccountsInfoAndContext(publicKeys, commitmentOrConfig);
|
|
5923
5977
|
return res.value;
|
|
5924
5978
|
}
|
|
5925
5979
|
/**
|
|
@@ -5927,10 +5981,17 @@ class Connection {
|
|
|
5927
5981
|
*/
|
|
5928
5982
|
|
|
5929
5983
|
|
|
5930
|
-
async getStakeActivation(publicKey,
|
|
5931
|
-
const
|
|
5932
|
-
|
|
5933
|
-
|
|
5984
|
+
async getStakeActivation(publicKey, commitmentOrConfig, epoch) {
|
|
5985
|
+
const {
|
|
5986
|
+
commitment,
|
|
5987
|
+
config
|
|
5988
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
5989
|
+
|
|
5990
|
+
const args = this._buildArgs([publicKey.toBase58()], commitment, undefined
|
|
5991
|
+
/* encoding */
|
|
5992
|
+
, { ...config,
|
|
5993
|
+
epoch: epoch != null ? epoch : config === null || config === void 0 ? void 0 : config.epoch
|
|
5994
|
+
});
|
|
5934
5995
|
|
|
5935
5996
|
const unsafeRes = await this._rpcRequest('getStakeActivation', args);
|
|
5936
5997
|
const res = create(unsafeRes, jsonRpcResult(StakeActivationResult));
|
|
@@ -5949,28 +6010,16 @@ class Connection {
|
|
|
5949
6010
|
|
|
5950
6011
|
|
|
5951
6012
|
async getProgramAccounts(programId, configOrCommitment) {
|
|
5952
|
-
const
|
|
5953
|
-
|
|
5954
|
-
|
|
5955
|
-
|
|
5956
|
-
|
|
5957
|
-
|
|
5958
|
-
|
|
5959
|
-
|
|
5960
|
-
commitment = configOrCommitment.commitment;
|
|
5961
|
-
encoding = configOrCommitment.encoding;
|
|
5962
|
-
|
|
5963
|
-
if (configOrCommitment.dataSlice) {
|
|
5964
|
-
extra.dataSlice = configOrCommitment.dataSlice;
|
|
5965
|
-
}
|
|
5966
|
-
|
|
5967
|
-
if (configOrCommitment.filters) {
|
|
5968
|
-
extra.filters = configOrCommitment.filters;
|
|
5969
|
-
}
|
|
5970
|
-
}
|
|
5971
|
-
}
|
|
6013
|
+
const {
|
|
6014
|
+
commitment,
|
|
6015
|
+
config
|
|
6016
|
+
} = extractCommitmentFromConfig(configOrCommitment);
|
|
6017
|
+
const {
|
|
6018
|
+
encoding,
|
|
6019
|
+
...configWithoutEncoding
|
|
6020
|
+
} = config || {};
|
|
5972
6021
|
|
|
5973
|
-
const args = this._buildArgs([programId.toBase58()], commitment, encoding || 'base64',
|
|
6022
|
+
const args = this._buildArgs([programId.toBase58()], commitment, encoding || 'base64', configWithoutEncoding);
|
|
5974
6023
|
|
|
5975
6024
|
const unsafeRes = await this._rpcRequest('getProgramAccounts', args);
|
|
5976
6025
|
const res = create(unsafeRes, jsonRpcResult(array(KeyedAccountInfoResult)));
|
|
@@ -5989,22 +6038,12 @@ class Connection {
|
|
|
5989
6038
|
|
|
5990
6039
|
|
|
5991
6040
|
async getParsedProgramAccounts(programId, configOrCommitment) {
|
|
5992
|
-
const
|
|
5993
|
-
|
|
5994
|
-
|
|
5995
|
-
|
|
5996
|
-
if (typeof configOrCommitment === 'string') {
|
|
5997
|
-
commitment = configOrCommitment;
|
|
5998
|
-
} else {
|
|
5999
|
-
commitment = configOrCommitment.commitment;
|
|
6000
|
-
|
|
6001
|
-
if (configOrCommitment.filters) {
|
|
6002
|
-
extra.filters = configOrCommitment.filters;
|
|
6003
|
-
}
|
|
6004
|
-
}
|
|
6005
|
-
}
|
|
6041
|
+
const {
|
|
6042
|
+
commitment,
|
|
6043
|
+
config
|
|
6044
|
+
} = extractCommitmentFromConfig(configOrCommitment);
|
|
6006
6045
|
|
|
6007
|
-
const args = this._buildArgs([programId.toBase58()], commitment, 'jsonParsed',
|
|
6046
|
+
const args = this._buildArgs([programId.toBase58()], commitment, 'jsonParsed', config);
|
|
6008
6047
|
|
|
6009
6048
|
const unsafeRes = await this._rpcRequest('getProgramAccounts', args);
|
|
6010
6049
|
const res = create(unsafeRes, jsonRpcResult(array(KeyedParsedAccountInfoResult)));
|
|
@@ -6171,8 +6210,15 @@ class Connection {
|
|
|
6171
6210
|
*/
|
|
6172
6211
|
|
|
6173
6212
|
|
|
6174
|
-
async getSlot(
|
|
6175
|
-
const
|
|
6213
|
+
async getSlot(commitmentOrConfig) {
|
|
6214
|
+
const {
|
|
6215
|
+
commitment,
|
|
6216
|
+
config
|
|
6217
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
6218
|
+
|
|
6219
|
+
const args = this._buildArgs([], commitment, undefined
|
|
6220
|
+
/* encoding */
|
|
6221
|
+
, config);
|
|
6176
6222
|
|
|
6177
6223
|
const unsafeRes = await this._rpcRequest('getSlot', args);
|
|
6178
6224
|
const res = create(unsafeRes, jsonRpcResult(number()));
|
|
@@ -6188,8 +6234,15 @@ class Connection {
|
|
|
6188
6234
|
*/
|
|
6189
6235
|
|
|
6190
6236
|
|
|
6191
|
-
async getSlotLeader(
|
|
6192
|
-
const
|
|
6237
|
+
async getSlotLeader(commitmentOrConfig) {
|
|
6238
|
+
const {
|
|
6239
|
+
commitment,
|
|
6240
|
+
config
|
|
6241
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
6242
|
+
|
|
6243
|
+
const args = this._buildArgs([], commitment, undefined
|
|
6244
|
+
/* encoding */
|
|
6245
|
+
, config);
|
|
6193
6246
|
|
|
6194
6247
|
const unsafeRes = await this._rpcRequest('getSlotLeader', args);
|
|
6195
6248
|
const res = create(unsafeRes, jsonRpcResult(string()));
|
|
@@ -6262,8 +6315,15 @@ class Connection {
|
|
|
6262
6315
|
*/
|
|
6263
6316
|
|
|
6264
6317
|
|
|
6265
|
-
async getTransactionCount(
|
|
6266
|
-
const
|
|
6318
|
+
async getTransactionCount(commitmentOrConfig) {
|
|
6319
|
+
const {
|
|
6320
|
+
commitment,
|
|
6321
|
+
config
|
|
6322
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
6323
|
+
|
|
6324
|
+
const args = this._buildArgs([], commitment, undefined
|
|
6325
|
+
/* encoding */
|
|
6326
|
+
, config);
|
|
6267
6327
|
|
|
6268
6328
|
const unsafeRes = await this._rpcRequest('getTransactionCount', args);
|
|
6269
6329
|
const res = create(unsafeRes, jsonRpcResult(number()));
|
|
@@ -6310,9 +6370,16 @@ class Connection {
|
|
|
6310
6370
|
*/
|
|
6311
6371
|
|
|
6312
6372
|
|
|
6313
|
-
async getInflationReward(addresses, epoch,
|
|
6314
|
-
const
|
|
6315
|
-
|
|
6373
|
+
async getInflationReward(addresses, epoch, commitmentOrConfig) {
|
|
6374
|
+
const {
|
|
6375
|
+
commitment,
|
|
6376
|
+
config
|
|
6377
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
6378
|
+
|
|
6379
|
+
const args = this._buildArgs([addresses.map(pubkey => pubkey.toBase58())], commitment, undefined
|
|
6380
|
+
/* encoding */
|
|
6381
|
+
, { ...config,
|
|
6382
|
+
epoch: epoch != null ? epoch : config === null || config === void 0 ? void 0 : config.epoch
|
|
6316
6383
|
});
|
|
6317
6384
|
|
|
6318
6385
|
const unsafeRes = await this._rpcRequest('getInflationReward', args);
|
|
@@ -6329,8 +6396,15 @@ class Connection {
|
|
|
6329
6396
|
*/
|
|
6330
6397
|
|
|
6331
6398
|
|
|
6332
|
-
async getEpochInfo(
|
|
6333
|
-
const
|
|
6399
|
+
async getEpochInfo(commitmentOrConfig) {
|
|
6400
|
+
const {
|
|
6401
|
+
commitment,
|
|
6402
|
+
config
|
|
6403
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
6404
|
+
|
|
6405
|
+
const args = this._buildArgs([], commitment, undefined
|
|
6406
|
+
/* encoding */
|
|
6407
|
+
, config);
|
|
6334
6408
|
|
|
6335
6409
|
const unsafeRes = await this._rpcRequest('getEpochInfo', args);
|
|
6336
6410
|
const res = create(unsafeRes, GetEpochInfoRpcResult);
|
|
@@ -6501,9 +6575,9 @@ class Connection {
|
|
|
6501
6575
|
*/
|
|
6502
6576
|
|
|
6503
6577
|
|
|
6504
|
-
async getLatestBlockhash(
|
|
6578
|
+
async getLatestBlockhash(commitmentOrConfig) {
|
|
6505
6579
|
try {
|
|
6506
|
-
const res = await this.getLatestBlockhashAndContext(
|
|
6580
|
+
const res = await this.getLatestBlockhashAndContext(commitmentOrConfig);
|
|
6507
6581
|
return res.value;
|
|
6508
6582
|
} catch (e) {
|
|
6509
6583
|
throw new Error('failed to get recent blockhash: ' + e);
|
|
@@ -6515,8 +6589,15 @@ class Connection {
|
|
|
6515
6589
|
*/
|
|
6516
6590
|
|
|
6517
6591
|
|
|
6518
|
-
async getLatestBlockhashAndContext(
|
|
6519
|
-
const
|
|
6592
|
+
async getLatestBlockhashAndContext(commitmentOrConfig) {
|
|
6593
|
+
const {
|
|
6594
|
+
commitment,
|
|
6595
|
+
config
|
|
6596
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
6597
|
+
|
|
6598
|
+
const args = this._buildArgs([], commitment, undefined
|
|
6599
|
+
/* encoding */
|
|
6600
|
+
, config);
|
|
6520
6601
|
|
|
6521
6602
|
const unsafeRes = await this._rpcRequest('getLatestBlockhash', args);
|
|
6522
6603
|
const res = create(unsafeRes, GetLatestBlockhashRpcResult);
|
|
@@ -6594,8 +6675,15 @@ class Connection {
|
|
|
6594
6675
|
*/
|
|
6595
6676
|
|
|
6596
6677
|
|
|
6597
|
-
async getBlockHeight(
|
|
6598
|
-
const
|
|
6678
|
+
async getBlockHeight(commitmentOrConfig) {
|
|
6679
|
+
const {
|
|
6680
|
+
commitment,
|
|
6681
|
+
config
|
|
6682
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
6683
|
+
|
|
6684
|
+
const args = this._buildArgs([], commitment, undefined
|
|
6685
|
+
/* encoding */
|
|
6686
|
+
, config);
|
|
6599
6687
|
|
|
6600
6688
|
const unsafeRes = await this._rpcRequest('getBlockHeight', args);
|
|
6601
6689
|
const res = create(unsafeRes, jsonRpcResult(number()));
|
|
@@ -7324,6 +7412,10 @@ class Connection {
|
|
|
7324
7412
|
config.maxRetries = options.maxRetries;
|
|
7325
7413
|
}
|
|
7326
7414
|
|
|
7415
|
+
if (options && options.minContextSlot != null) {
|
|
7416
|
+
config.minContextSlot = options.minContextSlot;
|
|
7417
|
+
}
|
|
7418
|
+
|
|
7327
7419
|
if (skipPreflight) {
|
|
7328
7420
|
config.skipPreflight = skipPreflight;
|
|
7329
7421
|
}
|
|
@@ -9733,7 +9825,8 @@ async function sendAndConfirmRawTransaction(connection, rawTransaction, confirma
|
|
|
9733
9825
|
|
|
9734
9826
|
const sendOptions = options && {
|
|
9735
9827
|
skipPreflight: options.skipPreflight,
|
|
9736
|
-
preflightCommitment: options.preflightCommitment || options.commitment
|
|
9828
|
+
preflightCommitment: options.preflightCommitment || options.commitment,
|
|
9829
|
+
minContextSlot: options.minContextSlot
|
|
9737
9830
|
};
|
|
9738
9831
|
const signature = await connection.sendRawTransaction(rawTransaction, sendOptions);
|
|
9739
9832
|
const commitment = options && options.commitment;
|