aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-09-25 19:05:44 +0800
committerFabio Berger <me@fabioberger.com>2018-09-25 19:05:44 +0800
commit55ca971186fd9318c1be9cc9e8c125f55c653cd9 (patch)
treec93f0c78970abe73dd5651369e1abf0dc7b6f40f
parent284930eb58c95c03f1a73b7c1f127701068e41e9 (diff)
downloaddexon-sol-tools-55ca971186fd9318c1be9cc9e8c125f55c653cd9.tar.gz
dexon-sol-tools-55ca971186fd9318c1be9cc9e8c125f55c653cd9.tar.zst
dexon-sol-tools-55ca971186fd9318c1be9cc9e8c125f55c653cd9.zip
Decode logs received from blockstream
-rw-r--r--packages/contract-wrappers/src/contract_wrappers/contract_wrapper.ts9
-rw-r--r--packages/order-watcher/src/order_watcher/event_watcher.ts9
2 files changed, 10 insertions, 8 deletions
diff --git a/packages/contract-wrappers/src/contract_wrappers/contract_wrapper.ts b/packages/contract-wrappers/src/contract_wrappers/contract_wrapper.ts
index 660f2d122..58c5bce6d 100644
--- a/packages/contract-wrappers/src/contract_wrappers/contract_wrapper.ts
+++ b/packages/contract-wrappers/src/contract_wrappers/contract_wrapper.ts
@@ -1,14 +1,14 @@
import { AbiDecoder, intervalUtils, logUtils } from '@0xproject/utils';
-import { Web3Wrapper } from '@0xproject/web3-wrapper';
+import { marshaller, Web3Wrapper } from '@0xproject/web3-wrapper';
import {
BlockParamLiteral,
- BlockWithoutTransactionData,
ContractAbi,
ContractArtifact,
FilterObject,
LogEntry,
LogWithDecodedArgs,
RawLog,
+ RawLogEntry,
} from 'ethereum-types';
import { Block, BlockAndLogStreamer, Log } from 'ethereumjs-blockstream';
import * as _ from 'lodash';
@@ -158,7 +158,8 @@ export abstract class ContractWrapper {
return addressIfExists;
}
}
- private _onLogStateChanged<ArgsType extends ContractEventArgs>(isRemoved: boolean, log: LogEntry): void {
+ private _onLogStateChanged<ArgsType extends ContractEventArgs>(isRemoved: boolean, rawLog: RawLogEntry): void {
+ const log: LogEntry = marshaller.unmarshalLog(rawLog);
_.forEach(this._filters, (filter: FilterObject, filterToken: string) => {
if (filterUtils.matchesFilter(log, filter)) {
const decodedLog = this._tryToDecodeLogOrNoop(log) as LogWithDecodedArgs<ArgsType>;
@@ -209,7 +210,7 @@ export abstract class ContractWrapper {
const shouldIncludeTransactionData = false;
const blockOrNull = await this._web3Wrapper.sendRawPayloadAsync({
method: 'eth_getBlockByNumber',
- params: ['latest', shouldIncludeTransactionData],
+ params: [BlockParamLiteral.Latest, shouldIncludeTransactionData],
});
return blockOrNull as Block;
}
diff --git a/packages/order-watcher/src/order_watcher/event_watcher.ts b/packages/order-watcher/src/order_watcher/event_watcher.ts
index d23052613..e73e1f9f9 100644
--- a/packages/order-watcher/src/order_watcher/event_watcher.ts
+++ b/packages/order-watcher/src/order_watcher/event_watcher.ts
@@ -1,6 +1,6 @@
import { intervalUtils, logUtils } from '@0xproject/utils';
-import { Web3Wrapper } from '@0xproject/web3-wrapper';
-import { BlockParamLiteral, FilterObject, LogEntry, Provider } from 'ethereum-types';
+import { marshaller, Web3Wrapper } from '@0xproject/web3-wrapper';
+import { BlockParamLiteral, FilterObject, LogEntry, Provider, RawLogEntry } from 'ethereum-types';
import { Block, BlockAndLogStreamer, Log } from 'ethereumjs-blockstream';
import * as _ from 'lodash';
@@ -96,7 +96,7 @@ export class EventWatcher {
const shouldIncludeTransactionData = false;
const blockOrNull = await this._web3Wrapper.sendRawPayloadAsync({
method: 'eth_getBlockByNumber',
- params: ['latest', shouldIncludeTransactionData],
+ params: [BlockParamLiteral.Latest, shouldIncludeTransactionData],
});
return blockOrNull as Block;
}
@@ -121,8 +121,9 @@ export class EventWatcher {
private async _onLogStateChangedAsync(
callback: EventWatcherCallback,
isRemoved: boolean,
- log: LogEntry,
+ rawLog: RawLogEntry,
): Promise<void> {
+ const log: LogEntry = marshaller.unmarshalLog(rawLog);
await this._emitDifferencesAsync(log, isRemoved ? LogEventState.Removed : LogEventState.Added, callback);
}
private async _reconcileBlockAsync(): Promise<void> {