aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Browne <stephenalexbrowne@gmail.com>2018-09-26 07:06:52 +0800
committerFred Carlsen <fred@sjelfull.no>2018-12-13 01:12:11 +0800
commit8702a354678b08b81d40c3254efbfe71e11ea522 (patch)
tree42d0a4387647e09a0fccf930c3511de7ce48ec6c
parent07f80500fa6904ff68b1be2a99d38f4b8a65ee48 (diff)
downloaddexon-sol-tools-8702a354678b08b81d40c3254efbfe71e11ea522.tar
dexon-sol-tools-8702a354678b08b81d40c3254efbfe71e11ea522.tar.gz
dexon-sol-tools-8702a354678b08b81d40c3254efbfe71e11ea522.tar.bz2
dexon-sol-tools-8702a354678b08b81d40c3254efbfe71e11ea522.tar.lz
dexon-sol-tools-8702a354678b08b81d40c3254efbfe71e11ea522.tar.xz
dexon-sol-tools-8702a354678b08b81d40c3254efbfe71e11ea522.tar.zst
dexon-sol-tools-8702a354678b08b81d40c3254efbfe71e11ea522.zip
For event entities, rename address -> contractAddress and make it a primary key
-rw-r--r--packages/pipeline/src/data_types/events/exchange_events.ts12
-rw-r--r--packages/pipeline/src/entities/ExchangeCancelEvent.ts2
-rw-r--r--packages/pipeline/src/entities/ExchangeCancelUpToEvent.ts2
-rw-r--r--packages/pipeline/src/entities/ExchangeFillEvent.ts2
-rw-r--r--packages/pipeline/src/index.ts12
5 files changed, 19 insertions, 11 deletions
diff --git a/packages/pipeline/src/data_types/events/exchange_events.ts b/packages/pipeline/src/data_types/events/exchange_events.ts
index 763a141ea..2d4059a0e 100644
--- a/packages/pipeline/src/data_types/events/exchange_events.ts
+++ b/packages/pipeline/src/data_types/events/exchange_events.ts
@@ -60,10 +60,10 @@ export function _convertToExchangeFillEvent(eventLog: LogWithDecodedArgs<Exchang
const takerAssetData = assetDataUtils.decodeAssetDataOrThrow(eventLog.args.takerAssetData);
const takerAssetType = takerAssetData.assetProxyId === AssetProxyId.ERC20 ? 'erc20' : 'erc721';
const exchangeFillEvent = new ExchangeFillEvent();
+ exchangeFillEvent.contractAddress = eventLog.address as string;
+ exchangeFillEvent.blockNumber = eventLog.blockNumber as number;
exchangeFillEvent.logIndex = eventLog.logIndex as number;
- exchangeFillEvent.address = eventLog.address as string;
exchangeFillEvent.rawData = eventLog.data as string;
- exchangeFillEvent.blockNumber = eventLog.blockNumber as number;
exchangeFillEvent.makerAddress = eventLog.args.makerAddress.toString();
exchangeFillEvent.takerAddress = eventLog.args.takerAddress.toString();
exchangeFillEvent.feeRecepientAddress = eventLog.args.feeRecipientAddress;
@@ -94,10 +94,10 @@ export function _convertToExchangeCancelEvent(
const takerAssetData = assetDataUtils.decodeAssetDataOrThrow(eventLog.args.takerAssetData);
const takerAssetType = takerAssetData.assetProxyId === AssetProxyId.ERC20 ? 'erc20' : 'erc721';
const exchangeCancelEvent = new ExchangeCancelEvent();
+ exchangeCancelEvent.contractAddress = eventLog.address as string;
+ exchangeCancelEvent.blockNumber = eventLog.blockNumber as number;
exchangeCancelEvent.logIndex = eventLog.logIndex as number;
- exchangeCancelEvent.address = eventLog.address as string;
exchangeCancelEvent.rawData = eventLog.data as string;
- exchangeCancelEvent.blockNumber = eventLog.blockNumber as number;
exchangeCancelEvent.makerAddress = eventLog.args.makerAddress.toString();
exchangeCancelEvent.takerAddress =
eventLog.args.takerAddress == null ? null : eventLog.args.takerAddress.toString();
@@ -121,10 +121,10 @@ export function _convertToExchangeCancelUpToEvent(
eventLog: LogWithDecodedArgs<ExchangeCancelUpToEventArgs>,
): ExchangeCancelUpToEvent {
const exchangeCancelUpToEvent = new ExchangeCancelUpToEvent();
+ exchangeCancelUpToEvent.contractAddress = eventLog.address as string;
+ exchangeCancelUpToEvent.blockNumber = eventLog.blockNumber as number;
exchangeCancelUpToEvent.logIndex = eventLog.logIndex as number;
- exchangeCancelUpToEvent.address = eventLog.address as string;
exchangeCancelUpToEvent.rawData = eventLog.data as string;
- exchangeCancelUpToEvent.blockNumber = eventLog.blockNumber as number;
exchangeCancelUpToEvent.makerAddress = eventLog.args.makerAddress.toString();
exchangeCancelUpToEvent.senderAddress = eventLog.args.senderAddress.toString();
exchangeCancelUpToEvent.orderEpoch = eventLog.args.orderEpoch.toString();
diff --git a/packages/pipeline/src/entities/ExchangeCancelEvent.ts b/packages/pipeline/src/entities/ExchangeCancelEvent.ts
index c925a4b01..d0188c2f5 100644
--- a/packages/pipeline/src/entities/ExchangeCancelEvent.ts
+++ b/packages/pipeline/src/entities/ExchangeCancelEvent.ts
@@ -4,10 +4,10 @@ import { AssetType } from '../types';
@Entity()
export class ExchangeCancelEvent extends BaseEntity {
+ @PrimaryColumn() public contractAddress!: string;
@PrimaryColumn() public logIndex!: number;
@PrimaryColumn() public blockNumber!: number;
- @Column() public address!: string;
@Column() public rawData!: string;
@Column() public makerAddress!: string;
diff --git a/packages/pipeline/src/entities/ExchangeCancelUpToEvent.ts b/packages/pipeline/src/entities/ExchangeCancelUpToEvent.ts
index 3021f7394..03a02b069 100644
--- a/packages/pipeline/src/entities/ExchangeCancelUpToEvent.ts
+++ b/packages/pipeline/src/entities/ExchangeCancelUpToEvent.ts
@@ -2,10 +2,10 @@ import { BaseEntity, Column, Entity, PrimaryColumn } from 'typeorm';
@Entity()
export class ExchangeCancelUpToEvent extends BaseEntity {
+ @PrimaryColumn() public contractAddress!: string;
@PrimaryColumn() public logIndex!: number;
@PrimaryColumn() public blockNumber!: number;
- @Column() public address!: string;
@Column() public rawData!: string;
@Column() public makerAddress!: string;
diff --git a/packages/pipeline/src/entities/ExchangeFillEvent.ts b/packages/pipeline/src/entities/ExchangeFillEvent.ts
index 9ac8eb349..abd73191a 100644
--- a/packages/pipeline/src/entities/ExchangeFillEvent.ts
+++ b/packages/pipeline/src/entities/ExchangeFillEvent.ts
@@ -4,10 +4,10 @@ import { AssetType } from '../types';
@Entity()
export class ExchangeFillEvent extends BaseEntity {
+ @PrimaryColumn() public contractAddress!: string;
@PrimaryColumn() public logIndex!: number;
@PrimaryColumn() public blockNumber!: number;
- @Column() public address!: string;
@Column() public rawData!: string;
@Column() public makerAddress!: string;
diff --git a/packages/pipeline/src/index.ts b/packages/pipeline/src/index.ts
index 1a010b6e5..07ab1d991 100644
--- a/packages/pipeline/src/index.ts
+++ b/packages/pipeline/src/index.ts
@@ -17,11 +17,19 @@ const EXCHANGE_ADDRESS = '0x4f833a24e1f95d70f028921e27040ca56e09ab0b';
const fillRepository = connection.getRepository(ExchangeFillEvent);
const cancelRepository = connection.getRepository(ExchangeCancelEvent);
const cancelUpToRepository = connection.getRepository(ExchangeCancelUpToEvent);
- console.log(`found ${(await fillRepository.count()) + (await cancelRepository.count())} existing events`);
+ console.log(
+ `found ${(await fillRepository.count()) +
+ (await cancelRepository.count()) +
+ (await cancelUpToRepository.count())} existing events`,
+ );
const rawEvents = await etherscan.getContractEventsAsync(EXCHANGE_ADDRESS);
const events = parseExchangeEvents(rawEvents);
for (const event of events) {
await event.save();
}
- console.log(`now there are ${(await fillRepository.count()) + (await cancelRepository.count())} total events`);
+ console.log(
+ `now there are ${(await fillRepository.count()) +
+ (await cancelRepository.count()) +
+ (await cancelUpToRepository.count())} total events`,
+ );
})();