/
globals.d.ts
83 lines (59 loc) · 1.73 KB
/
globals.d.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import 'web3-typed/callback/web3';
import * as Web3 from 'web3';
import {TransactionReceipt, Contract} from 'web3';
import {ParsedLog} from 'web3/parsed';
import {NumberLike} from 'bignumber.js';
type address = string;
type network = string;
interface IContractOptions {
from?: address;
gas?: NumberLike;
gasPrice?: NumberLike;
value?: NumberLike;
}
interface IContract<T> {
'new'(...args: any[]): Promise<T>;
deployed(): Promise<T>;
at(address: address): Promise<T>;
setProvider(provider: Web3.providers.Provider): void;
defaults(opts: IContractOptions): void;
isDeployed(): boolean;
resetAddress(): void;
hasNetwork(networkId: network): boolean;
detectNetwork(): Promise<network | undefined>;
web3: Web3;
currentProvider: Web3.providers.Provider;
synchronization_timeout: number;
network_id: network;
}
interface ITXResult {
tx: string;
receipt: TransactionReceipt;
logs: ParsedLog<string, any>[];
}
interface IParsedLog extends ParsedLog<any, any> {
}
interface ItTestFn {
(name: string, exec: (done: (err: any) => void) => any): any;
only: ItTestFn;
}
interface ISimpleCallable<T> {
call(tr?: Web3.TransactionRequest): Promise<T>;
}
interface IContractInstance {
abi: any[];
address: address;
contract: Contract;
sendTransaction(request: Web3.TransactionRequest): Promise<ITXResult>;
send(value: NumberLike): Promise<ITXResult>;
}
interface IMigrations extends IContractInstance {
lastCompletedMigration(): Promise<number>;
setCompleted(completed: number): Promise<any>;
setCompleted(upgrade: address): Promise<any>;
}
// Define global variables (truffle framework)
declare global {
const contract: (name: string, test: (accounts: string[]) => any) => void;
const web3: Web3;
}