Skip to content
This repository was archived by the owner on Sep 15, 2022. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/utils/abi_decoder.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { AbiDefinition, LogEntry } from 'ethereum-types';
import { ContractEventArgs, LogWithDecodedArgs, RawLog } from '../types';
export declare class AbiDecoder {
private _abiCoder;
private _savedABIs;
private _methodIds;
private static _padZeros;
Expand Down
8 changes: 4 additions & 4 deletions lib/utils/abi_decoder.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/utils/abi_decoder.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"homepage": "https://github.com/ProjectWyvern/wyvern-js#readme",
"dependencies": {
"@0x/assert": "^3.0.30",
"@0x/base-contract": "^6.4.4",
"@0x/base-contract": "^6.5.0",
"@0x/json-schemas": "^6.4.0",
"@0x/utils": "https://github.com/ProjectOpensea/0x-tools/raw/provider-patch/utils/0x-utils-6.5.0.tgz",
"@0x/web3-wrapper": "^7.6.1",
Expand All @@ -37,8 +37,7 @@
"ethers": "^4.0.49",
"json-loader": "^0.5.7",
"jsonschema": "^1.2.2",
"lodash": "^4.17.21",
"web3": "^1.7.0"
"lodash": "^4.17.21"
},
"devDependencies": {
"@0x/abi-gen": "^5.7.0",
Expand Down
8 changes: 4 additions & 4 deletions src/utils/abi_decoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

import { BigNumber } from '@0x/utils';
import { AbiDefinition, EventAbi, EventParameter, LogEntry } from 'ethereum-types';
import { AbiCoder, keccak256 } from 'ethers/utils';
import * as _ from 'lodash';
import Web3 from 'web3';
import * as SolidityCoder from 'web3/lib/solidity/coder';

import { AbiType, ContractEventArgs, DecodedLogArgs, LogWithDecodedArgs, RawLog, SolidityTypes } from '../types';

export class AbiDecoder {
private _abiCoder = new AbiCoder();
private _savedABIs: AbiDefinition[] = [];
private _methodIds: { [signatureHash: string]: EventAbi } = {};
private static _padZeros(address: string) {
Expand Down Expand Up @@ -39,7 +39,7 @@ export class AbiDecoder {

const nonIndexedInputs = _.filter(event.inputs, input => !input.indexed);
const dataTypes = _.map(nonIndexedInputs, input => input.type);
const decodedData = SolidityCoder.decodeParams(dataTypes, logData.slice('0x'.length));
const decodedData = this._abiCoder.decode(dataTypes, logData.slice('0x'.length));

_.map(event.inputs, (param: EventParameter) => {
// Indexed parameters are stored in topics. Non-indexed ones in decodedData
Expand Down Expand Up @@ -68,7 +68,7 @@ export class AbiDecoder {
if (abi.type === AbiType.Event) {
const eventAbi = abi as EventAbi;
const signature = `${eventAbi.name}(${_.map(eventAbi.inputs, input => input.type).join(',')})`;
const signatureHash = new Web3().utils.sha3(signature) as string;
const signatureHash = keccak256(signature);
this._methodIds[signatureHash] = eventAbi;
}
});
Expand Down
Loading