@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.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
|
|
@@ -1449,6 +1562,8 @@ declare module '@solana/web3.js' {
|
|
|
1449
1562
|
*/
|
|
1450
1563
|
export type HttpHeaders = {
|
|
1451
1564
|
[header: string]: string;
|
|
1565
|
+
} & {
|
|
1566
|
+
'solana-client'?: never;
|
|
1452
1567
|
};
|
|
1453
1568
|
/**
|
|
1454
1569
|
* The type of the JavaScript `fetch()` API
|
|
@@ -1508,12 +1623,15 @@ declare module '@solana/web3.js' {
|
|
|
1508
1623
|
*/
|
|
1509
1624
|
getBalanceAndContext(
|
|
1510
1625
|
publicKey: PublicKey,
|
|
1511
|
-
|
|
1626
|
+
commitmentOrConfig?: Commitment | GetBalanceConfig,
|
|
1512
1627
|
): Promise<RpcResponseAndContext<number>>;
|
|
1513
1628
|
/**
|
|
1514
1629
|
* Fetch the balance for the specified public key
|
|
1515
1630
|
*/
|
|
1516
|
-
getBalance(
|
|
1631
|
+
getBalance(
|
|
1632
|
+
publicKey: PublicKey,
|
|
1633
|
+
commitmentOrConfig?: Commitment | GetBalanceConfig,
|
|
1634
|
+
): Promise<number>;
|
|
1517
1635
|
/**
|
|
1518
1636
|
* Fetch the estimated production time of a block
|
|
1519
1637
|
*/
|
|
@@ -1555,7 +1673,7 @@ declare module '@solana/web3.js' {
|
|
|
1555
1673
|
getTokenAccountsByOwner(
|
|
1556
1674
|
ownerAddress: PublicKey,
|
|
1557
1675
|
filter: TokenAccountsFilter,
|
|
1558
|
-
|
|
1676
|
+
commitmentOrConfig?: Commitment | GetTokenAccountsByOwnerConfig,
|
|
1559
1677
|
): Promise<
|
|
1560
1678
|
RpcResponseAndContext<
|
|
1561
1679
|
Array<{
|
|
@@ -1600,7 +1718,7 @@ declare module '@solana/web3.js' {
|
|
|
1600
1718
|
*/
|
|
1601
1719
|
getAccountInfoAndContext(
|
|
1602
1720
|
publicKey: PublicKey,
|
|
1603
|
-
|
|
1721
|
+
commitmentOrConfig?: Commitment | GetAccountInfoConfig,
|
|
1604
1722
|
): Promise<RpcResponseAndContext<AccountInfo<Buffer> | null>>;
|
|
1605
1723
|
/**
|
|
1606
1724
|
* Fetch parsed account info for the specified public key
|
|
@@ -1616,28 +1734,28 @@ declare module '@solana/web3.js' {
|
|
|
1616
1734
|
*/
|
|
1617
1735
|
getAccountInfo(
|
|
1618
1736
|
publicKey: PublicKey,
|
|
1619
|
-
|
|
1737
|
+
commitmentOrConfig?: Commitment | GetAccountInfoConfig,
|
|
1620
1738
|
): Promise<AccountInfo<Buffer> | null>;
|
|
1621
1739
|
/**
|
|
1622
1740
|
* Fetch all the account info for multiple accounts specified by an array of public keys, return with context
|
|
1623
1741
|
*/
|
|
1624
1742
|
getMultipleAccountsInfoAndContext(
|
|
1625
1743
|
publicKeys: PublicKey[],
|
|
1626
|
-
|
|
1744
|
+
commitmentOrConfig?: Commitment | GetMultipleAccountsConfig,
|
|
1627
1745
|
): Promise<RpcResponseAndContext<(AccountInfo<Buffer> | null)[]>>;
|
|
1628
1746
|
/**
|
|
1629
1747
|
* Fetch all the account info for multiple accounts specified by an array of public keys
|
|
1630
1748
|
*/
|
|
1631
1749
|
getMultipleAccountsInfo(
|
|
1632
1750
|
publicKeys: PublicKey[],
|
|
1633
|
-
|
|
1751
|
+
commitmentOrConfig?: Commitment | GetMultipleAccountsConfig,
|
|
1634
1752
|
): Promise<(AccountInfo<Buffer> | null)[]>;
|
|
1635
1753
|
/**
|
|
1636
1754
|
* Returns epoch activation information for a stake account that has been delegated
|
|
1637
1755
|
*/
|
|
1638
1756
|
getStakeActivation(
|
|
1639
1757
|
publicKey: PublicKey,
|
|
1640
|
-
|
|
1758
|
+
commitmentOrConfig?: Commitment | GetStakeActivationConfig,
|
|
1641
1759
|
epoch?: number,
|
|
1642
1760
|
): Promise<StakeActivationData>;
|
|
1643
1761
|
/**
|
|
@@ -1688,11 +1806,13 @@ declare module '@solana/web3.js' {
|
|
|
1688
1806
|
/**
|
|
1689
1807
|
* Fetch the current slot that the node is processing
|
|
1690
1808
|
*/
|
|
1691
|
-
getSlot(
|
|
1809
|
+
getSlot(commitmentOrConfig?: Commitment | GetSlotConfig): Promise<number>;
|
|
1692
1810
|
/**
|
|
1693
1811
|
* Fetch the current slot leader of the cluster
|
|
1694
1812
|
*/
|
|
1695
|
-
getSlotLeader(
|
|
1813
|
+
getSlotLeader(
|
|
1814
|
+
commitmentOrConfig?: Commitment | GetSlotLeaderConfig,
|
|
1815
|
+
): Promise<string>;
|
|
1696
1816
|
/**
|
|
1697
1817
|
* Fetch `limit` number of slot leaders starting from `startSlot`
|
|
1698
1818
|
*
|
|
@@ -1717,7 +1837,9 @@ declare module '@solana/web3.js' {
|
|
|
1717
1837
|
/**
|
|
1718
1838
|
* Fetch the current transaction count of the cluster
|
|
1719
1839
|
*/
|
|
1720
|
-
getTransactionCount(
|
|
1840
|
+
getTransactionCount(
|
|
1841
|
+
commitmentOrConfig?: Commitment | GetTransactionCountConfig,
|
|
1842
|
+
): Promise<number>;
|
|
1721
1843
|
/**
|
|
1722
1844
|
* Fetch the current total currency supply of the cluster in lamports
|
|
1723
1845
|
*
|
|
@@ -1734,12 +1856,14 @@ declare module '@solana/web3.js' {
|
|
|
1734
1856
|
getInflationReward(
|
|
1735
1857
|
addresses: PublicKey[],
|
|
1736
1858
|
epoch?: number,
|
|
1737
|
-
|
|
1859
|
+
commitmentOrConfig?: Commitment | GetInflationRewardConfig,
|
|
1738
1860
|
): Promise<(InflationReward | null)[]>;
|
|
1739
1861
|
/**
|
|
1740
1862
|
* Fetch the Epoch Info parameters
|
|
1741
1863
|
*/
|
|
1742
|
-
getEpochInfo(
|
|
1864
|
+
getEpochInfo(
|
|
1865
|
+
commitmentOrConfig?: Commitment | GetEpochInfoConfig,
|
|
1866
|
+
): Promise<EpochInfo>;
|
|
1743
1867
|
/**
|
|
1744
1868
|
* Fetch the Epoch Schedule parameters
|
|
1745
1869
|
*/
|
|
@@ -1805,14 +1929,14 @@ declare module '@solana/web3.js' {
|
|
|
1805
1929
|
* @return {Promise<BlockhashWithExpiryBlockHeight>}
|
|
1806
1930
|
*/
|
|
1807
1931
|
getLatestBlockhash(
|
|
1808
|
-
|
|
1932
|
+
commitmentOrConfig?: Commitment | GetLatestBlockhashConfig,
|
|
1809
1933
|
): Promise<BlockhashWithExpiryBlockHeight>;
|
|
1810
1934
|
/**
|
|
1811
1935
|
* Fetch the latest blockhash from the cluster
|
|
1812
1936
|
* @return {Promise<BlockhashWithExpiryBlockHeight>}
|
|
1813
1937
|
*/
|
|
1814
1938
|
getLatestBlockhashAndContext(
|
|
1815
|
-
|
|
1939
|
+
commitmentOrConfig?: Commitment | GetLatestBlockhashConfig,
|
|
1816
1940
|
): Promise<RpcResponseAndContext<BlockhashWithExpiryBlockHeight>>;
|
|
1817
1941
|
/**
|
|
1818
1942
|
* Fetch the node version
|
|
@@ -1831,7 +1955,9 @@ declare module '@solana/web3.js' {
|
|
|
1831
1955
|
commitment?: Finality;
|
|
1832
1956
|
},
|
|
1833
1957
|
): Promise<BlockResponse | null>;
|
|
1834
|
-
getBlockHeight(
|
|
1958
|
+
getBlockHeight(
|
|
1959
|
+
commitmentOrConfig?: Commitment | GetBlockHeightConfig,
|
|
1960
|
+
): Promise<number>;
|
|
1835
1961
|
getBlockProduction(
|
|
1836
1962
|
configOrCommitment?: GetBlockProductionConfig | Commitment,
|
|
1837
1963
|
): Promise<RpcResponseAndContext<BlockProduction>>;
|
|
@@ -3371,6 +3497,42 @@ declare module '@solana/web3.js' {
|
|
|
3371
3497
|
logs: string[] | undefined;
|
|
3372
3498
|
constructor(message: string, logs?: string[]);
|
|
3373
3499
|
}
|
|
3500
|
+
export const SolanaJSONRPCErrorCode: {
|
|
3501
|
+
readonly JSON_RPC_SERVER_ERROR_BLOCK_CLEANED_UP: -32001;
|
|
3502
|
+
readonly JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE: -32002;
|
|
3503
|
+
readonly JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE: -32003;
|
|
3504
|
+
readonly JSON_RPC_SERVER_ERROR_BLOCK_NOT_AVAILABLE: -32004;
|
|
3505
|
+
readonly JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY: -32005;
|
|
3506
|
+
readonly JSON_RPC_SERVER_ERROR_TRANSACTION_PRECOMPILE_VERIFICATION_FAILURE: -32006;
|
|
3507
|
+
readonly JSON_RPC_SERVER_ERROR_SLOT_SKIPPED: -32007;
|
|
3508
|
+
readonly JSON_RPC_SERVER_ERROR_NO_SNAPSHOT: -32008;
|
|
3509
|
+
readonly JSON_RPC_SERVER_ERROR_LONG_TERM_STORAGE_SLOT_SKIPPED: -32009;
|
|
3510
|
+
readonly JSON_RPC_SERVER_ERROR_KEY_EXCLUDED_FROM_SECONDARY_INDEX: -32010;
|
|
3511
|
+
readonly JSON_RPC_SERVER_ERROR_TRANSACTION_HISTORY_NOT_AVAILABLE: -32011;
|
|
3512
|
+
readonly JSON_RPC_SCAN_ERROR: -32012;
|
|
3513
|
+
readonly JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_LEN_MISMATCH: -32013;
|
|
3514
|
+
readonly JSON_RPC_SERVER_ERROR_BLOCK_STATUS_NOT_AVAILABLE_YET: -32014;
|
|
3515
|
+
readonly JSON_RPC_SERVER_ERROR_UNSUPPORTED_TRANSACTION_VERSION: -32015;
|
|
3516
|
+
readonly JSON_RPC_SERVER_ERROR_MIN_CONTEXT_SLOT_NOT_REACHED: -32016;
|
|
3517
|
+
};
|
|
3518
|
+
export type SolanaJSONRPCErrorCodeEnum =
|
|
3519
|
+
typeof SolanaJSONRPCErrorCode[keyof typeof SolanaJSONRPCErrorCode];
|
|
3520
|
+
export class SolanaJSONRPCError extends Error {
|
|
3521
|
+
code: SolanaJSONRPCErrorCodeEnum | unknown;
|
|
3522
|
+
data?: any;
|
|
3523
|
+
constructor(
|
|
3524
|
+
{
|
|
3525
|
+
code,
|
|
3526
|
+
message,
|
|
3527
|
+
data,
|
|
3528
|
+
}: Readonly<{
|
|
3529
|
+
code: unknown;
|
|
3530
|
+
message: string;
|
|
3531
|
+
data?: any;
|
|
3532
|
+
}>,
|
|
3533
|
+
customMessage?: string,
|
|
3534
|
+
);
|
|
3535
|
+
}
|
|
3374
3536
|
|
|
3375
3537
|
/**
|
|
3376
3538
|
* Sign, send and confirm a transaction.
|