diff options
author | Leonid <logvinov.leon@gmail.com> | 2017-11-24 05:13:07 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-24 05:13:07 +0800 |
commit | 17e41f2391a73656cce2ddf43c27acd2ae6260fd (patch) | |
tree | 7eca02eb9838fec703343cb0a720f6a1e954e20c /packages/0x.js/src | |
parent | f97074dc84b5c45b9c487ee27ca7ed671bb6fd71 (diff) | |
parent | fcd37808d46d162b183b7c6d9aeb58ebc431caba (diff) | |
download | dexon-sol-tools-17e41f2391a73656cce2ddf43c27acd2ae6260fd.tar dexon-sol-tools-17e41f2391a73656cce2ddf43c27acd2ae6260fd.tar.gz dexon-sol-tools-17e41f2391a73656cce2ddf43c27acd2ae6260fd.tar.bz2 dexon-sol-tools-17e41f2391a73656cce2ddf43c27acd2ae6260fd.tar.lz dexon-sol-tools-17e41f2391a73656cce2ddf43c27acd2ae6260fd.tar.xz dexon-sol-tools-17e41f2391a73656cce2ddf43c27acd2ae6260fd.tar.zst dexon-sol-tools-17e41f2391a73656cce2ddf43c27acd2ae6260fd.zip |
Merge pull request #234 from 0xProject/feature/eventTypes
Make DecodedLogEvent contain web3 log under a log subkey
Diffstat (limited to 'packages/0x.js/src')
-rw-r--r-- | packages/0x.js/src/contract_wrappers/contract_wrapper.ts | 14 | ||||
-rw-r--r-- | packages/0x.js/src/types.ts | 5 |
2 files changed, 11 insertions, 8 deletions
diff --git a/packages/0x.js/src/contract_wrappers/contract_wrapper.ts b/packages/0x.js/src/contract_wrappers/contract_wrapper.ts index 7997b1647..c1c95c6db 100644 --- a/packages/0x.js/src/contract_wrappers/contract_wrapper.ts +++ b/packages/0x.js/src/contract_wrappers/contract_wrapper.ts @@ -95,13 +95,13 @@ export class ContractWrapper { await this._web3Wrapper.getContractInstanceFromArtifactAsync<ContractType>(artifact, addressIfExists); return contractInstance; } - private _onLogStateChanged<ArgsType extends ContractEventArgs>(removed: boolean, log: Web3.LogEntry): void { + private _onLogStateChanged<ArgsType extends ContractEventArgs>(isRemoved: boolean, log: Web3.LogEntry): void { _.forEach(this._filters, (filter: Web3.FilterObject, filterToken: string) => { if (filterUtils.matchesFilter(log, filter)) { const decodedLog = this._tryToDecodeLogOrNoop(log) as LogWithDecodedArgs<ArgsType>; const logEvent = { - ...decodedLog, - removed, + log: decodedLog, + isRemoved, }; this._filterCallbacks[filterToken](null, logEvent); } @@ -117,13 +117,13 @@ export class ContractWrapper { this._blockAndLogStreamInterval = intervalUtils.setAsyncExcludingInterval( this._reconcileBlockAsync.bind(this), constants.DEFAULT_BLOCK_POLLING_INTERVAL, ); - let removed = false; + let isRemoved = false; this._onLogAddedSubscriptionToken = this._blockAndLogStreamer.subscribeToOnLogAdded( - this._onLogStateChanged.bind(this, removed), + this._onLogStateChanged.bind(this, isRemoved), ); - removed = true; + isRemoved = true; this._onLogRemovedSubscriptionToken = this._blockAndLogStreamer.subscribeToOnLogRemoved( - this._onLogStateChanged.bind(this, removed), + this._onLogStateChanged.bind(this, isRemoved), ); } private _stopBlockAndLogStream(): void { diff --git a/packages/0x.js/src/types.ts b/packages/0x.js/src/types.ts index c3aabfd86..ac4106d0b 100644 --- a/packages/0x.js/src/types.ts +++ b/packages/0x.js/src/types.ts @@ -40,7 +40,10 @@ export type OrderValues = [BigNumber, BigNumber, BigNumber, BigNumber, BigNumber, BigNumber]; export type LogEvent = Web3.LogEntryEvent; -export type DecodedLogEvent<ArgsType> = Web3.DecodedLogEntryEvent<ArgsType>; +export interface DecodedLogEvent<ArgsType> { + isRemoved: boolean; + log: LogWithDecodedArgs<ArgsType>; +} export type EventCallback<ArgsType> = (err: null|Error, log?: DecodedLogEvent<ArgsType>) => void; export type EventWatcherCallback = (log: LogEvent) => void; |