Skip to content

Commit e3f892d

Browse files
committed
Type definition for two simple RPC methods: getBlockHeight and getBlocks
1 parent 0bc8528 commit e3f892d

File tree

4 files changed

+48
-0
lines changed

4 files changed

+48
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { GetBlockHeightApi } from './rpc-methods/getBlockHeight';
2+
import { GetBlocksApi } from './rpc-methods/getBlocks';
3+
4+
declare interface JsonRpcApi extends GetBlockHeightApi, GetBlocksApi {}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// TODO: Eventually move this into whatever package implements transactions
2+
declare type Finality = 'confirmed' | 'finalized' | 'processed';
3+
4+
declare type Slot =
5+
// TODO(solana-labs/solana/issues/30341) Represent as bigint
6+
number;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { IJsonRpcTransport } from '@solana/rpc-transport';
2+
3+
type GetBlockHeightApiResponse =
4+
// TODO(solana-labs/solana/issues/30341) Represent as bigint
5+
number;
6+
7+
declare interface GetBlockHeightApi {
8+
/**
9+
* Returns the current block height of the node
10+
*/
11+
getBlockHeight(
12+
transport: IJsonRpcTransport,
13+
config?: readonly {
14+
// Defaults to `finalized`
15+
commitment?: Finality;
16+
// The minimum slot that the request can be evaluated at
17+
minContextSlot?: Slot;
18+
}
19+
): Promise<GetBlockHeightApiResponse>;
20+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { IJsonRpcTransport } from '@solana/rpc-transport';
2+
3+
type GetBlocksApiResponse = Slot[];
4+
5+
declare interface GetBlocksApi {
6+
/**
7+
* Returns a list of confirmed blocks between two slots
8+
*/
9+
getBlocks(
10+
transport: IJsonRpcTransport,
11+
startSlot: Slot,
12+
endSlotInclusive?: Slot,
13+
config?: readonly {
14+
// Defaults to `finalized`
15+
commitment?: Exclude<Finality, 'processed'>;
16+
}
17+
): Promise<GetBlocksApiResponse>;
18+
}

0 commit comments

Comments
 (0)