aboutsummaryrefslogtreecommitdiffstats
path: root/packages/web3-typescript-typings/index.d.ts
blob: 18ad5a27f2ed039effbf2d33f95a56050f5baad0 (plain) (blame)
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
declare module 'web3' {

    import * as BigNumber from 'bignumber.js';

    class Web3 {
        public static providers: typeof providers;

        public constructor(provider?: Web3.Provider);

        public version: Web3.VersionApi;
        public eth: Web3.EthApi;
        public personal: Web3.PersonalApi | undefined;

        public setProvider(provider: Web3.Provider): void;
        public currentProvider: Web3.Provider;
        public fromWei(amount: number|BigNumber.BigNumber, unit: string): BigNumber.BigNumber;
        public toWei(amount: number|BigNumber.BigNumber, unit: string): BigNumber.BigNumber;
        public isAddress(address: string): boolean;
        public sha3(value: string, options?: Web3.Sha3Options): string;
    }

    namespace providers {
        class HttpProvider implements Web3.Provider {
            constructor(url?: string);
        }
    }

    namespace Web3 {
        type ContractAbi = Array<AbiDefinition>;

        type AbiDefinition = FunctionDescription|EventDescription;

        interface FunctionDescription {
            type: 'function'|'constructor'|'fallback';
            name?: string;
            inputs: Array<FunctionParameter>;
            outputs?: Array<FunctionParameter>;
            constant?: boolean;
            payable?: boolean;
        }

        interface EventParameter {
            name: string;
            type: string;
            indexed: boolean;
        }

        interface EventDescription {
            type: 'event';
            name: string;
            inputs: Array<EventParameter>;
            anonymous: boolean;
        }

        interface FunctionParameter {
            name: string;
            type: string;
        }

        interface Contract<A> {
            at(address: string): A;
        }

        interface FilterObject {
            fromBlock: number|string;
            toBlock: number|string;
            address: string;
            topics: string[];
        }

        interface SolidityEvent<A> {
            event: string;
            address: string;
            args: A;
        }

        interface FilterResult {
            get(callback: () => void): void;
            watch<A>(callback: (error: string|null, result: SolidityEvent<A>) => void): void;
            stopWatching(callback: () => void): void;
        }

        interface Provider {}

        interface Sha3Options {
            encoding: string;
        }

        interface EthApi {
          coinbase: string;
          defaultAccount: string;
          compile: {
            solidity(sourceString: string, cb?: (err: any, result: any) => void): object,
          };
          blockNumber: number;
          sign(address: string, message: string, callback: (err: Error, signData: string) => void): string;
          getBlock(blockHash: string, callback: (err: Error, blockObj: any) => void): BigNumber.BigNumber;
          getBlockNumber(callback: (err: Error, blockNumber: number) => void): void;
          contract<A>(abi: Web3.ContractAbi): Web3.Contract<A>;
          getBalance(addressHexString: string,
                     callback?: (err: any, result: BigNumber.BigNumber) => void): BigNumber.BigNumber;
          getCode(addressHexString: string,
                  callback?: (err: any, code: string) => void): string;
          filter(value: string|Web3.FilterObject): Web3.FilterResult;
          getAccounts(callback: (err: Error, value: any) => void): string[];
          sendTransaction(txData: any, callback: (err: Error, value: any) => void): void;
          getTransactionReceipt(txHash: string, callback: (err: Error, receipt: any) => void): void;
        }

        interface VersionApi {
          getNetwork(cd: (err: Error, networkId: string) => void): void;
          getNode(cd: (err: Error, nodeVersion: string) => void): void;
        }

        interface PersonalApi {
          listAccounts: string[] | undefined;
          newAccount(password?: string): string;
          unlockAccount(address: string, password?: string, duration?: number): boolean
          lockAccount(address: string): boolean
        }
    }
    /* tslint:disable */
    export = Web3;
    /* tslint:enable */
}