feat: add root and single commitment levels
This commit is contained in:
parent
1e1c9de367
commit
3b71ec1ff6
2
web3.js/module.d.ts
vendored
2
web3.js/module.d.ts
vendored
@ -46,7 +46,7 @@ declare module '@solana/web3.js' {
|
||||
value: T;
|
||||
};
|
||||
|
||||
export type Commitment = 'max' | 'recent';
|
||||
export type Commitment = 'max' | 'recent' | 'root' | 'single';
|
||||
|
||||
export type SignatureStatusConfig = {
|
||||
searchTransactionHistory: boolean;
|
||||
|
@ -59,7 +59,7 @@ declare module '@solana/web3.js' {
|
||||
value: T,
|
||||
};
|
||||
|
||||
declare export type Commitment = 'max' | 'recent';
|
||||
declare export type Commitment = 'max' | 'recent' | 'root' | 'single';
|
||||
|
||||
declare export type SignatureStatusConfig = {
|
||||
searchTransactionHistory: boolean,
|
||||
|
@ -89,12 +89,16 @@ function notificationResultAndContext(resultDescription: any) {
|
||||
|
||||
/**
|
||||
* The level of commitment desired when querying state
|
||||
* 'max': Query the most recent block which has reached max voter lockout
|
||||
* 'recent': Query the most recent block
|
||||
* <pre>
|
||||
* 'max': Query the most recent block which has been finalized by the cluster
|
||||
* 'recent': Query the most recent block which has reached 1 confirmation by the connected node
|
||||
* 'root': Query the most recent block which has been rooted by the connected node
|
||||
* 'single': Query the most recent block which has reached 1 confirmation by the cluster
|
||||
* </pre>
|
||||
*
|
||||
* @typedef {'max' | 'recent'} Commitment
|
||||
* @typedef {'max' | 'recent' | 'root' | 'single'} Commitment
|
||||
*/
|
||||
export type Commitment = 'max' | 'recent';
|
||||
export type Commitment = 'max' | 'recent' | 'root' | 'single';
|
||||
|
||||
/**
|
||||
* Configuration object for changing query behavior
|
||||
|
@ -1031,12 +1031,15 @@ test('get confirmed block', async () => {
|
||||
|
||||
test('get recent blockhash', async () => {
|
||||
const connection = new Connection(url);
|
||||
for (const commitment of ['max', 'recent', 'root', 'single']) {
|
||||
mockGetRecentBlockhash(commitment);
|
||||
|
||||
mockGetRecentBlockhash();
|
||||
|
||||
const {blockhash, feeCalculator} = await connection.getRecentBlockhash();
|
||||
expect(blockhash.length).toBeGreaterThanOrEqual(43);
|
||||
expect(feeCalculator.lamportsPerSignature).toBeGreaterThanOrEqual(0);
|
||||
const {blockhash, feeCalculator} = await connection.getRecentBlockhash(
|
||||
commitment,
|
||||
);
|
||||
expect(blockhash.length).toBeGreaterThanOrEqual(43);
|
||||
expect(feeCalculator.lamportsPerSignature).toBeGreaterThanOrEqual(0);
|
||||
}
|
||||
});
|
||||
|
||||
test('get block time', async () => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user