Added a (hacky) way to get TypeScript to support the Contract meta-class functions.

This commit is contained in:
Richard Moore 2018-07-18 16:32:16 -04:00
parent d701995bc0
commit 2aa2a38e37
No known key found for this signature in database
GPG Key ID: 525F70A6FCABC295
2 changed files with 21 additions and 2 deletions

View File

@ -9,7 +9,22 @@ import { hexDataLength, hexDataSlice, isHexString } from '../utils/bytes';
import { defineReadOnly, jsonCopy, shallowCopy } from '../utils/properties';
import { poll } from '../utils/web';
import { BigNumber, EventDescription, EventFilter, Listener, Log, MinimalProvider, ParamType, Signer, TransactionRequest, TransactionResponse } from '../utils/types';
import {
Signer,
MinimalProvider,
BigNumber,
ContractFunction,
EventDescription,
EventFilter,
ParamType,
Listener,
Log,
TransactionRequest,
TransactionResponse
} from '../utils/types';
import * as errors from '../utils/errors';
@ -201,10 +216,12 @@ export class Contract {
readonly provider: MinimalProvider;
readonly estimate: Bucket<(...params: Array<any>) => Promise<BigNumber>>;
readonly functions: Bucket<(...params: Array<any>) => Promise<any>>;
readonly functions: Bucket<ContractFunction>;
readonly filters: Bucket<(...params: Array<any>) => EventFilter>;
readonly [name: string]: ContractFunction | any;
readonly addressPromise: Promise<string>;
// This is only set if the contract was created with a call to deploy

View File

@ -304,6 +304,8 @@ export interface TransactionDescription {
///////////////////////////////
// Contract
export type ContractFunction = (...params: Array<any>) => Promise<any>;
export type EventFilter = {
address?: string;
topics?: Array<string>;