diff options
author | Alex Browne <stephenalexbrowne@gmail.com> | 2018-11-14 07:33:43 +0800 |
---|---|---|
committer | Alex Browne <stephenalexbrowne@gmail.com> | 2018-12-05 06:24:48 +0800 |
commit | 26280e4aba147ad6000b9df309e64db84b6932fc (patch) | |
tree | 5d8c2ba185216e35dde39de56964940ba54add93 /packages/pipeline/src/entities | |
parent | 55bbe1954b35ff0a6367f1ff820d32a32b48eff3 (diff) | |
download | dexon-0x-contracts-26280e4aba147ad6000b9df309e64db84b6932fc.tar dexon-0x-contracts-26280e4aba147ad6000b9df309e64db84b6932fc.tar.gz dexon-0x-contracts-26280e4aba147ad6000b9df309e64db84b6932fc.tar.bz2 dexon-0x-contracts-26280e4aba147ad6000b9df309e64db84b6932fc.tar.lz dexon-0x-contracts-26280e4aba147ad6000b9df309e64db84b6932fc.tar.xz dexon-0x-contracts-26280e4aba147ad6000b9df309e64db84b6932fc.tar.zst dexon-0x-contracts-26280e4aba147ad6000b9df309e64db84b6932fc.zip |
Implement scraping sra orders from radar relay
Diffstat (limited to 'packages/pipeline/src/entities')
-rw-r--r-- | packages/pipeline/src/entities/index.ts | 1 | ||||
-rw-r--r-- | packages/pipeline/src/entities/sra_order.ts | 4 | ||||
-rw-r--r-- | packages/pipeline/src/entities/sra_order_observed_timestamp.ts | 30 |
3 files changed, 33 insertions, 2 deletions
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; +} |