@apibara/protocol 2.1.0-beta.41 → 2.1.0-beta.42

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.
@@ -0,0 +1,102 @@
1
+ import { C as Cursor, B as Bytes, w as Client, S as StatusRequest, u as ClientCallOptions, f as StatusResponse, l as StreamDataRequest, v as StreamDataOptions, r as StreamDataResponse } from './protocol.8fb09325.js';
2
+
3
+ type FetchBlockRangeArgs<TFilter> = {
4
+ startBlock: bigint;
5
+ finalizedBlock: bigint;
6
+ filter: TFilter;
7
+ };
8
+ type FetchBlockRangeResult<TBlock> = {
9
+ startBlock: bigint;
10
+ endBlock: bigint;
11
+ data: FetchBlockResult<TBlock>[];
12
+ };
13
+ type FetchBlockResult<TBlock> = {
14
+ block: TBlock | null;
15
+ cursor: Cursor | undefined;
16
+ endCursor: Cursor;
17
+ };
18
+ type BlockInfo = {
19
+ blockNumber: bigint;
20
+ blockHash: Bytes;
21
+ parentBlockHash: Bytes;
22
+ };
23
+ type FetchBlockByNumberArgs<TFilter> = {
24
+ blockNumber: bigint;
25
+ expectedParentBlockHash: Bytes;
26
+ filter: TFilter;
27
+ };
28
+ type FetchBlockByNumberResult<TBlock> = {
29
+ status: "success";
30
+ data: FetchBlockResult<TBlock>;
31
+ blockInfo: BlockInfo;
32
+ } | {
33
+ status: "reorg";
34
+ blockInfo: BlockInfo;
35
+ };
36
+ type FetchCursorArgs = {
37
+ blockTag: "latest" | "finalized";
38
+ blockNumber?: undefined;
39
+ blockHash?: undefined;
40
+ } | {
41
+ blockTag?: undefined;
42
+ blockNumber: bigint;
43
+ blockHash?: undefined;
44
+ } | {
45
+ blockTag?: undefined;
46
+ blockNumber?: undefined;
47
+ blockHash: Bytes;
48
+ };
49
+ type ValidateFilterResult = {
50
+ valid: true;
51
+ error?: undefined;
52
+ } | {
53
+ valid: false;
54
+ error: string;
55
+ };
56
+ declare abstract class RpcStreamConfig<TFilter, TBlock> {
57
+ abstract headRefreshIntervalMs(): number;
58
+ abstract finalizedRefreshIntervalMs(): number;
59
+ abstract fetchCursor(args: FetchCursorArgs): Promise<BlockInfo | null>;
60
+ abstract validateFilter(filter: TFilter): ValidateFilterResult;
61
+ abstract fetchBlockRange(args: FetchBlockRangeArgs<TFilter>): Promise<FetchBlockRangeResult<TBlock>>;
62
+ abstract fetchBlockByNumber(args: FetchBlockByNumberArgs<TFilter>): Promise<FetchBlockByNumberResult<TBlock>>;
63
+ }
64
+
65
+ declare class RpcClient<TFilter, TBlock> implements Client<TFilter, TBlock> {
66
+ private config;
67
+ constructor(config: RpcStreamConfig<TFilter, TBlock>);
68
+ status(_request?: StatusRequest, _options?: ClientCallOptions): Promise<StatusResponse>;
69
+ streamData(request: StreamDataRequest<TFilter>, options?: StreamDataOptions): AsyncIterable<StreamDataResponse<TBlock>>;
70
+ }
71
+ declare function createRpcClient<TFilter, TBlock>(config: RpcStreamConfig<TFilter, TBlock>): RpcClient<TFilter, TBlock>;
72
+
73
+ declare class RpcDataStream<TFilter, TBlock> {
74
+ private config;
75
+ private request;
76
+ private options?;
77
+ private heartbeatIntervalMs;
78
+ constructor(config: RpcStreamConfig<TFilter, TBlock>, request: StreamDataRequest<TFilter>, options?: StreamDataOptions | undefined);
79
+ [Symbol.asyncIterator](): AsyncIterator<StreamDataResponse<TBlock>>;
80
+ private initialize;
81
+ }
82
+
83
+ type index_BlockInfo = BlockInfo;
84
+ type index_FetchBlockByNumberArgs<TFilter> = FetchBlockByNumberArgs<TFilter>;
85
+ type index_FetchBlockByNumberResult<TBlock> = FetchBlockByNumberResult<TBlock>;
86
+ type index_FetchBlockRangeArgs<TFilter> = FetchBlockRangeArgs<TFilter>;
87
+ type index_FetchBlockRangeResult<TBlock> = FetchBlockRangeResult<TBlock>;
88
+ type index_FetchBlockResult<TBlock> = FetchBlockResult<TBlock>;
89
+ type index_FetchCursorArgs = FetchCursorArgs;
90
+ type index_RpcClient<TFilter, TBlock> = RpcClient<TFilter, TBlock>;
91
+ declare const index_RpcClient: typeof RpcClient;
92
+ type index_RpcDataStream<TFilter, TBlock> = RpcDataStream<TFilter, TBlock>;
93
+ declare const index_RpcDataStream: typeof RpcDataStream;
94
+ type index_RpcStreamConfig<TFilter, TBlock> = RpcStreamConfig<TFilter, TBlock>;
95
+ declare const index_RpcStreamConfig: typeof RpcStreamConfig;
96
+ type index_ValidateFilterResult = ValidateFilterResult;
97
+ declare const index_createRpcClient: typeof createRpcClient;
98
+ declare namespace index {
99
+ export { type index_BlockInfo as BlockInfo, type index_FetchBlockByNumberArgs as FetchBlockByNumberArgs, type index_FetchBlockByNumberResult as FetchBlockByNumberResult, type index_FetchBlockRangeArgs as FetchBlockRangeArgs, type index_FetchBlockRangeResult as FetchBlockRangeResult, type index_FetchBlockResult as FetchBlockResult, type index_FetchCursorArgs as FetchCursorArgs, index_RpcClient as RpcClient, index_RpcDataStream as RpcDataStream, index_RpcStreamConfig as RpcStreamConfig, type index_ValidateFilterResult as ValidateFilterResult, index_createRpcClient as createRpcClient };
100
+ }
101
+
102
+ export { type BlockInfo as B, type FetchBlockRangeArgs as F, RpcStreamConfig as R, type ValidateFilterResult as V, type FetchBlockResult as a, type FetchBlockRangeResult as b, type FetchBlockByNumberArgs as c, type FetchBlockByNumberResult as d, type FetchCursorArgs as e, RpcClient as f, createRpcClient as g, RpcDataStream as h, index as i };
@@ -0,0 +1,102 @@
1
+ import { C as Cursor, B as Bytes, w as Client, S as StatusRequest, u as ClientCallOptions, f as StatusResponse, l as StreamDataRequest, v as StreamDataOptions, r as StreamDataResponse } from './protocol.0e734e33.cjs';
2
+
3
+ type FetchBlockRangeArgs<TFilter> = {
4
+ startBlock: bigint;
5
+ finalizedBlock: bigint;
6
+ filter: TFilter;
7
+ };
8
+ type FetchBlockRangeResult<TBlock> = {
9
+ startBlock: bigint;
10
+ endBlock: bigint;
11
+ data: FetchBlockResult<TBlock>[];
12
+ };
13
+ type FetchBlockResult<TBlock> = {
14
+ block: TBlock | null;
15
+ cursor: Cursor | undefined;
16
+ endCursor: Cursor;
17
+ };
18
+ type BlockInfo = {
19
+ blockNumber: bigint;
20
+ blockHash: Bytes;
21
+ parentBlockHash: Bytes;
22
+ };
23
+ type FetchBlockByNumberArgs<TFilter> = {
24
+ blockNumber: bigint;
25
+ expectedParentBlockHash: Bytes;
26
+ filter: TFilter;
27
+ };
28
+ type FetchBlockByNumberResult<TBlock> = {
29
+ status: "success";
30
+ data: FetchBlockResult<TBlock>;
31
+ blockInfo: BlockInfo;
32
+ } | {
33
+ status: "reorg";
34
+ blockInfo: BlockInfo;
35
+ };
36
+ type FetchCursorArgs = {
37
+ blockTag: "latest" | "finalized";
38
+ blockNumber?: undefined;
39
+ blockHash?: undefined;
40
+ } | {
41
+ blockTag?: undefined;
42
+ blockNumber: bigint;
43
+ blockHash?: undefined;
44
+ } | {
45
+ blockTag?: undefined;
46
+ blockNumber?: undefined;
47
+ blockHash: Bytes;
48
+ };
49
+ type ValidateFilterResult = {
50
+ valid: true;
51
+ error?: undefined;
52
+ } | {
53
+ valid: false;
54
+ error: string;
55
+ };
56
+ declare abstract class RpcStreamConfig<TFilter, TBlock> {
57
+ abstract headRefreshIntervalMs(): number;
58
+ abstract finalizedRefreshIntervalMs(): number;
59
+ abstract fetchCursor(args: FetchCursorArgs): Promise<BlockInfo | null>;
60
+ abstract validateFilter(filter: TFilter): ValidateFilterResult;
61
+ abstract fetchBlockRange(args: FetchBlockRangeArgs<TFilter>): Promise<FetchBlockRangeResult<TBlock>>;
62
+ abstract fetchBlockByNumber(args: FetchBlockByNumberArgs<TFilter>): Promise<FetchBlockByNumberResult<TBlock>>;
63
+ }
64
+
65
+ declare class RpcClient<TFilter, TBlock> implements Client<TFilter, TBlock> {
66
+ private config;
67
+ constructor(config: RpcStreamConfig<TFilter, TBlock>);
68
+ status(_request?: StatusRequest, _options?: ClientCallOptions): Promise<StatusResponse>;
69
+ streamData(request: StreamDataRequest<TFilter>, options?: StreamDataOptions): AsyncIterable<StreamDataResponse<TBlock>>;
70
+ }
71
+ declare function createRpcClient<TFilter, TBlock>(config: RpcStreamConfig<TFilter, TBlock>): RpcClient<TFilter, TBlock>;
72
+
73
+ declare class RpcDataStream<TFilter, TBlock> {
74
+ private config;
75
+ private request;
76
+ private options?;
77
+ private heartbeatIntervalMs;
78
+ constructor(config: RpcStreamConfig<TFilter, TBlock>, request: StreamDataRequest<TFilter>, options?: StreamDataOptions | undefined);
79
+ [Symbol.asyncIterator](): AsyncIterator<StreamDataResponse<TBlock>>;
80
+ private initialize;
81
+ }
82
+
83
+ type index_BlockInfo = BlockInfo;
84
+ type index_FetchBlockByNumberArgs<TFilter> = FetchBlockByNumberArgs<TFilter>;
85
+ type index_FetchBlockByNumberResult<TBlock> = FetchBlockByNumberResult<TBlock>;
86
+ type index_FetchBlockRangeArgs<TFilter> = FetchBlockRangeArgs<TFilter>;
87
+ type index_FetchBlockRangeResult<TBlock> = FetchBlockRangeResult<TBlock>;
88
+ type index_FetchBlockResult<TBlock> = FetchBlockResult<TBlock>;
89
+ type index_FetchCursorArgs = FetchCursorArgs;
90
+ type index_RpcClient<TFilter, TBlock> = RpcClient<TFilter, TBlock>;
91
+ declare const index_RpcClient: typeof RpcClient;
92
+ type index_RpcDataStream<TFilter, TBlock> = RpcDataStream<TFilter, TBlock>;
93
+ declare const index_RpcDataStream: typeof RpcDataStream;
94
+ type index_RpcStreamConfig<TFilter, TBlock> = RpcStreamConfig<TFilter, TBlock>;
95
+ declare const index_RpcStreamConfig: typeof RpcStreamConfig;
96
+ type index_ValidateFilterResult = ValidateFilterResult;
97
+ declare const index_createRpcClient: typeof createRpcClient;
98
+ declare namespace index {
99
+ export { type index_BlockInfo as BlockInfo, type index_FetchBlockByNumberArgs as FetchBlockByNumberArgs, type index_FetchBlockByNumberResult as FetchBlockByNumberResult, type index_FetchBlockRangeArgs as FetchBlockRangeArgs, type index_FetchBlockRangeResult as FetchBlockRangeResult, type index_FetchBlockResult as FetchBlockResult, type index_FetchCursorArgs as FetchCursorArgs, index_RpcClient as RpcClient, index_RpcDataStream as RpcDataStream, index_RpcStreamConfig as RpcStreamConfig, type index_ValidateFilterResult as ValidateFilterResult, index_createRpcClient as createRpcClient };
100
+ }
101
+
102
+ export { type BlockInfo as B, type FetchBlockRangeArgs as F, RpcStreamConfig as R, type ValidateFilterResult as V, type FetchBlockResult as a, type FetchBlockRangeResult as b, type FetchBlockByNumberArgs as c, type FetchBlockByNumberResult as d, type FetchCursorArgs as e, RpcClient as f, createRpcClient as g, RpcDataStream as h, index as i };