Rename ZeroExEvent to EventEmitter
This commit is contained in:
		@@ -14,12 +14,11 @@ import {
 | 
				
			|||||||
    SignedOrder,
 | 
					    SignedOrder,
 | 
				
			||||||
    ContractEvent,
 | 
					    ContractEvent,
 | 
				
			||||||
    ExchangeEvents,
 | 
					    ExchangeEvents,
 | 
				
			||||||
    ZeroExEvent,
 | 
					    EventEmitter,
 | 
				
			||||||
    SubscriptionOpts,
 | 
					    SubscriptionOpts,
 | 
				
			||||||
    IndexFilterValues,
 | 
					    IndexFilterValues,
 | 
				
			||||||
    CreateContractEvent,
 | 
					    CreateContractEvent,
 | 
				
			||||||
    ContractEventObj,
 | 
					    ContractEventObj,
 | 
				
			||||||
    EventCallback,
 | 
					 | 
				
			||||||
    ContractResponse,
 | 
					    ContractResponse,
 | 
				
			||||||
    OrderCancellationRequest,
 | 
					    OrderCancellationRequest,
 | 
				
			||||||
    OrderFillRequest,
 | 
					    OrderFillRequest,
 | 
				
			||||||
@@ -48,7 +47,7 @@ export class ExchangeWrapper extends ContractWrapper {
 | 
				
			|||||||
        [ExchangeContractErrCodes.ERROR_FILL_BALANCE_ALLOWANCE]: ExchangeContractErrs.FILL_BALANCE_ALLOWANCE_ERROR,
 | 
					        [ExchangeContractErrCodes.ERROR_FILL_BALANCE_ALLOWANCE]: ExchangeContractErrs.FILL_BALANCE_ALLOWANCE_ERROR,
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
    private _exchangeContractIfExists?: ExchangeContract;
 | 
					    private _exchangeContractIfExists?: ExchangeContract;
 | 
				
			||||||
    private _exchangeLogEventObjs: ZeroExEvent[];
 | 
					    private _exchangeLogEventEmitters: EventEmitter[];
 | 
				
			||||||
    private _tokenWrapper: TokenWrapper;
 | 
					    private _tokenWrapper: TokenWrapper;
 | 
				
			||||||
    private static _getOrderAddressesAndValues(order: Order): [OrderAddresses, OrderValues] {
 | 
					    private static _getOrderAddressesAndValues(order: Order): [OrderAddresses, OrderValues] {
 | 
				
			||||||
        const orderAddresses: OrderAddresses = [
 | 
					        const orderAddresses: OrderAddresses = [
 | 
				
			||||||
@@ -71,7 +70,7 @@ export class ExchangeWrapper extends ContractWrapper {
 | 
				
			|||||||
    constructor(web3Wrapper: Web3Wrapper, tokenWrapper: TokenWrapper) {
 | 
					    constructor(web3Wrapper: Web3Wrapper, tokenWrapper: TokenWrapper) {
 | 
				
			||||||
        super(web3Wrapper);
 | 
					        super(web3Wrapper);
 | 
				
			||||||
        this._tokenWrapper = tokenWrapper;
 | 
					        this._tokenWrapper = tokenWrapper;
 | 
				
			||||||
        this._exchangeLogEventObjs = [];
 | 
					        this._exchangeLogEventEmitters = [];
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    public async invalidateContractInstanceAsync(): Promise<void> {
 | 
					    public async invalidateContractInstanceAsync(): Promise<void> {
 | 
				
			||||||
        await this.stopWatchingAllEventsAsync();
 | 
					        await this.stopWatchingAllEventsAsync();
 | 
				
			||||||
@@ -518,11 +517,11 @@ export class ExchangeWrapper extends ContractWrapper {
 | 
				
			|||||||
     * @param   subscriptionOpts    Subscriptions options that let you configure the subscription.
 | 
					     * @param   subscriptionOpts    Subscriptions options that let you configure the subscription.
 | 
				
			||||||
     * @param   indexFilterValues   A JS object where the keys are indexed args returned by the event and
 | 
					     * @param   indexFilterValues   A JS object where the keys are indexed args returned by the event and
 | 
				
			||||||
     *                              the value is the value you are interested in. E.g `{maker: aUserAddressHex}`
 | 
					     *                              the value is the value you are interested in. E.g `{maker: aUserAddressHex}`
 | 
				
			||||||
     * @return                      ZeroExEvent object
 | 
					     * @return                      EventEmitter object
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public async subscribeAsync(eventName: ExchangeEvents, subscriptionOpts: SubscriptionOpts,
 | 
					    public async subscribeAsync(eventName: ExchangeEvents, subscriptionOpts: SubscriptionOpts,
 | 
				
			||||||
                                indexFilterValues: IndexFilterValues):
 | 
					                                indexFilterValues: IndexFilterValues):
 | 
				
			||||||
                                Promise<ZeroExEvent> {
 | 
					                                Promise<EventEmitter> {
 | 
				
			||||||
        const exchangeContract = await this._getExchangeContractAsync();
 | 
					        const exchangeContract = await this._getExchangeContractAsync();
 | 
				
			||||||
        let createLogEvent: CreateContractEvent;
 | 
					        let createLogEvent: CreateContractEvent;
 | 
				
			||||||
        switch (eventName) {
 | 
					        switch (eventName) {
 | 
				
			||||||
@@ -540,9 +539,9 @@ export class ExchangeWrapper extends ContractWrapper {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        const logEventObj: ContractEventObj = createLogEvent(indexFilterValues, subscriptionOpts);
 | 
					        const logEventObj: ContractEventObj = createLogEvent(indexFilterValues, subscriptionOpts);
 | 
				
			||||||
        const zeroExEvent = this._wrapEventAsZeroExEvent(logEventObj);
 | 
					        const eventEmitter = this._wrapEventEmitter(logEventObj);
 | 
				
			||||||
        this._exchangeLogEventObjs.push(zeroExEvent);
 | 
					        this._exchangeLogEventEmitters.push(eventEmitter);
 | 
				
			||||||
        return zeroExEvent;
 | 
					        return eventEmitter;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Returns the ethereum address of the current exchange contract
 | 
					     * Returns the ethereum address of the current exchange contract
 | 
				
			||||||
@@ -557,11 +556,12 @@ export class ExchangeWrapper extends ContractWrapper {
 | 
				
			|||||||
     * Stops watching for all exchange events
 | 
					     * Stops watching for all exchange events
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public async stopWatchingAllEventsAsync(): Promise<void> {
 | 
					    public async stopWatchingAllEventsAsync(): Promise<void> {
 | 
				
			||||||
        const stopWatchingPromises = _.map(this._exchangeLogEventObjs, logEventObj => logEventObj.stopWatchingAsync());
 | 
					        const stopWatchingPromises = _.map(this._exchangeLogEventEmitters,
 | 
				
			||||||
 | 
					                                           logEventObj => logEventObj.stopWatchingAsync());
 | 
				
			||||||
        await Promise.all(stopWatchingPromises);
 | 
					        await Promise.all(stopWatchingPromises);
 | 
				
			||||||
        this._exchangeLogEventObjs = [];
 | 
					        this._exchangeLogEventEmitters = [];
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    private _wrapEventAsZeroExEvent(event: ContractEventObj): ZeroExEvent {
 | 
					    private _wrapEventEmitter(event: ContractEventObj): EventEmitter {
 | 
				
			||||||
        const zeroExEvent = {
 | 
					        const zeroExEvent = {
 | 
				
			||||||
            watch: event.watch.bind(event),
 | 
					            watch: event.watch.bind(event),
 | 
				
			||||||
            stopWatchingAsync: async () => {
 | 
					            stopWatchingAsync: async () => {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -22,5 +22,5 @@ export {
 | 
				
			|||||||
    OrderCancellationRequest,
 | 
					    OrderCancellationRequest,
 | 
				
			||||||
    OrderFillRequest,
 | 
					    OrderFillRequest,
 | 
				
			||||||
    DoneCallback,
 | 
					    DoneCallback,
 | 
				
			||||||
    ZeroExEvent,
 | 
					    EventEmitter,
 | 
				
			||||||
} from './types';
 | 
					} from './types';
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -276,7 +276,7 @@ export interface Artifact {
 | 
				
			|||||||
    networks: {[networkId: number]: any};
 | 
					    networks: {[networkId: number]: any};
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export interface ZeroExEvent {
 | 
					export interface EventEmitter {
 | 
				
			||||||
    watch: (eventCallback: EventCallback) => void;
 | 
					    watch: (eventCallback: EventCallback) => void;
 | 
				
			||||||
    stopWatchingAsync: () => Promise<void>;
 | 
					    stopWatchingAsync: () => Promise<void>;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user