@solana/web3.js 1.45.0 → 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 +157 -73
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +157 -73
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +157 -73
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +142 -18
- package/lib/index.esm.js +157 -73
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +157 -73
- 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.d.ts
CHANGED
|
@@ -580,6 +580,8 @@ declare module '@solana/web3.js' {
|
|
|
580
580
|
preflightCommitment?: Commitment;
|
|
581
581
|
/** Maximum number of times for the RPC node to retry sending the transaction to the leader. */
|
|
582
582
|
maxRetries?: number;
|
|
583
|
+
/** The minimum slot that the request can be evaluated at */
|
|
584
|
+
minContextSlot?: number;
|
|
583
585
|
};
|
|
584
586
|
/**
|
|
585
587
|
* Options for confirming transactions
|
|
@@ -593,6 +595,8 @@ declare module '@solana/web3.js' {
|
|
|
593
595
|
preflightCommitment?: Commitment;
|
|
594
596
|
/** Maximum number of times for the RPC node to retry sending the transaction to the leader. */
|
|
595
597
|
maxRetries?: number;
|
|
598
|
+
/** The minimum slot that the request can be evaluated at */
|
|
599
|
+
minContextSlot?: number;
|
|
596
600
|
};
|
|
597
601
|
/**
|
|
598
602
|
* Options for getConfirmedSignaturesForAddress2
|
|
@@ -621,6 +625,8 @@ declare module '@solana/web3.js' {
|
|
|
621
625
|
until?: TransactionSignature;
|
|
622
626
|
/** Maximum transaction signatures to return (between 1 and 1,000, default: 1,000). */
|
|
623
627
|
limit?: number;
|
|
628
|
+
/** The minimum slot that the request can be evaluated at */
|
|
629
|
+
minContextSlot?: number;
|
|
624
630
|
};
|
|
625
631
|
/**
|
|
626
632
|
* RPC Response with extra contextual information
|
|
@@ -675,6 +681,80 @@ declare module '@solana/web3.js' {
|
|
|
675
681
|
* </pre>
|
|
676
682
|
*/
|
|
677
683
|
export type LargestAccountsFilter = 'circulating' | 'nonCirculating';
|
|
684
|
+
/**
|
|
685
|
+
* Configuration object for changing `getAccountInfo` query behavior
|
|
686
|
+
*/
|
|
687
|
+
export type GetAccountInfoConfig = {
|
|
688
|
+
/** The level of commitment desired */
|
|
689
|
+
commitment?: Commitment;
|
|
690
|
+
/** The minimum slot that the request can be evaluated at */
|
|
691
|
+
minContextSlot?: number;
|
|
692
|
+
};
|
|
693
|
+
/**
|
|
694
|
+
* Configuration object for changing `getBalance` query behavior
|
|
695
|
+
*/
|
|
696
|
+
export type GetBalanceConfig = {
|
|
697
|
+
/** The level of commitment desired */
|
|
698
|
+
commitment?: Commitment;
|
|
699
|
+
/** The minimum slot that the request can be evaluated at */
|
|
700
|
+
minContextSlot?: number;
|
|
701
|
+
};
|
|
702
|
+
/**
|
|
703
|
+
* Configuration object for changing `getBlockHeight` query behavior
|
|
704
|
+
*/
|
|
705
|
+
export type GetBlockHeightConfig = {
|
|
706
|
+
/** The level of commitment desired */
|
|
707
|
+
commitment?: Commitment;
|
|
708
|
+
/** The minimum slot that the request can be evaluated at */
|
|
709
|
+
minContextSlot?: number;
|
|
710
|
+
};
|
|
711
|
+
/**
|
|
712
|
+
* Configuration object for changing `getEpochInfo` query behavior
|
|
713
|
+
*/
|
|
714
|
+
export type GetEpochInfoConfig = {
|
|
715
|
+
/** The level of commitment desired */
|
|
716
|
+
commitment?: Commitment;
|
|
717
|
+
/** The minimum slot that the request can be evaluated at */
|
|
718
|
+
minContextSlot?: number;
|
|
719
|
+
};
|
|
720
|
+
/**
|
|
721
|
+
* Configuration object for changing `getInflationReward` query behavior
|
|
722
|
+
*/
|
|
723
|
+
export type GetInflationRewardConfig = {
|
|
724
|
+
/** The level of commitment desired */
|
|
725
|
+
commitment?: Commitment;
|
|
726
|
+
/** An epoch for which the reward occurs. If omitted, the previous epoch will be used */
|
|
727
|
+
epoch?: number;
|
|
728
|
+
/** The minimum slot that the request can be evaluated at */
|
|
729
|
+
minContextSlot?: number;
|
|
730
|
+
};
|
|
731
|
+
/**
|
|
732
|
+
* Configuration object for changing `getLatestBlockhash` query behavior
|
|
733
|
+
*/
|
|
734
|
+
export type GetLatestBlockhashConfig = {
|
|
735
|
+
/** The level of commitment desired */
|
|
736
|
+
commitment?: Commitment;
|
|
737
|
+
/** The minimum slot that the request can be evaluated at */
|
|
738
|
+
minContextSlot?: number;
|
|
739
|
+
};
|
|
740
|
+
/**
|
|
741
|
+
* Configuration object for changing `getSlot` query behavior
|
|
742
|
+
*/
|
|
743
|
+
export type GetSlotConfig = {
|
|
744
|
+
/** The level of commitment desired */
|
|
745
|
+
commitment?: Commitment;
|
|
746
|
+
/** The minimum slot that the request can be evaluated at */
|
|
747
|
+
minContextSlot?: number;
|
|
748
|
+
};
|
|
749
|
+
/**
|
|
750
|
+
* Configuration object for changing `getSlotLeader` query behavior
|
|
751
|
+
*/
|
|
752
|
+
export type GetSlotLeaderConfig = {
|
|
753
|
+
/** The level of commitment desired */
|
|
754
|
+
commitment?: Commitment;
|
|
755
|
+
/** The minimum slot that the request can be evaluated at */
|
|
756
|
+
minContextSlot?: number;
|
|
757
|
+
};
|
|
678
758
|
/**
|
|
679
759
|
* Configuration object for changing `getLargestAccounts` query behavior
|
|
680
760
|
*/
|
|
@@ -1277,6 +1357,8 @@ declare module '@solana/web3.js' {
|
|
|
1277
1357
|
dataSlice?: DataSlice;
|
|
1278
1358
|
/** Optional array of filters to apply to accounts */
|
|
1279
1359
|
filters?: GetProgramAccountsFilter[];
|
|
1360
|
+
/** The minimum slot that the request can be evaluated at */
|
|
1361
|
+
minContextSlot?: number;
|
|
1280
1362
|
};
|
|
1281
1363
|
/**
|
|
1282
1364
|
* Configuration object for getParsedProgramAccounts
|
|
@@ -1286,6 +1368,8 @@ declare module '@solana/web3.js' {
|
|
|
1286
1368
|
commitment?: Commitment;
|
|
1287
1369
|
/** Optional array of filters to apply to accounts */
|
|
1288
1370
|
filters?: GetProgramAccountsFilter[];
|
|
1371
|
+
/** The minimum slot that the request can be evaluated at */
|
|
1372
|
+
minContextSlot?: number;
|
|
1289
1373
|
};
|
|
1290
1374
|
/**
|
|
1291
1375
|
* Configuration object for getMultipleAccounts
|
|
@@ -1293,8 +1377,37 @@ declare module '@solana/web3.js' {
|
|
|
1293
1377
|
export type GetMultipleAccountsConfig = {
|
|
1294
1378
|
/** Optional commitment level */
|
|
1295
1379
|
commitment?: Commitment;
|
|
1296
|
-
/**
|
|
1297
|
-
|
|
1380
|
+
/** The minimum slot that the request can be evaluated at */
|
|
1381
|
+
minContextSlot?: number;
|
|
1382
|
+
};
|
|
1383
|
+
/**
|
|
1384
|
+
* Configuration object for `getStakeActivation`
|
|
1385
|
+
*/
|
|
1386
|
+
export type GetStakeActivationConfig = {
|
|
1387
|
+
/** Optional commitment level */
|
|
1388
|
+
commitment?: Commitment;
|
|
1389
|
+
/** Epoch for which to calculate activation details. If parameter not provided, defaults to current epoch */
|
|
1390
|
+
epoch?: number;
|
|
1391
|
+
/** The minimum slot that the request can be evaluated at */
|
|
1392
|
+
minContextSlot?: number;
|
|
1393
|
+
};
|
|
1394
|
+
/**
|
|
1395
|
+
* Configuration object for `getStakeActivation`
|
|
1396
|
+
*/
|
|
1397
|
+
export type GetTokenAccountsByOwnerConfig = {
|
|
1398
|
+
/** Optional commitment level */
|
|
1399
|
+
commitment?: Commitment;
|
|
1400
|
+
/** The minimum slot that the request can be evaluated at */
|
|
1401
|
+
minContextSlot?: number;
|
|
1402
|
+
};
|
|
1403
|
+
/**
|
|
1404
|
+
* Configuration object for `getStakeActivation`
|
|
1405
|
+
*/
|
|
1406
|
+
export type GetTransactionCountConfig = {
|
|
1407
|
+
/** Optional commitment level */
|
|
1408
|
+
commitment?: Commitment;
|
|
1409
|
+
/** The minimum slot that the request can be evaluated at */
|
|
1410
|
+
minContextSlot?: number;
|
|
1298
1411
|
};
|
|
1299
1412
|
/**
|
|
1300
1413
|
* Information describing an account
|
|
@@ -1510,12 +1623,15 @@ declare module '@solana/web3.js' {
|
|
|
1510
1623
|
*/
|
|
1511
1624
|
getBalanceAndContext(
|
|
1512
1625
|
publicKey: PublicKey,
|
|
1513
|
-
|
|
1626
|
+
commitmentOrConfig?: Commitment | GetBalanceConfig,
|
|
1514
1627
|
): Promise<RpcResponseAndContext<number>>;
|
|
1515
1628
|
/**
|
|
1516
1629
|
* Fetch the balance for the specified public key
|
|
1517
1630
|
*/
|
|
1518
|
-
getBalance(
|
|
1631
|
+
getBalance(
|
|
1632
|
+
publicKey: PublicKey,
|
|
1633
|
+
commitmentOrConfig?: Commitment | GetBalanceConfig,
|
|
1634
|
+
): Promise<number>;
|
|
1519
1635
|
/**
|
|
1520
1636
|
* Fetch the estimated production time of a block
|
|
1521
1637
|
*/
|
|
@@ -1557,7 +1673,7 @@ declare module '@solana/web3.js' {
|
|
|
1557
1673
|
getTokenAccountsByOwner(
|
|
1558
1674
|
ownerAddress: PublicKey,
|
|
1559
1675
|
filter: TokenAccountsFilter,
|
|
1560
|
-
|
|
1676
|
+
commitmentOrConfig?: Commitment | GetTokenAccountsByOwnerConfig,
|
|
1561
1677
|
): Promise<
|
|
1562
1678
|
RpcResponseAndContext<
|
|
1563
1679
|
Array<{
|
|
@@ -1602,7 +1718,7 @@ declare module '@solana/web3.js' {
|
|
|
1602
1718
|
*/
|
|
1603
1719
|
getAccountInfoAndContext(
|
|
1604
1720
|
publicKey: PublicKey,
|
|
1605
|
-
|
|
1721
|
+
commitmentOrConfig?: Commitment | GetAccountInfoConfig,
|
|
1606
1722
|
): Promise<RpcResponseAndContext<AccountInfo<Buffer> | null>>;
|
|
1607
1723
|
/**
|
|
1608
1724
|
* Fetch parsed account info for the specified public key
|
|
@@ -1618,28 +1734,28 @@ declare module '@solana/web3.js' {
|
|
|
1618
1734
|
*/
|
|
1619
1735
|
getAccountInfo(
|
|
1620
1736
|
publicKey: PublicKey,
|
|
1621
|
-
|
|
1737
|
+
commitmentOrConfig?: Commitment | GetAccountInfoConfig,
|
|
1622
1738
|
): Promise<AccountInfo<Buffer> | null>;
|
|
1623
1739
|
/**
|
|
1624
1740
|
* Fetch all the account info for multiple accounts specified by an array of public keys, return with context
|
|
1625
1741
|
*/
|
|
1626
1742
|
getMultipleAccountsInfoAndContext(
|
|
1627
1743
|
publicKeys: PublicKey[],
|
|
1628
|
-
|
|
1744
|
+
commitmentOrConfig?: Commitment | GetMultipleAccountsConfig,
|
|
1629
1745
|
): Promise<RpcResponseAndContext<(AccountInfo<Buffer> | null)[]>>;
|
|
1630
1746
|
/**
|
|
1631
1747
|
* Fetch all the account info for multiple accounts specified by an array of public keys
|
|
1632
1748
|
*/
|
|
1633
1749
|
getMultipleAccountsInfo(
|
|
1634
1750
|
publicKeys: PublicKey[],
|
|
1635
|
-
|
|
1751
|
+
commitmentOrConfig?: Commitment | GetMultipleAccountsConfig,
|
|
1636
1752
|
): Promise<(AccountInfo<Buffer> | null)[]>;
|
|
1637
1753
|
/**
|
|
1638
1754
|
* Returns epoch activation information for a stake account that has been delegated
|
|
1639
1755
|
*/
|
|
1640
1756
|
getStakeActivation(
|
|
1641
1757
|
publicKey: PublicKey,
|
|
1642
|
-
|
|
1758
|
+
commitmentOrConfig?: Commitment | GetStakeActivationConfig,
|
|
1643
1759
|
epoch?: number,
|
|
1644
1760
|
): Promise<StakeActivationData>;
|
|
1645
1761
|
/**
|
|
@@ -1690,11 +1806,13 @@ declare module '@solana/web3.js' {
|
|
|
1690
1806
|
/**
|
|
1691
1807
|
* Fetch the current slot that the node is processing
|
|
1692
1808
|
*/
|
|
1693
|
-
getSlot(
|
|
1809
|
+
getSlot(commitmentOrConfig?: Commitment | GetSlotConfig): Promise<number>;
|
|
1694
1810
|
/**
|
|
1695
1811
|
* Fetch the current slot leader of the cluster
|
|
1696
1812
|
*/
|
|
1697
|
-
getSlotLeader(
|
|
1813
|
+
getSlotLeader(
|
|
1814
|
+
commitmentOrConfig?: Commitment | GetSlotLeaderConfig,
|
|
1815
|
+
): Promise<string>;
|
|
1698
1816
|
/**
|
|
1699
1817
|
* Fetch `limit` number of slot leaders starting from `startSlot`
|
|
1700
1818
|
*
|
|
@@ -1719,7 +1837,9 @@ declare module '@solana/web3.js' {
|
|
|
1719
1837
|
/**
|
|
1720
1838
|
* Fetch the current transaction count of the cluster
|
|
1721
1839
|
*/
|
|
1722
|
-
getTransactionCount(
|
|
1840
|
+
getTransactionCount(
|
|
1841
|
+
commitmentOrConfig?: Commitment | GetTransactionCountConfig,
|
|
1842
|
+
): Promise<number>;
|
|
1723
1843
|
/**
|
|
1724
1844
|
* Fetch the current total currency supply of the cluster in lamports
|
|
1725
1845
|
*
|
|
@@ -1736,12 +1856,14 @@ declare module '@solana/web3.js' {
|
|
|
1736
1856
|
getInflationReward(
|
|
1737
1857
|
addresses: PublicKey[],
|
|
1738
1858
|
epoch?: number,
|
|
1739
|
-
|
|
1859
|
+
commitmentOrConfig?: Commitment | GetInflationRewardConfig,
|
|
1740
1860
|
): Promise<(InflationReward | null)[]>;
|
|
1741
1861
|
/**
|
|
1742
1862
|
* Fetch the Epoch Info parameters
|
|
1743
1863
|
*/
|
|
1744
|
-
getEpochInfo(
|
|
1864
|
+
getEpochInfo(
|
|
1865
|
+
commitmentOrConfig?: Commitment | GetEpochInfoConfig,
|
|
1866
|
+
): Promise<EpochInfo>;
|
|
1745
1867
|
/**
|
|
1746
1868
|
* Fetch the Epoch Schedule parameters
|
|
1747
1869
|
*/
|
|
@@ -1807,14 +1929,14 @@ declare module '@solana/web3.js' {
|
|
|
1807
1929
|
* @return {Promise<BlockhashWithExpiryBlockHeight>}
|
|
1808
1930
|
*/
|
|
1809
1931
|
getLatestBlockhash(
|
|
1810
|
-
|
|
1932
|
+
commitmentOrConfig?: Commitment | GetLatestBlockhashConfig,
|
|
1811
1933
|
): Promise<BlockhashWithExpiryBlockHeight>;
|
|
1812
1934
|
/**
|
|
1813
1935
|
* Fetch the latest blockhash from the cluster
|
|
1814
1936
|
* @return {Promise<BlockhashWithExpiryBlockHeight>}
|
|
1815
1937
|
*/
|
|
1816
1938
|
getLatestBlockhashAndContext(
|
|
1817
|
-
|
|
1939
|
+
commitmentOrConfig?: Commitment | GetLatestBlockhashConfig,
|
|
1818
1940
|
): Promise<RpcResponseAndContext<BlockhashWithExpiryBlockHeight>>;
|
|
1819
1941
|
/**
|
|
1820
1942
|
* Fetch the node version
|
|
@@ -1833,7 +1955,9 @@ declare module '@solana/web3.js' {
|
|
|
1833
1955
|
commitment?: Finality;
|
|
1834
1956
|
},
|
|
1835
1957
|
): Promise<BlockResponse | null>;
|
|
1836
|
-
getBlockHeight(
|
|
1958
|
+
getBlockHeight(
|
|
1959
|
+
commitmentOrConfig?: Commitment | GetBlockHeightConfig,
|
|
1960
|
+
): Promise<number>;
|
|
1837
1961
|
getBlockProduction(
|
|
1838
1962
|
configOrCommitment?: GetBlockProductionConfig | Commitment,
|
|
1839
1963
|
): Promise<RpcResponseAndContext<BlockProduction>>;
|
package/lib/index.esm.js
CHANGED
|
@@ -3097,7 +3097,8 @@ async function sendAndConfirmTransaction(connection, transaction, signers, optio
|
|
|
3097
3097
|
const sendOptions = options && {
|
|
3098
3098
|
skipPreflight: options.skipPreflight,
|
|
3099
3099
|
preflightCommitment: options.preflightCommitment || options.commitment,
|
|
3100
|
-
maxRetries: options.maxRetries
|
|
3100
|
+
maxRetries: options.maxRetries,
|
|
3101
|
+
minContextSlot: options.minContextSlot
|
|
3101
3102
|
};
|
|
3102
3103
|
const signature = await connection.sendTransaction(transaction, signers, sendOptions);
|
|
3103
3104
|
const status = transaction.recentBlockhash != null && transaction.lastValidBlockHeight != null ? (await connection.confirmTransaction({
|
|
@@ -4661,9 +4662,32 @@ const BLOCKHASH_CACHE_TIMEOUT_MS = 30 * 1000;
|
|
|
4661
4662
|
* https://gist.github.com/steveluscher/c057eca81d479ef705cdb53162f9971d
|
|
4662
4663
|
*/
|
|
4663
4664
|
|
|
4665
|
+
/** @internal */
|
|
4666
|
+
function extractCommitmentFromConfig(commitmentOrConfig) {
|
|
4667
|
+
let commitment;
|
|
4668
|
+
let config;
|
|
4669
|
+
|
|
4670
|
+
if (typeof commitmentOrConfig === 'string') {
|
|
4671
|
+
commitment = commitmentOrConfig;
|
|
4672
|
+
} else if (commitmentOrConfig) {
|
|
4673
|
+
const {
|
|
4674
|
+
commitment: specifiedCommitment,
|
|
4675
|
+
...specifiedConfig
|
|
4676
|
+
} = commitmentOrConfig;
|
|
4677
|
+
commitment = specifiedCommitment;
|
|
4678
|
+
config = specifiedConfig;
|
|
4679
|
+
}
|
|
4680
|
+
|
|
4681
|
+
return {
|
|
4682
|
+
commitment,
|
|
4683
|
+
config
|
|
4684
|
+
};
|
|
4685
|
+
}
|
|
4664
4686
|
/**
|
|
4665
4687
|
* @internal
|
|
4666
4688
|
*/
|
|
4689
|
+
|
|
4690
|
+
|
|
4667
4691
|
function createRpcResult(result) {
|
|
4668
4692
|
return union([type({
|
|
4669
4693
|
jsonrpc: literal('2.0'),
|
|
@@ -5706,8 +5730,16 @@ class Connection {
|
|
|
5706
5730
|
*/
|
|
5707
5731
|
|
|
5708
5732
|
|
|
5709
|
-
async getBalanceAndContext(publicKey,
|
|
5710
|
-
|
|
5733
|
+
async getBalanceAndContext(publicKey, commitmentOrConfig) {
|
|
5734
|
+
/** @internal */
|
|
5735
|
+
const {
|
|
5736
|
+
commitment,
|
|
5737
|
+
config
|
|
5738
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
5739
|
+
|
|
5740
|
+
const args = this._buildArgs([publicKey.toBase58()], commitment, undefined
|
|
5741
|
+
/* encoding */
|
|
5742
|
+
, config);
|
|
5711
5743
|
|
|
5712
5744
|
const unsafeRes = await this._rpcRequest('getBalance', args);
|
|
5713
5745
|
const res = create(unsafeRes, jsonRpcResultAndContext(number()));
|
|
@@ -5723,8 +5755,8 @@ class Connection {
|
|
|
5723
5755
|
*/
|
|
5724
5756
|
|
|
5725
5757
|
|
|
5726
|
-
async getBalance(publicKey,
|
|
5727
|
-
return await this.getBalanceAndContext(publicKey,
|
|
5758
|
+
async getBalance(publicKey, commitmentOrConfig) {
|
|
5759
|
+
return await this.getBalanceAndContext(publicKey, commitmentOrConfig).then(x => x.value).catch(e => {
|
|
5728
5760
|
throw new Error('failed to get balance of account ' + publicKey.toBase58() + ': ' + e);
|
|
5729
5761
|
});
|
|
5730
5762
|
}
|
|
@@ -5846,7 +5878,11 @@ class Connection {
|
|
|
5846
5878
|
*/
|
|
5847
5879
|
|
|
5848
5880
|
|
|
5849
|
-
async getTokenAccountsByOwner(ownerAddress, filter,
|
|
5881
|
+
async getTokenAccountsByOwner(ownerAddress, filter, commitmentOrConfig) {
|
|
5882
|
+
const {
|
|
5883
|
+
commitment,
|
|
5884
|
+
config
|
|
5885
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
5850
5886
|
let _args = [ownerAddress.toBase58()];
|
|
5851
5887
|
|
|
5852
5888
|
if ('mint' in filter) {
|
|
@@ -5859,7 +5895,7 @@ class Connection {
|
|
|
5859
5895
|
});
|
|
5860
5896
|
}
|
|
5861
5897
|
|
|
5862
|
-
const args = this._buildArgs(_args, commitment, 'base64');
|
|
5898
|
+
const args = this._buildArgs(_args, commitment, 'base64', config);
|
|
5863
5899
|
|
|
5864
5900
|
const unsafeRes = await this._rpcRequest('getTokenAccountsByOwner', args);
|
|
5865
5901
|
const res = create(unsafeRes, GetTokenAccountsByOwner);
|
|
@@ -5943,8 +5979,13 @@ class Connection {
|
|
|
5943
5979
|
*/
|
|
5944
5980
|
|
|
5945
5981
|
|
|
5946
|
-
async getAccountInfoAndContext(publicKey,
|
|
5947
|
-
const
|
|
5982
|
+
async getAccountInfoAndContext(publicKey, commitmentOrConfig) {
|
|
5983
|
+
const {
|
|
5984
|
+
commitment,
|
|
5985
|
+
config
|
|
5986
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
5987
|
+
|
|
5988
|
+
const args = this._buildArgs([publicKey.toBase58()], commitment, 'base64', config);
|
|
5948
5989
|
|
|
5949
5990
|
const unsafeRes = await this._rpcRequest('getAccountInfo', args);
|
|
5950
5991
|
const res = create(unsafeRes, jsonRpcResultAndContext(nullable(AccountInfoResult)));
|
|
@@ -5977,9 +6018,9 @@ class Connection {
|
|
|
5977
6018
|
*/
|
|
5978
6019
|
|
|
5979
6020
|
|
|
5980
|
-
async getAccountInfo(publicKey,
|
|
6021
|
+
async getAccountInfo(publicKey, commitmentOrConfig) {
|
|
5981
6022
|
try {
|
|
5982
|
-
const res = await this.getAccountInfoAndContext(publicKey,
|
|
6023
|
+
const res = await this.getAccountInfoAndContext(publicKey, commitmentOrConfig);
|
|
5983
6024
|
return res.value;
|
|
5984
6025
|
} catch (e) {
|
|
5985
6026
|
throw new Error('failed to get info about account ' + publicKey.toBase58() + ': ' + e);
|
|
@@ -5990,10 +6031,14 @@ class Connection {
|
|
|
5990
6031
|
*/
|
|
5991
6032
|
|
|
5992
6033
|
|
|
5993
|
-
async getMultipleAccountsInfoAndContext(publicKeys,
|
|
6034
|
+
async getMultipleAccountsInfoAndContext(publicKeys, commitmentOrConfig) {
|
|
6035
|
+
const {
|
|
6036
|
+
commitment,
|
|
6037
|
+
config
|
|
6038
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
5994
6039
|
const keys = publicKeys.map(key => key.toBase58());
|
|
5995
6040
|
|
|
5996
|
-
const args = this._buildArgs([keys], commitment, 'base64');
|
|
6041
|
+
const args = this._buildArgs([keys], commitment, 'base64', config);
|
|
5997
6042
|
|
|
5998
6043
|
const unsafeRes = await this._rpcRequest('getMultipleAccounts', args);
|
|
5999
6044
|
const res = create(unsafeRes, jsonRpcResultAndContext(array(nullable(AccountInfoResult))));
|
|
@@ -6009,8 +6054,8 @@ class Connection {
|
|
|
6009
6054
|
*/
|
|
6010
6055
|
|
|
6011
6056
|
|
|
6012
|
-
async getMultipleAccountsInfo(publicKeys,
|
|
6013
|
-
const res = await this.getMultipleAccountsInfoAndContext(publicKeys,
|
|
6057
|
+
async getMultipleAccountsInfo(publicKeys, commitmentOrConfig) {
|
|
6058
|
+
const res = await this.getMultipleAccountsInfoAndContext(publicKeys, commitmentOrConfig);
|
|
6014
6059
|
return res.value;
|
|
6015
6060
|
}
|
|
6016
6061
|
/**
|
|
@@ -6018,10 +6063,17 @@ class Connection {
|
|
|
6018
6063
|
*/
|
|
6019
6064
|
|
|
6020
6065
|
|
|
6021
|
-
async getStakeActivation(publicKey,
|
|
6022
|
-
const
|
|
6023
|
-
|
|
6024
|
-
|
|
6066
|
+
async getStakeActivation(publicKey, commitmentOrConfig, epoch) {
|
|
6067
|
+
const {
|
|
6068
|
+
commitment,
|
|
6069
|
+
config
|
|
6070
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
6071
|
+
|
|
6072
|
+
const args = this._buildArgs([publicKey.toBase58()], commitment, undefined
|
|
6073
|
+
/* encoding */
|
|
6074
|
+
, { ...config,
|
|
6075
|
+
epoch: epoch != null ? epoch : config === null || config === void 0 ? void 0 : config.epoch
|
|
6076
|
+
});
|
|
6025
6077
|
|
|
6026
6078
|
const unsafeRes = await this._rpcRequest('getStakeActivation', args);
|
|
6027
6079
|
const res = create(unsafeRes, jsonRpcResult(StakeActivationResult));
|
|
@@ -6040,28 +6092,16 @@ class Connection {
|
|
|
6040
6092
|
|
|
6041
6093
|
|
|
6042
6094
|
async getProgramAccounts(programId, configOrCommitment) {
|
|
6043
|
-
const
|
|
6044
|
-
|
|
6045
|
-
|
|
6046
|
-
|
|
6047
|
-
|
|
6048
|
-
|
|
6049
|
-
|
|
6050
|
-
|
|
6051
|
-
commitment = configOrCommitment.commitment;
|
|
6052
|
-
encoding = configOrCommitment.encoding;
|
|
6053
|
-
|
|
6054
|
-
if (configOrCommitment.dataSlice) {
|
|
6055
|
-
extra.dataSlice = configOrCommitment.dataSlice;
|
|
6056
|
-
}
|
|
6057
|
-
|
|
6058
|
-
if (configOrCommitment.filters) {
|
|
6059
|
-
extra.filters = configOrCommitment.filters;
|
|
6060
|
-
}
|
|
6061
|
-
}
|
|
6062
|
-
}
|
|
6095
|
+
const {
|
|
6096
|
+
commitment,
|
|
6097
|
+
config
|
|
6098
|
+
} = extractCommitmentFromConfig(configOrCommitment);
|
|
6099
|
+
const {
|
|
6100
|
+
encoding,
|
|
6101
|
+
...configWithoutEncoding
|
|
6102
|
+
} = config || {};
|
|
6063
6103
|
|
|
6064
|
-
const args = this._buildArgs([programId.toBase58()], commitment, encoding || 'base64',
|
|
6104
|
+
const args = this._buildArgs([programId.toBase58()], commitment, encoding || 'base64', configWithoutEncoding);
|
|
6065
6105
|
|
|
6066
6106
|
const unsafeRes = await this._rpcRequest('getProgramAccounts', args);
|
|
6067
6107
|
const res = create(unsafeRes, jsonRpcResult(array(KeyedAccountInfoResult)));
|
|
@@ -6080,22 +6120,12 @@ class Connection {
|
|
|
6080
6120
|
|
|
6081
6121
|
|
|
6082
6122
|
async getParsedProgramAccounts(programId, configOrCommitment) {
|
|
6083
|
-
const
|
|
6084
|
-
|
|
6085
|
-
|
|
6086
|
-
|
|
6087
|
-
if (typeof configOrCommitment === 'string') {
|
|
6088
|
-
commitment = configOrCommitment;
|
|
6089
|
-
} else {
|
|
6090
|
-
commitment = configOrCommitment.commitment;
|
|
6091
|
-
|
|
6092
|
-
if (configOrCommitment.filters) {
|
|
6093
|
-
extra.filters = configOrCommitment.filters;
|
|
6094
|
-
}
|
|
6095
|
-
}
|
|
6096
|
-
}
|
|
6123
|
+
const {
|
|
6124
|
+
commitment,
|
|
6125
|
+
config
|
|
6126
|
+
} = extractCommitmentFromConfig(configOrCommitment);
|
|
6097
6127
|
|
|
6098
|
-
const args = this._buildArgs([programId.toBase58()], commitment, 'jsonParsed',
|
|
6128
|
+
const args = this._buildArgs([programId.toBase58()], commitment, 'jsonParsed', config);
|
|
6099
6129
|
|
|
6100
6130
|
const unsafeRes = await this._rpcRequest('getProgramAccounts', args);
|
|
6101
6131
|
const res = create(unsafeRes, jsonRpcResult(array(KeyedParsedAccountInfoResult)));
|
|
@@ -6262,8 +6292,15 @@ class Connection {
|
|
|
6262
6292
|
*/
|
|
6263
6293
|
|
|
6264
6294
|
|
|
6265
|
-
async getSlot(
|
|
6266
|
-
const
|
|
6295
|
+
async getSlot(commitmentOrConfig) {
|
|
6296
|
+
const {
|
|
6297
|
+
commitment,
|
|
6298
|
+
config
|
|
6299
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
6300
|
+
|
|
6301
|
+
const args = this._buildArgs([], commitment, undefined
|
|
6302
|
+
/* encoding */
|
|
6303
|
+
, config);
|
|
6267
6304
|
|
|
6268
6305
|
const unsafeRes = await this._rpcRequest('getSlot', args);
|
|
6269
6306
|
const res = create(unsafeRes, jsonRpcResult(number()));
|
|
@@ -6279,8 +6316,15 @@ class Connection {
|
|
|
6279
6316
|
*/
|
|
6280
6317
|
|
|
6281
6318
|
|
|
6282
|
-
async getSlotLeader(
|
|
6283
|
-
const
|
|
6319
|
+
async getSlotLeader(commitmentOrConfig) {
|
|
6320
|
+
const {
|
|
6321
|
+
commitment,
|
|
6322
|
+
config
|
|
6323
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
6324
|
+
|
|
6325
|
+
const args = this._buildArgs([], commitment, undefined
|
|
6326
|
+
/* encoding */
|
|
6327
|
+
, config);
|
|
6284
6328
|
|
|
6285
6329
|
const unsafeRes = await this._rpcRequest('getSlotLeader', args);
|
|
6286
6330
|
const res = create(unsafeRes, jsonRpcResult(string()));
|
|
@@ -6353,8 +6397,15 @@ class Connection {
|
|
|
6353
6397
|
*/
|
|
6354
6398
|
|
|
6355
6399
|
|
|
6356
|
-
async getTransactionCount(
|
|
6357
|
-
const
|
|
6400
|
+
async getTransactionCount(commitmentOrConfig) {
|
|
6401
|
+
const {
|
|
6402
|
+
commitment,
|
|
6403
|
+
config
|
|
6404
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
6405
|
+
|
|
6406
|
+
const args = this._buildArgs([], commitment, undefined
|
|
6407
|
+
/* encoding */
|
|
6408
|
+
, config);
|
|
6358
6409
|
|
|
6359
6410
|
const unsafeRes = await this._rpcRequest('getTransactionCount', args);
|
|
6360
6411
|
const res = create(unsafeRes, jsonRpcResult(number()));
|
|
@@ -6401,9 +6452,16 @@ class Connection {
|
|
|
6401
6452
|
*/
|
|
6402
6453
|
|
|
6403
6454
|
|
|
6404
|
-
async getInflationReward(addresses, epoch,
|
|
6405
|
-
const
|
|
6406
|
-
|
|
6455
|
+
async getInflationReward(addresses, epoch, commitmentOrConfig) {
|
|
6456
|
+
const {
|
|
6457
|
+
commitment,
|
|
6458
|
+
config
|
|
6459
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
6460
|
+
|
|
6461
|
+
const args = this._buildArgs([addresses.map(pubkey => pubkey.toBase58())], commitment, undefined
|
|
6462
|
+
/* encoding */
|
|
6463
|
+
, { ...config,
|
|
6464
|
+
epoch: epoch != null ? epoch : config === null || config === void 0 ? void 0 : config.epoch
|
|
6407
6465
|
});
|
|
6408
6466
|
|
|
6409
6467
|
const unsafeRes = await this._rpcRequest('getInflationReward', args);
|
|
@@ -6420,8 +6478,15 @@ class Connection {
|
|
|
6420
6478
|
*/
|
|
6421
6479
|
|
|
6422
6480
|
|
|
6423
|
-
async getEpochInfo(
|
|
6424
|
-
const
|
|
6481
|
+
async getEpochInfo(commitmentOrConfig) {
|
|
6482
|
+
const {
|
|
6483
|
+
commitment,
|
|
6484
|
+
config
|
|
6485
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
6486
|
+
|
|
6487
|
+
const args = this._buildArgs([], commitment, undefined
|
|
6488
|
+
/* encoding */
|
|
6489
|
+
, config);
|
|
6425
6490
|
|
|
6426
6491
|
const unsafeRes = await this._rpcRequest('getEpochInfo', args);
|
|
6427
6492
|
const res = create(unsafeRes, GetEpochInfoRpcResult);
|
|
@@ -6592,9 +6657,9 @@ class Connection {
|
|
|
6592
6657
|
*/
|
|
6593
6658
|
|
|
6594
6659
|
|
|
6595
|
-
async getLatestBlockhash(
|
|
6660
|
+
async getLatestBlockhash(commitmentOrConfig) {
|
|
6596
6661
|
try {
|
|
6597
|
-
const res = await this.getLatestBlockhashAndContext(
|
|
6662
|
+
const res = await this.getLatestBlockhashAndContext(commitmentOrConfig);
|
|
6598
6663
|
return res.value;
|
|
6599
6664
|
} catch (e) {
|
|
6600
6665
|
throw new Error('failed to get recent blockhash: ' + e);
|
|
@@ -6606,8 +6671,15 @@ class Connection {
|
|
|
6606
6671
|
*/
|
|
6607
6672
|
|
|
6608
6673
|
|
|
6609
|
-
async getLatestBlockhashAndContext(
|
|
6610
|
-
const
|
|
6674
|
+
async getLatestBlockhashAndContext(commitmentOrConfig) {
|
|
6675
|
+
const {
|
|
6676
|
+
commitment,
|
|
6677
|
+
config
|
|
6678
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
6679
|
+
|
|
6680
|
+
const args = this._buildArgs([], commitment, undefined
|
|
6681
|
+
/* encoding */
|
|
6682
|
+
, config);
|
|
6611
6683
|
|
|
6612
6684
|
const unsafeRes = await this._rpcRequest('getLatestBlockhash', args);
|
|
6613
6685
|
const res = create(unsafeRes, GetLatestBlockhashRpcResult);
|
|
@@ -6685,8 +6757,15 @@ class Connection {
|
|
|
6685
6757
|
*/
|
|
6686
6758
|
|
|
6687
6759
|
|
|
6688
|
-
async getBlockHeight(
|
|
6689
|
-
const
|
|
6760
|
+
async getBlockHeight(commitmentOrConfig) {
|
|
6761
|
+
const {
|
|
6762
|
+
commitment,
|
|
6763
|
+
config
|
|
6764
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
6765
|
+
|
|
6766
|
+
const args = this._buildArgs([], commitment, undefined
|
|
6767
|
+
/* encoding */
|
|
6768
|
+
, config);
|
|
6690
6769
|
|
|
6691
6770
|
const unsafeRes = await this._rpcRequest('getBlockHeight', args);
|
|
6692
6771
|
const res = create(unsafeRes, jsonRpcResult(number()));
|
|
@@ -7415,6 +7494,10 @@ class Connection {
|
|
|
7415
7494
|
config.maxRetries = options.maxRetries;
|
|
7416
7495
|
}
|
|
7417
7496
|
|
|
7497
|
+
if (options && options.minContextSlot != null) {
|
|
7498
|
+
config.minContextSlot = options.minContextSlot;
|
|
7499
|
+
}
|
|
7500
|
+
|
|
7418
7501
|
if (skipPreflight) {
|
|
7419
7502
|
config.skipPreflight = skipPreflight;
|
|
7420
7503
|
}
|
|
@@ -9824,7 +9907,8 @@ async function sendAndConfirmRawTransaction(connection, rawTransaction, confirma
|
|
|
9824
9907
|
|
|
9825
9908
|
const sendOptions = options && {
|
|
9826
9909
|
skipPreflight: options.skipPreflight,
|
|
9827
|
-
preflightCommitment: options.preflightCommitment || options.commitment
|
|
9910
|
+
preflightCommitment: options.preflightCommitment || options.commitment,
|
|
9911
|
+
minContextSlot: options.minContextSlot
|
|
9828
9912
|
};
|
|
9829
9913
|
const signature = await connection.sendRawTransaction(rawTransaction, sendOptions);
|
|
9830
9914
|
const commitment = options && options.commitment;
|