UNPKG

2.04 kBTypeScriptView Raw
1declare module "ganache-core" {
2 import { Server as HttpServer } from "http";
3 export interface JsonRpcPayload {
4 jsonrpc: string;
5 method: string;
6 params: any[];
7 id?: string | number;
8 }
9
10 export interface JsonRpcResponse {
11 jsonrpc: string;
12 id: number;
13 result?: any;
14 error?: string;
15 }
16
17 namespace Ganache {
18 export interface IProviderOptions {
19 account_keys_path?: string;
20 accounts?: object[];
21 allowUnlimitedContractSize?: boolean;
22 blockTime?: number;
23 db_path?: string;
24 debug?: boolean;
25 default_balance_ether?: number;
26 fork?: string | object;
27 fork_block_number?: string | number;
28 forkCacheSize?: number;
29 gasLimit?: string | number;
30 gasPrice?: string;
31 hardfork?: "byzantium" | "constantinople" | "petersburg" | "istanbul" | "muirGlacier";
32 hd_path?: string;
33 locked?: boolean;
34 logger?: {
35 log(msg: string): void;
36 };
37 mnemonic?: string;
38 network_id?: number;
39 networkId?: number;
40 port?: number;
41 seed?: any;
42 time?: Date;
43 total_accounts?: number;
44 unlocked_accounts?: string[];
45 verbose?: boolean;
46 vmErrorsOnRPCResponse?: boolean;
47 ws?: boolean;
48 }
49
50 export interface IServerOptions extends IProviderOptions {
51 keepAliveTimeout?: number;
52 }
53
54 export function provider(opts?: IProviderOptions): Provider;
55 export function server(opts?: IServerOptions): Server;
56
57 export interface Server extends HttpServer {
58 provider: Provider
59 }
60
61 export interface Provider {
62 send(
63 payload: JsonRpcPayload,
64 callback: (error: Error | null, result?: JsonRpcResponse) => void
65 ): void;
66
67 on(type: string, callback: () => void): void;
68
69 once(type: string, callback: () => void): void;
70
71 removeListener(type: string, callback: () => void): void;
72
73 removeAllListeners(type: string): void;
74
75 close: (callback: Function) => void;
76 }
77 }
78 export default Ganache;
79}