aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-10-03 17:20:33 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2017-10-04 16:14:19 +0800
commita9681072ee4b45bda23b754fa46175b68c09b8b9 (patch)
tree0dcbcb44fec31b1df6ce37a9e308b7f8bac476d2
parent16af052a168f64b6ba12b336cce9d404d383ce84 (diff)
downloaddexon-sol-tools-a9681072ee4b45bda23b754fa46175b68c09b8b9.tar
dexon-sol-tools-a9681072ee4b45bda23b754fa46175b68c09b8b9.tar.gz
dexon-sol-tools-a9681072ee4b45bda23b754fa46175b68c09b8b9.tar.bz2
dexon-sol-tools-a9681072ee4b45bda23b754fa46175b68c09b8b9.tar.lz
dexon-sol-tools-a9681072ee4b45bda23b754fa46175b68c09b8b9.tar.xz
dexon-sol-tools-a9681072ee4b45bda23b754fa46175b68c09b8b9.tar.zst
dexon-sol-tools-a9681072ee4b45bda23b754fa46175b68c09b8b9.zip
Factor out tryToDecodeLogOrNoOp
-rw-r--r--src/0x.ts23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/0x.ts b/src/0x.ts
index ae29b8d70..275689f30 100644
--- a/src/0x.ts
+++ b/src/0x.ts
@@ -302,17 +302,7 @@ export class ZeroEx {
const transactionReceipt = await this._web3Wrapper.getTransactionReceiptAsync(txHash);
if (!_.isNull(transactionReceipt)) {
intervalUtils.clearAsyncExcludingInterval(intervalId);
- const logsWithDecodedArgs = _.map(transactionReceipt.logs, (log: Web3.LogEntry) => {
- const decodedLog = this._abiDecoder.decodeLog(log);
- if (_.isUndefined(decodedLog)) {
- return log;
- }
- const logWithDecodedArgs: LogWithDecodedArgs = {
- ...log,
- ...decodedLog,
- };
- return logWithDecodedArgs;
- });
+ const logsWithDecodedArgs = _.map(transactionReceipt.logs, this.tryToDecodeLogOrNoOp.bind(this));
const transactionReceiptWithDecodedLogArgs: TransactionReceiptWithDecodedLogs = {
...transactionReceipt,
logs: logsWithDecodedArgs,
@@ -332,6 +322,17 @@ export class ZeroEx {
const logs = await this._web3Wrapper.getLogsAsync(filter);
return logs;
}
+ private tryToDecodeLogOrNoOp(log: Web3.LogEntry): LogWithDecodedArgs|Web3.LogEntry {
+ const decodedLog = this._abiDecoder.decodeLog(log);
+ if (_.isUndefined(decodedLog)) {
+ return log;
+ }
+ const logWithDecodedArgs: LogWithDecodedArgs = {
+ ...log,
+ ...decodedLog,
+ };
+ return logWithDecodedArgs;
+ }
/*
* HACK: `TokenWrapper` needs a token transfer proxy address. `TokenTransferProxy` address is fetched from
* an `ExchangeWrapper`. `ExchangeWrapper` needs `TokenWrapper` to validate orders, creating a dependency cycle.