diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-03-27 21:19:23 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-03-27 23:56:21 +0800 |
commit | d72b7299c66ea6d63eb14595b06456c02b2ad99b (patch) | |
tree | e026f0af7f779c0c94ddc1261f630dd8ca923af5 /packages/0x.js/src/utils | |
parent | 066d13f5b7260d28b13195c4f9aed48b4ae96cc3 (diff) | |
download | dexon-sol-tools-d72b7299c66ea6d63eb14595b06456c02b2ad99b.tar dexon-sol-tools-d72b7299c66ea6d63eb14595b06456c02b2ad99b.tar.gz dexon-sol-tools-d72b7299c66ea6d63eb14595b06456c02b2ad99b.tar.bz2 dexon-sol-tools-d72b7299c66ea6d63eb14595b06456c02b2ad99b.tar.lz dexon-sol-tools-d72b7299c66ea6d63eb14595b06456c02b2ad99b.tar.xz dexon-sol-tools-d72b7299c66ea6d63eb14595b06456c02b2ad99b.tar.zst dexon-sol-tools-d72b7299c66ea6d63eb14595b06456c02b2ad99b.zip |
Move common types out of web3 types
Diffstat (limited to 'packages/0x.js/src/utils')
-rw-r--r-- | packages/0x.js/src/utils/filter_utils.ts | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/packages/0x.js/src/utils/filter_utils.ts b/packages/0x.js/src/utils/filter_utils.ts index 97205ace3..c5df7321e 100644 --- a/packages/0x.js/src/utils/filter_utils.ts +++ b/packages/0x.js/src/utils/filter_utils.ts @@ -1,8 +1,16 @@ +import { + ConstructorAbi, + ContractAbi, + EventAbi, + FallbackAbi, + FilterObject, + LogEntry, + MethodAbi, +} from '@0xproject/types'; import * as ethUtil from 'ethereumjs-util'; import * as jsSHA3 from 'js-sha3'; import * as _ from 'lodash'; import * as uuid from 'uuid/v4'; -import * as Web3 from 'web3'; import { BlockRange, ContractEvents, IndexedFilterValues } from '../types'; @@ -16,15 +24,15 @@ export const filterUtils = { address: string, eventName: ContractEvents, indexFilterValues: IndexedFilterValues, - abi: Web3.ContractAbi, + abi: ContractAbi, blockRange?: BlockRange, - ): Web3.FilterObject { - const eventAbi = _.find(abi, { name: eventName }) as Web3.EventAbi; + ): FilterObject { + const eventAbi = _.find(abi, { name: eventName }) as EventAbi; const eventSignature = filterUtils.getEventSignatureFromAbiByName(eventAbi, eventName); const topicForEventSignature = ethUtil.addHexPrefix(jsSHA3.keccak256(eventSignature)); const topicsForIndexedArgs = filterUtils.getTopicsForIndexedArgs(eventAbi, indexFilterValues); const topics = [topicForEventSignature, ...topicsForIndexedArgs]; - let filter: Web3.FilterObject = { + let filter: FilterObject = { address, topics, }; @@ -36,12 +44,12 @@ export const filterUtils = { } return filter; }, - getEventSignatureFromAbiByName(eventAbi: Web3.EventAbi, eventName: ContractEvents): string { + getEventSignatureFromAbiByName(eventAbi: EventAbi, eventName: ContractEvents): string { const types = _.map(eventAbi.inputs, 'type'); const signature = `${eventAbi.name}(${types.join(',')})`; return signature; }, - getTopicsForIndexedArgs(abi: Web3.EventAbi, indexFilterValues: IndexedFilterValues): Array<string | null> { + getTopicsForIndexedArgs(abi: EventAbi, indexFilterValues: IndexedFilterValues): Array<string | null> { const topics: Array<string | null> = []; for (const eventInput of abi.inputs) { if (!eventInput.indexed) { @@ -60,7 +68,7 @@ export const filterUtils = { } return topics; }, - matchesFilter(log: Web3.LogEntry, filter: Web3.FilterObject): boolean { + matchesFilter(log: LogEntry, filter: FilterObject): boolean { if (!_.isUndefined(filter.address) && log.address !== filter.address) { return false; } |