aboutsummaryrefslogtreecommitdiffstats
path: root/packages/0x.js/src/utils/filter_utils.ts
diff options
context:
space:
mode:
authorBrandon Millman <brandon.millman@gmail.com>2018-01-09 08:35:12 +0800
committerBrandon Millman <brandon.millman@gmail.com>2018-01-09 08:35:12 +0800
commit734cf5819aee5d46719d1ca387666bfda6e475bd (patch)
tree264785cb0666e011b49842b47ac4b2408dddaa28 /packages/0x.js/src/utils/filter_utils.ts
parent9f3acf8e2888b6105062e47664ecd5adaaf3c889 (diff)
parent35e0b6143ab1405259471e1c9c698bfcd869df5a (diff)
downloaddexon-sol-tools-734cf5819aee5d46719d1ca387666bfda6e475bd.tar
dexon-sol-tools-734cf5819aee5d46719d1ca387666bfda6e475bd.tar.gz
dexon-sol-tools-734cf5819aee5d46719d1ca387666bfda6e475bd.tar.bz2
dexon-sol-tools-734cf5819aee5d46719d1ca387666bfda6e475bd.tar.lz
dexon-sol-tools-734cf5819aee5d46719d1ca387666bfda6e475bd.tar.xz
dexon-sol-tools-734cf5819aee5d46719d1ca387666bfda6e475bd.tar.zst
dexon-sol-tools-734cf5819aee5d46719d1ca387666bfda6e475bd.zip
Merge branch 'development' into fix/mutatedInput
* development: Changes to abi-gen after code review Added constructor ABIs to abi-gen Describe #295 in a CHANGELOG Add #302 description to changelog Fix formatting Apply prettier config Install prettier Remove formatting esilnt rules sendTransactionAsync should return txHash string Added Event generation to abi-gen Publish Add dates to CHANGELOG entries Update subproviders CHANGELOG Support both personal_sign and eth_sign Fix Ledger tests given change from `personal_sign` to `eth_sign` Update subprovider to catch correct RPC method Rename guide Update contribution guide Fix broken links in the abi-gen README Fix typing generation for arrays in which types separated by |s
Diffstat (limited to 'packages/0x.js/src/utils/filter_utils.ts')
-rw-r--r--packages/0x.js/src/utils/filter_utils.ts22
1 files changed, 13 insertions, 9 deletions
diff --git a/packages/0x.js/src/utils/filter_utils.ts b/packages/0x.js/src/utils/filter_utils.ts
index 65161c33e..97205ace3 100644
--- a/packages/0x.js/src/utils/filter_utils.ts
+++ b/packages/0x.js/src/utils/filter_utils.ts
@@ -4,7 +4,7 @@ import * as _ from 'lodash';
import * as uuid from 'uuid/v4';
import * as Web3 from 'web3';
-import {BlockRange, ContractEvents, IndexedFilterValues} from '../types';
+import { BlockRange, ContractEvents, IndexedFilterValues } from '../types';
const TOPIC_LENGTH = 32;
@@ -12,10 +12,14 @@ export const filterUtils = {
generateUUID(): string {
return uuid();
},
- getFilter(address: string, eventName: ContractEvents,
- indexFilterValues: IndexedFilterValues, abi: Web3.ContractAbi,
- blockRange?: BlockRange): Web3.FilterObject {
- const eventAbi = _.find(abi, {name: eventName}) as Web3.EventAbi;
+ getFilter(
+ address: string,
+ eventName: ContractEvents,
+ indexFilterValues: IndexedFilterValues,
+ abi: Web3.ContractAbi,
+ blockRange?: BlockRange,
+ ): Web3.FilterObject {
+ const eventAbi = _.find(abi, { name: eventName }) as Web3.EventAbi;
const eventSignature = filterUtils.getEventSignatureFromAbiByName(eventAbi, eventName);
const topicForEventSignature = ethUtil.addHexPrefix(jsSHA3.keccak256(eventSignature));
const topicsForIndexedArgs = filterUtils.getTopicsForIndexedArgs(eventAbi, indexFilterValues);
@@ -37,8 +41,8 @@ export const filterUtils = {
const signature = `${eventAbi.name}(${types.join(',')})`;
return signature;
},
- getTopicsForIndexedArgs(abi: Web3.EventAbi, indexFilterValues: IndexedFilterValues): Array<string|null> {
- const topics: Array<string|null> = [];
+ getTopicsForIndexedArgs(abi: Web3.EventAbi, indexFilterValues: IndexedFilterValues): Array<string | null> {
+ const topics: Array<string | null> = [];
for (const eventInput of abi.inputs) {
if (!eventInput.indexed) {
continue;
@@ -65,12 +69,12 @@ export const filterUtils = {
}
return true;
},
- matchesTopics(logTopics: string[], filterTopics: Array<string[]|string|null>): boolean {
+ matchesTopics(logTopics: string[], filterTopics: Array<string[] | string | null>): boolean {
const matchesTopic = _.zipWith(logTopics, filterTopics, filterUtils.matchesTopic.bind(filterUtils));
const matchesTopics = _.every(matchesTopic);
return matchesTopics;
},
- matchesTopic(logTopic: string, filterTopic: string[]|string|null): boolean {
+ matchesTopic(logTopic: string, filterTopic: string[] | string | null): boolean {
if (_.isArray(filterTopic)) {
return _.includes(filterTopic, logTopic);
}