UNPKG

1.7 kBTypeScriptView Raw
1import { Callback, EventLog, EventEmitter } from "../types";
2import { TransactionObject, BlockType } from "./types";
3import { ABIDefinition } from "./abi";
4import { Provider } from "../providers";
5
6interface CustomOptions {
7 address?: string;
8 jsonInterface?: ABIDefinition[];
9 data?: string;
10 from?: string;
11 gasPrice?: string;
12 gas?: number;
13}
14
15interface contractOptions {
16 address: string;
17 jsonInterface: ABIDefinition[];
18 data: string;
19 from: string;
20 gasPrice: string;
21 gas: number;
22}
23
24export default class Contract {
25 constructor(
26 jsonInterface: any[],
27 address?: string,
28 options?: CustomOptions
29 );
30 options: contractOptions;
31 methods: {
32 [fnName: string]: (...args: any[]) => TransactionObject<any>;
33 };
34 deploy(options: {
35 data: string;
36 arguments: any[];
37 }): TransactionObject<Contract>;
38 events: {
39 [eventName: string]: (
40 options?: {
41 filter?: object;
42 fromBlock?: BlockType;
43 topics?: string[];
44 },
45 cb?: Callback<EventLog>
46 ) => EventEmitter;
47 allEvents: (
48 options?: {
49 filter?: object;
50 fromBlock?: BlockType;
51 topics?: string[];
52 },
53 cb?: Callback<EventLog>
54 ) => EventEmitter;
55 };
56 getPastEvents(
57 event: string,
58 options?: {
59 filter?: object;
60 fromBlock?: BlockType;
61 toBlock?: BlockType;
62 topics?: string[];
63 },
64 cb?: Callback<EventLog[]>
65 ): Promise<EventLog[]>;
66 setProvider(provider: Provider): void;
67}