/*
This file is part of confluxWeb.
confluxWeb is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
confluxWeb is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with confluxWeb. If not, see .
*/
import BN = require('bn.js');
import {provider} from 'conflux-web-providers';
import {AbiInput, AbiOutput, AbiItem} from 'conflux-web-utils';
import {PromiEvent} from 'conflux-web-core';
export class Contract {
constructor(
provider: provider,
abi: AbiItem[],
address?: string,
options?: ContractOptions
)
address: string;
jsonInterface: AbiModel;
options: Options;
clone(): Contract;
deploy(options: DeployOptions): ContractSendMethod;
methods: any;
once(event: string, callback: (error: Error, event: EventData) => void): void;
once(event: string, options: EventOptions, callback: (error: Error, event: EventData) => void): void;
events: any;
getPastEvents(event: string): Promise;
getPastEvents(event: string, options: EventOptions, callback: (error: Error, event: EventData) => void): Promise;
getPastEvents(event: string, options: EventOptions): Promise;
getPastEvents(event: string, callback: (error: Error, event: EventData) => void): Promise;
}
export class ContractModuleFactory {
} // TODO: Define methods
export interface Options {
address: string;
data: string;
}
export interface DeployOptions {
data: string;
arguments?: any[];
}
export interface ContractSendMethod {
send(options: SendOptions, callback?: (err: Error, contracts: Contract) => void): PromiEvent;
estimateGas(options: EstimateGasOptions, callback?: (err: Error, gas: number) => void): Promise;
estimateGas(callback: (err: Error, gas: number) => void): Promise;
estimateGas(options: EstimateGasOptions, callback: (err: Error, gas: number) => void): Promise;
estimateGas(options: EstimateGasOptions): Promise;
estimateGas(): Promise;
encodeABI(): string;
}
export interface SendOptions {
from: string;
gasPrice?: string;
gas?: number;
value?: number | string | BN;
}
export interface EstimateGasOptions {
from?: string;
gas?: number;
value?: number | string | BN;
}
export interface ContractOptions {
from: string;
gasPrice: string;
gas: number;
data: string;
}
export interface EventOptions {
filter?: {};
fromBlock?: number;
toBlock?: string | number;
topics?: any[];
}
export interface EventData {
returnValues: {
[key: string]: any;
},
raw: {
data: string;
topics: string[];
},
event: string;
signature: string;
logIndex: number;
transactionIndex: number;
transactionHash: string;
blockHash: string;
blockNumber: number;
address: string;
}
export interface AbiModel {
getMethod(name: string): AbiItemModel | false;
getMethods(): AbiItemModel[];
hasMethod(name: string): boolean;
getEvent(name: string): AbiItemModel | false;
getEvents(): AbiItemModel[];
getEventBySignature(signature: string): AbiItemModel;
hasEvent(name: string): boolean;
}
export interface AbiItemModel {
signature: string;
name: string;
payable: boolean;
anonymous: boolean;
getInputLength(): number;
getInputs(): AbiInput[];
getIndexedInputs(): AbiInput[];
getOutputs(): AbiOutput[];
isOfType(): boolean;
}