UNPKG

2.34 kBTypeScriptView Raw
1export type Callback<T> = (error: Error, result: T) => void;
2
3export interface EventEmitter {
4 on(type: "data", handler: (event: EventLog) => void): EventEmitter;
5 on(type: "changed", handler: (receipt: EventLog) => void): EventEmitter;
6 on(type: "error", handler: (error: Error) => void): EventEmitter;
7 on(
8 type: "error" | "data" | "changed",
9 handler: (error: Error | TransactionReceipt | string) => void
10 ): EventEmitter;
11}
12
13export interface EventLog {
14 event: string;
15 address: string;
16 returnValues: any;
17 logIndex: number;
18 transactionIndex: number;
19 transactionHash: string;
20 blockHash: string;
21 blockNumber: number;
22 raw?: { data: string; topics: string[] };
23}
24
25export interface TransactionReceipt {
26 transactionHash: string;
27 transactionIndex: number;
28 blockHash: string;
29 blockNumber: number;
30 from: string;
31 to: string;
32 contractAddress: string;
33 cumulativeGasUsed: number;
34 gasUsed: number;
35 logs?: Log[];
36 events?: {
37 [eventName: string]: EventLog;
38 };
39 status: string;
40}
41
42export interface EncodedTransaction {
43 raw: string;
44 tx: {
45 nonce: string;
46 gasPrice: string;
47 gas: string;
48 to: string;
49 value: string;
50 input: string;
51 v: string;
52 r: string;
53 s: string;
54 hash: string;
55 };
56}
57
58export interface Logs {
59 fromBlock?: number;
60 address?: string;
61 topics?: Array<string | string[]>;
62}
63export interface Log {
64 address: string;
65 data: string;
66 topics: string[];
67 logIndex: number;
68 transactionHash: string;
69 transactionIndex: number;
70 blockHash: string;
71 blockNumber: number;
72}
73export interface Subscribe<T> {
74 subscription: {
75 id: string;
76 subscribe(callback?: Callback<Subscribe<T>>): Subscribe<T>;
77 unsubscribe(callback?: Callback<boolean>): void | boolean;
78 arguments: object;
79 };
80 on(type: "data" | "changed", handler: (data: T) => void): void;
81 on(type: "error", handler: (data: Error) => void): void;
82}
83
84export interface Shh {
85 generateSymKeyFromPassword(password: string): Promise<string>;
86 generateSymKeyFromPassword(
87 password: string,
88 callback: Callback<string>
89 ): void;
90 // TODO: type every method
91}
92export class Bzz {} // TODO: Type