aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorAlex Browne <stephenalexbrowne@gmail.com>2018-09-26 06:31:41 +0800
committerFred Carlsen <fred@sjelfull.no>2018-12-06 19:04:24 +0800
commitdc04d025af21227d8da4841ccb7e5bd6d69a930f (patch)
tree54d0a539de21bc8c73dc2a2f5ec101ac68d1ca1a /packages
parent5262d3b1f2227d5e4988e801a4318aa6e0e0ab68 (diff)
downloaddexon-sol-tools-dc04d025af21227d8da4841ccb7e5bd6d69a930f.tar
dexon-sol-tools-dc04d025af21227d8da4841ccb7e5bd6d69a930f.tar.gz
dexon-sol-tools-dc04d025af21227d8da4841ccb7e5bd6d69a930f.tar.bz2
dexon-sol-tools-dc04d025af21227d8da4841ccb7e5bd6d69a930f.tar.lz
dexon-sol-tools-dc04d025af21227d8da4841ccb7e5bd6d69a930f.tar.xz
dexon-sol-tools-dc04d025af21227d8da4841ccb7e5bd6d69a930f.tar.zst
dexon-sol-tools-dc04d025af21227d8da4841ccb7e5bd6d69a930f.zip
Use multi-primary keys for event and filter null logIndexes
Diffstat (limited to 'packages')
-rw-r--r--packages/pipeline/src/data_types/events/exchange_events.ts13
-rw-r--r--packages/pipeline/src/entities/ExchangeCancelEvent.ts2
-rw-r--r--packages/pipeline/src/entities/ExchangeFillEvent.ts2
-rw-r--r--packages/pipeline/src/index.ts4
4 files changed, 15 insertions, 6 deletions
diff --git a/packages/pipeline/src/data_types/events/exchange_events.ts b/packages/pipeline/src/data_types/events/exchange_events.ts
index 3938f3a69..cc4332f6f 100644
--- a/packages/pipeline/src/data_types/events/exchange_events.ts
+++ b/packages/pipeline/src/data_types/events/exchange_events.ts
@@ -2,7 +2,7 @@ import { ExchangeCancelEventArgs, ExchangeEventArgs, ExchangeFillEventArgs } fro
import { assetDataUtils } from '@0xproject/order-utils';
import { AssetProxyId, ERC721AssetData } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
-import { LogWithDecodedArgs } from 'ethereum-types';
+import { LogEntry, LogWithDecodedArgs } from 'ethereum-types';
import * as R from 'ramda';
import { artifacts } from '../../artifacts';
@@ -22,10 +22,19 @@ export function parseExchangeEvents(rawEventsResponse: EventsResponse): Exchange
eventResponse => decodeLogEntry<ExchangeEventArgs>(exchangeContractAbi, eventResponse),
logEntries,
);
- const filteredLogEntries = R.filter(logEntry => R.contains(logEntry.event, ['Fill', 'Cancel']), decodedLogEntries);
+ const filteredLogEntries = R.filter(shouldIncludeLogEntry, decodedLogEntries);
return R.map(_convertToEntity, filteredLogEntries);
}
+export function shouldIncludeLogEntry(logEntry: LogWithDecodedArgs<ExchangeEventArgs>): boolean {
+ if (!R.contains(logEntry.event, ['Fill', 'Cancel'])) {
+ return false;
+ } else if (logEntry.logIndex == null || isNaN(logEntry.logIndex)) {
+ return false;
+ }
+ return true;
+}
+
export function _convertToEntity(eventLog: LogWithDecodedArgs<ExchangeEventArgs>): ExchangeEventEntity {
switch (eventLog.event) {
case 'Fill':
diff --git a/packages/pipeline/src/entities/ExchangeCancelEvent.ts b/packages/pipeline/src/entities/ExchangeCancelEvent.ts
index 8e21518d3..c925a4b01 100644
--- a/packages/pipeline/src/entities/ExchangeCancelEvent.ts
+++ b/packages/pipeline/src/entities/ExchangeCancelEvent.ts
@@ -5,10 +5,10 @@ import { AssetType } from '../types';
@Entity()
export class ExchangeCancelEvent extends BaseEntity {
@PrimaryColumn() public logIndex!: number;
+ @PrimaryColumn() public blockNumber!: number;
@Column() public address!: string;
@Column() public rawData!: string;
- @Column() public blockNumber!: number;
@Column() public makerAddress!: string;
@Column({ nullable: true, type: String })
diff --git a/packages/pipeline/src/entities/ExchangeFillEvent.ts b/packages/pipeline/src/entities/ExchangeFillEvent.ts
index e66bd64e3..9ac8eb349 100644
--- a/packages/pipeline/src/entities/ExchangeFillEvent.ts
+++ b/packages/pipeline/src/entities/ExchangeFillEvent.ts
@@ -5,10 +5,10 @@ import { AssetType } from '../types';
@Entity()
export class ExchangeFillEvent extends BaseEntity {
@PrimaryColumn() public logIndex!: number;
+ @PrimaryColumn() public blockNumber!: number;
@Column() public address!: string;
@Column() public rawData!: string;
- @Column() public blockNumber!: number;
@Column() public makerAddress!: string;
@Column() public takerAddress!: string;
diff --git a/packages/pipeline/src/index.ts b/packages/pipeline/src/index.ts
index c68df95bf..67b1f6fb2 100644
--- a/packages/pipeline/src/index.ts
+++ b/packages/pipeline/src/index.ts
@@ -1,13 +1,13 @@
+import * as R from 'ramda';
import 'reflect-metadata';
import { createConnection } from 'typeorm';
import { Etherscan } from './data_sources/etherscan';
+import { parseExchangeEvents } from './data_types/events/exchange_events';
import { ExchangeCancelEvent } from './entities/ExchangeCancelEvent';
import { ExchangeFillEvent } from './entities/ExchangeFillEvent';
import { config } from './ormconfig';
-import { parseExchangeEvents } from './data_types/events/exchange_events';
-
const etherscan = new Etherscan(process.env.ETHERSCAN_API_KEY as string);
const EXCHANGE_ADDRESS = '0x4f833a24e1f95d70f028921e27040ca56e09ab0b';