-
Notifications
You must be signed in to change notification settings - Fork 9
/
index.d.ts
96 lines (78 loc) · 2.33 KB
/
index.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
84
85
86
87
88
89
90
91
92
93
94
95
96
/**
* Globals
*/
/// <reference types="chai" />
/// <reference types="mocha" />
declare type BN = import("bn.js");
declare type Web3 = import("web3");
declare const assert: Chai.AssertStatic;
declare const expect: Chai.ExpectStatic;
declare const web3: Web3;
declare const artifacts: Truffle.Artifacts;
/**
* Global contract function
*/
interface ContractFunction extends Mocha.SuiteFunction {
(title: string, fn: (this: Mocha.Suite, accounts: Truffle.Accounts) => void): Mocha.Suite;
only: ExclusiveContractFunction;
skip: PendingContractFunction;
}
interface ExclusiveContractFunction extends Mocha.ExclusiveSuiteFunction {
(title: string, fn: (this: Mocha.Suite, accounts: Truffle.Accounts) => void): Mocha.Suite;
}
interface PendingContractFunction extends Mocha.PendingSuiteFunction {
(title: string, fn: (this: Mocha.Suite, accounts: Truffle.Accounts) => void): Mocha.Suite | void;
}
declare const contract: ContractFunction;
/**
* Namespace
*/
declare namespace Truffle {
type Accounts = string[];
interface TransactionDetails {
from?: string;
gas?: BN | number | string;
gasPrice?: BN | number | string;
value?: BN | string;
}
export interface TransactionLog {
address: string;
args: any;
blockHash: string;
blockNumber: number;
event: string;
logIndex: number;
transactionHash: string;
transactionIndex: number;
type: string;
}
export interface TransactionResponse {
tx: string;
receipt: any;
logs: TransactionLog[];
}
interface Contract<T> extends ContractNew<any[]> {
deployed(): Promise<T>;
at(address: string): T;
address: string;
contractName: string;
}
interface ContractInstance {
address: string;
contract: any;
transactionHash: string;
}
interface ContractNew<ARGs extends any[]> {
"new"(...args: ARGs): any;
}
interface Deployer {
link(library: Truffle.Contract<any>, destination: Truffle.Contract<any>): Deployer;
link(library: Truffle.Contract<any>, destinations: Array<Truffle.Contract<any>>): Deployer;
deploy<T extends any[]>(c: ContractNew<T>, ...args: T): Deployer;
}
type Migration = (deploy: Deployer, network: string, accounts: Accounts) => void;
// Wanna exact typings for your smartcontracts? Use typechain
interface Artifacts {
require<T = any>(name: string): T;
}
}