UNPKG

1.93 kBTypeScriptView Raw
1/*
2 This file is part of confluxWeb.
3 confluxWeb is free software: you can redistribute it and/or modify
4 it under the terms of the GNU Lesser General Public License as published by
5 the Free Software Foundation, either version 3 of the License, or
6 (at your option) any later version.
7 confluxWeb is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 GNU Lesser General Public License for more details.
11 You should have received a copy of the GNU Lesser General Public License
12 along with confluxWeb. If not, see <http://www.gnu.org/licenses/>.
13*/
14
15import {Utils} from 'conflux-web-utils';
16import {AbstractConfluxWebModule, PromiEvent} from 'conflux-web-core';
17import {formatters} from 'conflux-web-core-helpers';
18
19export class AbstractMethod {
20 constructor(
21 rpcMethod: string,
22 parametersAmount: number,
23 utils: Utils,
24 formatters: formatters,
25 moduleInstance: AbstractConfluxWebModule
26 );
27
28 utils: Utils;
29 formatters: formatters;
30 promiEvent: PromiEvent<any>;
31 rpcMethod: string;
32 parametersAmount: number;
33 parameters: any[];
34
35 getArguments(): any;
36
37 setArguments(args: any[]): void;
38
39 isHash(parameter: string): boolean;
40
41 hasWallets(): boolean;
42
43 callback(error: string | Error, response: any): void;
44
45 beforeExecution(moduleInstance: AbstractConfluxWebModule): void;
46
47 afterExecution(response: any): any;
48
49 execute(): Promise<any> | PromiEvent<any> | string;
50
51 clearSubscriptions(unsubscribeMethod: string): Promise<boolean | Error>;
52}
53
54export class AbstractMethodFactory {
55 constructor(utils: Utils, formatters: formatters);
56
57 methods: null | object;
58 hasMethod: boolean;
59
60 createMethod(name: string, moduleInstance: AbstractConfluxWebModule): AbstractMethod;
61}