aboutsummaryrefslogtreecommitdiffstats
path: root/packages/web3-typescript-typings/index.d.ts
blob: bcb5dc575b4b519baab176d2f12fd69a628bfe4b (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
declare module 'web3' {

    import * as BigNumber from 'bignumber.js';

    class Web3 {
        public static providers: typeof providers;

        public version: {
            getNetwork(): number;
            getNode(): string;
        };

        public eth: {
            coinbase: string;
            defaultAccount: string;
            compile: {
                solidity(sourceString: string, cb?: (err: any, result: any) => void): object,
            }
            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(abi: AbiDefinition[]): Contract;
            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|FilterObject): 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;
        };

        public setProvider(provider: providers.Provider): void;
        public currentProvider(): any;
        public fromWei(amount: BigNumber.BigNumber, unit: string): BigNumber.BigNumber;
        public toWei(amount: BigNumber.BigNumber, unit: string): BigNumber.BigNumber;
        public isAddress(address: string): boolean;
    }

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

    interface AbiDefinition {
        constants: boolean;
        inputs: AbiIOParameter[];
        name: string;
        outputs: AbiIOParameter[];
        type: string;
    }

    interface Contract {}

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

    interface FilterResult {
        get(callback: () => void): void;
        watch(callback: () => void): void;
        stopWatching(): void;
    }

    namespace providers {
        interface Provider {}

        class HttpProvider implements Provider {
            constructor(url?: string);
        }
    }

    namespace Web3 {} // Empty module so the class is exportable as a module
    export = Web3;
}