import { RequestManager } from './RequestManager' ; import { SolidityFunction } from './SolidityFunction' ; import { SolidityEvent } from './SolidityEvent' ; import { AllSolidityEvents } from './AllSolidityEvents' ; import { EthFilter } from './Filter' ; import { AbiEvent , AbiFunction , AbiItem , FilterOptions } from './Schema' ; param contract function addFunctionsToContract ( contract ) { contract . abi . filter ( function ( json ) : json is AbiFunction { return json . type === 'function' ; } ) . map ( function ( json ) { return new SolidityFunction ( json ) ; } ) . forEach ( function ( f ) { f . attachToContract ( contract ) ; } ) ; } param contract function addEventsToContract ( contract ) { let events = contract . abi . filter ( function ( json ) : json is AbiEvent { return json . type === 'event' ; } ) ; let allEvents = new AllSolidityEvents ( contract . requestManager , events , contract . address ) ; events . map ( function ( json ) { return new SolidityEvent ( contract . requestManager , json , contract . address ) ; } ) . forEach ( function ( e ) { e . attachToContract ( contract ) ; } ) ; return allEvents . getAllEventsFunction ( ) ; } public export type EventFilterCreator = ( indexed : { [ key ] : any ; } , options ? : FilterOptions ) => Promise < EthFilter > ; public export class Contract { allEvents : ( options : FilterOptions ) => Promise < EthFilter > ; events : { [ key ] : EventFilterCreator ; } = { } ; transactionHash : string | null = null ; constructor ( public requestManager , public abi , public address ) { this . address = address ; this . abi = abi ; addFunctionsToContract ( this ) ; this . allEvents = addEventsToContract ( this ) ; } }