aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--package.json1
-rw-r--r--src/contract_wrappers/contract_wrapper.ts9
-rw-r--r--src/utils/filter_utils.ts5
-rw-r--r--src/web3_wrapper.ts4
-rw-r--r--yarn.lock4
5 files changed, 10 insertions, 13 deletions
diff --git a/package.json b/package.json
index 59b0c9cf9..941ccc504 100644
--- a/package.json
+++ b/package.json
@@ -99,6 +99,7 @@
"ethereumjs-blockstream": "^2.0.6",
"ethereumjs-util": "^5.1.1",
"find-versions": "^2.0.0",
+ "js-sha3": "^0.6.1",
"lodash": "^4.17.4",
"publish-release": "^1.3.3",
"uuid": "^3.1.0",
diff --git a/src/contract_wrappers/contract_wrapper.ts b/src/contract_wrappers/contract_wrapper.ts
index f3ebae871..0bd7cc8b1 100644
--- a/src/contract_wrappers/contract_wrapper.ts
+++ b/src/contract_wrappers/contract_wrapper.ts
@@ -38,9 +38,7 @@ export class ContractWrapper {
protected _subscribe(address: string, eventName: ContractEvents,
indexFilterValues: IndexedFilterValues, abi: Web3.ContractAbi,
callback: EventCallback): string {
- const filter = filterUtils.getFilter(
- this._web3Wrapper.keccak256.bind(this._web3Wrapper), address, eventName, indexFilterValues, abi,
- );
+ const filter = filterUtils.getFilter(address, eventName, indexFilterValues, abi);
if (_.isEmpty(this._filters)) {
this._startBlockAndLogStream();
}
@@ -62,10 +60,7 @@ export class ContractWrapper {
protected async _getLogsAsync(address: string, eventName: ContractEvents, subscriptionOpts: SubscriptionOpts,
indexFilterValues: IndexedFilterValues,
abi: Web3.ContractAbi): Promise<LogWithDecodedArgs[]> {
- const filter = filterUtils.getFilter(
- this._web3Wrapper.keccak256.bind(this._web3Wrapper), address, eventName, indexFilterValues, abi,
- subscriptionOpts,
- );
+ const filter = filterUtils.getFilter(address, eventName, indexFilterValues, abi, subscriptionOpts);
const logs = await this._web3Wrapper.getLogsAsync(filter);
const logsWithDecodedArguments = _.map(logs, this._tryToDecodeLogOrNoop.bind(this));
return logsWithDecodedArguments;
diff --git a/src/utils/filter_utils.ts b/src/utils/filter_utils.ts
index ee39b6836..2bd745815 100644
--- a/src/utils/filter_utils.ts
+++ b/src/utils/filter_utils.ts
@@ -2,6 +2,7 @@ import * as _ from 'lodash';
import * as Web3 from 'web3';
import * as uuid from 'uuid/v4';
import * as ethUtil from 'ethereumjs-util';
+import * as jsSHA3 from 'js-sha3';
import {ContractEvents, IndexedFilterValues, SubscriptionOpts} from '../types';
const TOPIC_LENGTH = 32;
@@ -10,12 +11,12 @@ export const filterUtils = {
generateUUID(): string {
return uuid();
},
- getFilter(keccak256: (data: string) => string, address: string, eventName: ContractEvents,
+ getFilter(address: string, eventName: ContractEvents,
indexFilterValues: IndexedFilterValues, abi: Web3.ContractAbi,
subscriptionOpts?: SubscriptionOpts): Web3.FilterObject {
const eventAbi = _.find(abi, {name: eventName}) as Web3.EventAbi;
const eventSignature = filterUtils.getEventSignatureFromAbiByName(eventAbi, eventName);
- const topicForEventSignature = keccak256(eventSignature);
+ const topicForEventSignature = jsSHA3.keccak256(eventSignature);
const topicsForIndexedArgs = filterUtils.getTopicsForIndexedArgs(eventAbi, indexFilterValues);
const topics = [topicForEventSignature, ...topicsForIndexedArgs];
let filter: Web3.FilterObject = {
diff --git a/src/web3_wrapper.ts b/src/web3_wrapper.ts
index fd9b74b8b..9de75c809 100644
--- a/src/web3_wrapper.ts
+++ b/src/web3_wrapper.ts
@@ -116,10 +116,6 @@ export class Web3Wrapper {
const logs = await this.sendRawPayloadAsync(payload);
return logs;
}
- public keccak256(data: string): string {
- const hash = this.web3.sha3(data);
- return hash;
- }
private getContractInstance<A extends Web3.ContractInstance>(abi: Web3.ContractAbi, address: string): A {
const web3ContractInstance = this.web3.eth.contract(abi).at(address);
const contractInstance = new Contract(web3ContractInstance, this.defaults) as any as A;
diff --git a/yarn.lock b/yarn.lock
index 577aa03c1..ab9b520f0 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2637,6 +2637,10 @@ js-sha3@^0.3.1:
version "0.3.1"
resolved "https://registry.yarnpkg.com/js-sha3/-/js-sha3-0.3.1.tgz#86122802142f0828502a0d1dee1d95e253bb0243"
+js-sha3@^0.6.1:
+ version "0.6.1"
+ resolved "https://registry.yarnpkg.com/js-sha3/-/js-sha3-0.6.1.tgz#5b89f77a7477679877f58c4a075240934b1f95c0"
+
js-tokens@^3.0.0:
version "3.0.2"
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b"