diff options
author | Leonid <logvinov.leon@gmail.com> | 2017-09-06 21:26:29 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-06 21:26:29 +0800 |
commit | cb44b77d0b64bf4a0808cf1fea488ab2e1a60cf3 (patch) | |
tree | f7630683357f6a2273557d7027a1985f8a28f94b /src/0x.ts | |
parent | 92eb68bf2c412d42322ab7f483af91666ccbdcb1 (diff) | |
parent | 1baf06531755597e37498005eb2c29aef5114fab (diff) | |
download | dexon-sol-tools-cb44b77d0b64bf4a0808cf1fea488ab2e1a60cf3.tar dexon-sol-tools-cb44b77d0b64bf4a0808cf1fea488ab2e1a60cf3.tar.gz dexon-sol-tools-cb44b77d0b64bf4a0808cf1fea488ab2e1a60cf3.tar.bz2 dexon-sol-tools-cb44b77d0b64bf4a0808cf1fea488ab2e1a60cf3.tar.lz dexon-sol-tools-cb44b77d0b64bf4a0808cf1fea488ab2e1a60cf3.tar.xz dexon-sol-tools-cb44b77d0b64bf4a0808cf1fea488ab2e1a60cf3.tar.zst dexon-sol-tools-cb44b77d0b64bf4a0808cf1fea488ab2e1a60cf3.zip |
Merge pull request #156 from 0xProject/feature/custom-abi-decoder
Custom abi decoder
Diffstat (limited to 'src/0x.ts')
-rw-r--r-- | src/0x.ts | 24 |
1 files changed, 10 insertions, 14 deletions
@@ -12,6 +12,7 @@ import {constants} from './utils/constants'; import {utils} from './utils/utils'; import {signatureUtils} from './utils/signature_utils'; import {assert} from './utils/assert'; +import {AbiDecoder} from './utils/abi_decoder'; import {artifacts} from './artifacts'; import {ExchangeWrapper} from './contract_wrappers/exchange_wrapper'; import {TokenRegistryWrapper} from './contract_wrappers/token_registry_wrapper'; @@ -70,6 +71,7 @@ export class ZeroEx { */ public proxy: TokenTransferProxyWrapper; private _web3Wrapper: Web3Wrapper; + private _abiDecoder: AbiDecoder; /** * Verifies that the elliptic curve signature `signature` was generated * by signing `data` with the private key corresponding to the `signerAddress` address. @@ -183,7 +185,9 @@ export class ZeroEx { // We re-assign the send method so that Web3@1.0 providers work with 0x.js (provider as any).sendAsync = (provider as any).send; } - this._registerArtifactsWithinABIDecoder(); + const artifactJSONs = _.values(artifacts); + const abiArrays = _.map(artifactJSONs, artifact => artifact.abi); + this._abiDecoder = new AbiDecoder(abiArrays); const gasPrice = _.isUndefined(config) ? undefined : config.gasPrice; const defaults = { gasPrice, @@ -281,16 +285,13 @@ export class ZeroEx { if (!_.isNull(transactionReceipt)) { clearInterval(intervalId); const logsWithDecodedArgs = _.map(transactionReceipt.logs, (log: Web3.LogEntry) => { - const decodedLog = abiDecoder.decodeLogs([log])[0]; - const decodedArgs = decodedLog.events; - const args: DecodedLogArgs = {}; - _.forEach(decodedArgs, arg => { - args[arg.name] = arg.value; - }); + const decodedLog = this._abiDecoder.decodeLog(log); + if (_.isUndefined(decodedLog)) { + return log; + } const logWithDecodedArgs: LogWithDecodedArgs = { ...log, - args, - event: decodedLog.name, + ...decodedLog, }; return logWithDecodedArgs; }); @@ -304,9 +305,4 @@ export class ZeroEx { }); return txReceiptPromise; } - private _registerArtifactsWithinABIDecoder(): void { - for (const artifact of _.values(artifacts)) { - abiDecoder.addABI(artifact.abi); - } - } } |