From 4e6919a6e58d76766098262664c78f92d888337d Mon Sep 17 00:00:00 2001 From: Alex Browne Date: Wed, 19 Sep 2018 17:30:34 -0700 Subject: Add typeorm and begin inserting database records --- .../pipeline/src/entities/ExchangeFillEvent.ts | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 packages/pipeline/src/entities/ExchangeFillEvent.ts (limited to 'packages/pipeline/src/entities') diff --git a/packages/pipeline/src/entities/ExchangeFillEvent.ts b/packages/pipeline/src/entities/ExchangeFillEvent.ts new file mode 100644 index 000000000..1e9e8d986 --- /dev/null +++ b/packages/pipeline/src/entities/ExchangeFillEvent.ts @@ -0,0 +1,24 @@ +import { Column, Entity, PrimaryColumn } from 'typeorm'; + +@Entity() +export class ExchangeFillEvent { + @PrimaryColumn() public logIndex!: number; + + @Column() public address!: string; + @Column() public rawData!: string; + @Column() public blockNumber!: number; + + @Column() public makerAddress!: string; + @Column() public takerAddress!: string; + @Column() public feeRecepientAddress!: string; + @Column() public senderAddress!: string; + @Column() public makerAssetFilledAmount!: string; + @Column() public takerAssetFilledAmount!: string; + @Column() public makerFeePaid!: string; + @Column() public takerFeePaid!: string; + @Column() public orderHash!: string; + // TODO(albrow): Decode asset data. + @Column() public makerAssetData!: string; + @Column() public takerAssetData!: string; + // TODO(albrow): Include topics? +} -- cgit v1.2.3 From 9e9104578c8526ff48ecdda8b87d61ccb3d66a2d Mon Sep 17 00:00:00 2001 From: Alex Browne Date: Thu, 20 Sep 2018 17:25:48 -0700 Subject: Add support for decoding asset data --- packages/pipeline/src/entities/ExchangeFillEvent.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'packages/pipeline/src/entities') diff --git a/packages/pipeline/src/entities/ExchangeFillEvent.ts b/packages/pipeline/src/entities/ExchangeFillEvent.ts index 1e9e8d986..1716c60d1 100644 --- a/packages/pipeline/src/entities/ExchangeFillEvent.ts +++ b/packages/pipeline/src/entities/ExchangeFillEvent.ts @@ -1,5 +1,7 @@ import { Column, Entity, PrimaryColumn } from 'typeorm'; +export type ExchangeFillEventAssetType = 'erc20' | 'erc721'; + @Entity() export class ExchangeFillEvent { @PrimaryColumn() public logIndex!: number; @@ -17,8 +19,17 @@ export class ExchangeFillEvent { @Column() public makerFeePaid!: string; @Column() public takerFeePaid!: string; @Column() public orderHash!: string; - // TODO(albrow): Decode asset data. - @Column() public makerAssetData!: string; - @Column() public takerAssetData!: string; + @Column() public rawMakerAssetData!: string; + @Column() public makerAssetType!: ExchangeFillEventAssetType; + @Column() public makerAssetProxyId!: string; + @Column() public makerTokenAddress!: string; + @Column({ nullable: true, type: String }) + public makerTokenId!: string | null; + @Column() public rawTakerAssetData!: string; + @Column() public takerAssetType!: ExchangeFillEventAssetType; + @Column() public takerAssetProxyId!: string; + @Column() public takerTokenAddress!: string; + @Column({ nullable: true, type: String }) + public takerTokenId!: string | null; // TODO(albrow): Include topics? } -- cgit v1.2.3 From fe523e1f3f765077bdaf4dfc345c9dca67693668 Mon Sep 17 00:00:00 2001 From: Alex Browne Date: Tue, 25 Sep 2018 12:54:10 -0700 Subject: Re-organize event parsing and decoding --- packages/pipeline/src/entities/ExchangeFillEvent.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'packages/pipeline/src/entities') diff --git a/packages/pipeline/src/entities/ExchangeFillEvent.ts b/packages/pipeline/src/entities/ExchangeFillEvent.ts index 1716c60d1..a7e817240 100644 --- a/packages/pipeline/src/entities/ExchangeFillEvent.ts +++ b/packages/pipeline/src/entities/ExchangeFillEvent.ts @@ -1,9 +1,9 @@ -import { Column, Entity, PrimaryColumn } from 'typeorm'; +import { BaseEntity, Column, Entity, PrimaryColumn } from 'typeorm'; export type ExchangeFillEventAssetType = 'erc20' | 'erc721'; @Entity() -export class ExchangeFillEvent { +export class ExchangeFillEvent extends BaseEntity { @PrimaryColumn() public logIndex!: number; @Column() public address!: string; -- cgit v1.2.3 From 60bc27c616c411cf67bf89e669fb293135359685 Mon Sep 17 00:00:00 2001 From: Alex Browne Date: Tue, 25 Sep 2018 15:03:49 -0700 Subject: Implement scraping and parsing exchange cancel events --- .../pipeline/src/entities/ExchangeCancelEvent.ts | 32 ++++++++++++++++++++++ .../pipeline/src/entities/ExchangeFillEvent.ts | 6 ++-- 2 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 packages/pipeline/src/entities/ExchangeCancelEvent.ts (limited to 'packages/pipeline/src/entities') diff --git a/packages/pipeline/src/entities/ExchangeCancelEvent.ts b/packages/pipeline/src/entities/ExchangeCancelEvent.ts new file mode 100644 index 000000000..8e21518d3 --- /dev/null +++ b/packages/pipeline/src/entities/ExchangeCancelEvent.ts @@ -0,0 +1,32 @@ +import { BaseEntity, Column, Entity, PrimaryColumn } from 'typeorm'; + +import { AssetType } from '../types'; + +@Entity() +export class ExchangeCancelEvent extends BaseEntity { + @PrimaryColumn() public logIndex!: number; + + @Column() public address!: string; + @Column() public rawData!: string; + @Column() public blockNumber!: number; + + @Column() public makerAddress!: string; + @Column({ nullable: true, type: String }) + public takerAddress!: string; + @Column() public feeRecepientAddress!: string; + @Column() public senderAddress!: string; + @Column() public orderHash!: string; + @Column() public rawMakerAssetData!: string; + @Column() public makerAssetType!: AssetType; + @Column() public makerAssetProxyId!: string; + @Column() public makerTokenAddress!: string; + @Column({ nullable: true, type: String }) + public makerTokenId!: string | null; + @Column() public rawTakerAssetData!: string; + @Column() public takerAssetType!: AssetType; + @Column() public takerAssetProxyId!: string; + @Column() public takerTokenAddress!: string; + @Column({ nullable: true, type: String }) + public takerTokenId!: string | null; + // TODO(albrow): Include topics? +} diff --git a/packages/pipeline/src/entities/ExchangeFillEvent.ts b/packages/pipeline/src/entities/ExchangeFillEvent.ts index a7e817240..e66bd64e3 100644 --- a/packages/pipeline/src/entities/ExchangeFillEvent.ts +++ b/packages/pipeline/src/entities/ExchangeFillEvent.ts @@ -1,6 +1,6 @@ import { BaseEntity, Column, Entity, PrimaryColumn } from 'typeorm'; -export type ExchangeFillEventAssetType = 'erc20' | 'erc721'; +import { AssetType } from '../types'; @Entity() export class ExchangeFillEvent extends BaseEntity { @@ -20,13 +20,13 @@ export class ExchangeFillEvent extends BaseEntity { @Column() public takerFeePaid!: string; @Column() public orderHash!: string; @Column() public rawMakerAssetData!: string; - @Column() public makerAssetType!: ExchangeFillEventAssetType; + @Column() public makerAssetType!: AssetType; @Column() public makerAssetProxyId!: string; @Column() public makerTokenAddress!: string; @Column({ nullable: true, type: String }) public makerTokenId!: string | null; @Column() public rawTakerAssetData!: string; - @Column() public takerAssetType!: ExchangeFillEventAssetType; + @Column() public takerAssetType!: AssetType; @Column() public takerAssetProxyId!: string; @Column() public takerTokenAddress!: string; @Column({ nullable: true, type: String }) -- cgit v1.2.3 From 40610830da70ae406227e80c700efea11042ba68 Mon Sep 17 00:00:00 2001 From: Alex Browne Date: Tue, 25 Sep 2018 15:31:41 -0700 Subject: Use multi-primary keys for event and filter null logIndexes --- packages/pipeline/src/entities/ExchangeCancelEvent.ts | 2 +- packages/pipeline/src/entities/ExchangeFillEvent.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'packages/pipeline/src/entities') 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; -- cgit v1.2.3 From b0de2a388fc7079bc45c7886b002420783021416 Mon Sep 17 00:00:00 2001 From: Alex Browne Date: Tue, 25 Sep 2018 16:03:54 -0700 Subject: Implement scraping and parsing exchange CancelUpTo events --- packages/pipeline/src/entities/ExchangeCancelUpToEvent.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 packages/pipeline/src/entities/ExchangeCancelUpToEvent.ts (limited to 'packages/pipeline/src/entities') diff --git a/packages/pipeline/src/entities/ExchangeCancelUpToEvent.ts b/packages/pipeline/src/entities/ExchangeCancelUpToEvent.ts new file mode 100644 index 000000000..3021f7394 --- /dev/null +++ b/packages/pipeline/src/entities/ExchangeCancelUpToEvent.ts @@ -0,0 +1,15 @@ +import { BaseEntity, Column, Entity, PrimaryColumn } from 'typeorm'; + +@Entity() +export class ExchangeCancelUpToEvent extends BaseEntity { + @PrimaryColumn() public logIndex!: number; + @PrimaryColumn() public blockNumber!: number; + + @Column() public address!: string; + @Column() public rawData!: string; + + @Column() public makerAddress!: string; + @Column() public senderAddress!: string; + @Column() public orderEpoch!: string; + // TODO(albrow): Include topics? +} -- cgit v1.2.3 From 71a015f2aa32fedd3d3c5e9d5a3fa4eb272b2852 Mon Sep 17 00:00:00 2001 From: Alex Browne Date: Tue, 25 Sep 2018 16:06:52 -0700 Subject: For event entities, rename address -> contractAddress and make it a primary key --- packages/pipeline/src/entities/ExchangeCancelEvent.ts | 2 +- packages/pipeline/src/entities/ExchangeCancelUpToEvent.ts | 2 +- packages/pipeline/src/entities/ExchangeFillEvent.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'packages/pipeline/src/entities') 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; -- cgit v1.2.3 From 9ab55ccec0478e65f9d605aa2da7ed1fa13e01ac Mon Sep 17 00:00:00 2001 From: Alex Browne Date: Wed, 26 Sep 2018 16:42:48 -0700 Subject: Add preliminary support for scraping orders from SRA endpoints (no pagination, only RR support for now) --- .../pipeline/src/entities/ExchangeCancelEvent.ts | 2 ++ .../pipeline/src/entities/ExchangeFillEvent.ts | 2 ++ packages/pipeline/src/entities/SraOrder.ts | 40 ++++++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 packages/pipeline/src/entities/SraOrder.ts (limited to 'packages/pipeline/src/entities') diff --git a/packages/pipeline/src/entities/ExchangeCancelEvent.ts b/packages/pipeline/src/entities/ExchangeCancelEvent.ts index d0188c2f5..7010ab9f2 100644 --- a/packages/pipeline/src/entities/ExchangeCancelEvent.ts +++ b/packages/pipeline/src/entities/ExchangeCancelEvent.ts @@ -16,6 +16,7 @@ export class ExchangeCancelEvent extends BaseEntity { @Column() public feeRecepientAddress!: string; @Column() public senderAddress!: string; @Column() public orderHash!: string; + @Column() public rawMakerAssetData!: string; @Column() public makerAssetType!: AssetType; @Column() public makerAssetProxyId!: string; @@ -28,5 +29,6 @@ export class ExchangeCancelEvent extends BaseEntity { @Column() public takerTokenAddress!: string; @Column({ nullable: true, type: String }) public takerTokenId!: string | null; + // TODO(albrow): Include topics? } diff --git a/packages/pipeline/src/entities/ExchangeFillEvent.ts b/packages/pipeline/src/entities/ExchangeFillEvent.ts index abd73191a..5eafa7449 100644 --- a/packages/pipeline/src/entities/ExchangeFillEvent.ts +++ b/packages/pipeline/src/entities/ExchangeFillEvent.ts @@ -19,6 +19,7 @@ export class ExchangeFillEvent extends BaseEntity { @Column() public makerFeePaid!: string; @Column() public takerFeePaid!: string; @Column() public orderHash!: string; + @Column() public rawMakerAssetData!: string; @Column() public makerAssetType!: AssetType; @Column() public makerAssetProxyId!: string; @@ -31,5 +32,6 @@ export class ExchangeFillEvent extends BaseEntity { @Column() public takerTokenAddress!: string; @Column({ nullable: true, type: String }) public takerTokenId!: string | null; + // TODO(albrow): Include topics? } diff --git a/packages/pipeline/src/entities/SraOrder.ts b/packages/pipeline/src/entities/SraOrder.ts new file mode 100644 index 000000000..c9a1f926d --- /dev/null +++ b/packages/pipeline/src/entities/SraOrder.ts @@ -0,0 +1,40 @@ +import { BaseEntity, Column, Entity, PrimaryColumn } from 'typeorm'; + +import { AssetType } from '../types'; + +@Entity() +export class SraOrder extends BaseEntity { + @PrimaryColumn() public exchangeAddress!: string; + @PrimaryColumn() public orderHashHex!: string; + + @Column() public lastUpdatedTimestamp!: number; + @Column() public firstSeenTimestamp!: number; + + @Column() public makerAddress!: string; + @Column() public takerAddress!: string; + @Column() public feeRecipientAddress!: string; + @Column() public senderAddress!: string; + @Column() public makerAssetAmount!: string; + @Column() public takerAssetAmount!: string; + @Column() public makerFee!: string; + @Column() public takerFee!: string; + @Column() public expirationTimeSeconds!: string; + @Column() public salt!: string; + @Column() public signature!: string; + + @Column() public rawMakerAssetData!: string; + @Column() public makerAssetType!: AssetType; + @Column() public makerAssetProxyId!: string; + @Column() public makerTokenAddress!: string; + @Column({ nullable: true, type: String }) + public makerTokenId!: string | null; + @Column() public rawTakerAssetData!: string; + @Column() public takerAssetType!: AssetType; + @Column() public takerAssetProxyId!: string; + @Column() public takerTokenAddress!: string; + @Column({ nullable: true, type: String }) + public takerTokenId!: string | null; + + // TODO(albrow): Make this optional? + @Column() public metaDataJson!: string; +} -- cgit v1.2.3 From dd093daf916ee3d6ce0021be0a245990e0cd2c56 Mon Sep 17 00:00:00 2001 From: Alex Browne Date: Thu, 27 Sep 2018 13:53:37 -0700 Subject: Add soruceUrl to SraOrder entity --- packages/pipeline/src/entities/SraOrder.ts | 1 + 1 file changed, 1 insertion(+) (limited to 'packages/pipeline/src/entities') diff --git a/packages/pipeline/src/entities/SraOrder.ts b/packages/pipeline/src/entities/SraOrder.ts index c9a1f926d..e4987df57 100644 --- a/packages/pipeline/src/entities/SraOrder.ts +++ b/packages/pipeline/src/entities/SraOrder.ts @@ -7,6 +7,7 @@ export class SraOrder extends BaseEntity { @PrimaryColumn() public exchangeAddress!: string; @PrimaryColumn() public orderHashHex!: string; + @Column() public sourceUrl!: string; @Column() public lastUpdatedTimestamp!: number; @Column() public firstSeenTimestamp!: number; -- cgit v1.2.3 From 3a19faa5ff8a66395c5eb8d1400338cefaa21187 Mon Sep 17 00:00:00 2001 From: Alex Browne Date: Thu, 18 Oct 2018 17:44:48 -0700 Subject: Update script to work with existing v1 pipeline data --- packages/pipeline/src/entities/ExchangeCancelEvent.ts | 5 +++-- packages/pipeline/src/entities/ExchangeCancelUpToEvent.ts | 5 +++-- packages/pipeline/src/entities/ExchangeFillEvent.ts | 7 ++++--- packages/pipeline/src/entities/SraOrder.ts | 4 ++-- 4 files changed, 12 insertions(+), 9 deletions(-) (limited to 'packages/pipeline/src/entities') diff --git a/packages/pipeline/src/entities/ExchangeCancelEvent.ts b/packages/pipeline/src/entities/ExchangeCancelEvent.ts index 7010ab9f2..698b9e2ec 100644 --- a/packages/pipeline/src/entities/ExchangeCancelEvent.ts +++ b/packages/pipeline/src/entities/ExchangeCancelEvent.ts @@ -1,15 +1,16 @@ -import { BaseEntity, Column, Entity, PrimaryColumn } from 'typeorm'; +import { Column, Entity, PrimaryColumn } from 'typeorm'; import { AssetType } from '../types'; @Entity() -export class ExchangeCancelEvent extends BaseEntity { +export class ExchangeCancelEvent { @PrimaryColumn() public contractAddress!: string; @PrimaryColumn() public logIndex!: number; @PrimaryColumn() public blockNumber!: number; @Column() public rawData!: string; + // TODO(albrow): Include transaction hash @Column() public makerAddress!: string; @Column({ nullable: true, type: String }) public takerAddress!: string; diff --git a/packages/pipeline/src/entities/ExchangeCancelUpToEvent.ts b/packages/pipeline/src/entities/ExchangeCancelUpToEvent.ts index 03a02b069..3ca75ccf7 100644 --- a/packages/pipeline/src/entities/ExchangeCancelUpToEvent.ts +++ b/packages/pipeline/src/entities/ExchangeCancelUpToEvent.ts @@ -1,11 +1,12 @@ -import { BaseEntity, Column, Entity, PrimaryColumn } from 'typeorm'; +import { Column, Entity, PrimaryColumn } from 'typeorm'; @Entity() -export class ExchangeCancelUpToEvent extends BaseEntity { +export class ExchangeCancelUpToEvent { @PrimaryColumn() public contractAddress!: string; @PrimaryColumn() public logIndex!: number; @PrimaryColumn() public blockNumber!: number; + // TODO(albrow): Include transaction hash @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 5eafa7449..6e549af93 100644 --- a/packages/pipeline/src/entities/ExchangeFillEvent.ts +++ b/packages/pipeline/src/entities/ExchangeFillEvent.ts @@ -1,18 +1,19 @@ -import { BaseEntity, Column, Entity, PrimaryColumn } from 'typeorm'; +import { Column, Entity, PrimaryColumn } from 'typeorm'; import { AssetType } from '../types'; @Entity() -export class ExchangeFillEvent extends BaseEntity { +export class ExchangeFillEvent { @PrimaryColumn() public contractAddress!: string; @PrimaryColumn() public logIndex!: number; @PrimaryColumn() public blockNumber!: number; @Column() public rawData!: string; + @Column() public transactionHash!: string; @Column() public makerAddress!: string; @Column() public takerAddress!: string; - @Column() public feeRecepientAddress!: string; + @Column() public feeRecipientAddress!: string; @Column() public senderAddress!: string; @Column() public makerAssetFilledAmount!: string; @Column() public takerAssetFilledAmount!: string; diff --git a/packages/pipeline/src/entities/SraOrder.ts b/packages/pipeline/src/entities/SraOrder.ts index e4987df57..a22f7c4e5 100644 --- a/packages/pipeline/src/entities/SraOrder.ts +++ b/packages/pipeline/src/entities/SraOrder.ts @@ -1,9 +1,9 @@ -import { BaseEntity, Column, Entity, PrimaryColumn } from 'typeorm'; +import { Column, Entity, PrimaryColumn } from 'typeorm'; import { AssetType } from '../types'; @Entity() -export class SraOrder extends BaseEntity { +export class SraOrder { @PrimaryColumn() public exchangeAddress!: string; @PrimaryColumn() public orderHashHex!: string; -- cgit v1.2.3 From bb440b683a7a4d966694de2b897f51f22dadb31c Mon Sep 17 00:00:00 2001 From: Alex Browne Date: Tue, 23 Oct 2018 16:03:52 -0700 Subject: Implement support for getting and parsing blocks and transactions --- packages/pipeline/src/entities/Block.ts | 9 +++++++++ packages/pipeline/src/entities/Transaction.ts | 11 +++++++++++ 2 files changed, 20 insertions(+) create mode 100644 packages/pipeline/src/entities/Block.ts create mode 100644 packages/pipeline/src/entities/Transaction.ts (limited to 'packages/pipeline/src/entities') diff --git a/packages/pipeline/src/entities/Block.ts b/packages/pipeline/src/entities/Block.ts new file mode 100644 index 000000000..49e0ef840 --- /dev/null +++ b/packages/pipeline/src/entities/Block.ts @@ -0,0 +1,9 @@ +import { Column, Entity, PrimaryColumn } from 'typeorm'; + +@Entity() +export class Block { + @PrimaryColumn() public hash!: string; + @PrimaryColumn() public number!: number; + + @Column() public unixTimestampSeconds!: number; +} diff --git a/packages/pipeline/src/entities/Transaction.ts b/packages/pipeline/src/entities/Transaction.ts new file mode 100644 index 000000000..d89d44746 --- /dev/null +++ b/packages/pipeline/src/entities/Transaction.ts @@ -0,0 +1,11 @@ +import { Column, Entity, PrimaryColumn } from 'typeorm'; + +@Entity() +export class Transaction { + @PrimaryColumn() public transactionHash!: string; + @PrimaryColumn() public blockHash!: string; + @PrimaryColumn() public blockNumber!: number; + + @Column() public gasUsed!: number; + @Column() public gasPrice!: number; +} -- cgit v1.2.3 From 5e22a862b77d4947361342972c28a8552d13018e Mon Sep 17 00:00:00 2001 From: Alex Browne Date: Wed, 24 Oct 2018 18:34:20 -0700 Subject: Implement fetching and parsing relayer info --- packages/pipeline/src/entities/Relayer.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 packages/pipeline/src/entities/Relayer.ts (limited to 'packages/pipeline/src/entities') diff --git a/packages/pipeline/src/entities/Relayer.ts b/packages/pipeline/src/entities/Relayer.ts new file mode 100644 index 000000000..ebdcbf345 --- /dev/null +++ b/packages/pipeline/src/entities/Relayer.ts @@ -0,0 +1,22 @@ +import { Column, Entity, PrimaryColumn } from 'typeorm'; + +@Entity() +export class Relayer { + @PrimaryColumn() public name!: string; + + @Column() public url!: string; + @Column({ nullable: true, type: String }) + public sraHttpEndpoint!: string | null; + @Column({ nullable: true, type: String }) + public sraWsEndpoint!: string | null; + @Column({ nullable: true, type: String }) + public appUrl!: string | null; + + // TODO(albrow): Add exchange contract or protocol version? + // TODO(albrow): Add network ids for addresses? + + @Column({ type: 'varchar', array: true }) + public feeRecipientAddresses!: string[]; + @Column({ type: 'varchar', array: true }) + public takerAddresses!: string[]; +} -- cgit v1.2.3 From 8248fbb231a0c0acd59fd1f265114dd6dc78a253 Mon Sep 17 00:00:00 2001 From: Alex Browne Date: Wed, 7 Nov 2018 15:29:34 -0800 Subject: Update relayer code to use new relayer-registry format --- packages/pipeline/src/entities/Relayer.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'packages/pipeline/src/entities') diff --git a/packages/pipeline/src/entities/Relayer.ts b/packages/pipeline/src/entities/Relayer.ts index ebdcbf345..605355fa8 100644 --- a/packages/pipeline/src/entities/Relayer.ts +++ b/packages/pipeline/src/entities/Relayer.ts @@ -2,8 +2,9 @@ import { Column, Entity, PrimaryColumn } from 'typeorm'; @Entity() export class Relayer { - @PrimaryColumn() public name!: string; + @PrimaryColumn() public uuid!: string; + @Column() public name!: string; @Column() public url!: string; @Column({ nullable: true, type: String }) public sraHttpEndpoint!: string | null; -- cgit v1.2.3 From 830d0f3b21ae26a2b683c388211e442e82bc7459 Mon Sep 17 00:00:00 2001 From: Alex Browne Date: Wed, 7 Nov 2018 15:56:35 -0800 Subject: Use bigint for gasUsed and gasPrice in Transaction --- packages/pipeline/src/entities/Transaction.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'packages/pipeline/src/entities') diff --git a/packages/pipeline/src/entities/Transaction.ts b/packages/pipeline/src/entities/Transaction.ts index d89d44746..8a68da813 100644 --- a/packages/pipeline/src/entities/Transaction.ts +++ b/packages/pipeline/src/entities/Transaction.ts @@ -6,6 +6,8 @@ export class Transaction { @PrimaryColumn() public blockHash!: string; @PrimaryColumn() public blockNumber!: number; - @Column() public gasUsed!: number; - @Column() public gasPrice!: number; + @Column({ type: 'bigint' }) + public gasUsed!: number; + @Column({ type: 'bigint' }) + public gasPrice!: number; } -- cgit v1.2.3 From ccad046eb649a60fdf7319a075fa41490d593ae8 Mon Sep 17 00:00:00 2001 From: Alex Browne Date: Thu, 8 Nov 2018 10:15:09 -0800 Subject: Reorganize entities. Make scripts work from any directory. --- .../pipeline/src/entities/ExchangeCancelEvent.ts | 35 ------------------ .../src/entities/ExchangeCancelUpToEvent.ts | 16 --------- .../pipeline/src/entities/ExchangeFillEvent.ts | 38 -------------------- packages/pipeline/src/entities/SraOrder.ts | 41 ---------------------- .../pipeline/src/entities/exchange_cancel_event.ts | 35 ++++++++++++++++++ .../src/entities/exchange_cancel_up_to_event.ts | 16 +++++++++ .../pipeline/src/entities/exchange_fill_event.ts | 38 ++++++++++++++++++++ packages/pipeline/src/entities/index.ts | 7 ++++ packages/pipeline/src/entities/sra_order.ts | 41 ++++++++++++++++++++++ 9 files changed, 137 insertions(+), 130 deletions(-) delete mode 100644 packages/pipeline/src/entities/ExchangeCancelEvent.ts delete mode 100644 packages/pipeline/src/entities/ExchangeCancelUpToEvent.ts delete mode 100644 packages/pipeline/src/entities/ExchangeFillEvent.ts delete mode 100644 packages/pipeline/src/entities/SraOrder.ts create mode 100644 packages/pipeline/src/entities/exchange_cancel_event.ts create mode 100644 packages/pipeline/src/entities/exchange_cancel_up_to_event.ts create mode 100644 packages/pipeline/src/entities/exchange_fill_event.ts create mode 100644 packages/pipeline/src/entities/index.ts create mode 100644 packages/pipeline/src/entities/sra_order.ts (limited to 'packages/pipeline/src/entities') diff --git a/packages/pipeline/src/entities/ExchangeCancelEvent.ts b/packages/pipeline/src/entities/ExchangeCancelEvent.ts deleted file mode 100644 index 698b9e2ec..000000000 --- a/packages/pipeline/src/entities/ExchangeCancelEvent.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { Column, Entity, PrimaryColumn } from 'typeorm'; - -import { AssetType } from '../types'; - -@Entity() -export class ExchangeCancelEvent { - @PrimaryColumn() public contractAddress!: string; - @PrimaryColumn() public logIndex!: number; - @PrimaryColumn() public blockNumber!: number; - - @Column() public rawData!: string; - - // TODO(albrow): Include transaction hash - @Column() public makerAddress!: string; - @Column({ nullable: true, type: String }) - public takerAddress!: string; - @Column() public feeRecepientAddress!: string; - @Column() public senderAddress!: string; - @Column() public orderHash!: string; - - @Column() public rawMakerAssetData!: string; - @Column() public makerAssetType!: AssetType; - @Column() public makerAssetProxyId!: string; - @Column() public makerTokenAddress!: string; - @Column({ nullable: true, type: String }) - public makerTokenId!: string | null; - @Column() public rawTakerAssetData!: string; - @Column() public takerAssetType!: AssetType; - @Column() public takerAssetProxyId!: string; - @Column() public takerTokenAddress!: string; - @Column({ nullable: true, type: String }) - public takerTokenId!: string | null; - - // TODO(albrow): Include topics? -} diff --git a/packages/pipeline/src/entities/ExchangeCancelUpToEvent.ts b/packages/pipeline/src/entities/ExchangeCancelUpToEvent.ts deleted file mode 100644 index 3ca75ccf7..000000000 --- a/packages/pipeline/src/entities/ExchangeCancelUpToEvent.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { Column, Entity, PrimaryColumn } from 'typeorm'; - -@Entity() -export class ExchangeCancelUpToEvent { - @PrimaryColumn() public contractAddress!: string; - @PrimaryColumn() public logIndex!: number; - @PrimaryColumn() public blockNumber!: number; - - // TODO(albrow): Include transaction hash - @Column() public rawData!: string; - - @Column() public makerAddress!: string; - @Column() public senderAddress!: string; - @Column() public orderEpoch!: string; - // TODO(albrow): Include topics? -} diff --git a/packages/pipeline/src/entities/ExchangeFillEvent.ts b/packages/pipeline/src/entities/ExchangeFillEvent.ts deleted file mode 100644 index 6e549af93..000000000 --- a/packages/pipeline/src/entities/ExchangeFillEvent.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { Column, Entity, PrimaryColumn } from 'typeorm'; - -import { AssetType } from '../types'; - -@Entity() -export class ExchangeFillEvent { - @PrimaryColumn() public contractAddress!: string; - @PrimaryColumn() public logIndex!: number; - @PrimaryColumn() public blockNumber!: number; - - @Column() public rawData!: string; - - @Column() public transactionHash!: string; - @Column() public makerAddress!: string; - @Column() public takerAddress!: string; - @Column() public feeRecipientAddress!: string; - @Column() public senderAddress!: string; - @Column() public makerAssetFilledAmount!: string; - @Column() public takerAssetFilledAmount!: string; - @Column() public makerFeePaid!: string; - @Column() public takerFeePaid!: string; - @Column() public orderHash!: string; - - @Column() public rawMakerAssetData!: string; - @Column() public makerAssetType!: AssetType; - @Column() public makerAssetProxyId!: string; - @Column() public makerTokenAddress!: string; - @Column({ nullable: true, type: String }) - public makerTokenId!: string | null; - @Column() public rawTakerAssetData!: string; - @Column() public takerAssetType!: AssetType; - @Column() public takerAssetProxyId!: string; - @Column() public takerTokenAddress!: string; - @Column({ nullable: true, type: String }) - public takerTokenId!: string | null; - - // TODO(albrow): Include topics? -} diff --git a/packages/pipeline/src/entities/SraOrder.ts b/packages/pipeline/src/entities/SraOrder.ts deleted file mode 100644 index a22f7c4e5..000000000 --- a/packages/pipeline/src/entities/SraOrder.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { Column, Entity, PrimaryColumn } from 'typeorm'; - -import { AssetType } from '../types'; - -@Entity() -export class SraOrder { - @PrimaryColumn() public exchangeAddress!: string; - @PrimaryColumn() public orderHashHex!: string; - - @Column() public sourceUrl!: string; - @Column() public lastUpdatedTimestamp!: number; - @Column() public firstSeenTimestamp!: number; - - @Column() public makerAddress!: string; - @Column() public takerAddress!: string; - @Column() public feeRecipientAddress!: string; - @Column() public senderAddress!: string; - @Column() public makerAssetAmount!: string; - @Column() public takerAssetAmount!: string; - @Column() public makerFee!: string; - @Column() public takerFee!: string; - @Column() public expirationTimeSeconds!: string; - @Column() public salt!: string; - @Column() public signature!: string; - - @Column() public rawMakerAssetData!: string; - @Column() public makerAssetType!: AssetType; - @Column() public makerAssetProxyId!: string; - @Column() public makerTokenAddress!: string; - @Column({ nullable: true, type: String }) - public makerTokenId!: string | null; - @Column() public rawTakerAssetData!: string; - @Column() public takerAssetType!: AssetType; - @Column() public takerAssetProxyId!: string; - @Column() public takerTokenAddress!: string; - @Column({ nullable: true, type: String }) - public takerTokenId!: string | null; - - // TODO(albrow): Make this optional? - @Column() public metaDataJson!: string; -} diff --git a/packages/pipeline/src/entities/exchange_cancel_event.ts b/packages/pipeline/src/entities/exchange_cancel_event.ts new file mode 100644 index 000000000..698b9e2ec --- /dev/null +++ b/packages/pipeline/src/entities/exchange_cancel_event.ts @@ -0,0 +1,35 @@ +import { Column, Entity, PrimaryColumn } from 'typeorm'; + +import { AssetType } from '../types'; + +@Entity() +export class ExchangeCancelEvent { + @PrimaryColumn() public contractAddress!: string; + @PrimaryColumn() public logIndex!: number; + @PrimaryColumn() public blockNumber!: number; + + @Column() public rawData!: string; + + // TODO(albrow): Include transaction hash + @Column() public makerAddress!: string; + @Column({ nullable: true, type: String }) + public takerAddress!: string; + @Column() public feeRecepientAddress!: string; + @Column() public senderAddress!: string; + @Column() public orderHash!: string; + + @Column() public rawMakerAssetData!: string; + @Column() public makerAssetType!: AssetType; + @Column() public makerAssetProxyId!: string; + @Column() public makerTokenAddress!: string; + @Column({ nullable: true, type: String }) + public makerTokenId!: string | null; + @Column() public rawTakerAssetData!: string; + @Column() public takerAssetType!: AssetType; + @Column() public takerAssetProxyId!: string; + @Column() public takerTokenAddress!: string; + @Column({ nullable: true, type: String }) + public takerTokenId!: string | null; + + // TODO(albrow): Include topics? +} diff --git a/packages/pipeline/src/entities/exchange_cancel_up_to_event.ts b/packages/pipeline/src/entities/exchange_cancel_up_to_event.ts new file mode 100644 index 000000000..3ca75ccf7 --- /dev/null +++ b/packages/pipeline/src/entities/exchange_cancel_up_to_event.ts @@ -0,0 +1,16 @@ +import { Column, Entity, PrimaryColumn } from 'typeorm'; + +@Entity() +export class ExchangeCancelUpToEvent { + @PrimaryColumn() public contractAddress!: string; + @PrimaryColumn() public logIndex!: number; + @PrimaryColumn() public blockNumber!: number; + + // TODO(albrow): Include transaction hash + @Column() public rawData!: string; + + @Column() public makerAddress!: string; + @Column() public senderAddress!: string; + @Column() public orderEpoch!: string; + // TODO(albrow): Include topics? +} diff --git a/packages/pipeline/src/entities/exchange_fill_event.ts b/packages/pipeline/src/entities/exchange_fill_event.ts new file mode 100644 index 000000000..6e549af93 --- /dev/null +++ b/packages/pipeline/src/entities/exchange_fill_event.ts @@ -0,0 +1,38 @@ +import { Column, Entity, PrimaryColumn } from 'typeorm'; + +import { AssetType } from '../types'; + +@Entity() +export class ExchangeFillEvent { + @PrimaryColumn() public contractAddress!: string; + @PrimaryColumn() public logIndex!: number; + @PrimaryColumn() public blockNumber!: number; + + @Column() public rawData!: string; + + @Column() public transactionHash!: string; + @Column() public makerAddress!: string; + @Column() public takerAddress!: string; + @Column() public feeRecipientAddress!: string; + @Column() public senderAddress!: string; + @Column() public makerAssetFilledAmount!: string; + @Column() public takerAssetFilledAmount!: string; + @Column() public makerFeePaid!: string; + @Column() public takerFeePaid!: string; + @Column() public orderHash!: string; + + @Column() public rawMakerAssetData!: string; + @Column() public makerAssetType!: AssetType; + @Column() public makerAssetProxyId!: string; + @Column() public makerTokenAddress!: string; + @Column({ nullable: true, type: String }) + public makerTokenId!: string | null; + @Column() public rawTakerAssetData!: string; + @Column() public takerAssetType!: AssetType; + @Column() public takerAssetProxyId!: string; + @Column() public takerTokenAddress!: string; + @Column({ nullable: true, type: String }) + public takerTokenId!: string | null; + + // TODO(albrow): Include topics? +} diff --git a/packages/pipeline/src/entities/index.ts b/packages/pipeline/src/entities/index.ts new file mode 100644 index 000000000..4cd8d9da2 --- /dev/null +++ b/packages/pipeline/src/entities/index.ts @@ -0,0 +1,7 @@ +export { Block } from './block'; +export { ExchangeCancelEvent } from './exchange_cancel_event'; +export { ExchangeCancelUpToEvent } from './exchange_cancel_up_to_event'; +export { ExchangeFillEvent } from './exchange_fill_event'; +export { Relayer } from './relayer'; +export { SraOrder } from './sra_order'; +export { Transaction } from './transaction'; diff --git a/packages/pipeline/src/entities/sra_order.ts b/packages/pipeline/src/entities/sra_order.ts new file mode 100644 index 000000000..a22f7c4e5 --- /dev/null +++ b/packages/pipeline/src/entities/sra_order.ts @@ -0,0 +1,41 @@ +import { Column, Entity, PrimaryColumn } from 'typeorm'; + +import { AssetType } from '../types'; + +@Entity() +export class SraOrder { + @PrimaryColumn() public exchangeAddress!: string; + @PrimaryColumn() public orderHashHex!: string; + + @Column() public sourceUrl!: string; + @Column() public lastUpdatedTimestamp!: number; + @Column() public firstSeenTimestamp!: number; + + @Column() public makerAddress!: string; + @Column() public takerAddress!: string; + @Column() public feeRecipientAddress!: string; + @Column() public senderAddress!: string; + @Column() public makerAssetAmount!: string; + @Column() public takerAssetAmount!: string; + @Column() public makerFee!: string; + @Column() public takerFee!: string; + @Column() public expirationTimeSeconds!: string; + @Column() public salt!: string; + @Column() public signature!: string; + + @Column() public rawMakerAssetData!: string; + @Column() public makerAssetType!: AssetType; + @Column() public makerAssetProxyId!: string; + @Column() public makerTokenAddress!: string; + @Column({ nullable: true, type: String }) + public makerTokenId!: string | null; + @Column() public rawTakerAssetData!: string; + @Column() public takerAssetType!: AssetType; + @Column() public takerAssetProxyId!: string; + @Column() public takerTokenAddress!: string; + @Column({ nullable: true, type: String }) + public takerTokenId!: string | null; + + // TODO(albrow): Make this optional? + @Column() public metaDataJson!: string; +} -- cgit v1.2.3 From 53cc9e9bedc6adf2247a190dbb758c9411033cab Mon Sep 17 00:00:00 2001 From: Alex Browne Date: Thu, 8 Nov 2018 10:53:18 -0800 Subject: Rename table and column names --- packages/pipeline/src/entities/Block.ts | 5 +- packages/pipeline/src/entities/Relayer.ts | 12 ++-- packages/pipeline/src/entities/Transaction.ts | 15 ++-- .../pipeline/src/entities/exchange_cancel_event.ts | 56 +++++++++------ .../src/entities/exchange_cancel_up_to_event.ts | 23 +++--- .../pipeline/src/entities/exchange_fill_event.ts | 72 ++++++++++++------- packages/pipeline/src/entities/sra_order.ts | 81 ++++++++++++++-------- 7 files changed, 169 insertions(+), 95 deletions(-) (limited to 'packages/pipeline/src/entities') diff --git a/packages/pipeline/src/entities/Block.ts b/packages/pipeline/src/entities/Block.ts index 49e0ef840..5bd51f3d2 100644 --- a/packages/pipeline/src/entities/Block.ts +++ b/packages/pipeline/src/entities/Block.ts @@ -1,9 +1,10 @@ import { Column, Entity, PrimaryColumn } from 'typeorm'; -@Entity() +@Entity({ name: 'blocks' }) export class Block { @PrimaryColumn() public hash!: string; @PrimaryColumn() public number!: number; - @Column() public unixTimestampSeconds!: number; + @Column({ name: 'unix_timestamp_seconds' }) + public unixTimestampSeconds!: number; } diff --git a/packages/pipeline/src/entities/Relayer.ts b/packages/pipeline/src/entities/Relayer.ts index 605355fa8..94b5232a8 100644 --- a/packages/pipeline/src/entities/Relayer.ts +++ b/packages/pipeline/src/entities/Relayer.ts @@ -1,23 +1,23 @@ import { Column, Entity, PrimaryColumn } from 'typeorm'; -@Entity() +@Entity({ name: 'relayers' }) export class Relayer { @PrimaryColumn() public uuid!: string; @Column() public name!: string; @Column() public url!: string; - @Column({ nullable: true, type: String }) + @Column({ nullable: true, type: String, name: 'sra_http_endpoint' }) public sraHttpEndpoint!: string | null; - @Column({ nullable: true, type: String }) + @Column({ nullable: true, type: String, name: 'sra_ws_endpoint' }) public sraWsEndpoint!: string | null; - @Column({ nullable: true, type: String }) + @Column({ nullable: true, type: String, name: 'app_url' }) public appUrl!: string | null; // TODO(albrow): Add exchange contract or protocol version? // TODO(albrow): Add network ids for addresses? - @Column({ type: 'varchar', array: true }) + @Column({ type: 'varchar', array: true, name: 'fee_recipient_addresses' }) public feeRecipientAddresses!: string[]; - @Column({ type: 'varchar', array: true }) + @Column({ type: 'varchar', array: true, name: 'taker_addresses' }) public takerAddresses!: string[]; } diff --git a/packages/pipeline/src/entities/Transaction.ts b/packages/pipeline/src/entities/Transaction.ts index 8a68da813..eb2883fda 100644 --- a/packages/pipeline/src/entities/Transaction.ts +++ b/packages/pipeline/src/entities/Transaction.ts @@ -1,13 +1,16 @@ import { Column, Entity, PrimaryColumn } from 'typeorm'; -@Entity() +@Entity({ name: 'transactions' }) export class Transaction { - @PrimaryColumn() public transactionHash!: string; - @PrimaryColumn() public blockHash!: string; - @PrimaryColumn() public blockNumber!: number; + @PrimaryColumn({ name: 'transaction_hash' }) + public transactionHash!: string; + @PrimaryColumn({ name: 'block_hash' }) + public blockHash!: string; + @PrimaryColumn({ name: 'block_number' }) + public blockNumber!: number; - @Column({ type: 'bigint' }) + @Column({ type: 'bigint', name: 'gas_used' }) public gasUsed!: number; - @Column({ type: 'bigint' }) + @Column({ type: 'bigint', name: 'gas_price' }) public gasPrice!: number; } diff --git a/packages/pipeline/src/entities/exchange_cancel_event.ts b/packages/pipeline/src/entities/exchange_cancel_event.ts index 698b9e2ec..6d0c3bc32 100644 --- a/packages/pipeline/src/entities/exchange_cancel_event.ts +++ b/packages/pipeline/src/entities/exchange_cancel_event.ts @@ -2,33 +2,49 @@ import { Column, Entity, PrimaryColumn } from 'typeorm'; import { AssetType } from '../types'; -@Entity() +@Entity({ name: 'exchange_cancel_events' }) export class ExchangeCancelEvent { - @PrimaryColumn() public contractAddress!: string; - @PrimaryColumn() public logIndex!: number; - @PrimaryColumn() public blockNumber!: number; + @PrimaryColumn({ name: 'contract_address' }) + public contractAddress!: string; + @PrimaryColumn({ name: 'log_index' }) + public logIndex!: number; + @PrimaryColumn({ name: 'block_number' }) + public blockNumber!: number; - @Column() public rawData!: string; + @Column({ name: 'raw_data' }) + public rawData!: string; // TODO(albrow): Include transaction hash - @Column() public makerAddress!: string; - @Column({ nullable: true, type: String }) + @Column({ name: 'maker_address' }) + public makerAddress!: string; + @Column({ nullable: true, type: String, name: 'taker_address' }) public takerAddress!: string; - @Column() public feeRecepientAddress!: string; - @Column() public senderAddress!: string; - @Column() public orderHash!: string; + @Column({ name: 'fee_recipient_address' }) + public feeRecipientAddress!: string; + @Column({ name: 'sender_address' }) + public senderAddress!: string; + @Column({ name: 'order_hash' }) + public orderHash!: string; - @Column() public rawMakerAssetData!: string; - @Column() public makerAssetType!: AssetType; - @Column() public makerAssetProxyId!: string; - @Column() public makerTokenAddress!: string; - @Column({ nullable: true, type: String }) + @Column({ name: 'raw_maker_asset_data' }) + public rawMakerAssetData!: string; + @Column({ name: 'maker_asset_type' }) + public makerAssetType!: AssetType; + @Column({ name: 'maker_asset_proxy_id' }) + public makerAssetProxyId!: string; + @Column({ name: 'maker_token_address' }) + public makerTokenAddress!: string; + @Column({ nullable: true, type: String, name: 'maker_token_id' }) public makerTokenId!: string | null; - @Column() public rawTakerAssetData!: string; - @Column() public takerAssetType!: AssetType; - @Column() public takerAssetProxyId!: string; - @Column() public takerTokenAddress!: string; - @Column({ nullable: true, type: String }) + @Column({ name: 'raw_taker_asset_data' }) + public rawTakerAssetData!: string; + @Column({ name: 'taker_asset_type' }) + public takerAssetType!: AssetType; + @Column({ name: 'taker_asset_proxy_id' }) + public takerAssetProxyId!: string; + @Column({ name: 'taker_token_address' }) + public takerTokenAddress!: string; + @Column({ nullable: true, type: String, name: 'taker_token_id' }) public takerTokenId!: string | null; // TODO(albrow): Include topics? diff --git a/packages/pipeline/src/entities/exchange_cancel_up_to_event.ts b/packages/pipeline/src/entities/exchange_cancel_up_to_event.ts index 3ca75ccf7..891550050 100644 --- a/packages/pipeline/src/entities/exchange_cancel_up_to_event.ts +++ b/packages/pipeline/src/entities/exchange_cancel_up_to_event.ts @@ -1,16 +1,23 @@ import { Column, Entity, PrimaryColumn } from 'typeorm'; -@Entity() +@Entity({ name: 'exchange_cancel_up_to_event' }) export class ExchangeCancelUpToEvent { - @PrimaryColumn() public contractAddress!: string; - @PrimaryColumn() public logIndex!: number; - @PrimaryColumn() public blockNumber!: number; + @PrimaryColumn({ name: 'contract_address' }) + public contractAddress!: string; + @PrimaryColumn({ name: 'log_index' }) + public logIndex!: number; + @PrimaryColumn({ name: 'block_number' }) + public blockNumber!: number; // TODO(albrow): Include transaction hash - @Column() public rawData!: string; + @Column({ name: 'raw_data' }) + public rawData!: string; - @Column() public makerAddress!: string; - @Column() public senderAddress!: string; - @Column() public orderEpoch!: string; + @Column({ name: 'maker_address' }) + public makerAddress!: string; + @Column({ name: 'sender_address' }) + public senderAddress!: string; + @Column({ name: 'order_epoch' }) + public orderEpoch!: string; // TODO(albrow): Include topics? } diff --git a/packages/pipeline/src/entities/exchange_fill_event.ts b/packages/pipeline/src/entities/exchange_fill_event.ts index 6e549af93..0c5546d7e 100644 --- a/packages/pipeline/src/entities/exchange_fill_event.ts +++ b/packages/pipeline/src/entities/exchange_fill_event.ts @@ -2,36 +2,58 @@ import { Column, Entity, PrimaryColumn } from 'typeorm'; import { AssetType } from '../types'; -@Entity() +@Entity({ name: 'exchange_fill_events' }) export class ExchangeFillEvent { - @PrimaryColumn() public contractAddress!: string; - @PrimaryColumn() public logIndex!: number; - @PrimaryColumn() public blockNumber!: number; + @PrimaryColumn({ name: 'contract_address' }) + public contractAddress!: string; + @PrimaryColumn({ name: 'log_index' }) + public logIndex!: number; + @PrimaryColumn({ name: 'block_number' }) + public blockNumber!: number; - @Column() public rawData!: string; + @Column({ name: 'raw_data' }) + public rawData!: string; - @Column() public transactionHash!: string; - @Column() public makerAddress!: string; - @Column() public takerAddress!: string; - @Column() public feeRecipientAddress!: string; - @Column() public senderAddress!: string; - @Column() public makerAssetFilledAmount!: string; - @Column() public takerAssetFilledAmount!: string; - @Column() public makerFeePaid!: string; - @Column() public takerFeePaid!: string; - @Column() public orderHash!: string; + @Column({ name: 'transaction_hash' }) + public transactionHash!: string; + @Column({ name: 'maker_address' }) + public makerAddress!: string; + @Column({ name: 'taker_address' }) + public takerAddress!: string; + @Column({ name: 'fee_recipient_address' }) + public feeRecipientAddress!: string; + @Column({ name: 'sender_address' }) + public senderAddress!: string; + @Column({ name: 'maker_asset_filled_amount' }) + public makerAssetFilledAmount!: string; + @Column({ name: 'taker_asset_filled_amount' }) + public takerAssetFilledAmount!: string; + @Column({ name: 'maker_fee_paid' }) + public makerFeePaid!: string; + @Column({ name: 'taker_fee_paid' }) + public takerFeePaid!: string; + @Column({ name: 'order_hash' }) + public orderHash!: string; - @Column() public rawMakerAssetData!: string; - @Column() public makerAssetType!: AssetType; - @Column() public makerAssetProxyId!: string; - @Column() public makerTokenAddress!: string; - @Column({ nullable: true, type: String }) + @Column({ name: 'raw_maker_asset_data' }) + public rawMakerAssetData!: string; + @Column({ name: 'maker_asset_type' }) + public makerAssetType!: AssetType; + @Column({ name: 'maker_asset_proxy_id' }) + public makerAssetProxyId!: string; + @Column({ name: 'maker_token_address' }) + public makerTokenAddress!: string; + @Column({ nullable: true, type: String, name: 'maker_token_id' }) public makerTokenId!: string | null; - @Column() public rawTakerAssetData!: string; - @Column() public takerAssetType!: AssetType; - @Column() public takerAssetProxyId!: string; - @Column() public takerTokenAddress!: string; - @Column({ nullable: true, type: String }) + @Column({ name: 'raw_taker_asset_data' }) + public rawTakerAssetData!: string; + @Column({ name: 'taker_asset_type' }) + public takerAssetType!: AssetType; + @Column({ name: 'taker_asset_proxy_id' }) + public takerAssetProxyId!: string; + @Column({ name: 'taker_token_address' }) + public takerTokenAddress!: string; + @Column({ nullable: true, type: String, name: 'taker_token_id' }) public takerTokenId!: string | null; // TODO(albrow): Include topics? diff --git a/packages/pipeline/src/entities/sra_order.ts b/packages/pipeline/src/entities/sra_order.ts index a22f7c4e5..f3f79852f 100644 --- a/packages/pipeline/src/entities/sra_order.ts +++ b/packages/pipeline/src/entities/sra_order.ts @@ -2,40 +2,65 @@ import { Column, Entity, PrimaryColumn } from 'typeorm'; import { AssetType } from '../types'; -@Entity() +@Entity({ name: 'sra_orders' }) export class SraOrder { - @PrimaryColumn() public exchangeAddress!: string; - @PrimaryColumn() public orderHashHex!: string; + @PrimaryColumn({ name: 'exchange_address' }) + public exchangeAddress!: string; + @PrimaryColumn({ name: 'order_hash_hex' }) + public orderHashHex!: string; - @Column() public sourceUrl!: string; - @Column() public lastUpdatedTimestamp!: number; - @Column() public firstSeenTimestamp!: number; + @Column({ name: 'source_url' }) + public sourceUrl!: string; + @Column({ name: 'last_updated_timestamp' }) + public lastUpdatedTimestamp!: number; + @Column({ name: 'first_seen_timestamp' }) + public firstSeenTimestamp!: number; - @Column() public makerAddress!: string; - @Column() public takerAddress!: string; - @Column() public feeRecipientAddress!: string; - @Column() public senderAddress!: string; - @Column() public makerAssetAmount!: string; - @Column() public takerAssetAmount!: string; - @Column() public makerFee!: string; - @Column() public takerFee!: string; - @Column() public expirationTimeSeconds!: string; - @Column() public salt!: string; - @Column() public signature!: string; + @Column({ name: 'maker_address' }) + public makerAddress!: string; + @Column({ name: 'taker_address' }) + public takerAddress!: string; + @Column({ name: 'fee_recipient_address' }) + public feeRecipientAddress!: string; + @Column({ name: 'sender_address' }) + public senderAddress!: string; + @Column({ name: 'maker_asset_amount' }) + public makerAssetAmount!: string; + @Column({ name: 'taker_asset_amount' }) + public takerAssetAmount!: string; + @Column({ name: 'maker_fee' }) + public makerFee!: string; + @Column({ name: 'taker_fee' }) + public takerFee!: string; + @Column({ name: 'expiration_time_seconds' }) + public expirationTimeSeconds!: string; + @Column({ name: 'salt' }) + public salt!: string; + @Column({ name: 'signature' }) + public signature!: string; - @Column() public rawMakerAssetData!: string; - @Column() public makerAssetType!: AssetType; - @Column() public makerAssetProxyId!: string; - @Column() public makerTokenAddress!: string; - @Column({ nullable: true, type: String }) + @Column({ name: 'raw_maker_asset_data' }) + public rawMakerAssetData!: string; + @Column({ name: 'maker_asset_type' }) + public makerAssetType!: AssetType; + @Column({ name: 'maker_asset_proxy_id' }) + public makerAssetProxyId!: string; + @Column({ name: 'maker_token_address' }) + public makerTokenAddress!: string; + @Column({ nullable: true, type: String, name: 'maker_token_id' }) public makerTokenId!: string | null; - @Column() public rawTakerAssetData!: string; - @Column() public takerAssetType!: AssetType; - @Column() public takerAssetProxyId!: string; - @Column() public takerTokenAddress!: string; - @Column({ nullable: true, type: String }) + @Column({ name: 'raw_taker_asset_data' }) + public rawTakerAssetData!: string; + @Column({ name: 'taker_asset_type' }) + public takerAssetType!: AssetType; + @Column({ name: 'taker_asset_proxy_id' }) + public takerAssetProxyId!: string; + @Column({ name: 'taker_token_address' }) + public takerTokenAddress!: string; + @Column({ nullable: true, type: String, name: 'taker_token_id' }) public takerTokenId!: string | null; // TODO(albrow): Make this optional? - @Column() public metaDataJson!: string; + @Column({ name: 'metadata_json' }) + public metadataJson!: string; } -- cgit v1.2.3 From 6fb333f2003a67277a7605332f146adb2758cdd0 Mon Sep 17 00:00:00 2001 From: Alex Browne Date: Thu, 8 Nov 2018 12:35:59 -0800 Subject: Rename Transaction.ts to transaction.ts Rename Relayer.ts to relayer.ts Rename Block.ts to block.ts --- packages/pipeline/src/entities/Block.ts | 10 ---------- packages/pipeline/src/entities/Relayer.ts | 23 ----------------------- packages/pipeline/src/entities/Transaction.ts | 16 ---------------- packages/pipeline/src/entities/block.ts | 10 ++++++++++ packages/pipeline/src/entities/relayer.ts | 23 +++++++++++++++++++++++ packages/pipeline/src/entities/transaction.ts | 16 ++++++++++++++++ 6 files changed, 49 insertions(+), 49 deletions(-) delete mode 100644 packages/pipeline/src/entities/Block.ts delete mode 100644 packages/pipeline/src/entities/Relayer.ts delete mode 100644 packages/pipeline/src/entities/Transaction.ts create mode 100644 packages/pipeline/src/entities/block.ts create mode 100644 packages/pipeline/src/entities/relayer.ts create mode 100644 packages/pipeline/src/entities/transaction.ts (limited to 'packages/pipeline/src/entities') diff --git a/packages/pipeline/src/entities/Block.ts b/packages/pipeline/src/entities/Block.ts deleted file mode 100644 index 5bd51f3d2..000000000 --- a/packages/pipeline/src/entities/Block.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { Column, Entity, PrimaryColumn } from 'typeorm'; - -@Entity({ name: 'blocks' }) -export class Block { - @PrimaryColumn() public hash!: string; - @PrimaryColumn() public number!: number; - - @Column({ name: 'unix_timestamp_seconds' }) - public unixTimestampSeconds!: number; -} diff --git a/packages/pipeline/src/entities/Relayer.ts b/packages/pipeline/src/entities/Relayer.ts deleted file mode 100644 index 94b5232a8..000000000 --- a/packages/pipeline/src/entities/Relayer.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { Column, Entity, PrimaryColumn } from 'typeorm'; - -@Entity({ name: 'relayers' }) -export class Relayer { - @PrimaryColumn() public uuid!: string; - - @Column() public name!: string; - @Column() public url!: string; - @Column({ nullable: true, type: String, name: 'sra_http_endpoint' }) - public sraHttpEndpoint!: string | null; - @Column({ nullable: true, type: String, name: 'sra_ws_endpoint' }) - public sraWsEndpoint!: string | null; - @Column({ nullable: true, type: String, name: 'app_url' }) - public appUrl!: string | null; - - // TODO(albrow): Add exchange contract or protocol version? - // TODO(albrow): Add network ids for addresses? - - @Column({ type: 'varchar', array: true, name: 'fee_recipient_addresses' }) - public feeRecipientAddresses!: string[]; - @Column({ type: 'varchar', array: true, name: 'taker_addresses' }) - public takerAddresses!: string[]; -} diff --git a/packages/pipeline/src/entities/Transaction.ts b/packages/pipeline/src/entities/Transaction.ts deleted file mode 100644 index eb2883fda..000000000 --- a/packages/pipeline/src/entities/Transaction.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { Column, Entity, PrimaryColumn } from 'typeorm'; - -@Entity({ name: 'transactions' }) -export class Transaction { - @PrimaryColumn({ name: 'transaction_hash' }) - public transactionHash!: string; - @PrimaryColumn({ name: 'block_hash' }) - public blockHash!: string; - @PrimaryColumn({ name: 'block_number' }) - public blockNumber!: number; - - @Column({ type: 'bigint', name: 'gas_used' }) - public gasUsed!: number; - @Column({ type: 'bigint', name: 'gas_price' }) - public gasPrice!: number; -} diff --git a/packages/pipeline/src/entities/block.ts b/packages/pipeline/src/entities/block.ts new file mode 100644 index 000000000..5bd51f3d2 --- /dev/null +++ b/packages/pipeline/src/entities/block.ts @@ -0,0 +1,10 @@ +import { Column, Entity, PrimaryColumn } from 'typeorm'; + +@Entity({ name: 'blocks' }) +export class Block { + @PrimaryColumn() public hash!: string; + @PrimaryColumn() public number!: number; + + @Column({ name: 'unix_timestamp_seconds' }) + public unixTimestampSeconds!: number; +} diff --git a/packages/pipeline/src/entities/relayer.ts b/packages/pipeline/src/entities/relayer.ts new file mode 100644 index 000000000..94b5232a8 --- /dev/null +++ b/packages/pipeline/src/entities/relayer.ts @@ -0,0 +1,23 @@ +import { Column, Entity, PrimaryColumn } from 'typeorm'; + +@Entity({ name: 'relayers' }) +export class Relayer { + @PrimaryColumn() public uuid!: string; + + @Column() public name!: string; + @Column() public url!: string; + @Column({ nullable: true, type: String, name: 'sra_http_endpoint' }) + public sraHttpEndpoint!: string | null; + @Column({ nullable: true, type: String, name: 'sra_ws_endpoint' }) + public sraWsEndpoint!: string | null; + @Column({ nullable: true, type: String, name: 'app_url' }) + public appUrl!: string | null; + + // TODO(albrow): Add exchange contract or protocol version? + // TODO(albrow): Add network ids for addresses? + + @Column({ type: 'varchar', array: true, name: 'fee_recipient_addresses' }) + public feeRecipientAddresses!: string[]; + @Column({ type: 'varchar', array: true, name: 'taker_addresses' }) + public takerAddresses!: string[]; +} diff --git a/packages/pipeline/src/entities/transaction.ts b/packages/pipeline/src/entities/transaction.ts new file mode 100644 index 000000000..eb2883fda --- /dev/null +++ b/packages/pipeline/src/entities/transaction.ts @@ -0,0 +1,16 @@ +import { Column, Entity, PrimaryColumn } from 'typeorm'; + +@Entity({ name: 'transactions' }) +export class Transaction { + @PrimaryColumn({ name: 'transaction_hash' }) + public transactionHash!: string; + @PrimaryColumn({ name: 'block_hash' }) + public blockHash!: string; + @PrimaryColumn({ name: 'block_number' }) + public blockNumber!: number; + + @Column({ type: 'bigint', name: 'gas_used' }) + public gasUsed!: number; + @Column({ type: 'bigint', name: 'gas_price' }) + public gasPrice!: number; +} -- cgit v1.2.3 From 599a3f9b9614be6db1c9979514f3acca3f48bd05 Mon Sep 17 00:00:00 2001 From: Jake Ellowitz Date: Tue, 13 Nov 2018 09:38:23 -0800 Subject: Mapping dev schema to initial migration --- .../pipeline/src/entities/exchange_cancel_up_to_event.ts | 2 +- packages/pipeline/src/entities/index.ts | 1 + .../pipeline/src/entities/token_on_chain_metadata.ts | 16 ++++++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 packages/pipeline/src/entities/token_on_chain_metadata.ts (limited to 'packages/pipeline/src/entities') diff --git a/packages/pipeline/src/entities/exchange_cancel_up_to_event.ts b/packages/pipeline/src/entities/exchange_cancel_up_to_event.ts index 891550050..bc3bab6bb 100644 --- a/packages/pipeline/src/entities/exchange_cancel_up_to_event.ts +++ b/packages/pipeline/src/entities/exchange_cancel_up_to_event.ts @@ -1,6 +1,6 @@ import { Column, Entity, PrimaryColumn } from 'typeorm'; -@Entity({ name: 'exchange_cancel_up_to_event' }) +@Entity({ name: 'exchange_cancel_up_to_events' }) export class ExchangeCancelUpToEvent { @PrimaryColumn({ name: 'contract_address' }) public contractAddress!: string; diff --git a/packages/pipeline/src/entities/index.ts b/packages/pipeline/src/entities/index.ts index 4cd8d9da2..6e024f280 100644 --- a/packages/pipeline/src/entities/index.ts +++ b/packages/pipeline/src/entities/index.ts @@ -5,3 +5,4 @@ export { ExchangeFillEvent } from './exchange_fill_event'; export { Relayer } from './relayer'; export { SraOrder } from './sra_order'; export { Transaction } from './transaction'; +export { TokenOnChainMetadata } from './token_on_chain_metadata'; diff --git a/packages/pipeline/src/entities/token_on_chain_metadata.ts b/packages/pipeline/src/entities/token_on_chain_metadata.ts new file mode 100644 index 000000000..fc21d0aed --- /dev/null +++ b/packages/pipeline/src/entities/token_on_chain_metadata.ts @@ -0,0 +1,16 @@ +import { Column, Entity, PrimaryColumn } from 'typeorm'; + +@Entity({ name: 'token_on_chain_metadata' }) +export class TokenOnChainMetadata { + @PrimaryColumn({ type: 'nvarchar', nullable: false }) + public address!: string; + + @Column({ type: 'integer', nullable: false }) + public decimals!: number; + + @Column({ type: 'nvarchar', nullable: false }) + public symbol!: string; + + @Column({ type: 'nvarchar', nullable: false }) + public name!: string; +} \ No newline at end of file -- cgit v1.2.3 From 96134003e1aa1903bdf051e39e7e244cc8684043 Mon Sep 17 00:00:00 2001 From: Jake Ellowitz Date: Tue, 13 Nov 2018 09:57:02 -0800 Subject: Pointing entities to raw schema Fix linter issues --- packages/pipeline/src/entities/block.ts | 2 +- packages/pipeline/src/entities/exchange_cancel_event.ts | 2 +- packages/pipeline/src/entities/exchange_cancel_up_to_event.ts | 2 +- packages/pipeline/src/entities/exchange_fill_event.ts | 2 +- packages/pipeline/src/entities/relayer.ts | 2 +- packages/pipeline/src/entities/sra_order.ts | 2 +- packages/pipeline/src/entities/token_on_chain_metadata.ts | 4 ++-- packages/pipeline/src/entities/transaction.ts | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) (limited to 'packages/pipeline/src/entities') diff --git a/packages/pipeline/src/entities/block.ts b/packages/pipeline/src/entities/block.ts index 5bd51f3d2..51be37703 100644 --- a/packages/pipeline/src/entities/block.ts +++ b/packages/pipeline/src/entities/block.ts @@ -1,6 +1,6 @@ import { Column, Entity, PrimaryColumn } from 'typeorm'; -@Entity({ name: 'blocks' }) +@Entity({ name: 'blocks', schema: 'raw' }) export class Block { @PrimaryColumn() public hash!: string; @PrimaryColumn() public number!: number; diff --git a/packages/pipeline/src/entities/exchange_cancel_event.ts b/packages/pipeline/src/entities/exchange_cancel_event.ts index 6d0c3bc32..781e1c4bb 100644 --- a/packages/pipeline/src/entities/exchange_cancel_event.ts +++ b/packages/pipeline/src/entities/exchange_cancel_event.ts @@ -2,7 +2,7 @@ import { Column, Entity, PrimaryColumn } from 'typeorm'; import { AssetType } from '../types'; -@Entity({ name: 'exchange_cancel_events' }) +@Entity({ name: 'exchange_cancel_events', schema: 'raw' }) export class ExchangeCancelEvent { @PrimaryColumn({ name: 'contract_address' }) public contractAddress!: string; diff --git a/packages/pipeline/src/entities/exchange_cancel_up_to_event.ts b/packages/pipeline/src/entities/exchange_cancel_up_to_event.ts index bc3bab6bb..7306a1a87 100644 --- a/packages/pipeline/src/entities/exchange_cancel_up_to_event.ts +++ b/packages/pipeline/src/entities/exchange_cancel_up_to_event.ts @@ -1,6 +1,6 @@ import { Column, Entity, PrimaryColumn } from 'typeorm'; -@Entity({ name: 'exchange_cancel_up_to_events' }) +@Entity({ name: 'exchange_cancel_up_to_events', schema: 'raw' }) export class ExchangeCancelUpToEvent { @PrimaryColumn({ name: 'contract_address' }) public contractAddress!: string; diff --git a/packages/pipeline/src/entities/exchange_fill_event.ts b/packages/pipeline/src/entities/exchange_fill_event.ts index 0c5546d7e..6202e558b 100644 --- a/packages/pipeline/src/entities/exchange_fill_event.ts +++ b/packages/pipeline/src/entities/exchange_fill_event.ts @@ -2,7 +2,7 @@ import { Column, Entity, PrimaryColumn } from 'typeorm'; import { AssetType } from '../types'; -@Entity({ name: 'exchange_fill_events' }) +@Entity({ name: 'exchange_fill_events', schema: 'raw' }) export class ExchangeFillEvent { @PrimaryColumn({ name: 'contract_address' }) public contractAddress!: string; diff --git a/packages/pipeline/src/entities/relayer.ts b/packages/pipeline/src/entities/relayer.ts index 94b5232a8..ef1f9cf2a 100644 --- a/packages/pipeline/src/entities/relayer.ts +++ b/packages/pipeline/src/entities/relayer.ts @@ -1,6 +1,6 @@ import { Column, Entity, PrimaryColumn } from 'typeorm'; -@Entity({ name: 'relayers' }) +@Entity({ name: 'relayers', schema: 'raw' }) export class Relayer { @PrimaryColumn() public uuid!: string; diff --git a/packages/pipeline/src/entities/sra_order.ts b/packages/pipeline/src/entities/sra_order.ts index f3f79852f..e59161c81 100644 --- a/packages/pipeline/src/entities/sra_order.ts +++ b/packages/pipeline/src/entities/sra_order.ts @@ -2,7 +2,7 @@ import { Column, Entity, PrimaryColumn } from 'typeorm'; import { AssetType } from '../types'; -@Entity({ name: 'sra_orders' }) +@Entity({ name: 'sra_orders', schema: 'raw' }) export class SraOrder { @PrimaryColumn({ name: 'exchange_address' }) public exchangeAddress!: string; diff --git a/packages/pipeline/src/entities/token_on_chain_metadata.ts b/packages/pipeline/src/entities/token_on_chain_metadata.ts index fc21d0aed..325d28e91 100644 --- a/packages/pipeline/src/entities/token_on_chain_metadata.ts +++ b/packages/pipeline/src/entities/token_on_chain_metadata.ts @@ -1,6 +1,6 @@ import { Column, Entity, PrimaryColumn } from 'typeorm'; -@Entity({ name: 'token_on_chain_metadata' }) +@Entity({ name: 'token_on_chain_metadata', schema: 'raw' }) export class TokenOnChainMetadata { @PrimaryColumn({ type: 'nvarchar', nullable: false }) public address!: string; @@ -13,4 +13,4 @@ export class TokenOnChainMetadata { @Column({ type: 'nvarchar', nullable: false }) public name!: string; -} \ No newline at end of file +} diff --git a/packages/pipeline/src/entities/transaction.ts b/packages/pipeline/src/entities/transaction.ts index eb2883fda..dd2143df5 100644 --- a/packages/pipeline/src/entities/transaction.ts +++ b/packages/pipeline/src/entities/transaction.ts @@ -1,6 +1,6 @@ import { Column, Entity, PrimaryColumn } from 'typeorm'; -@Entity({ name: 'transactions' }) +@Entity({ name: 'transactions', schema: 'raw' }) export class Transaction { @PrimaryColumn({ name: 'transaction_hash' }) public transactionHash!: string; -- cgit v1.2.3 From 2cbb82eb0498c539ea16afe4012bd69f154ad027 Mon Sep 17 00:00:00 2001 From: Alex Browne Date: Tue, 13 Nov 2018 14:57:58 -0800 Subject: Update schema for sra_orders --- packages/pipeline/src/entities/sra_order.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'packages/pipeline/src/entities') diff --git a/packages/pipeline/src/entities/sra_order.ts b/packages/pipeline/src/entities/sra_order.ts index e59161c81..4b7f652d3 100644 --- a/packages/pipeline/src/entities/sra_order.ts +++ b/packages/pipeline/src/entities/sra_order.ts @@ -8,13 +8,8 @@ export class SraOrder { public exchangeAddress!: string; @PrimaryColumn({ name: 'order_hash_hex' }) public orderHashHex!: string; - - @Column({ name: 'source_url' }) + @PrimaryColumn({ name: 'source_url' }) public sourceUrl!: string; - @Column({ name: 'last_updated_timestamp' }) - public lastUpdatedTimestamp!: number; - @Column({ name: 'first_seen_timestamp' }) - public firstSeenTimestamp!: number; @Column({ name: 'maker_address' }) public makerAddress!: string; -- cgit v1.2.3 From 26280e4aba147ad6000b9df309e64db84b6932fc Mon Sep 17 00:00:00 2001 From: Alex Browne Date: Tue, 13 Nov 2018 15:33:43 -0800 Subject: Implement scraping sra orders from radar relay --- packages/pipeline/src/entities/index.ts | 1 + packages/pipeline/src/entities/sra_order.ts | 4 +-- .../src/entities/sra_order_observed_timestamp.ts | 30 ++++++++++++++++++++++ 3 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 packages/pipeline/src/entities/sra_order_observed_timestamp.ts (limited to 'packages/pipeline/src/entities') diff --git a/packages/pipeline/src/entities/index.ts b/packages/pipeline/src/entities/index.ts index 6e024f280..442eec9cd 100644 --- a/packages/pipeline/src/entities/index.ts +++ b/packages/pipeline/src/entities/index.ts @@ -6,3 +6,4 @@ export { Relayer } from './relayer'; export { SraOrder } from './sra_order'; export { Transaction } from './transaction'; export { TokenOnChainMetadata } from './token_on_chain_metadata'; +export { SraOrdersObservedTimeStamp, createObservedTimestampForOrder } from './sra_order_observed_timestamp'; diff --git a/packages/pipeline/src/entities/sra_order.ts b/packages/pipeline/src/entities/sra_order.ts index 4b7f652d3..2bdb1ba2e 100644 --- a/packages/pipeline/src/entities/sra_order.ts +++ b/packages/pipeline/src/entities/sra_order.ts @@ -19,9 +19,9 @@ export class SraOrder { public feeRecipientAddress!: string; @Column({ name: 'sender_address' }) public senderAddress!: string; - @Column({ name: 'maker_asset_amount' }) + @Column({ name: 'maker_asset_filled_amount' }) public makerAssetAmount!: string; - @Column({ name: 'taker_asset_amount' }) + @Column({ name: 'taker_asset_filled_amount' }) public takerAssetAmount!: string; @Column({ name: 'maker_fee' }) public makerFee!: string; diff --git a/packages/pipeline/src/entities/sra_order_observed_timestamp.ts b/packages/pipeline/src/entities/sra_order_observed_timestamp.ts new file mode 100644 index 000000000..bdb6cd36b --- /dev/null +++ b/packages/pipeline/src/entities/sra_order_observed_timestamp.ts @@ -0,0 +1,30 @@ +import { Entity, PrimaryColumn } from 'typeorm'; + +import { SraOrder } from './sra_order'; + +@Entity({ name: 'sra_orders_observed_timestamps', schema: 'raw' }) +export class SraOrdersObservedTimeStamp { + @PrimaryColumn({ name: 'exchange_address' }) + public exchangeAddress!: string; + @PrimaryColumn({ name: 'order_hash_hex' }) + public orderHashHex!: string; + @PrimaryColumn({ name: 'source_url' }) + public sourceUrl!: string; + + @PrimaryColumn({ name: 'observed_timestamp' }) + public observedTimestamp!: number; +} + +/** + * Returns a new SraOrdersObservedTimeStamp for the given order based on the + * current time. + * @param order The order to generate a timestamp for. + */ +export function createObservedTimestampForOrder(order: SraOrder): SraOrdersObservedTimeStamp { + const observed = new SraOrdersObservedTimeStamp(); + observed.exchangeAddress = order.exchangeAddress; + observed.orderHashHex = order.orderHashHex; + observed.sourceUrl = order.sourceUrl; + observed.observedTimestamp = Date.now(); + return observed; +} -- cgit v1.2.3 From a948305e7a488ad01404fa04c95dacc98b4b0061 Mon Sep 17 00:00:00 2001 From: Alex Browne Date: Tue, 13 Nov 2018 15:44:53 -0800 Subject: Rename taker and maker amounts in sra_orders --- packages/pipeline/src/entities/sra_order.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'packages/pipeline/src/entities') diff --git a/packages/pipeline/src/entities/sra_order.ts b/packages/pipeline/src/entities/sra_order.ts index 2bdb1ba2e..4b7f652d3 100644 --- a/packages/pipeline/src/entities/sra_order.ts +++ b/packages/pipeline/src/entities/sra_order.ts @@ -19,9 +19,9 @@ export class SraOrder { public feeRecipientAddress!: string; @Column({ name: 'sender_address' }) public senderAddress!: string; - @Column({ name: 'maker_asset_filled_amount' }) + @Column({ name: 'maker_asset_amount' }) public makerAssetAmount!: string; - @Column({ name: 'taker_asset_filled_amount' }) + @Column({ name: 'taker_asset_amount' }) public takerAssetAmount!: string; @Column({ name: 'maker_fee' }) public makerFee!: string; -- cgit v1.2.3 From 303bbc42f4322448998f3fde202574335d1190e6 Mon Sep 17 00:00:00 2001 From: Alex Browne Date: Wed, 14 Nov 2018 15:58:36 -0800 Subject: Change some column types from varchar to numeric --- .../src/entities/exchange_cancel_up_to_event.ts | 7 ++++-- .../pipeline/src/entities/exchange_fill_event.ts | 18 ++++++++------- packages/pipeline/src/entities/sra_order.ts | 26 ++++++++++++---------- 3 files changed, 29 insertions(+), 22 deletions(-) (limited to 'packages/pipeline/src/entities') diff --git a/packages/pipeline/src/entities/exchange_cancel_up_to_event.ts b/packages/pipeline/src/entities/exchange_cancel_up_to_event.ts index 7306a1a87..752631b85 100644 --- a/packages/pipeline/src/entities/exchange_cancel_up_to_event.ts +++ b/packages/pipeline/src/entities/exchange_cancel_up_to_event.ts @@ -1,5 +1,8 @@ +import { BigNumber } from '@0x/utils'; import { Column, Entity, PrimaryColumn } from 'typeorm'; +import { bigNumberTransformer } from '../utils'; + @Entity({ name: 'exchange_cancel_up_to_events', schema: 'raw' }) export class ExchangeCancelUpToEvent { @PrimaryColumn({ name: 'contract_address' }) @@ -17,7 +20,7 @@ export class ExchangeCancelUpToEvent { public makerAddress!: string; @Column({ name: 'sender_address' }) public senderAddress!: string; - @Column({ name: 'order_epoch' }) - public orderEpoch!: string; + @Column({ name: 'order_epoch', type: 'numeric', transformer: bigNumberTransformer }) + public orderEpoch!: BigNumber; // TODO(albrow): Include topics? } diff --git a/packages/pipeline/src/entities/exchange_fill_event.ts b/packages/pipeline/src/entities/exchange_fill_event.ts index 6202e558b..aa082436b 100644 --- a/packages/pipeline/src/entities/exchange_fill_event.ts +++ b/packages/pipeline/src/entities/exchange_fill_event.ts @@ -1,6 +1,8 @@ +import { BigNumber } from '@0x/utils'; import { Column, Entity, PrimaryColumn } from 'typeorm'; import { AssetType } from '../types'; +import { bigNumberTransformer } from '../utils'; @Entity({ name: 'exchange_fill_events', schema: 'raw' }) export class ExchangeFillEvent { @@ -24,14 +26,14 @@ export class ExchangeFillEvent { public feeRecipientAddress!: string; @Column({ name: 'sender_address' }) public senderAddress!: string; - @Column({ name: 'maker_asset_filled_amount' }) - public makerAssetFilledAmount!: string; - @Column({ name: 'taker_asset_filled_amount' }) - public takerAssetFilledAmount!: string; - @Column({ name: 'maker_fee_paid' }) - public makerFeePaid!: string; - @Column({ name: 'taker_fee_paid' }) - public takerFeePaid!: string; + @Column({ name: 'maker_asset_filled_amount', type: 'numeric', transformer: bigNumberTransformer }) + public makerAssetFilledAmount!: BigNumber; + @Column({ name: 'taker_asset_filled_amount', type: 'numeric', transformer: bigNumberTransformer }) + public takerAssetFilledAmount!: BigNumber; + @Column({ name: 'maker_fee_paid', type: 'numeric', transformer: bigNumberTransformer }) + public makerFeePaid!: BigNumber; + @Column({ name: 'taker_fee_paid', type: 'numeric', transformer: bigNumberTransformer }) + public takerFeePaid!: BigNumber; @Column({ name: 'order_hash' }) public orderHash!: string; diff --git a/packages/pipeline/src/entities/sra_order.ts b/packages/pipeline/src/entities/sra_order.ts index 4b7f652d3..9c730a0bb 100644 --- a/packages/pipeline/src/entities/sra_order.ts +++ b/packages/pipeline/src/entities/sra_order.ts @@ -1,6 +1,8 @@ +import { BigNumber } from '@0x/utils'; import { Column, Entity, PrimaryColumn } from 'typeorm'; import { AssetType } from '../types'; +import { bigNumberTransformer } from '../utils'; @Entity({ name: 'sra_orders', schema: 'raw' }) export class SraOrder { @@ -19,18 +21,18 @@ export class SraOrder { public feeRecipientAddress!: string; @Column({ name: 'sender_address' }) public senderAddress!: string; - @Column({ name: 'maker_asset_amount' }) - public makerAssetAmount!: string; - @Column({ name: 'taker_asset_amount' }) - public takerAssetAmount!: string; - @Column({ name: 'maker_fee' }) - public makerFee!: string; - @Column({ name: 'taker_fee' }) - public takerFee!: string; - @Column({ name: 'expiration_time_seconds' }) - public expirationTimeSeconds!: string; - @Column({ name: 'salt' }) - public salt!: string; + @Column({ name: 'maker_asset_amount', type: 'numeric', transformer: bigNumberTransformer }) + public makerAssetAmount!: BigNumber; + @Column({ name: 'taker_asset_amount', type: 'numeric', transformer: bigNumberTransformer }) + public takerAssetAmount!: BigNumber; + @Column({ name: 'maker_fee', type: 'numeric', transformer: bigNumberTransformer }) + public makerFee!: BigNumber; + @Column({ name: 'taker_fee', type: 'numeric', transformer: bigNumberTransformer }) + public takerFee!: BigNumber; + @Column({ name: 'expiration_time_seconds', type: 'numeric', transformer: bigNumberTransformer }) + public expirationTimeSeconds!: BigNumber; + @Column({ name: 'salt', type: 'numeric', transformer: bigNumberTransformer }) + public salt!: BigNumber; @Column({ name: 'signature' }) public signature!: string; -- cgit v1.2.3 From b771020f8804b3f9853d44ffa2b43195cc08162a Mon Sep 17 00:00:00 2001 From: Alex Browne Date: Wed, 14 Nov 2018 18:47:22 -0800 Subject: Add homepage_url to relayers --- packages/pipeline/src/entities/relayer.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'packages/pipeline/src/entities') diff --git a/packages/pipeline/src/entities/relayer.ts b/packages/pipeline/src/entities/relayer.ts index ef1f9cf2a..b3a856fd8 100644 --- a/packages/pipeline/src/entities/relayer.ts +++ b/packages/pipeline/src/entities/relayer.ts @@ -5,19 +5,20 @@ export class Relayer { @PrimaryColumn() public uuid!: string; @Column() public name!: string; - @Column() public url!: string; - @Column({ nullable: true, type: String, name: 'sra_http_endpoint' }) + @Column({ name: 'homepage_url', type: 'varchar' }) + public homepageUrl!: string; + @Column({ name: 'sra_http_endpoint', type: 'varchar', nullable: true }) public sraHttpEndpoint!: string | null; - @Column({ nullable: true, type: String, name: 'sra_ws_endpoint' }) + @Column({ name: 'sra_ws_endpoint', type: 'varchar', nullable: true }) public sraWsEndpoint!: string | null; - @Column({ nullable: true, type: String, name: 'app_url' }) + @Column({ name: 'app_url', type: 'varchar', nullable: true }) public appUrl!: string | null; // TODO(albrow): Add exchange contract or protocol version? // TODO(albrow): Add network ids for addresses? - @Column({ type: 'varchar', array: true, name: 'fee_recipient_addresses' }) + @Column({ name: 'fee_recipient_addresses', type: 'varchar', array: true }) public feeRecipientAddresses!: string[]; - @Column({ type: 'varchar', array: true, name: 'taker_addresses' }) + @Column({ name: 'taker_addresses', type: 'varchar', array: true }) public takerAddresses!: string[]; } -- cgit v1.2.3 From 0397ff8b2206ab4e9308a524d635ec37ec9dda99 Mon Sep 17 00:00:00 2001 From: Alex Browne Date: Thu, 15 Nov 2018 13:09:44 -0800 Subject: Add transactionHash to CancelUpToEvent and CancelEvent entities --- packages/pipeline/src/entities/exchange_cancel_event.ts | 3 ++- packages/pipeline/src/entities/exchange_cancel_up_to_event.ts | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'packages/pipeline/src/entities') diff --git a/packages/pipeline/src/entities/exchange_cancel_event.ts b/packages/pipeline/src/entities/exchange_cancel_event.ts index 781e1c4bb..5a40ba799 100644 --- a/packages/pipeline/src/entities/exchange_cancel_event.ts +++ b/packages/pipeline/src/entities/exchange_cancel_event.ts @@ -14,7 +14,8 @@ export class ExchangeCancelEvent { @Column({ name: 'raw_data' }) public rawData!: string; - // TODO(albrow): Include transaction hash + @Column({ name: 'transaction_hash' }) + public transactionHash!: string; @Column({ name: 'maker_address' }) public makerAddress!: string; @Column({ nullable: true, type: String, name: 'taker_address' }) diff --git a/packages/pipeline/src/entities/exchange_cancel_up_to_event.ts b/packages/pipeline/src/entities/exchange_cancel_up_to_event.ts index 752631b85..9b1c6174a 100644 --- a/packages/pipeline/src/entities/exchange_cancel_up_to_event.ts +++ b/packages/pipeline/src/entities/exchange_cancel_up_to_event.ts @@ -16,6 +16,8 @@ export class ExchangeCancelUpToEvent { @Column({ name: 'raw_data' }) public rawData!: string; + @Column({ name: 'transaction_hash' }) + public transactionHash!: string; @Column({ name: 'maker_address' }) public makerAddress!: string; @Column({ name: 'sender_address' }) -- cgit v1.2.3 From 24fd2d9730d58a58929f401674175ad8a5a7fbc1 Mon Sep 17 00:00:00 2001 From: Alex Browne Date: Fri, 16 Nov 2018 12:55:54 -0800 Subject: Add support for pulling Cancel and CancelUpTo events --- packages/pipeline/src/entities/index.ts | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'packages/pipeline/src/entities') diff --git a/packages/pipeline/src/entities/index.ts b/packages/pipeline/src/entities/index.ts index 442eec9cd..d3c61bcb9 100644 --- a/packages/pipeline/src/entities/index.ts +++ b/packages/pipeline/src/entities/index.ts @@ -1,3 +1,7 @@ +import { ExchangeCancelEvent } from './exchange_cancel_event'; +import { ExchangeCancelUpToEvent } from './exchange_cancel_up_to_event'; +import { ExchangeFillEvent } from './exchange_fill_event'; + export { Block } from './block'; export { ExchangeCancelEvent } from './exchange_cancel_event'; export { ExchangeCancelUpToEvent } from './exchange_cancel_up_to_event'; @@ -7,3 +11,5 @@ export { SraOrder } from './sra_order'; export { Transaction } from './transaction'; export { TokenOnChainMetadata } from './token_on_chain_metadata'; export { SraOrdersObservedTimeStamp, createObservedTimestampForOrder } from './sra_order_observed_timestamp'; + +export type ExchangeEvent = ExchangeFillEvent | ExchangeCancelEvent | ExchangeCancelUpToEvent; -- cgit v1.2.3 From 9986717671fe8e14c2168f7479bdaffe406bedc0 Mon Sep 17 00:00:00 2001 From: Alex Browne Date: Mon, 19 Nov 2018 18:38:11 -0800 Subject: Add script for pulling missing block data --- packages/pipeline/src/entities/block.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'packages/pipeline/src/entities') diff --git a/packages/pipeline/src/entities/block.ts b/packages/pipeline/src/entities/block.ts index 51be37703..f2efc6390 100644 --- a/packages/pipeline/src/entities/block.ts +++ b/packages/pipeline/src/entities/block.ts @@ -5,6 +5,6 @@ export class Block { @PrimaryColumn() public hash!: string; @PrimaryColumn() public number!: number; - @Column({ name: 'unix_timestamp_seconds' }) - public unixTimestampSeconds!: number; + @Column({ name: 'timestamp' }) + public timestamp!: number; } -- cgit v1.2.3 From c6af5131b0b06433d6294260274e187ad61f4ef7 Mon Sep 17 00:00:00 2001 From: Jake Ellowitz Date: Mon, 19 Nov 2018 16:24:07 -0800 Subject: Pull token metadata re trusted tokens --- packages/pipeline/src/entities/index.ts | 2 ++ packages/pipeline/src/entities/ohlcv_external.ts | 20 ++++++++++++++++++++ .../pipeline/src/entities/token_on_chain_metadata.ts | 6 ++++++ packages/pipeline/src/entities/trusted_tokens.ts | 7 +++++++ 4 files changed, 35 insertions(+) create mode 100644 packages/pipeline/src/entities/ohlcv_external.ts create mode 100644 packages/pipeline/src/entities/trusted_tokens.ts (limited to 'packages/pipeline/src/entities') diff --git a/packages/pipeline/src/entities/index.ts b/packages/pipeline/src/entities/index.ts index d3c61bcb9..769efb092 100644 --- a/packages/pipeline/src/entities/index.ts +++ b/packages/pipeline/src/entities/index.ts @@ -10,6 +10,8 @@ export { Relayer } from './relayer'; export { SraOrder } from './sra_order'; export { Transaction } from './transaction'; export { TokenOnChainMetadata } from './token_on_chain_metadata'; +export { TrustedToken } from './trusted_tokens'; export { SraOrdersObservedTimeStamp, createObservedTimestampForOrder } from './sra_order_observed_timestamp'; +export { OHLCVExternal } from './ohlcv_external'; export type ExchangeEvent = ExchangeFillEvent | ExchangeCancelEvent | ExchangeCancelUpToEvent; diff --git a/packages/pipeline/src/entities/ohlcv_external.ts b/packages/pipeline/src/entities/ohlcv_external.ts new file mode 100644 index 000000000..3fbb4c499 --- /dev/null +++ b/packages/pipeline/src/entities/ohlcv_external.ts @@ -0,0 +1,20 @@ +import { Column, Entity, PrimaryColumn } from 'typeorm'; + +@Entity({ name: 'ohlcv_external', schema: 'raw' }) +export class OHLCVExternal { + @PrimaryColumn() public exchange!: string; + @PrimaryColumn() public from_symbol!: string; + @PrimaryColumn() public to_symbol!: string; + @PrimaryColumn() public start_time!: number; + @PrimaryColumn() public end_time!: number; + + @Column() public open!: number; + @Column() public close!: number; + @Column() public low!: number; + @Column() public high!: number; + @Column() public volume_from!: number; + @Column() public volume_to!: number; + + @PrimaryColumn() public source!: string; + @PrimaryColumn() public observed_timestamp!: number; +} \ No newline at end of file diff --git a/packages/pipeline/src/entities/token_on_chain_metadata.ts b/packages/pipeline/src/entities/token_on_chain_metadata.ts index 325d28e91..ca1f1827b 100644 --- a/packages/pipeline/src/entities/token_on_chain_metadata.ts +++ b/packages/pipeline/src/entities/token_on_chain_metadata.ts @@ -14,3 +14,9 @@ export class TokenOnChainMetadata { @Column({ type: 'nvarchar', nullable: false }) public name!: string; } + +@Entity({ name: 'trusted_tokens', schema: 'raw' }) +export class TrustedTokens { + @PrimaryColumn() public address!: string; + @PrimaryColumn() public authority!: string; +} diff --git a/packages/pipeline/src/entities/trusted_tokens.ts b/packages/pipeline/src/entities/trusted_tokens.ts new file mode 100644 index 000000000..6ec27c963 --- /dev/null +++ b/packages/pipeline/src/entities/trusted_tokens.ts @@ -0,0 +1,7 @@ +import { Column, Entity, PrimaryColumn } from 'typeorm'; + +@Entity({ name: 'trusted_tokens', schema: 'raw' }) +export class TrustedToken { + @PrimaryColumn() public address!: string; + @PrimaryColumn() public authority!: string; +} -- cgit v1.2.3 From dea89c4e221d5b22de97b27573719cd27ce250c7 Mon Sep 17 00:00:00 2001 From: Jake Ellowitz Date: Mon, 19 Nov 2018 19:11:51 -0800 Subject: metadata and trusted sources in same raw table --- packages/pipeline/src/entities/index.ts | 3 +-- packages/pipeline/src/entities/ohlcv_external.ts | 18 +++++++++--------- packages/pipeline/src/entities/token_metadata.ts | 19 +++++++++++++++++++ .../src/entities/token_on_chain_metadata.ts | 22 ---------------------- packages/pipeline/src/entities/trusted_tokens.ts | 7 ------- 5 files changed, 29 insertions(+), 40 deletions(-) create mode 100644 packages/pipeline/src/entities/token_metadata.ts delete mode 100644 packages/pipeline/src/entities/token_on_chain_metadata.ts delete mode 100644 packages/pipeline/src/entities/trusted_tokens.ts (limited to 'packages/pipeline/src/entities') diff --git a/packages/pipeline/src/entities/index.ts b/packages/pipeline/src/entities/index.ts index 769efb092..a8f159a2a 100644 --- a/packages/pipeline/src/entities/index.ts +++ b/packages/pipeline/src/entities/index.ts @@ -9,8 +9,7 @@ export { ExchangeFillEvent } from './exchange_fill_event'; export { Relayer } from './relayer'; export { SraOrder } from './sra_order'; export { Transaction } from './transaction'; -export { TokenOnChainMetadata } from './token_on_chain_metadata'; -export { TrustedToken } from './trusted_tokens'; +export { TokenMetadata } from './token_metadata'; export { SraOrdersObservedTimeStamp, createObservedTimestampForOrder } from './sra_order_observed_timestamp'; export { OHLCVExternal } from './ohlcv_external'; diff --git a/packages/pipeline/src/entities/ohlcv_external.ts b/packages/pipeline/src/entities/ohlcv_external.ts index 3fbb4c499..95cd4f2f5 100644 --- a/packages/pipeline/src/entities/ohlcv_external.ts +++ b/packages/pipeline/src/entities/ohlcv_external.ts @@ -3,18 +3,18 @@ import { Column, Entity, PrimaryColumn } from 'typeorm'; @Entity({ name: 'ohlcv_external', schema: 'raw' }) export class OHLCVExternal { @PrimaryColumn() public exchange!: string; - @PrimaryColumn() public from_symbol!: string; - @PrimaryColumn() public to_symbol!: string; - @PrimaryColumn() public start_time!: number; - @PrimaryColumn() public end_time!: number; - + @PrimaryColumn() public fromSymbol!: string; + @PrimaryColumn() public toSymbol!: string; + @PrimaryColumn() public startTime!: number; + @PrimaryColumn() public endTime!: number; + @Column() public open!: number; @Column() public close!: number; @Column() public low!: number; @Column() public high!: number; - @Column() public volume_from!: number; - @Column() public volume_to!: number; + @Column() public volumeFrom!: number; + @Column() public volumeTo!: number; @PrimaryColumn() public source!: string; - @PrimaryColumn() public observed_timestamp!: number; -} \ No newline at end of file + @PrimaryColumn() public observedTimestamp!: number; +} diff --git a/packages/pipeline/src/entities/token_metadata.ts b/packages/pipeline/src/entities/token_metadata.ts new file mode 100644 index 000000000..4a0bceefe --- /dev/null +++ b/packages/pipeline/src/entities/token_metadata.ts @@ -0,0 +1,19 @@ +import { Column, Entity, PrimaryColumn } from 'typeorm'; + +@Entity({ name: 'token_metadata', schema: 'raw' }) +export class TokenMetadata { + @PrimaryColumn({ type: 'varchar', nullable: false }) + public address!: string; + + @PrimaryColumn({ type: 'varchar', nullable: false }) + public authority!: string; + + @Column({ type: 'integer', nullable: true }) + public decimals!: number; + + @Column({ type: 'varchar', nullable: true }) + public symbol!: string; + + @Column({ type: 'varchar', nullable: true }) + public name!: string; +} diff --git a/packages/pipeline/src/entities/token_on_chain_metadata.ts b/packages/pipeline/src/entities/token_on_chain_metadata.ts deleted file mode 100644 index ca1f1827b..000000000 --- a/packages/pipeline/src/entities/token_on_chain_metadata.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { Column, Entity, PrimaryColumn } from 'typeorm'; - -@Entity({ name: 'token_on_chain_metadata', schema: 'raw' }) -export class TokenOnChainMetadata { - @PrimaryColumn({ type: 'nvarchar', nullable: false }) - public address!: string; - - @Column({ type: 'integer', nullable: false }) - public decimals!: number; - - @Column({ type: 'nvarchar', nullable: false }) - public symbol!: string; - - @Column({ type: 'nvarchar', nullable: false }) - public name!: string; -} - -@Entity({ name: 'trusted_tokens', schema: 'raw' }) -export class TrustedTokens { - @PrimaryColumn() public address!: string; - @PrimaryColumn() public authority!: string; -} diff --git a/packages/pipeline/src/entities/trusted_tokens.ts b/packages/pipeline/src/entities/trusted_tokens.ts deleted file mode 100644 index 6ec27c963..000000000 --- a/packages/pipeline/src/entities/trusted_tokens.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { Column, Entity, PrimaryColumn } from 'typeorm'; - -@Entity({ name: 'trusted_tokens', schema: 'raw' }) -export class TrustedToken { - @PrimaryColumn() public address!: string; - @PrimaryColumn() public authority!: string; -} -- cgit v1.2.3 From 3d211c415b58a67f84332ff512bf9372cac5a3ac Mon Sep 17 00:00:00 2001 From: Alex Browne Date: Wed, 28 Nov 2018 13:21:04 -0800 Subject: Introduce framework for running basic tests for entities (#1344) * Introduce framework for running basic tests for entities * Add pipeline tests to CircleCI config * Make pipeline tests more configurable and fix CircleCI config * Add coverage dir to pipeline package * Add basic tests for all exchange event entities * Add tests for remaining entities * Create separate test scripts in package.json and add new info to README * Update db_setup.ts to revert migrations even if you are using docker * Automatically pull the postgres image if needed * Add comment about why NumberToBigIntTransformer is needed --- packages/pipeline/src/entities/block.ts | 7 +++++-- packages/pipeline/src/entities/exchange_cancel_event.ts | 3 ++- packages/pipeline/src/entities/exchange_cancel_up_to_event.ts | 4 ++-- packages/pipeline/src/entities/exchange_fill_event.ts | 4 ++-- packages/pipeline/src/entities/sra_order_observed_timestamp.ts | 4 +++- packages/pipeline/src/entities/token_metadata.ts | 8 +++++--- packages/pipeline/src/entities/transaction.ts | 8 +++++--- 7 files changed, 24 insertions(+), 14 deletions(-) (limited to 'packages/pipeline/src/entities') diff --git a/packages/pipeline/src/entities/block.ts b/packages/pipeline/src/entities/block.ts index f2efc6390..398946622 100644 --- a/packages/pipeline/src/entities/block.ts +++ b/packages/pipeline/src/entities/block.ts @@ -1,10 +1,13 @@ import { Column, Entity, PrimaryColumn } from 'typeorm'; +import { numberToBigIntTransformer } from '../utils'; + @Entity({ name: 'blocks', schema: 'raw' }) export class Block { @PrimaryColumn() public hash!: string; - @PrimaryColumn() public number!: number; + @PrimaryColumn({ transformer: numberToBigIntTransformer }) + public number!: number; - @Column({ name: 'timestamp' }) + @Column({ name: 'timestamp', transformer: numberToBigIntTransformer }) public timestamp!: number; } diff --git a/packages/pipeline/src/entities/exchange_cancel_event.ts b/packages/pipeline/src/entities/exchange_cancel_event.ts index 5a40ba799..2fcc17df6 100644 --- a/packages/pipeline/src/entities/exchange_cancel_event.ts +++ b/packages/pipeline/src/entities/exchange_cancel_event.ts @@ -1,6 +1,7 @@ import { Column, Entity, PrimaryColumn } from 'typeorm'; import { AssetType } from '../types'; +import { numberToBigIntTransformer } from '../utils'; @Entity({ name: 'exchange_cancel_events', schema: 'raw' }) export class ExchangeCancelEvent { @@ -8,7 +9,7 @@ export class ExchangeCancelEvent { public contractAddress!: string; @PrimaryColumn({ name: 'log_index' }) public logIndex!: number; - @PrimaryColumn({ name: 'block_number' }) + @PrimaryColumn({ name: 'block_number', transformer: numberToBigIntTransformer }) public blockNumber!: number; @Column({ name: 'raw_data' }) diff --git a/packages/pipeline/src/entities/exchange_cancel_up_to_event.ts b/packages/pipeline/src/entities/exchange_cancel_up_to_event.ts index 9b1c6174a..60ead324f 100644 --- a/packages/pipeline/src/entities/exchange_cancel_up_to_event.ts +++ b/packages/pipeline/src/entities/exchange_cancel_up_to_event.ts @@ -1,7 +1,7 @@ import { BigNumber } from '@0x/utils'; import { Column, Entity, PrimaryColumn } from 'typeorm'; -import { bigNumberTransformer } from '../utils'; +import { bigNumberTransformer, numberToBigIntTransformer } from '../utils'; @Entity({ name: 'exchange_cancel_up_to_events', schema: 'raw' }) export class ExchangeCancelUpToEvent { @@ -9,7 +9,7 @@ export class ExchangeCancelUpToEvent { public contractAddress!: string; @PrimaryColumn({ name: 'log_index' }) public logIndex!: number; - @PrimaryColumn({ name: 'block_number' }) + @PrimaryColumn({ name: 'block_number', transformer: numberToBigIntTransformer }) public blockNumber!: number; // TODO(albrow): Include transaction hash diff --git a/packages/pipeline/src/entities/exchange_fill_event.ts b/packages/pipeline/src/entities/exchange_fill_event.ts index aa082436b..bbf0abf58 100644 --- a/packages/pipeline/src/entities/exchange_fill_event.ts +++ b/packages/pipeline/src/entities/exchange_fill_event.ts @@ -2,7 +2,7 @@ import { BigNumber } from '@0x/utils'; import { Column, Entity, PrimaryColumn } from 'typeorm'; import { AssetType } from '../types'; -import { bigNumberTransformer } from '../utils'; +import { bigNumberTransformer, numberToBigIntTransformer } from '../utils'; @Entity({ name: 'exchange_fill_events', schema: 'raw' }) export class ExchangeFillEvent { @@ -10,7 +10,7 @@ export class ExchangeFillEvent { public contractAddress!: string; @PrimaryColumn({ name: 'log_index' }) public logIndex!: number; - @PrimaryColumn({ name: 'block_number' }) + @PrimaryColumn({ name: 'block_number', transformer: numberToBigIntTransformer }) public blockNumber!: number; @Column({ name: 'raw_data' }) diff --git a/packages/pipeline/src/entities/sra_order_observed_timestamp.ts b/packages/pipeline/src/entities/sra_order_observed_timestamp.ts index bdb6cd36b..cd2d41397 100644 --- a/packages/pipeline/src/entities/sra_order_observed_timestamp.ts +++ b/packages/pipeline/src/entities/sra_order_observed_timestamp.ts @@ -1,5 +1,7 @@ import { Entity, PrimaryColumn } from 'typeorm'; +import { numberToBigIntTransformer } from '../utils'; + import { SraOrder } from './sra_order'; @Entity({ name: 'sra_orders_observed_timestamps', schema: 'raw' }) @@ -11,7 +13,7 @@ export class SraOrdersObservedTimeStamp { @PrimaryColumn({ name: 'source_url' }) public sourceUrl!: string; - @PrimaryColumn({ name: 'observed_timestamp' }) + @PrimaryColumn({ name: 'observed_timestamp', transformer: numberToBigIntTransformer }) public observedTimestamp!: number; } diff --git a/packages/pipeline/src/entities/token_metadata.ts b/packages/pipeline/src/entities/token_metadata.ts index 4a0bceefe..ca1e57937 100644 --- a/packages/pipeline/src/entities/token_metadata.ts +++ b/packages/pipeline/src/entities/token_metadata.ts @@ -8,12 +8,14 @@ export class TokenMetadata { @PrimaryColumn({ type: 'varchar', nullable: false }) public authority!: string; + // TODO(albrow): Convert decimals field to type BigNumber/numeric because it + // comes from a 256-bit integer in a smart contract. @Column({ type: 'integer', nullable: true }) - public decimals!: number; + public decimals!: number | null; @Column({ type: 'varchar', nullable: true }) - public symbol!: string; + public symbol!: string | null; @Column({ type: 'varchar', nullable: true }) - public name!: string; + public name!: string | null; } diff --git a/packages/pipeline/src/entities/transaction.ts b/packages/pipeline/src/entities/transaction.ts index dd2143df5..91e4ecb5d 100644 --- a/packages/pipeline/src/entities/transaction.ts +++ b/packages/pipeline/src/entities/transaction.ts @@ -1,16 +1,18 @@ import { Column, Entity, PrimaryColumn } from 'typeorm'; +import { numberToBigIntTransformer } from '../utils'; + @Entity({ name: 'transactions', schema: 'raw' }) export class Transaction { @PrimaryColumn({ name: 'transaction_hash' }) public transactionHash!: string; @PrimaryColumn({ name: 'block_hash' }) public blockHash!: string; - @PrimaryColumn({ name: 'block_number' }) + @PrimaryColumn({ name: 'block_number', transformer: numberToBigIntTransformer }) public blockNumber!: number; - @Column({ type: 'bigint', name: 'gas_used' }) + @Column({ type: 'bigint', name: 'gas_used', transformer: numberToBigIntTransformer }) public gasUsed!: number; - @Column({ type: 'bigint', name: 'gas_price' }) + @Column({ type: 'bigint', name: 'gas_price', transformer: numberToBigIntTransformer }) public gasPrice!: number; } -- cgit v1.2.3 From 7198b441e0d85785eec7244dd60bcd92269d954e Mon Sep 17 00:00:00 2001 From: Alex Browne Date: Thu, 29 Nov 2018 11:40:09 -0800 Subject: Add script for parsing competing dex trades from Bloxy (#1355) --- packages/pipeline/src/entities/dex_trade.ts | 54 +++++++++++++++++++++++++++++ packages/pipeline/src/entities/index.ts | 7 ++-- 2 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 packages/pipeline/src/entities/dex_trade.ts (limited to 'packages/pipeline/src/entities') diff --git a/packages/pipeline/src/entities/dex_trade.ts b/packages/pipeline/src/entities/dex_trade.ts new file mode 100644 index 000000000..9d288cb51 --- /dev/null +++ b/packages/pipeline/src/entities/dex_trade.ts @@ -0,0 +1,54 @@ +import { BigNumber } from '@0x/utils'; +import { Column, Entity, PrimaryColumn } from 'typeorm'; + +import { bigNumberTransformer, numberToBigIntTransformer } from '../utils'; + +@Entity({ name: 'dex_trades', schema: 'raw' }) +export class DexTrade { + @PrimaryColumn({ name: 'source_url' }) + public sourceUrl!: string; + @PrimaryColumn({ name: 'tx_hash' }) + public txHash!: string; + + @Column({ name: 'tx_timestamp', type: 'bigint', transformer: numberToBigIntTransformer }) + public txTimestamp!: number; + @Column({ name: 'tx_date' }) + public txDate!: string; + @Column({ name: 'tx_sender' }) + public txSender!: string; + @Column({ name: 'smart_contract_id', type: 'bigint', transformer: numberToBigIntTransformer }) + public smartContractId!: number; + @Column({ name: 'smart_contract_address' }) + public smartContractAddress!: string; + @Column({ name: 'contract_type' }) + public contractType!: string; + @Column({ type: 'varchar' }) + public maker!: string; + @Column({ type: 'varchar' }) + public taker!: string; + @Column({ name: 'amount_buy', type: 'numeric', transformer: bigNumberTransformer }) + public amountBuy!: BigNumber; + @Column({ name: 'maker_fee_amount', type: 'numeric', transformer: bigNumberTransformer }) + public makerFeeAmount!: BigNumber; + @Column({ name: 'buy_currency_id', type: 'bigint', transformer: numberToBigIntTransformer }) + public buyCurrencyId!: number; + @Column({ name: 'buy_symbol' }) + public buySymbol!: string; + @Column({ name: 'amount_sell', type: 'numeric', transformer: bigNumberTransformer }) + public amountSell!: BigNumber; + @Column({ name: 'taker_fee_amount', type: 'numeric', transformer: bigNumberTransformer }) + public takerFeeAmount!: BigNumber; + @Column({ name: 'sell_currency_id', type: 'bigint', transformer: numberToBigIntTransformer }) + public sellCurrencyId!: number; + @Column({ name: 'sell_symbol' }) + public sellSymbol!: string; + @Column({ name: 'maker_annotation' }) + public makerAnnotation!: string; + @Column({ name: 'taker_annotation' }) + public takerAnnotation!: string; + @Column() public protocol!: string; + @Column({ name: 'buy_address', type: 'varchar', nullable: true }) + public buyAddress!: string | null; + @Column({ name: 'sell_address', type: 'varchar', nullable: true }) + public sellAddress!: string | null; +} diff --git a/packages/pipeline/src/entities/index.ts b/packages/pipeline/src/entities/index.ts index a8f159a2a..d3056a477 100644 --- a/packages/pipeline/src/entities/index.ts +++ b/packages/pipeline/src/entities/index.ts @@ -3,14 +3,15 @@ import { ExchangeCancelUpToEvent } from './exchange_cancel_up_to_event'; import { ExchangeFillEvent } from './exchange_fill_event'; export { Block } from './block'; +export { DexTrade } from './dex_trade'; export { ExchangeCancelEvent } from './exchange_cancel_event'; export { ExchangeCancelUpToEvent } from './exchange_cancel_up_to_event'; export { ExchangeFillEvent } from './exchange_fill_event'; +export { OHLCVExternal } from './ohlcv_external'; export { Relayer } from './relayer'; export { SraOrder } from './sra_order'; -export { Transaction } from './transaction'; -export { TokenMetadata } from './token_metadata'; export { SraOrdersObservedTimeStamp, createObservedTimestampForOrder } from './sra_order_observed_timestamp'; -export { OHLCVExternal } from './ohlcv_external'; +export { TokenMetadata } from './token_metadata'; +export { Transaction } from './transaction'; export type ExchangeEvent = ExchangeFillEvent | ExchangeCancelEvent | ExchangeCancelUpToEvent; -- cgit v1.2.3 From 87ffa5d7ab19d2288bf68131a7e7ec77578c564c Mon Sep 17 00:00:00 2001 From: zkao Date: Tue, 4 Dec 2018 13:21:46 -0800 Subject: Token_orderbook_snapshots for Ddex and Paradex(#1354) * Implements the TokenOrderbookSnapshot Table * Scripts, Data Sources and Entities to pull Ddex and Paradex API data. --- packages/pipeline/src/entities/index.ts | 1 + packages/pipeline/src/entities/token_order.ts | 29 +++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 packages/pipeline/src/entities/token_order.ts (limited to 'packages/pipeline/src/entities') diff --git a/packages/pipeline/src/entities/index.ts b/packages/pipeline/src/entities/index.ts index d3056a477..db0814e38 100644 --- a/packages/pipeline/src/entities/index.ts +++ b/packages/pipeline/src/entities/index.ts @@ -12,6 +12,7 @@ export { Relayer } from './relayer'; export { SraOrder } from './sra_order'; export { SraOrdersObservedTimeStamp, createObservedTimestampForOrder } from './sra_order_observed_timestamp'; export { TokenMetadata } from './token_metadata'; +export { TokenOrderbookSnapshot } from './token_order'; export { Transaction } from './transaction'; export type ExchangeEvent = ExchangeFillEvent | ExchangeCancelEvent | ExchangeCancelUpToEvent; diff --git a/packages/pipeline/src/entities/token_order.ts b/packages/pipeline/src/entities/token_order.ts new file mode 100644 index 000000000..557705767 --- /dev/null +++ b/packages/pipeline/src/entities/token_order.ts @@ -0,0 +1,29 @@ +import { BigNumber } from '@0x/utils'; +import { Column, Entity, PrimaryColumn } from 'typeorm'; + +import { OrderType } from '../types'; +import { bigNumberTransformer, numberToBigIntTransformer } from '../utils'; + +@Entity({ name: 'token_orderbook_snapshots', schema: 'raw' }) +export class TokenOrderbookSnapshot { + @PrimaryColumn({ name: 'observed_timestamp', type: 'bigint', transformer: numberToBigIntTransformer }) + public observedTimestamp!: number; + @PrimaryColumn({ name: 'source' }) + public source!: string; + @Column({ name: 'order_type' }) + public orderType!: OrderType; + @PrimaryColumn({ name: 'price', type: 'numeric', transformer: bigNumberTransformer }) + public price!: BigNumber; + @PrimaryColumn({ name: 'base_asset_symbol' }) + public baseAssetSymbol!: string; + @Column({ name: 'base_asset_address' }) + public baseAssetAddress!: string; + @Column({ name: 'base_volume', type: 'numeric', transformer: bigNumberTransformer }) + public baseVolume!: BigNumber; + @PrimaryColumn({ name: 'quote_asset_symbol' }) + public quoteAssetSymbol!: string; + @Column({ name: 'quote_asset_address' }) + public quoteAssetAddress!: string; + @Column({ name: 'quote_volume', type: 'numeric', transformer: bigNumberTransformer }) + public quoteVolume!: BigNumber; +} -- cgit v1.2.3 From 8c21a700bae0c751f7f9ca47f9a47628a4478911 Mon Sep 17 00:00:00 2001 From: Xianny <8582774+xianny@users.noreply.github.com> Date: Tue, 4 Dec 2018 13:36:18 -0800 Subject: pull OHLCV records from Crypto Compare (#1349) * [WIP] pull OHLCV records from Crypto Compare * lint * refactor to pull logic out of script and into modules * add entity test for ohlcv_external entity * implement rate limit and chronological backfill for ohlcv * add unit tests; cleanup variable names * Fetch OHLCV pairs params from events table * better method names * fix outdated test * lint * Clean up after review * oops * fix failing test * better filtering of most recent records * fix bug when generating pairs * fix default earliest backfill date * fix bug with retrieving backfill time * prettier --- packages/pipeline/src/entities/ohlcv_external.ts | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'packages/pipeline/src/entities') diff --git a/packages/pipeline/src/entities/ohlcv_external.ts b/packages/pipeline/src/entities/ohlcv_external.ts index 95cd4f2f5..4f55dd930 100644 --- a/packages/pipeline/src/entities/ohlcv_external.ts +++ b/packages/pipeline/src/entities/ohlcv_external.ts @@ -1,20 +1,30 @@ import { Column, Entity, PrimaryColumn } from 'typeorm'; +import { numberToBigIntTransformer } from '../utils'; + @Entity({ name: 'ohlcv_external', schema: 'raw' }) export class OHLCVExternal { @PrimaryColumn() public exchange!: string; - @PrimaryColumn() public fromSymbol!: string; - @PrimaryColumn() public toSymbol!: string; - @PrimaryColumn() public startTime!: number; - @PrimaryColumn() public endTime!: number; + + @PrimaryColumn({ name: 'from_symbol', type: 'varchar' }) + public fromSymbol!: string; + @PrimaryColumn({ name: 'to_symbol', type: 'varchar' }) + public toSymbol!: string; + @PrimaryColumn({ name: 'start_time', transformer: numberToBigIntTransformer }) + public startTime!: number; + @PrimaryColumn({ name: 'end_time', transformer: numberToBigIntTransformer }) + public endTime!: number; @Column() public open!: number; @Column() public close!: number; @Column() public low!: number; @Column() public high!: number; - @Column() public volumeFrom!: number; - @Column() public volumeTo!: number; + @Column({ name: 'volume_from' }) + public volumeFrom!: number; + @Column({ name: 'volume_to' }) + public volumeTo!: number; @PrimaryColumn() public source!: string; - @PrimaryColumn() public observedTimestamp!: number; + @PrimaryColumn({ name: 'observed_timestamp', transformer: numberToBigIntTransformer }) + public observedTimestamp!: number; } -- cgit v1.2.3 From 00f86ca0f7871639d2b0be496f6f8c5e0d8d7ffe Mon Sep 17 00:00:00 2001 From: Alex Browne Date: Tue, 4 Dec 2018 20:04:08 -0800 Subject: Address PR feedback --- packages/pipeline/src/entities/exchange_cancel_event.ts | 2 -- packages/pipeline/src/entities/exchange_cancel_up_to_event.ts | 2 -- packages/pipeline/src/entities/exchange_fill_event.ts | 2 -- packages/pipeline/src/entities/relayer.ts | 3 --- packages/pipeline/src/entities/token_metadata.ts | 9 +++++---- 5 files changed, 5 insertions(+), 13 deletions(-) (limited to 'packages/pipeline/src/entities') diff --git a/packages/pipeline/src/entities/exchange_cancel_event.ts b/packages/pipeline/src/entities/exchange_cancel_event.ts index 2fcc17df6..38f99c903 100644 --- a/packages/pipeline/src/entities/exchange_cancel_event.ts +++ b/packages/pipeline/src/entities/exchange_cancel_event.ts @@ -48,6 +48,4 @@ export class ExchangeCancelEvent { public takerTokenAddress!: string; @Column({ nullable: true, type: String, name: 'taker_token_id' }) public takerTokenId!: string | null; - - // TODO(albrow): Include topics? } diff --git a/packages/pipeline/src/entities/exchange_cancel_up_to_event.ts b/packages/pipeline/src/entities/exchange_cancel_up_to_event.ts index 60ead324f..27580305e 100644 --- a/packages/pipeline/src/entities/exchange_cancel_up_to_event.ts +++ b/packages/pipeline/src/entities/exchange_cancel_up_to_event.ts @@ -12,7 +12,6 @@ export class ExchangeCancelUpToEvent { @PrimaryColumn({ name: 'block_number', transformer: numberToBigIntTransformer }) public blockNumber!: number; - // TODO(albrow): Include transaction hash @Column({ name: 'raw_data' }) public rawData!: string; @@ -24,5 +23,4 @@ export class ExchangeCancelUpToEvent { public senderAddress!: string; @Column({ name: 'order_epoch', type: 'numeric', transformer: bigNumberTransformer }) public orderEpoch!: BigNumber; - // TODO(albrow): Include topics? } diff --git a/packages/pipeline/src/entities/exchange_fill_event.ts b/packages/pipeline/src/entities/exchange_fill_event.ts index bbf0abf58..9b7727615 100644 --- a/packages/pipeline/src/entities/exchange_fill_event.ts +++ b/packages/pipeline/src/entities/exchange_fill_event.ts @@ -57,6 +57,4 @@ export class ExchangeFillEvent { public takerTokenAddress!: string; @Column({ nullable: true, type: String, name: 'taker_token_id' }) public takerTokenId!: string | null; - - // TODO(albrow): Include topics? } diff --git a/packages/pipeline/src/entities/relayer.ts b/packages/pipeline/src/entities/relayer.ts index b3a856fd8..5af8578b4 100644 --- a/packages/pipeline/src/entities/relayer.ts +++ b/packages/pipeline/src/entities/relayer.ts @@ -14,9 +14,6 @@ export class Relayer { @Column({ name: 'app_url', type: 'varchar', nullable: true }) public appUrl!: string | null; - // TODO(albrow): Add exchange contract or protocol version? - // TODO(albrow): Add network ids for addresses? - @Column({ name: 'fee_recipient_addresses', type: 'varchar', array: true }) public feeRecipientAddresses!: string[]; @Column({ name: 'taker_addresses', type: 'varchar', array: true }) diff --git a/packages/pipeline/src/entities/token_metadata.ts b/packages/pipeline/src/entities/token_metadata.ts index ca1e57937..911b53972 100644 --- a/packages/pipeline/src/entities/token_metadata.ts +++ b/packages/pipeline/src/entities/token_metadata.ts @@ -1,5 +1,8 @@ +import { BigNumber } from '@0x/utils'; import { Column, Entity, PrimaryColumn } from 'typeorm'; +import { bigNumberTransformer } from '../utils/transformers'; + @Entity({ name: 'token_metadata', schema: 'raw' }) export class TokenMetadata { @PrimaryColumn({ type: 'varchar', nullable: false }) @@ -8,10 +11,8 @@ export class TokenMetadata { @PrimaryColumn({ type: 'varchar', nullable: false }) public authority!: string; - // TODO(albrow): Convert decimals field to type BigNumber/numeric because it - // comes from a 256-bit integer in a smart contract. - @Column({ type: 'integer', nullable: true }) - public decimals!: number | null; + @Column({ type: 'numeric', transformer: bigNumberTransformer, nullable: true }) + public decimals!: BigNumber | null; @Column({ type: 'varchar', nullable: true }) public symbol!: string | null; -- cgit v1.2.3 From e0348f9c044b4909260e4864398b4f50232da620 Mon Sep 17 00:00:00 2001 From: Alex Browne Date: Tue, 4 Dec 2018 20:20:49 -0800 Subject: Change type of transactions.gas_used and gas_price to BigNumber/numeric --- packages/pipeline/src/entities/transaction.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'packages/pipeline/src/entities') diff --git a/packages/pipeline/src/entities/transaction.ts b/packages/pipeline/src/entities/transaction.ts index 91e4ecb5d..742050177 100644 --- a/packages/pipeline/src/entities/transaction.ts +++ b/packages/pipeline/src/entities/transaction.ts @@ -1,6 +1,7 @@ +import { BigNumber } from '@0x/utils'; import { Column, Entity, PrimaryColumn } from 'typeorm'; -import { numberToBigIntTransformer } from '../utils'; +import { bigNumberTransformer, numberToBigIntTransformer } from '../utils'; @Entity({ name: 'transactions', schema: 'raw' }) export class Transaction { @@ -11,8 +12,8 @@ export class Transaction { @PrimaryColumn({ name: 'block_number', transformer: numberToBigIntTransformer }) public blockNumber!: number; - @Column({ type: 'bigint', name: 'gas_used', transformer: numberToBigIntTransformer }) - public gasUsed!: number; - @Column({ type: 'bigint', name: 'gas_price', transformer: numberToBigIntTransformer }) - public gasPrice!: number; + @Column({ type: 'numeric', name: 'gas_used', transformer: bigNumberTransformer }) + public gasUsed!: BigNumber; + @Column({ type: 'numeric', name: 'gas_price', transformer: bigNumberTransformer }) + public gasPrice!: BigNumber; } -- cgit v1.2.3