aboutsummaryrefslogtreecommitdiffstats
path: root/packages/pipeline/src/index.ts
diff options
context:
space:
mode:
authorAlex Browne <stephenalexbrowne@gmail.com>2018-09-21 08:25:48 +0800
committerFred Carlsen <fred@sjelfull.no>2018-12-06 19:04:24 +0800
commit0133bec07d84c5b73d17a5b9fd0ab1c2ded88f8c (patch)
tree63e06020c3cfa9e7b772b784e780324afc31d8e7 /packages/pipeline/src/index.ts
parentbd7bde9bb02a4d51f3a65e255262caf5f5072cd4 (diff)
downloaddexon-sol-tools-0133bec07d84c5b73d17a5b9fd0ab1c2ded88f8c.tar
dexon-sol-tools-0133bec07d84c5b73d17a5b9fd0ab1c2ded88f8c.tar.gz
dexon-sol-tools-0133bec07d84c5b73d17a5b9fd0ab1c2ded88f8c.tar.bz2
dexon-sol-tools-0133bec07d84c5b73d17a5b9fd0ab1c2ded88f8c.tar.lz
dexon-sol-tools-0133bec07d84c5b73d17a5b9fd0ab1c2ded88f8c.tar.xz
dexon-sol-tools-0133bec07d84c5b73d17a5b9fd0ab1c2ded88f8c.tar.zst
dexon-sol-tools-0133bec07d84c5b73d17a5b9fd0ab1c2ded88f8c.zip
Add support for decoding asset data
Diffstat (limited to 'packages/pipeline/src/index.ts')
-rw-r--r--packages/pipeline/src/index.ts27
1 files changed, 4 insertions, 23 deletions
diff --git a/packages/pipeline/src/index.ts b/packages/pipeline/src/index.ts
index d70ec3e3e..db26343e0 100644
--- a/packages/pipeline/src/index.ts
+++ b/packages/pipeline/src/index.ts
@@ -1,4 +1,5 @@
import { ExchangeFillEventArgs } from '@0xproject/contract-wrappers';
+import { assetDataUtils } from '@0xproject/order-utils';
import { LogWithDecodedArgs } from 'ethereum-types';
import 'reflect-metadata';
import { createConnection } from 'typeorm';
@@ -14,32 +15,12 @@ const etherscan = new Etherscan(process.env.ETHERSCAN_API_KEY as string);
const connection = await createConnection(config);
const repository = connection.getRepository(ExchangeFillEvent);
console.log(`found ${await repository.count()} existing fill events`);
- const eventLogs = await etherscan.getContractEventsAsync(
+ const events = await etherscan.getContractEventsAsync(
'0x4f833a24e1f95d70f028921e27040ca56e09ab0b',
artifacts.Exchange.compilerOutput.abi,
);
- for (const eventLog of eventLogs) {
- if (eventLog.event !== 'Fill') {
- continue;
- }
- const fillEventLog = eventLog as LogWithDecodedArgs<ExchangeFillEventArgs>;
- const exchangeFillEvent = new ExchangeFillEvent();
- exchangeFillEvent.logIndex = fillEventLog.logIndex as number;
- exchangeFillEvent.address = fillEventLog.address as string;
- exchangeFillEvent.rawData = fillEventLog.data as string;
- exchangeFillEvent.blockNumber = fillEventLog.blockNumber as number;
- exchangeFillEvent.makerAddress = fillEventLog.args.makerAddress.toString();
- exchangeFillEvent.takerAddress = fillEventLog.args.takerAddress.toString();
- exchangeFillEvent.feeRecepientAddress = fillEventLog.args.feeRecipientAddress;
- exchangeFillEvent.senderAddress = fillEventLog.args.senderAddress;
- exchangeFillEvent.makerAssetFilledAmount = fillEventLog.args.makerAssetFilledAmount.toString();
- exchangeFillEvent.takerAssetFilledAmount = fillEventLog.args.takerAssetFilledAmount.toString();
- exchangeFillEvent.makerFeePaid = fillEventLog.args.makerFeePaid.toString();
- exchangeFillEvent.takerFeePaid = fillEventLog.args.takerFeePaid.toString();
- exchangeFillEvent.orderHash = fillEventLog.args.orderHash;
- exchangeFillEvent.makerAssetData = fillEventLog.args.makerAssetData;
- exchangeFillEvent.takerAssetData = fillEventLog.args.takerAssetData;
- await repository.save(exchangeFillEvent);
+ for (const event of events) {
+ await repository.save(event);
}
console.log(`now ${await repository.count()} total fill events`);
})();