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