/
interface.ts
46 lines (34 loc) · 1.15 KB
/
interface.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { OperationEntry } from '@taquito/rpc';
export type FilterExpression = {
or?: ExpressionOrOpFilter[];
and?: ExpressionOrOpFilter[];
};
export interface OpHashFilter {
opHash: string;
}
export interface SourceFilter {
source: string;
}
export interface KindFilter {
kind: string;
}
export interface DestinationFilter {
destination: string;
}
export type OpFilter = OpHashFilter | SourceFilter | KindFilter | DestinationFilter;
export type ExpressionOrOpFilter = OpFilter | FilterExpression
export type Filter = ExpressionOrOpFilter | ExpressionOrOpFilter[];
export type OperationContent = OperationEntry['contents'][0] & {hash: string};
export interface SubscribeProvider {
subscribe(filter: 'head'): Subscription<string>;
subscribeOperation(filter: Filter): Subscription<OperationContent>;
}
export interface Subscription<T> {
on(type: 'error', cb: (error: Error) => void): void;
on(type: 'data', cb: (data: T) => void): void;
on(type: 'close', cb: () => void): void;
off(type: 'error', cb: (error: Error) => void): void;
off(type: 'data', cb: (data: T) => void): void;
off(type: 'close', cb: () => void): void;
close(): void;
}