From 91e7485ecc4e780ef454b642a52c3d93faa95af1 Mon Sep 17 00:00:00 2001 From: Alex Browne Date: Wed, 17 Oct 2018 16:44:07 -0700 Subject: Update to use ContractWrappers + Infura instead of Etherscan --- packages/pipeline/package.json | 22 +- .../contract-wrappers/exchange_events.ts | 51 +++ .../pipeline/src/data_sources/etherscan/index.ts | 52 --- .../pipeline/src/data_types/events/event_utils.ts | 35 -- .../src/data_types/events/exchange_events.ts | 130 ------- .../pipeline/src/data_types/sra_orders/index.ts | 54 --- packages/pipeline/src/index.ts | 43 +-- packages/pipeline/src/parsers/events/index.ts | 111 ++++++ packages/pipeline/src/parsers/sra_orders/index.ts | 54 +++ .../test/data_types/events/event_utils_test.ts | 86 ----- .../test/data_types/events/exchange_events_test.ts | 77 ---- .../test/data_types/sra_orders/index_test.ts | 79 ---- .../pipeline/test/parsers/events/index_test.ts | 77 ++++ .../pipeline/test/parsers/sra_orders/index_test.ts | 70 ++++ yarn.lock | 411 +++------------------ 15 files changed, 445 insertions(+), 907 deletions(-) create mode 100644 packages/pipeline/src/data_sources/contract-wrappers/exchange_events.ts delete mode 100644 packages/pipeline/src/data_sources/etherscan/index.ts delete mode 100644 packages/pipeline/src/data_types/events/event_utils.ts delete mode 100644 packages/pipeline/src/data_types/events/exchange_events.ts delete mode 100644 packages/pipeline/src/data_types/sra_orders/index.ts create mode 100644 packages/pipeline/src/parsers/events/index.ts create mode 100644 packages/pipeline/src/parsers/sra_orders/index.ts delete mode 100644 packages/pipeline/test/data_types/events/event_utils_test.ts delete mode 100644 packages/pipeline/test/data_types/events/exchange_events_test.ts delete mode 100644 packages/pipeline/test/data_types/sra_orders/index_test.ts create mode 100644 packages/pipeline/test/parsers/events/index_test.ts create mode 100644 packages/pipeline/test/parsers/sra_orders/index_test.ts diff --git a/packages/pipeline/package.json b/packages/pipeline/package.json index be23bfe2c..0071fab2c 100644 --- a/packages/pipeline/package.json +++ b/packages/pipeline/package.json @@ -1,5 +1,5 @@ { - "name": "@0xproject/pipeline", + "name": "@0x/pipeline", "version": "0.0.1", "private": true, "description": "Data pipeline for offline analysis", @@ -25,7 +25,8 @@ }, "license": "Apache-2.0", "devDependencies": { - "@0xproject/tslint-config": "^1.0.7", + "@types/ramda": "^0.25.38", + "@0x/tslint-config": "^1.0.9", "chai": "^4.1.2", "chai-as-promised": "^7.1.1", "chai-bignumber": "^2.0.2", @@ -35,14 +36,15 @@ "typescript": "3.0.1" }, "dependencies": { - "@0xproject/contract-artifacts": "^1.0.0", - "@0xproject/connect": "^2.0.4", - "@0xproject/contract-wrappers": "^1.0.1", - "@0xproject/order-utils": "^1.0.2", - "@0xproject/subproviders": "^2.0.2", - "@0xproject/types": "^1.0.1", - "@0xproject/utils": "^1.0.8", - "@types/ramda": "^0.25.38", + "@0x/dev-utils": "^1.0.13", + "@0x/contract-artifacts": "^1.0.1", + "@0x/connect": "^3.0.2", + "@0x/contract-wrappers": "^3.0.0", + "@0x/order-utils": "^2.0.0", + "@0x/subproviders": "^2.1.0", + "@0x/types": "^1.2.0", + "@0x/utils": "^2.0.3", + "@0x/web3-wrapper": "^3.1.0", "axios": "^0.18.0", "ethereum-types": "^1.0.6", "ramda": "^0.25.0", diff --git a/packages/pipeline/src/data_sources/contract-wrappers/exchange_events.ts b/packages/pipeline/src/data_sources/contract-wrappers/exchange_events.ts new file mode 100644 index 000000000..77217c601 --- /dev/null +++ b/packages/pipeline/src/data_sources/contract-wrappers/exchange_events.ts @@ -0,0 +1,51 @@ +import { ContractWrappers, ExchangeEvents, ExchangeFillEventArgs, ExchangeWrapper } from '@0xproject/contract-wrappers'; +import { Web3ProviderEngine } from '@0xproject/subproviders'; +import { Web3Wrapper } from '@0xproject/web3-wrapper'; +import { LogWithDecodedArgs } from 'ethereum-types'; + +const BLOCK_FINALITY_THRESHOLD = 10; // When to consider blocks as final. Used to compute default toBlock. +const NUM_BLOCKS_PER_QUERY = 100000; // Number of blocks to query for events at a time. +const EXCHANGE_START_BLOCK = 6271590; // Block number when the Exchange contract was deployed to mainnet. + +export class ExchangeEventsSource { + private _exchangeWrapper: ExchangeWrapper; + private _web3Wrapper: Web3Wrapper; + constructor(provider: Web3ProviderEngine, networkId: number) { + this._web3Wrapper = new Web3Wrapper(provider); + const contractWrappers = new ContractWrappers(provider, { networkId }); + this._exchangeWrapper = contractWrappers.exchange; + } + + // TODO(albrow): Get Cancel and CancelUpTo events. + + public async getFillEventsAsync( + fromBlock: number = EXCHANGE_START_BLOCK, + toBlock?: number, + ): Promise>> { + const calculatedToBlock = + toBlock === undefined + ? (await this._web3Wrapper.getBlockNumberAsync()) - BLOCK_FINALITY_THRESHOLD + : toBlock; + let events: Array> = []; + for (let currFromBlock = fromBlock; currFromBlock <= calculatedToBlock; currFromBlock += NUM_BLOCKS_PER_QUERY) { + events = events.concat( + await this._getFillEventsForRangeAsync(currFromBlock, currFromBlock + NUM_BLOCKS_PER_QUERY - 1), + ); + } + return events; + } + + private async _getFillEventsForRangeAsync( + fromBlock: number, + toBlock: number, + ): Promise>> { + return this._exchangeWrapper.getLogsAsync( + ExchangeEvents.Fill, + { + fromBlock, + toBlock, + }, + {}, + ); + } +} diff --git a/packages/pipeline/src/data_sources/etherscan/index.ts b/packages/pipeline/src/data_sources/etherscan/index.ts deleted file mode 100644 index 044fff02e..000000000 --- a/packages/pipeline/src/data_sources/etherscan/index.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { default as axios } from 'axios'; -import { BlockParam, BlockParamLiteral } from 'ethereum-types'; - -const ETHERSCAN_URL = 'https://api.etherscan.io/api'; - -export class Etherscan { - private readonly _apiKey: string; - constructor(apiKey: string) { - this._apiKey = apiKey; - } - - /** - * Gets the raw events for a specific contract and block range. - * @param contractAddress The address of the contract to get the events for. - * @param fromBlock The start of the block range to get events for (inclusive). - * @param toBlock The end of the block range to get events for (inclusive). - * @returns A list of decoded events. - */ - public async getContractEventsAsync( - contractAddress: string, - fromBlock: BlockParam = BlockParamLiteral.Earliest, - toBlock: BlockParam = BlockParamLiteral.Latest, - ): Promise { - const fullURL = `${ETHERSCAN_URL}?module=logs&action=getLogs&address=${contractAddress}&fromBlock=${fromBlock}&toBlock=${toBlock}&apikey=${ - this._apiKey - }`; - const resp = await axios.get(fullURL); - // TODO(albrow): Check response code. - return resp.data; - } -} - -// Raw events response from etherescan.io -export interface EventsResponse { - status: string; - message: string; - result: EventsResponseResult[]; -} - -// Events as represented in the response from etherscan.io -export interface EventsResponseResult { - address: string; - topics: string[]; - data: string; - blockNumber: string; - timeStamp: string; - gasPrice: string; - gasUsed: string; - logIndex: string; - transactionHash: string; - transactionIndex: string; -} diff --git a/packages/pipeline/src/data_types/events/event_utils.ts b/packages/pipeline/src/data_types/events/event_utils.ts deleted file mode 100644 index 6be964807..000000000 --- a/packages/pipeline/src/data_types/events/event_utils.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { AbiDecoder } from '@0xproject/utils'; -import { AbiDefinition, LogEntry, LogWithDecodedArgs } from 'ethereum-types'; - -import { EventsResponseResult } from '../../data_sources/etherscan'; - -const hexRadix = 16; - -function hexToInt(hex: string): number { - return parseInt(hex.replace('0x', ''), hexRadix); -} - -// Converts a raw event response to a LogEntry -export function convertResponseToLogEntry(result: EventsResponseResult): LogEntry { - return { - logIndex: hexToInt(result.logIndex), - transactionIndex: hexToInt(result.transactionIndex), - transactionHash: result.transactionHash, - blockHash: '', - blockNumber: hexToInt(result.blockNumber), - address: result.address, - data: result.data, - topics: result.topics, - }; -} - -// Decodes a LogEntry into a LogWithDecodedArgs -export function decodeLogEntry( - contractAbi: AbiDefinition[], - log: LogEntry, -): LogWithDecodedArgs { - const abiDecoder = new AbiDecoder([contractAbi]); - const logWithDecodedArgs = abiDecoder.tryToDecodeLogOrNoop(log); - // tslint:disable-next-line:no-unnecessary-type-assertion - return logWithDecodedArgs as LogWithDecodedArgs; -} diff --git a/packages/pipeline/src/data_types/events/exchange_events.ts b/packages/pipeline/src/data_types/events/exchange_events.ts deleted file mode 100644 index 30ef058f3..000000000 --- a/packages/pipeline/src/data_types/events/exchange_events.ts +++ /dev/null @@ -1,130 +0,0 @@ -import { Exchange } from '@0xproject/contract-artifacts'; -import { - ExchangeCancelEventArgs, - ExchangeCancelUpToEventArgs, - ExchangeEventArgs, - ExchangeFillEventArgs, -} from '@0xproject/contract-wrappers'; -import { assetDataUtils } from '@0xproject/order-utils'; -import { AssetProxyId, ERC721AssetData } from '@0xproject/types'; -import { LogWithDecodedArgs } from 'ethereum-types'; -import * as R from 'ramda'; - -import { EventsResponse } from '../../data_sources/etherscan'; -import { ExchangeCancelEvent } from '../../entities/ExchangeCancelEvent'; -import { ExchangeCancelUpToEvent } from '../../entities/ExchangeCancelUpToEvent'; -import { ExchangeFillEvent } from '../../entities/ExchangeFillEvent'; -import { bigNumbertoStringOrNull } from '../../utils'; - -import { convertResponseToLogEntry, decodeLogEntry } from './event_utils'; - -export type ExchangeEventEntity = ExchangeFillEvent | ExchangeCancelEvent | ExchangeCancelUpToEvent; - -export function parseExchangeEvents(rawEventsResponse: EventsResponse): ExchangeEventEntity[] { - const logEntries = R.map(convertResponseToLogEntry, rawEventsResponse.result); - const decodedLogEntries = R.map( - eventResponse => decodeLogEntry(Exchange.compilerOutput.abi, eventResponse), - logEntries, - ); - const filteredLogEntries = R.filter(shouldIncludeLogEntry, decodedLogEntries); - return R.map(_convertToEntity, filteredLogEntries); -} - -export function shouldIncludeLogEntry(logEntry: LogWithDecodedArgs): boolean { - if (!R.contains(logEntry.event, ['Fill', 'Cancel', 'CancelUpTo'])) { - return false; - } else if (logEntry.logIndex == null || isNaN(logEntry.logIndex)) { - return false; - } - return true; -} - -export function _convertToEntity(eventLog: LogWithDecodedArgs): ExchangeEventEntity { - switch (eventLog.event) { - case 'Fill': - return _convertToExchangeFillEvent(eventLog as LogWithDecodedArgs); - case 'Cancel': - return _convertToExchangeCancelEvent(eventLog as LogWithDecodedArgs); - case 'CancelUpTo': - return _convertToExchangeCancelUpToEvent(eventLog as LogWithDecodedArgs); - default: - throw new Error('unexpected eventLog.event type: ' + eventLog.event); - } -} - -export function _convertToExchangeFillEvent(eventLog: LogWithDecodedArgs): ExchangeFillEvent { - const makerAssetData = assetDataUtils.decodeAssetDataOrThrow(eventLog.args.makerAssetData); - const makerAssetType = makerAssetData.assetProxyId === AssetProxyId.ERC20 ? 'erc20' : 'erc721'; - const takerAssetData = assetDataUtils.decodeAssetDataOrThrow(eventLog.args.takerAssetData); - const takerAssetType = takerAssetData.assetProxyId === AssetProxyId.ERC20 ? 'erc20' : 'erc721'; - const exchangeFillEvent = new ExchangeFillEvent(); - exchangeFillEvent.contractAddress = eventLog.address as string; - exchangeFillEvent.blockNumber = eventLog.blockNumber as number; - exchangeFillEvent.logIndex = eventLog.logIndex as number; - exchangeFillEvent.rawData = eventLog.data as string; - exchangeFillEvent.makerAddress = eventLog.args.makerAddress.toString(); - exchangeFillEvent.takerAddress = eventLog.args.takerAddress.toString(); - exchangeFillEvent.feeRecepientAddress = eventLog.args.feeRecipientAddress; - exchangeFillEvent.senderAddress = eventLog.args.senderAddress; - exchangeFillEvent.makerAssetFilledAmount = eventLog.args.makerAssetFilledAmount.toString(); - exchangeFillEvent.takerAssetFilledAmount = eventLog.args.takerAssetFilledAmount.toString(); - exchangeFillEvent.makerFeePaid = eventLog.args.makerFeePaid.toString(); - exchangeFillEvent.takerFeePaid = eventLog.args.takerFeePaid.toString(); - exchangeFillEvent.orderHash = eventLog.args.orderHash; - exchangeFillEvent.rawMakerAssetData = eventLog.args.makerAssetData; - exchangeFillEvent.makerAssetType = makerAssetType; - exchangeFillEvent.makerAssetProxyId = makerAssetData.assetProxyId; - exchangeFillEvent.makerTokenAddress = makerAssetData.tokenAddress; - exchangeFillEvent.makerTokenId = bigNumbertoStringOrNull((makerAssetData as ERC721AssetData).tokenId); - exchangeFillEvent.rawTakerAssetData = eventLog.args.takerAssetData; - exchangeFillEvent.takerAssetType = takerAssetType; - exchangeFillEvent.takerAssetProxyId = takerAssetData.assetProxyId; - exchangeFillEvent.takerTokenAddress = takerAssetData.tokenAddress; - exchangeFillEvent.takerTokenId = bigNumbertoStringOrNull((takerAssetData as ERC721AssetData).tokenId); - return exchangeFillEvent; -} - -export function _convertToExchangeCancelEvent( - eventLog: LogWithDecodedArgs, -): ExchangeCancelEvent { - const makerAssetData = assetDataUtils.decodeAssetDataOrThrow(eventLog.args.makerAssetData); - const makerAssetType = makerAssetData.assetProxyId === AssetProxyId.ERC20 ? 'erc20' : 'erc721'; - const takerAssetData = assetDataUtils.decodeAssetDataOrThrow(eventLog.args.takerAssetData); - const takerAssetType = takerAssetData.assetProxyId === AssetProxyId.ERC20 ? 'erc20' : 'erc721'; - const exchangeCancelEvent = new ExchangeCancelEvent(); - exchangeCancelEvent.contractAddress = eventLog.address as string; - exchangeCancelEvent.blockNumber = eventLog.blockNumber as number; - exchangeCancelEvent.logIndex = eventLog.logIndex as number; - exchangeCancelEvent.rawData = eventLog.data as string; - exchangeCancelEvent.makerAddress = eventLog.args.makerAddress.toString(); - exchangeCancelEvent.takerAddress = - eventLog.args.takerAddress == null ? null : eventLog.args.takerAddress.toString(); - exchangeCancelEvent.feeRecepientAddress = eventLog.args.feeRecipientAddress; - exchangeCancelEvent.senderAddress = eventLog.args.senderAddress; - exchangeCancelEvent.orderHash = eventLog.args.orderHash; - exchangeCancelEvent.rawMakerAssetData = eventLog.args.makerAssetData; - exchangeCancelEvent.makerAssetType = makerAssetType; - exchangeCancelEvent.makerAssetProxyId = makerAssetData.assetProxyId; - exchangeCancelEvent.makerTokenAddress = makerAssetData.tokenAddress; - exchangeCancelEvent.makerTokenId = bigNumbertoStringOrNull((makerAssetData as ERC721AssetData).tokenId); - exchangeCancelEvent.rawTakerAssetData = eventLog.args.takerAssetData; - exchangeCancelEvent.takerAssetType = takerAssetType; - exchangeCancelEvent.takerAssetProxyId = takerAssetData.assetProxyId; - exchangeCancelEvent.takerTokenAddress = takerAssetData.tokenAddress; - exchangeCancelEvent.takerTokenId = bigNumbertoStringOrNull((takerAssetData as ERC721AssetData).tokenId); - return exchangeCancelEvent; -} - -export function _convertToExchangeCancelUpToEvent( - eventLog: LogWithDecodedArgs, -): ExchangeCancelUpToEvent { - const exchangeCancelUpToEvent = new ExchangeCancelUpToEvent(); - exchangeCancelUpToEvent.contractAddress = eventLog.address as string; - exchangeCancelUpToEvent.blockNumber = eventLog.blockNumber as number; - exchangeCancelUpToEvent.logIndex = eventLog.logIndex as number; - exchangeCancelUpToEvent.rawData = eventLog.data as string; - exchangeCancelUpToEvent.makerAddress = eventLog.args.makerAddress.toString(); - exchangeCancelUpToEvent.senderAddress = eventLog.args.senderAddress.toString(); - exchangeCancelUpToEvent.orderEpoch = eventLog.args.orderEpoch.toString(); - return exchangeCancelUpToEvent; -} diff --git a/packages/pipeline/src/data_types/sra_orders/index.ts b/packages/pipeline/src/data_types/sra_orders/index.ts deleted file mode 100644 index fb2b74dfe..000000000 --- a/packages/pipeline/src/data_types/sra_orders/index.ts +++ /dev/null @@ -1,54 +0,0 @@ -import { APIOrder, OrdersResponse } from '@0xproject/connect'; -import { assetDataUtils, orderHashUtils } from '@0xproject/order-utils'; -import { AssetProxyId, ERC721AssetData } from '@0xproject/types'; -import * as R from 'ramda'; - -import { SraOrder } from '../../entities/SraOrder'; -import { bigNumbertoStringOrNull } from '../../utils'; - -export function parseSraOrders(rawOrdersResponse: OrdersResponse): SraOrder[] { - return R.map(_convertToEntity, rawOrdersResponse.records); -} - -export function _convertToEntity(apiOrder: APIOrder): SraOrder { - // TODO(albrow): refactor out common asset data decoding code. - const makerAssetData = assetDataUtils.decodeAssetDataOrThrow(apiOrder.order.makerAssetData); - const makerAssetType = makerAssetData.assetProxyId === AssetProxyId.ERC20 ? 'erc20' : 'erc721'; - const takerAssetData = assetDataUtils.decodeAssetDataOrThrow(apiOrder.order.takerAssetData); - const takerAssetType = takerAssetData.assetProxyId === AssetProxyId.ERC20 ? 'erc20' : 'erc721'; - - const sraOrder = new SraOrder(); - sraOrder.exchangeAddress = apiOrder.order.exchangeAddress; - sraOrder.orderHashHex = orderHashUtils.getOrderHashHex(apiOrder.order); - - // TODO(albrow): Set these fields to the correct values upstack. - sraOrder.lastUpdatedTimestamp = 0; - sraOrder.firstSeenTimestamp = 0; - - sraOrder.makerAddress = apiOrder.order.makerAddress; - sraOrder.takerAddress = apiOrder.order.takerAddress; - sraOrder.feeRecipientAddress = apiOrder.order.feeRecipientAddress; - sraOrder.senderAddress = apiOrder.order.senderAddress; - sraOrder.makerAssetAmount = apiOrder.order.makerAssetAmount.toString(); - sraOrder.takerAssetAmount = apiOrder.order.takerAssetAmount.toString(); - sraOrder.makerFee = apiOrder.order.makerFee.toString(); - sraOrder.takerFee = apiOrder.order.takerFee.toString(); - sraOrder.expirationTimeSeconds = apiOrder.order.expirationTimeSeconds.toString(); - sraOrder.salt = apiOrder.order.salt.toString(); - sraOrder.signature = apiOrder.order.signature; - - sraOrder.rawMakerAssetData = apiOrder.order.makerAssetData; - sraOrder.makerAssetType = makerAssetType; - sraOrder.makerAssetProxyId = makerAssetData.assetProxyId; - sraOrder.makerTokenAddress = makerAssetData.tokenAddress; - sraOrder.makerTokenId = bigNumbertoStringOrNull((makerAssetData as ERC721AssetData).tokenId); - sraOrder.rawTakerAssetData = apiOrder.order.takerAssetData; - sraOrder.takerAssetType = takerAssetType; - sraOrder.takerAssetProxyId = takerAssetData.assetProxyId; - sraOrder.takerTokenAddress = takerAssetData.tokenAddress; - sraOrder.takerTokenId = bigNumbertoStringOrNull((takerAssetData as ERC721AssetData).tokenId); - - sraOrder.metaDataJson = JSON.stringify(apiOrder.metaData); - - return sraOrder; -} diff --git a/packages/pipeline/src/index.ts b/packages/pipeline/src/index.ts index a1dbb35ff..77c92cc34 100644 --- a/packages/pipeline/src/index.ts +++ b/packages/pipeline/src/index.ts @@ -1,52 +1,43 @@ import { HttpClient } from '@0xproject/connect'; +import { web3Factory } from '@0xproject/dev-utils'; import 'reflect-metadata'; import { Connection, createConnection } from 'typeorm'; -import { Etherscan } from './data_sources/etherscan'; -import { parseExchangeEvents } from './data_types/events/exchange_events'; -import { parseSraOrders } from './data_types/sra_orders'; -import { ExchangeCancelEvent } from './entities/ExchangeCancelEvent'; -import { ExchangeCancelUpToEvent } from './entities/ExchangeCancelUpToEvent'; -import { ExchangeFillEvent } from './entities/ExchangeFillEvent'; +import { ExchangeEventsSource } from './data_sources/contract-wrappers/exchange_events'; import { SraOrder } from './entities/SraOrder'; import { config } from './ormconfig'; - -const etherscan = new Etherscan(process.env.ETHERSCAN_API_KEY as string); -const EXCHANGE_ADDRESS = '0x4f833a24e1f95d70f028921e27040ca56e09ab0b'; +import { parseExchangeEvents } from './parsers/events'; +import { parseSraOrders } from './parsers/sra_orders'; let connection: Connection; (async () => { connection = await createConnection(config); await getExchangeEventsAsync(); - await getSraOrdersAsync(); + // await getSraOrdersAsync(); })(); +// TODO(albrow): Separately: Errors do not appear to be handled correctly. If you use the +// wrong rpcUrl it just returns early with no error. async function getExchangeEventsAsync(): Promise { - const fillRepository = connection.getRepository(ExchangeFillEvent); - const cancelRepository = connection.getRepository(ExchangeCancelEvent); - const cancelUpToRepository = connection.getRepository(ExchangeCancelUpToEvent); - console.log( - `found ${(await fillRepository.count()) + - (await cancelRepository.count()) + - (await cancelUpToRepository.count())} existing events`, - ); - const rawEvents = await etherscan.getContractEventsAsync(EXCHANGE_ADDRESS); - const events = parseExchangeEvents(rawEvents); + const provider = web3Factory.getRpcProvider({ + rpcUrl: 'https://mainnet.infura.io', + }); + const exchangeEvents = new ExchangeEventsSource(provider, 1); + const eventLogs = await exchangeEvents.getFillEventsAsync(); + const events = parseExchangeEvents(eventLogs); + console.log('Got events: ' + events.length); for (const event of events) { await event.save(); } - console.log( - `now there are ${(await fillRepository.count()) + - (await cancelRepository.count()) + - (await cancelUpToRepository.count())} total events`, - ); + console.log('Saved events.'); + console.log('Exiting process'); + process.exit(0); } async function getSraOrdersAsync(): Promise { const orderRepository = connection.getRepository(SraOrder); console.log(`found ${await orderRepository.count()} existing orders`); - const sraUrl = 'https://api.radarrelay.com/0x/v2'; const connect = new HttpClient(sraUrl); const rawOrders = await connect.getOrdersAsync(); diff --git a/packages/pipeline/src/parsers/events/index.ts b/packages/pipeline/src/parsers/events/index.ts new file mode 100644 index 000000000..66f382dda --- /dev/null +++ b/packages/pipeline/src/parsers/events/index.ts @@ -0,0 +1,111 @@ +import { + ExchangeCancelEventArgs, + ExchangeCancelUpToEventArgs, + ExchangeEventArgs, + ExchangeFillEventArgs, +} from '@0xproject/contract-wrappers'; +import { assetDataUtils } from '@0xproject/order-utils'; +import { AssetProxyId, ERC721AssetData } from '@0xproject/types'; +import { LogWithDecodedArgs } from 'ethereum-types'; +import * as R from 'ramda'; + +import { ExchangeCancelEvent } from '../../entities/ExchangeCancelEvent'; +import { ExchangeCancelUpToEvent } from '../../entities/ExchangeCancelUpToEvent'; +import { ExchangeFillEvent } from '../../entities/ExchangeFillEvent'; +import { bigNumbertoStringOrNull } from '../../utils'; + +export type ExchangeEventEntity = ExchangeFillEvent | ExchangeCancelEvent | ExchangeCancelUpToEvent; + +export const parseExchangeEvents: ( + eventLogs: Array>, +) => ExchangeEventEntity[] = R.map(_convertToEntity); + +export function _convertToEntity(eventLog: LogWithDecodedArgs): ExchangeEventEntity { + switch (eventLog.event) { + case 'Fill': + return _convertToExchangeFillEvent(eventLog as LogWithDecodedArgs); + case 'Cancel': + return _convertToExchangeCancelEvent(eventLog as LogWithDecodedArgs); + case 'CancelUpTo': + return _convertToExchangeCancelUpToEvent(eventLog as LogWithDecodedArgs); + default: + throw new Error('unexpected eventLog.event type: ' + eventLog.event); + } +} + +export function _convertToExchangeFillEvent(eventLog: LogWithDecodedArgs): ExchangeFillEvent { + const makerAssetData = assetDataUtils.decodeAssetDataOrThrow(eventLog.args.makerAssetData); + const makerAssetType = makerAssetData.assetProxyId === AssetProxyId.ERC20 ? 'erc20' : 'erc721'; + const takerAssetData = assetDataUtils.decodeAssetDataOrThrow(eventLog.args.takerAssetData); + const takerAssetType = takerAssetData.assetProxyId === AssetProxyId.ERC20 ? 'erc20' : 'erc721'; + const exchangeFillEvent = new ExchangeFillEvent(); + exchangeFillEvent.contractAddress = eventLog.address as string; + exchangeFillEvent.blockNumber = eventLog.blockNumber as number; + exchangeFillEvent.logIndex = eventLog.logIndex as number; + exchangeFillEvent.rawData = eventLog.data as string; + exchangeFillEvent.makerAddress = eventLog.args.makerAddress.toString(); + exchangeFillEvent.takerAddress = eventLog.args.takerAddress.toString(); + exchangeFillEvent.feeRecepientAddress = eventLog.args.feeRecipientAddress; + exchangeFillEvent.senderAddress = eventLog.args.senderAddress; + exchangeFillEvent.makerAssetFilledAmount = eventLog.args.makerAssetFilledAmount.toString(); + exchangeFillEvent.takerAssetFilledAmount = eventLog.args.takerAssetFilledAmount.toString(); + exchangeFillEvent.makerFeePaid = eventLog.args.makerFeePaid.toString(); + exchangeFillEvent.takerFeePaid = eventLog.args.takerFeePaid.toString(); + exchangeFillEvent.orderHash = eventLog.args.orderHash; + exchangeFillEvent.rawMakerAssetData = eventLog.args.makerAssetData; + exchangeFillEvent.makerAssetType = makerAssetType; + exchangeFillEvent.makerAssetProxyId = makerAssetData.assetProxyId; + exchangeFillEvent.makerTokenAddress = makerAssetData.tokenAddress; + exchangeFillEvent.makerTokenId = bigNumbertoStringOrNull((makerAssetData as ERC721AssetData).tokenId); + exchangeFillEvent.rawTakerAssetData = eventLog.args.takerAssetData; + exchangeFillEvent.takerAssetType = takerAssetType; + exchangeFillEvent.takerAssetProxyId = takerAssetData.assetProxyId; + exchangeFillEvent.takerTokenAddress = takerAssetData.tokenAddress; + exchangeFillEvent.takerTokenId = bigNumbertoStringOrNull((takerAssetData as ERC721AssetData).tokenId); + return exchangeFillEvent; +} + +export function _convertToExchangeCancelEvent( + eventLog: LogWithDecodedArgs, +): ExchangeCancelEvent { + const makerAssetData = assetDataUtils.decodeAssetDataOrThrow(eventLog.args.makerAssetData); + const makerAssetType = makerAssetData.assetProxyId === AssetProxyId.ERC20 ? 'erc20' : 'erc721'; + const takerAssetData = assetDataUtils.decodeAssetDataOrThrow(eventLog.args.takerAssetData); + const takerAssetType = takerAssetData.assetProxyId === AssetProxyId.ERC20 ? 'erc20' : 'erc721'; + const exchangeCancelEvent = new ExchangeCancelEvent(); + exchangeCancelEvent.contractAddress = eventLog.address as string; + exchangeCancelEvent.blockNumber = eventLog.blockNumber as number; + exchangeCancelEvent.logIndex = eventLog.logIndex as number; + exchangeCancelEvent.rawData = eventLog.data as string; + exchangeCancelEvent.makerAddress = eventLog.args.makerAddress.toString(); + exchangeCancelEvent.takerAddress = + eventLog.args.takerAddress == null ? null : eventLog.args.takerAddress.toString(); + exchangeCancelEvent.feeRecepientAddress = eventLog.args.feeRecipientAddress; + exchangeCancelEvent.senderAddress = eventLog.args.senderAddress; + exchangeCancelEvent.orderHash = eventLog.args.orderHash; + exchangeCancelEvent.rawMakerAssetData = eventLog.args.makerAssetData; + exchangeCancelEvent.makerAssetType = makerAssetType; + exchangeCancelEvent.makerAssetProxyId = makerAssetData.assetProxyId; + exchangeCancelEvent.makerTokenAddress = makerAssetData.tokenAddress; + exchangeCancelEvent.makerTokenId = bigNumbertoStringOrNull((makerAssetData as ERC721AssetData).tokenId); + exchangeCancelEvent.rawTakerAssetData = eventLog.args.takerAssetData; + exchangeCancelEvent.takerAssetType = takerAssetType; + exchangeCancelEvent.takerAssetProxyId = takerAssetData.assetProxyId; + exchangeCancelEvent.takerTokenAddress = takerAssetData.tokenAddress; + exchangeCancelEvent.takerTokenId = bigNumbertoStringOrNull((takerAssetData as ERC721AssetData).tokenId); + return exchangeCancelEvent; +} + +export function _convertToExchangeCancelUpToEvent( + eventLog: LogWithDecodedArgs, +): ExchangeCancelUpToEvent { + const exchangeCancelUpToEvent = new ExchangeCancelUpToEvent(); + exchangeCancelUpToEvent.contractAddress = eventLog.address as string; + exchangeCancelUpToEvent.blockNumber = eventLog.blockNumber as number; + exchangeCancelUpToEvent.logIndex = eventLog.logIndex as number; + exchangeCancelUpToEvent.rawData = eventLog.data as string; + exchangeCancelUpToEvent.makerAddress = eventLog.args.makerAddress.toString(); + exchangeCancelUpToEvent.senderAddress = eventLog.args.senderAddress.toString(); + exchangeCancelUpToEvent.orderEpoch = eventLog.args.orderEpoch.toString(); + return exchangeCancelUpToEvent; +} diff --git a/packages/pipeline/src/parsers/sra_orders/index.ts b/packages/pipeline/src/parsers/sra_orders/index.ts new file mode 100644 index 000000000..fb2b74dfe --- /dev/null +++ b/packages/pipeline/src/parsers/sra_orders/index.ts @@ -0,0 +1,54 @@ +import { APIOrder, OrdersResponse } from '@0xproject/connect'; +import { assetDataUtils, orderHashUtils } from '@0xproject/order-utils'; +import { AssetProxyId, ERC721AssetData } from '@0xproject/types'; +import * as R from 'ramda'; + +import { SraOrder } from '../../entities/SraOrder'; +import { bigNumbertoStringOrNull } from '../../utils'; + +export function parseSraOrders(rawOrdersResponse: OrdersResponse): SraOrder[] { + return R.map(_convertToEntity, rawOrdersResponse.records); +} + +export function _convertToEntity(apiOrder: APIOrder): SraOrder { + // TODO(albrow): refactor out common asset data decoding code. + const makerAssetData = assetDataUtils.decodeAssetDataOrThrow(apiOrder.order.makerAssetData); + const makerAssetType = makerAssetData.assetProxyId === AssetProxyId.ERC20 ? 'erc20' : 'erc721'; + const takerAssetData = assetDataUtils.decodeAssetDataOrThrow(apiOrder.order.takerAssetData); + const takerAssetType = takerAssetData.assetProxyId === AssetProxyId.ERC20 ? 'erc20' : 'erc721'; + + const sraOrder = new SraOrder(); + sraOrder.exchangeAddress = apiOrder.order.exchangeAddress; + sraOrder.orderHashHex = orderHashUtils.getOrderHashHex(apiOrder.order); + + // TODO(albrow): Set these fields to the correct values upstack. + sraOrder.lastUpdatedTimestamp = 0; + sraOrder.firstSeenTimestamp = 0; + + sraOrder.makerAddress = apiOrder.order.makerAddress; + sraOrder.takerAddress = apiOrder.order.takerAddress; + sraOrder.feeRecipientAddress = apiOrder.order.feeRecipientAddress; + sraOrder.senderAddress = apiOrder.order.senderAddress; + sraOrder.makerAssetAmount = apiOrder.order.makerAssetAmount.toString(); + sraOrder.takerAssetAmount = apiOrder.order.takerAssetAmount.toString(); + sraOrder.makerFee = apiOrder.order.makerFee.toString(); + sraOrder.takerFee = apiOrder.order.takerFee.toString(); + sraOrder.expirationTimeSeconds = apiOrder.order.expirationTimeSeconds.toString(); + sraOrder.salt = apiOrder.order.salt.toString(); + sraOrder.signature = apiOrder.order.signature; + + sraOrder.rawMakerAssetData = apiOrder.order.makerAssetData; + sraOrder.makerAssetType = makerAssetType; + sraOrder.makerAssetProxyId = makerAssetData.assetProxyId; + sraOrder.makerTokenAddress = makerAssetData.tokenAddress; + sraOrder.makerTokenId = bigNumbertoStringOrNull((makerAssetData as ERC721AssetData).tokenId); + sraOrder.rawTakerAssetData = apiOrder.order.takerAssetData; + sraOrder.takerAssetType = takerAssetType; + sraOrder.takerAssetProxyId = takerAssetData.assetProxyId; + sraOrder.takerTokenAddress = takerAssetData.tokenAddress; + sraOrder.takerTokenId = bigNumbertoStringOrNull((takerAssetData as ERC721AssetData).tokenId); + + sraOrder.metaDataJson = JSON.stringify(apiOrder.metaData); + + return sraOrder; +} diff --git a/packages/pipeline/test/data_types/events/event_utils_test.ts b/packages/pipeline/test/data_types/events/event_utils_test.ts deleted file mode 100644 index 731819106..000000000 --- a/packages/pipeline/test/data_types/events/event_utils_test.ts +++ /dev/null @@ -1,86 +0,0 @@ -import { Exchange } from '@0xproject/contract-artifacts'; -import { BigNumber } from '@0xproject/utils'; -import * as chai from 'chai'; -import { DecodedLogArgs, LogEntry, LogWithDecodedArgs } from 'ethereum-types'; -import 'mocha'; - -import { EventsResponseResult } from '../../../src/data_sources/etherscan'; -import { convertResponseToLogEntry, decodeLogEntry } from '../../../src/data_types/events/event_utils'; -import { chaiSetup } from '../../utils/chai_setup'; - -chaiSetup.configure(); -const expect = chai.expect; - -describe('event_utils', () => { - describe('convertResponseToLogEntry', () => { - it('converts EventsResponseResult to LogEntry', () => { - const input: EventsResponseResult = { - address: '0x4f833a24e1f95d70f028921e27040ca56e09ab0b', - topics: [ - '0x82af639571738f4ebd4268fb0363d8957ebe1bbb9e78dba5ebd69eed39b154f0', - '0x00000000000000000000000067032ef7be8fa07c4335d0134099db0f3875e930', - '0x0000000000000000000000000000000000000000000000000000000000000000', - ], - data: '0x00000000000000000000000000000000000000000000000000000165f2d3f94d', - blockNumber: '0x61127b', - timeStamp: '0x5ba2878e', - gasPrice: '0x1a13b8600', - gasUsed: '0xd9dc', - logIndex: '0x63', - transactionHash: '0xa3f71931ddab6e758b9d1755b2715b376759f49f23fff60755f7e073367d61b5', - transactionIndex: '0x35', - }; - const expected: LogEntry = { - logIndex: 99, - transactionIndex: 53, - transactionHash: input.transactionHash, - blockHash: '', - blockNumber: 6361723, - address: input.address, - data: input.data, - topics: input.topics, - }; - const actual = convertResponseToLogEntry(input); - expect(actual).deep.equal(expected); - }); - }); - describe('decodeLogEntry', () => { - it('decodes LogEntry into LogWithDecodedArgs', () => { - const input: LogEntry = { - logIndex: 96, - transactionIndex: 52, - transactionHash: '0x02b59043e9b38b430c8c66abe67ab4a9e5509def8f8552b54231e88db1839831', - blockHash: '', - blockNumber: 6361723, - address: '0x4f833a24e1f95d70f028921e27040ca56e09ab0b', - data: - '0x00000000000000000000000067032ef7be8fa07c4335d0134099db0f3875e93000000000000000000000000067032ef7be8fa07c4335d0134099db0f3875e930000000000000000000000000000000000000000000000000000000174876e8000000000000000000000000000000000000000000000000000000000013ab668000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001600000000000000000000000000000000000000000000000000000000000000024f47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024f47261b0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000000', - topics: [ - '0x0bcc4c97732e47d9946f229edb95f5b6323f601300e4690de719993f3c371129', - '0x0000000000000000000000003f7f832abb3be28442c0e48b7222e02b322c78f3', - '0x000000000000000000000000a258b39954cef5cb142fd567a46cddb31a670124', - '0x523404b4e6f847d9aefcf5be024be396449b4635590291fd7a28a8c940843858', - ], - }; - const expected: LogWithDecodedArgs = { - ...input, - event: 'Fill', - args: { - makerAddress: '0x3f7f832abb3be28442c0e48b7222e02b322c78f3', - feeRecipientAddress: '0xa258b39954cef5cb142fd567a46cddb31a670124', - takerAddress: '0x67032ef7be8fa07c4335d0134099db0f3875e930', - senderAddress: '0x67032ef7be8fa07c4335d0134099db0f3875e930', - makerAssetFilledAmount: new BigNumber('100000000000'), - takerAssetFilledAmount: new BigNumber('330000000'), - makerFeePaid: new BigNumber('0'), - takerFeePaid: new BigNumber('0'), - orderHash: '0x523404b4e6f847d9aefcf5be024be396449b4635590291fd7a28a8c940843858', - makerAssetData: '0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498', - takerAssetData: '0xf47261b0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', - }, - }; - const actual = decodeLogEntry(Exchange.compilerOutput.abi, input); - expect(actual).deep.equal(expected); - }); - }); -}); diff --git a/packages/pipeline/test/data_types/events/exchange_events_test.ts b/packages/pipeline/test/data_types/events/exchange_events_test.ts deleted file mode 100644 index f1432892d..000000000 --- a/packages/pipeline/test/data_types/events/exchange_events_test.ts +++ /dev/null @@ -1,77 +0,0 @@ -import { ExchangeFillEventArgs } from '@0xproject/contract-wrappers'; -import { BigNumber } from '@0xproject/utils'; -import * as chai from 'chai'; -import { LogWithDecodedArgs } from 'ethereum-types'; -import 'mocha'; - -import { _convertToEntity } from '../../../src/data_types/events/exchange_events'; -import { ExchangeFillEvent } from '../../../src/entities/ExchangeFillEvent'; -import { chaiSetup } from '../../utils/chai_setup'; - -chaiSetup.configure(); -const expect = chai.expect; - -// tslint:disable:custom-no-magic-numbers -describe('exchange_events', () => { - describe('_convertToEntity', () => { - it('converts LogWithDecodedArgs to ExchangeFillEvent entity', () => { - const input: LogWithDecodedArgs = { - logIndex: 102, - transactionIndex: 38, - transactionHash: '0x6dd106d002873746072fc5e496dd0fb2541b68c77bcf9184ae19a42fd33657fe', - blockHash: '', - blockNumber: 6276262, - address: '0x4f833a24e1f95d70f028921e27040ca56e09ab0b', - data: - '0x000000000000000000000000f6da68519f78b0d0bc93c701e86affcb75c92428000000000000000000000000f6da68519f78b0d0bc93c701e86affcb75c92428000000000000000000000000000000000000000000000000002386f26fc10000000000000000000000000000000000000000000000000000016345785d8a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001600000000000000000000000000000000000000000000000000000000000000024f47261b0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024f47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f49800000000000000000000000000000000000000000000000000000000', - topics: [ - '0x0bcc4c97732e47d9946f229edb95f5b6323f601300e4690de719993f3c371129', - '0x000000000000000000000000f6da68519f78b0d0bc93c701e86affcb75c92428', - '0x000000000000000000000000c370d2a5920344aa6b7d8d11250e3e861434cbdd', - '0xab12ed2cbaa5615ab690b9da75a46e53ddfcf3f1a68655b5fe0d94c75a1aac4a', - ], - event: 'Fill', - args: { - makerAddress: '0xf6da68519f78b0d0bc93c701e86affcb75c92428', - feeRecipientAddress: '0xc370d2a5920344aa6b7d8d11250e3e861434cbdd', - takerAddress: '0xf6da68519f78b0d0bc93c701e86affcb75c92428', - senderAddress: '0xf6da68519f78b0d0bc93c701e86affcb75c92428', - makerAssetFilledAmount: new BigNumber('10000000000000000'), - takerAssetFilledAmount: new BigNumber('100000000000000000'), - makerFeePaid: new BigNumber('0'), - takerFeePaid: new BigNumber('0'), - orderHash: '0xab12ed2cbaa5615ab690b9da75a46e53ddfcf3f1a68655b5fe0d94c75a1aac4a', - makerAssetData: '0xf47261b0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', - takerAssetData: '0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498', - }, - }; - const expected = new ExchangeFillEvent(); - expected.contractAddress = '0x4f833a24e1f95d70f028921e27040ca56e09ab0b'; - expected.blockNumber = 6276262; - expected.logIndex = 102; - expected.rawData = - '0x000000000000000000000000f6da68519f78b0d0bc93c701e86affcb75c92428000000000000000000000000f6da68519f78b0d0bc93c701e86affcb75c92428000000000000000000000000000000000000000000000000002386f26fc10000000000000000000000000000000000000000000000000000016345785d8a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001600000000000000000000000000000000000000000000000000000000000000024f47261b0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024f47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f49800000000000000000000000000000000000000000000000000000000'; - expected.makerAddress = '0xf6da68519f78b0d0bc93c701e86affcb75c92428'; - expected.takerAddress = '0xf6da68519f78b0d0bc93c701e86affcb75c92428'; - expected.feeRecepientAddress = '0xc370d2a5920344aa6b7d8d11250e3e861434cbdd'; - expected.senderAddress = '0xf6da68519f78b0d0bc93c701e86affcb75c92428'; - expected.makerAssetFilledAmount = '10000000000000000'; - expected.takerAssetFilledAmount = '100000000000000000'; - expected.makerFeePaid = '0'; - expected.takerFeePaid = '0'; - expected.orderHash = '0xab12ed2cbaa5615ab690b9da75a46e53ddfcf3f1a68655b5fe0d94c75a1aac4a'; - expected.rawMakerAssetData = '0xf47261b0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'; - expected.makerAssetType = 'erc20'; - expected.makerAssetProxyId = '0xf47261b0'; - expected.makerTokenAddress = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'; - expected.makerTokenId = null; - expected.rawTakerAssetData = '0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498'; - expected.takerAssetType = 'erc20'; - expected.takerAssetProxyId = '0xf47261b0'; - expected.takerTokenAddress = '0xe41d2489571d322189246dafa5ebde1f4699f498'; - expected.takerTokenId = null; - const actual = _convertToEntity(input); - expect(actual).deep.equal(expected); - }); - }); -}); diff --git a/packages/pipeline/test/data_types/sra_orders/index_test.ts b/packages/pipeline/test/data_types/sra_orders/index_test.ts deleted file mode 100644 index 174f89b4f..000000000 --- a/packages/pipeline/test/data_types/sra_orders/index_test.ts +++ /dev/null @@ -1,79 +0,0 @@ -import { APIOrder } from '@0xproject/types'; -import { BigNumber } from '@0xproject/utils'; -import * as chai from 'chai'; -import 'mocha'; -import { Connection, createConnection } from 'typeorm'; - -import { _convertToEntity } from '../../../src/data_types/sra_orders'; -import { SraOrder } from '../../../src/entities/SraOrder'; -import { chaiSetup } from '../../utils/chai_setup'; - -import { config } from '../../../src/ormconfig'; - -chaiSetup.configure(); -const expect = chai.expect; - -// tslint:disable:custom-no-magic-numbers -describe('sra_orders', () => { - describe('_convertToEntity', () => { - before(async () => { - // HACK(albrow): We don't actually use this connection but it seems - // to be required because chai calls the inspect method of the - // entity and that method requires a "default" connection. - await createConnection(config); - }); - it('converts ApiOrder to SraOrder entity', () => { - const input: APIOrder = { - order: { - makerAddress: '0xb45df06e38540a675fdb5b598abf2c0dbe9d6b81', - takerAddress: '0x0000000000000000000000000000000000000000', - feeRecipientAddress: '0xa258b39954cef5cb142fd567a46cddb31a670124', - senderAddress: '0x0000000000000000000000000000000000000000', - makerAssetAmount: new BigNumber('1619310371000000000'), - takerAssetAmount: new BigNumber('8178335207070707070707'), - makerFee: new BigNumber('0'), - takerFee: new BigNumber('0'), - exchangeAddress: '0x4f833a24e1f95d70f028921e27040ca56e09ab0b', - expirationTimeSeconds: new BigNumber('1538529488'), - signature: - '0x1b5a5d672b0d647b5797387ccbb89d822d5d2e873346b014f4ff816ff0783f2a7a0d2824d2d7042ec8ea375bc7f870963e1cb8248f1db03ddf125e27b5963aa11f03', - salt: new BigNumber('1537924688891'), - makerAssetData: '0xf47261b0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', - takerAssetData: '0xf47261b000000000000000000000000042d6622dece394b54999fbd73d108123806f6a18', - }, - metaData: { isThisArbitraryData: true, powerLevel: 9001 }, - }; - const expected = new SraOrder(); - expected.exchangeAddress = '0x4f833a24e1f95d70f028921e27040ca56e09ab0b'; - expected.orderHashHex = '0x1bdbeb0d088a33da28b9ee6d94e8771452f90f4a69107da2fa75195d61b9a1c9'; - expected.lastUpdatedTimestamp = 0; - expected.firstSeenTimestamp = 0; - expected.makerAddress = '0xb45df06e38540a675fdb5b598abf2c0dbe9d6b81'; - expected.takerAddress = '0x0000000000000000000000000000000000000000'; - expected.feeRecipientAddress = '0xa258b39954cef5cb142fd567a46cddb31a670124'; - expected.senderAddress = '0x0000000000000000000000000000000000000000'; - expected.makerAssetAmount = '1619310371000000000'; - expected.takerAssetAmount = '8178335207070707070707'; - expected.makerFee = '0'; - expected.takerFee = '0'; - expected.expirationTimeSeconds = '1538529488'; - expected.salt = '1537924688891'; - expected.signature = - '0x1b5a5d672b0d647b5797387ccbb89d822d5d2e873346b014f4ff816ff0783f2a7a0d2824d2d7042ec8ea375bc7f870963e1cb8248f1db03ddf125e27b5963aa11f03'; - expected.rawMakerAssetData = '0xf47261b0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'; - expected.makerAssetType = 'erc20'; - expected.makerAssetProxyId = '0xf47261b0'; - expected.makerTokenAddress = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'; - expected.makerTokenId = null; - expected.rawTakerAssetData = '0xf47261b000000000000000000000000042d6622dece394b54999fbd73d108123806f6a18'; - expected.takerAssetType = 'erc20'; - expected.takerAssetProxyId = '0xf47261b0'; - expected.takerTokenAddress = '0x42d6622dece394b54999fbd73d108123806f6a18'; - expected.takerTokenId = null; - expected.metaDataJson = '{"isThisArbitraryData":true,"powerLevel":9001}'; - - const actual = _convertToEntity(input); - expect(actual).deep.equal(expected); - }); - }); -}); diff --git a/packages/pipeline/test/parsers/events/index_test.ts b/packages/pipeline/test/parsers/events/index_test.ts new file mode 100644 index 000000000..2a2db1a94 --- /dev/null +++ b/packages/pipeline/test/parsers/events/index_test.ts @@ -0,0 +1,77 @@ +import { ExchangeFillEventArgs } from '@0xproject/contract-wrappers'; +import { BigNumber } from '@0xproject/utils'; +import * as chai from 'chai'; +import { LogWithDecodedArgs } from 'ethereum-types'; +import 'mocha'; + +import { ExchangeFillEvent } from '../../../src/entities/ExchangeFillEvent'; +import { _convertToEntity } from '../../../src/parsers/events'; +import { chaiSetup } from '../../utils/chai_setup'; + +chaiSetup.configure(); +const expect = chai.expect; + +// tslint:disable:custom-no-magic-numbers +describe('exchange_events', () => { + describe('_convertToEntity', () => { + it('converts LogWithDecodedArgs to ExchangeFillEvent entity', () => { + const input: LogWithDecodedArgs = { + logIndex: 102, + transactionIndex: 38, + transactionHash: '0x6dd106d002873746072fc5e496dd0fb2541b68c77bcf9184ae19a42fd33657fe', + blockHash: '', + blockNumber: 6276262, + address: '0x4f833a24e1f95d70f028921e27040ca56e09ab0b', + data: + '0x000000000000000000000000f6da68519f78b0d0bc93c701e86affcb75c92428000000000000000000000000f6da68519f78b0d0bc93c701e86affcb75c92428000000000000000000000000000000000000000000000000002386f26fc10000000000000000000000000000000000000000000000000000016345785d8a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001600000000000000000000000000000000000000000000000000000000000000024f47261b0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024f47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f49800000000000000000000000000000000000000000000000000000000', + topics: [ + '0x0bcc4c97732e47d9946f229edb95f5b6323f601300e4690de719993f3c371129', + '0x000000000000000000000000f6da68519f78b0d0bc93c701e86affcb75c92428', + '0x000000000000000000000000c370d2a5920344aa6b7d8d11250e3e861434cbdd', + '0xab12ed2cbaa5615ab690b9da75a46e53ddfcf3f1a68655b5fe0d94c75a1aac4a', + ], + event: 'Fill', + args: { + makerAddress: '0xf6da68519f78b0d0bc93c701e86affcb75c92428', + feeRecipientAddress: '0xc370d2a5920344aa6b7d8d11250e3e861434cbdd', + takerAddress: '0xf6da68519f78b0d0bc93c701e86affcb75c92428', + senderAddress: '0xf6da68519f78b0d0bc93c701e86affcb75c92428', + makerAssetFilledAmount: new BigNumber('10000000000000000'), + takerAssetFilledAmount: new BigNumber('100000000000000000'), + makerFeePaid: new BigNumber('0'), + takerFeePaid: new BigNumber('0'), + orderHash: '0xab12ed2cbaa5615ab690b9da75a46e53ddfcf3f1a68655b5fe0d94c75a1aac4a', + makerAssetData: '0xf47261b0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', + takerAssetData: '0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498', + }, + }; + const expected = new ExchangeFillEvent(); + expected.contractAddress = '0x4f833a24e1f95d70f028921e27040ca56e09ab0b'; + expected.blockNumber = 6276262; + expected.logIndex = 102; + expected.rawData = + '0x000000000000000000000000f6da68519f78b0d0bc93c701e86affcb75c92428000000000000000000000000f6da68519f78b0d0bc93c701e86affcb75c92428000000000000000000000000000000000000000000000000002386f26fc10000000000000000000000000000000000000000000000000000016345785d8a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001600000000000000000000000000000000000000000000000000000000000000024f47261b0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024f47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f49800000000000000000000000000000000000000000000000000000000'; + expected.makerAddress = '0xf6da68519f78b0d0bc93c701e86affcb75c92428'; + expected.takerAddress = '0xf6da68519f78b0d0bc93c701e86affcb75c92428'; + expected.feeRecepientAddress = '0xc370d2a5920344aa6b7d8d11250e3e861434cbdd'; + expected.senderAddress = '0xf6da68519f78b0d0bc93c701e86affcb75c92428'; + expected.makerAssetFilledAmount = '10000000000000000'; + expected.takerAssetFilledAmount = '100000000000000000'; + expected.makerFeePaid = '0'; + expected.takerFeePaid = '0'; + expected.orderHash = '0xab12ed2cbaa5615ab690b9da75a46e53ddfcf3f1a68655b5fe0d94c75a1aac4a'; + expected.rawMakerAssetData = '0xf47261b0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'; + expected.makerAssetType = 'erc20'; + expected.makerAssetProxyId = '0xf47261b0'; + expected.makerTokenAddress = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'; + expected.makerTokenId = null; + expected.rawTakerAssetData = '0xf47261b0000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498'; + expected.takerAssetType = 'erc20'; + expected.takerAssetProxyId = '0xf47261b0'; + expected.takerTokenAddress = '0xe41d2489571d322189246dafa5ebde1f4699f498'; + expected.takerTokenId = null; + const actual = _convertToEntity(input); + expect(actual).deep.equal(expected); + }); + }); +}); diff --git a/packages/pipeline/test/parsers/sra_orders/index_test.ts b/packages/pipeline/test/parsers/sra_orders/index_test.ts new file mode 100644 index 000000000..952a6f3c6 --- /dev/null +++ b/packages/pipeline/test/parsers/sra_orders/index_test.ts @@ -0,0 +1,70 @@ +import { APIOrder } from '@0xproject/types'; +import { BigNumber } from '@0xproject/utils'; +import * as chai from 'chai'; +import 'mocha'; + +import { SraOrder } from '../../../src/entities/SraOrder'; +import { _convertToEntity } from '../../../src/parsers/sra_orders'; +import { chaiSetup } from '../../utils/chai_setup'; + +chaiSetup.configure(); +const expect = chai.expect; + +// tslint:disable:custom-no-magic-numbers +describe('sra_orders', () => { + describe('_convertToEntity', () => { + it('converts ApiOrder to SraOrder entity', () => { + const input: APIOrder = { + order: { + makerAddress: '0xb45df06e38540a675fdb5b598abf2c0dbe9d6b81', + takerAddress: '0x0000000000000000000000000000000000000000', + feeRecipientAddress: '0xa258b39954cef5cb142fd567a46cddb31a670124', + senderAddress: '0x0000000000000000000000000000000000000000', + makerAssetAmount: new BigNumber('1619310371000000000'), + takerAssetAmount: new BigNumber('8178335207070707070707'), + makerFee: new BigNumber('0'), + takerFee: new BigNumber('0'), + exchangeAddress: '0x4f833a24e1f95d70f028921e27040ca56e09ab0b', + expirationTimeSeconds: new BigNumber('1538529488'), + signature: + '0x1b5a5d672b0d647b5797387ccbb89d822d5d2e873346b014f4ff816ff0783f2a7a0d2824d2d7042ec8ea375bc7f870963e1cb8248f1db03ddf125e27b5963aa11f03', + salt: new BigNumber('1537924688891'), + makerAssetData: '0xf47261b0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', + takerAssetData: '0xf47261b000000000000000000000000042d6622dece394b54999fbd73d108123806f6a18', + }, + metaData: { isThisArbitraryData: true, powerLevel: 9001 }, + }; + const expected = new SraOrder(); + expected.exchangeAddress = '0x4f833a24e1f95d70f028921e27040ca56e09ab0b'; + expected.orderHashHex = '0x1bdbeb0d088a33da28b9ee6d94e8771452f90f4a69107da2fa75195d61b9a1c9'; + expected.lastUpdatedTimestamp = 0; + expected.firstSeenTimestamp = 0; + expected.makerAddress = '0xb45df06e38540a675fdb5b598abf2c0dbe9d6b81'; + expected.takerAddress = '0x0000000000000000000000000000000000000000'; + expected.feeRecipientAddress = '0xa258b39954cef5cb142fd567a46cddb31a670124'; + expected.senderAddress = '0x0000000000000000000000000000000000000000'; + expected.makerAssetAmount = '1619310371000000000'; + expected.takerAssetAmount = '8178335207070707070707'; + expected.makerFee = '0'; + expected.takerFee = '0'; + expected.expirationTimeSeconds = '1538529488'; + expected.salt = '1537924688891'; + expected.signature = + '0x1b5a5d672b0d647b5797387ccbb89d822d5d2e873346b014f4ff816ff0783f2a7a0d2824d2d7042ec8ea375bc7f870963e1cb8248f1db03ddf125e27b5963aa11f03'; + expected.rawMakerAssetData = '0xf47261b0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'; + expected.makerAssetType = 'erc20'; + expected.makerAssetProxyId = '0xf47261b0'; + expected.makerTokenAddress = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'; + expected.makerTokenId = null; + expected.rawTakerAssetData = '0xf47261b000000000000000000000000042d6622dece394b54999fbd73d108123806f6a18'; + expected.takerAssetType = 'erc20'; + expected.takerAssetProxyId = '0xf47261b0'; + expected.takerTokenAddress = '0x42d6622dece394b54999fbd73d108123806f6a18'; + expected.takerTokenId = null; + expected.metaDataJson = '{"isThisArbitraryData":true,"powerLevel":9001}'; + + const actual = _convertToEntity(input); + expect(actual).deep.equal(expected); + }); + }); +}); diff --git a/yarn.lock b/yarn.lock index 38318d0a7..c3546946c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -472,294 +472,67 @@ npmlog "^4.1.2" write-file-atomic "^2.3.0" -"@0xproject/assert@^0.2.14": - version "0.2.14" - resolved "https://registry.yarnpkg.com/@0xproject/assert/-/assert-0.2.14.tgz#7d5a373fedc8eb482716b730f4dddf3ef33bfa29" - dependencies: - "@0xproject/json-schemas" "^0.8.3" - "@0xproject/typescript-typings" "^0.4.3" - "@0xproject/utils" "^0.7.3" - lodash "4.17.10" - valid-url "1.0.9" - -"@0xproject/assert@^1.0.10", "@0xproject/assert@^1.0.11", "@0xproject/assert@^1.0.13": - version "1.0.13" - resolved "https://registry.yarnpkg.com/@0xproject/assert/-/assert-1.0.13.tgz#e370ccce08933dd2a970bdd02b92e59c65dd75d4" +"@0x/abi-gen-wrappers@^1.0.2": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@0x/abi-gen-wrappers/-/abi-gen-wrappers-1.1.0.tgz#d4e4f10699b5da6bcfadc3842f165fc59f686e09" dependencies: - "@0xproject/json-schemas" "^1.0.7" - "@0xproject/typescript-typings" "^3.0.2" - "@0xproject/utils" "^2.0.2" - lodash "^4.17.5" - valid-url "^1.0.9" + "@0x/base-contract" "^3.0.7" -"@0xproject/base-contract@^2.0.4": - version "2.0.5" - resolved "https://registry.yarnpkg.com/@0xproject/base-contract/-/base-contract-2.0.5.tgz#caca54b33efeb82c53142a96becc6871c96974d6" +"@0x/contract-addresses@^1.1.0": + version "1.2.0" + resolved "https://registry.yarnpkg.com/@0x/contract-addresses/-/contract-addresses-1.2.0.tgz#aa5001d73adb1ec9cc58ab4f6e0cac0acc4ad0a8" dependencies: - "@0xproject/typescript-typings" "^2.0.2" - "@0xproject/utils" "^1.0.11" - "@0xproject/web3-wrapper" "^3.0.1" - ethereum-types "^1.0.8" - ethers "3.0.22" lodash "^4.17.5" -"@0xproject/base-contract@^3.0.1": +"@0x/contract-wrappers@^3.0.0": version "3.0.1" - resolved "https://registry.yarnpkg.com/@0xproject/base-contract/-/base-contract-3.0.1.tgz#ae6ff8c4492affcb015324d6a1a8de72b22e1f8b" - dependencies: - "@0xproject/typescript-typings" "^3.0.2" - "@0xproject/utils" "^2.0.2" - "@0xproject/web3-wrapper" "^3.0.3" - ethereum-types "^1.0.11" - ethers "4.0.0-beta.14" - lodash "^4.17.5" - -"@0xproject/connect@^2.0.4": - version "2.0.4" - resolved "https://registry.yarnpkg.com/@0xproject/connect/-/connect-2.0.4.tgz#d61cd382edbb80120c8efce91dc85d2c668a5c5e" - dependencies: - "@0xproject/assert" "^1.0.11" - "@0xproject/json-schemas" "^1.0.4" - "@0xproject/order-utils" "^1.0.5" - "@0xproject/types" "^1.1.1" - "@0xproject/typescript-typings" "^2.0.2" - "@0xproject/utils" "^1.0.11" - lodash "^4.17.5" - query-string "^5.0.1" - sinon "^4.0.0" - uuid "^3.3.2" - websocket "^1.0.25" - -"@0xproject/contract-wrappers@^1.0.1": - version "1.0.5" - resolved "https://registry.yarnpkg.com/@0xproject/contract-wrappers/-/contract-wrappers-1.0.5.tgz#5a522b3fd8404b8c42169d5be7e3b6903a7b1356" - dependencies: - "@0xproject/assert" "^1.0.10" - "@0xproject/base-contract" "^2.0.4" - "@0xproject/fill-scenarios" "^1.0.4" - "@0xproject/json-schemas" "^1.0.3" - "@0xproject/order-utils" "^1.0.4" - "@0xproject/types" "^1.1.0" - "@0xproject/typescript-typings" "^2.0.1" - "@0xproject/utils" "^1.0.10" - "@0xproject/web3-wrapper" "^3.0.0" - ethereum-types "^1.0.7" - ethereumjs-blockstream "5.0.0" + resolved "https://registry.yarnpkg.com/@0x/contract-wrappers/-/contract-wrappers-3.0.1.tgz#e25f5812595d994ff66e36aa2aa99eb53becfc7c" + dependencies: + "@0x/abi-gen-wrappers" "^1.0.2" + "@0x/assert" "^1.0.15" + "@0x/contract-addresses" "^1.1.0" + "@0x/contract-artifacts" "^1.1.0" + "@0x/fill-scenarios" "^1.0.9" + "@0x/json-schemas" "^2.0.1" + "@0x/order-utils" "^2.0.1" + "@0x/types" "^1.2.1" + "@0x/typescript-typings" "^3.0.4" + "@0x/utils" "^2.0.4" + "@0x/web3-wrapper" "^3.1.1" + ethereum-types "^1.1.2" + ethereumjs-blockstream "6.0.0" ethereumjs-util "^5.1.1" - ethers "3.0.22" + ethers "~4.0.4" js-sha3 "^0.7.0" lodash "^4.17.5" uuid "^3.1.0" -"@0xproject/fill-scenarios@^1.0.4": - version "1.0.7" - resolved "https://registry.yarnpkg.com/@0xproject/fill-scenarios/-/fill-scenarios-1.0.7.tgz#3a5e7acec46065ccbd7f50d4052d653242aa2da2" - dependencies: - "@0xproject/base-contract" "^3.0.1" - "@0xproject/order-utils" "^1.0.7" - "@0xproject/types" "^1.1.4" - "@0xproject/typescript-typings" "^3.0.2" - "@0xproject/utils" "^2.0.2" - "@0xproject/web3-wrapper" "^3.0.3" - ethereum-types "^1.0.11" - ethers "4.0.0-beta.14" - lodash "^4.17.5" - -"@0xproject/json-schemas@^0.8.3": - version "0.8.3" - resolved "https://registry.yarnpkg.com/@0xproject/json-schemas/-/json-schemas-0.8.3.tgz#455e6219a6bd05e990392165192a983a9ab89f26" - dependencies: - "@0xproject/typescript-typings" "^0.4.3" - "@types/node" "9.6.0" - jsonschema "1.2.2" - lodash.values "4.3.0" - -"@0xproject/json-schemas@^1.0.3", "@0xproject/json-schemas@^1.0.4", "@0xproject/json-schemas@^1.0.7": - version "1.0.7" - resolved "https://registry.yarnpkg.com/@0xproject/json-schemas/-/json-schemas-1.0.7.tgz#64b5692a1bcc5938ce2da01fc2f8aecd72ec35be" - dependencies: - "@0xproject/typescript-typings" "^3.0.2" - "@types/node" "*" - jsonschema "^1.2.0" - lodash.values "^4.3.0" - -"@0xproject/npm-cli-login@^0.0.11": - version "0.0.11" - resolved "https://registry.yarnpkg.com/@0xproject/npm-cli-login/-/npm-cli-login-0.0.11.tgz#3f1ec06112ce62aad300ff0575358f68aeecde2e" - dependencies: - npm-registry-client "7.0.9" - -"@0xproject/order-utils@^1.0.2", "@0xproject/order-utils@^1.0.4", "@0xproject/order-utils@^1.0.5", "@0xproject/order-utils@^1.0.7": - version "1.0.7" - resolved "https://registry.yarnpkg.com/@0xproject/order-utils/-/order-utils-1.0.7.tgz#475cd5f1a11dc7816847abb4d3fd17bbaf32bf4f" - dependencies: - "@0xproject/assert" "^1.0.13" - "@0xproject/base-contract" "^3.0.1" - "@0xproject/json-schemas" "^1.0.7" - "@0xproject/types" "^1.1.4" - "@0xproject/typescript-typings" "^3.0.2" - "@0xproject/utils" "^2.0.2" - "@0xproject/web3-wrapper" "^3.0.3" +"@0x/order-utils@^2.0.0", "@0x/order-utils@^2.0.1": + version "2.0.1" + resolved "https://registry.yarnpkg.com/@0x/order-utils/-/order-utils-2.0.1.tgz#8c46d7aeb9e2cce54a0822824c12427cbe5f7eb4" + dependencies: + "@0x/abi-gen-wrappers" "^1.0.2" + "@0x/assert" "^1.0.15" + "@0x/base-contract" "^3.0.3" + "@0x/contract-artifacts" "^1.1.0" + "@0x/json-schemas" "^2.0.1" + "@0x/types" "^1.2.1" + "@0x/typescript-typings" "^3.0.4" + "@0x/utils" "^2.0.4" + "@0x/web3-wrapper" "^3.1.1" "@types/node" "*" bn.js "^4.11.8" - ethereum-types "^1.0.11" + ethereum-types "^1.1.2" ethereumjs-abi "0.6.5" ethereumjs-util "^5.1.1" - ethers "4.0.0-beta.14" - lodash "^4.17.5" - -"@0xproject/subproviders@^2.0.2": - version "2.0.7" - resolved "https://registry.yarnpkg.com/@0xproject/subproviders/-/subproviders-2.0.7.tgz#0b126f6d6df0ad7bd65689fae5a2d109991f019e" - dependencies: - "@0xproject/assert" "^1.0.13" - "@0xproject/types" "^1.1.4" - "@0xproject/typescript-typings" "^3.0.2" - "@0xproject/utils" "^2.0.2" - "@0xproject/web3-wrapper" "^3.0.3" - "@ledgerhq/hw-app-eth" "^4.3.0" - "@ledgerhq/hw-transport-u2f" "^4.3.0" - "@types/eth-lightwallet" "^3.0.0" - "@types/ganache-core" "^2.1.0" - "@types/hdkey" "^0.7.0" - bip39 "^2.5.0" - bn.js "^4.11.8" - eth-lightwallet "^3.0.1" - ethereum-types "^1.0.11" - ethereumjs-tx "^1.3.5" - ethereumjs-util "^5.1.1" - ganache-core "0xProject/ganache-core#monorepo-dep" - hdkey "^0.7.1" - json-rpc-error "2.0.0" + ethers "~4.0.4" lodash "^4.17.5" - semaphore-async-await "^1.5.1" - web3-provider-engine "14.0.6" - optionalDependencies: - "@ledgerhq/hw-transport-node-hid" "^4.3.0" -"@0xproject/tslint-config@^1.0.7": - version "1.0.8" - resolved "https://registry.yarnpkg.com/@0xproject/tslint-config/-/tslint-config-1.0.8.tgz#cfdce03b84dd2e108278b0024f89fe30218299e0" - dependencies: - lodash "^4.17.5" - tslint "5.11.0" - tslint-eslint-rules "5.4.0" - tslint-react "^3.2.0" - tsutils "3.0.0" - -"@0xproject/types@^0.8.2": - version "0.8.2" - resolved "https://registry.yarnpkg.com/@0xproject/types/-/types-0.8.2.tgz#6f936b73bfb6f017b5102002d97da0881da92d1b" - dependencies: - "@types/node" "9.6.0" - bignumber.js "~4.1.0" - -"@0xproject/types@^1.0.1", "@0xproject/types@^1.1.0", "@0xproject/types@^1.1.1", "@0xproject/types@^1.1.4": - version "1.1.4" - resolved "https://registry.yarnpkg.com/@0xproject/types/-/types-1.1.4.tgz#3ffd65e670d6a21dab19ee0ffd5fad0056291b8e" - dependencies: - "@types/node" "*" - bignumber.js "~4.1.0" - ethereum-types "^1.0.11" - -"@0xproject/typescript-typings@^0.4.3": - version "0.4.3" - resolved "https://registry.yarnpkg.com/@0xproject/typescript-typings/-/typescript-typings-0.4.3.tgz#f99f939a43f2764ad7182fcd78a71212a1d76d96" - dependencies: - "@0xproject/types" "^0.8.2" - bignumber.js "~4.1.0" - ethereum-types "^0.0.2" - -"@0xproject/typescript-typings@^1.0.3": - version "1.0.5" - resolved "https://registry.yarnpkg.com/@0xproject/typescript-typings/-/typescript-typings-1.0.5.tgz#a808443419f26a7b90d63d1afd3efbfb48644184" - dependencies: - "@types/bn.js" "^4.11.0" - "@types/react" "*" - bignumber.js "~4.1.0" - ethereum-types "^1.0.5" - popper.js "1.14.3" - -"@0xproject/typescript-typings@^2.0.1", "@0xproject/typescript-typings@^2.0.2": - version "2.0.2" - resolved "https://registry.yarnpkg.com/@0xproject/typescript-typings/-/typescript-typings-2.0.2.tgz#1812f64e341f1d24c09b8b5a951cbde0e5fff9c2" - dependencies: - "@types/bn.js" "^4.11.0" - "@types/react" "*" - bignumber.js "~4.1.0" - ethereum-types "^1.0.8" - popper.js "1.14.3" - -"@0xproject/typescript-typings@^3.0.2": - version "3.0.2" - resolved "https://registry.yarnpkg.com/@0xproject/typescript-typings/-/typescript-typings-3.0.2.tgz#797416af57618304cffb7a0053cf1822725b8dcd" - dependencies: - "@types/bn.js" "^4.11.0" - "@types/react" "*" - bignumber.js "~4.1.0" - ethereum-types "^1.0.11" - popper.js "1.14.3" - -"@0xproject/utils@^0.7.3": - version "0.7.3" - resolved "https://registry.yarnpkg.com/@0xproject/utils/-/utils-0.7.3.tgz#ffa7c6da9bf0dd3e13694f185dcfc48a8981ff05" - dependencies: - "@0xproject/typescript-typings" "^0.4.3" - "@types/node" "9.6.0" - bignumber.js "~4.1.0" - ethereum-types "^0.0.2" - ethereumjs-util "^5.1.1" - ethers "3.0.22" - js-sha3 "0.7.0" - lodash "4.17.10" - web3 "0.20.6" - -"@0xproject/utils@^1.0.10", "@0xproject/utils@^1.0.11", "@0xproject/utils@^1.0.4", "@0xproject/utils@^1.0.8": - version "1.0.11" - resolved "https://registry.yarnpkg.com/@0xproject/utils/-/utils-1.0.11.tgz#5b53e7d9d4dbe68e219049218c9db04e97c37429" - dependencies: - "@0xproject/types" "^1.1.1" - "@0xproject/typescript-typings" "^2.0.2" - "@types/node" "*" - abortcontroller-polyfill "^1.1.9" - bignumber.js "~4.1.0" - detect-node "2.0.3" - ethereum-types "^1.0.8" - ethereumjs-util "^5.1.1" - ethers "3.0.22" - isomorphic-fetch "^2.2.1" - js-sha3 "^0.7.0" - lodash "^4.17.5" - -"@0xproject/utils@^2.0.2": - version "2.0.2" - resolved "https://registry.yarnpkg.com/@0xproject/utils/-/utils-2.0.2.tgz#5a0cba11ea8378378a600ed7b25c82834038c932" - dependencies: - "@0xproject/types" "^1.1.4" - "@0xproject/typescript-typings" "^3.0.2" - "@types/node" "*" - abortcontroller-polyfill "^1.1.9" - bignumber.js "~4.1.0" - detect-node "2.0.3" - ethereum-types "^1.0.11" - ethereumjs-util "^5.1.1" - ethers "4.0.0-beta.14" - isomorphic-fetch "^2.2.1" - js-sha3 "^0.7.0" - lodash "^4.17.5" - -"@0xproject/web3-wrapper@^3.0.0", "@0xproject/web3-wrapper@^3.0.1", "@0xproject/web3-wrapper@^3.0.3": - version "3.0.3" - resolved "https://registry.yarnpkg.com/@0xproject/web3-wrapper/-/web3-wrapper-3.0.3.tgz#2faaf3fa75308480efbbbb75416a1e416596d989" +"@0xproject/npm-cli-login@^0.0.11": + version "0.0.11" + resolved "https://registry.yarnpkg.com/@0xproject/npm-cli-login/-/npm-cli-login-0.0.11.tgz#3f1ec06112ce62aad300ff0575358f68aeecde2e" dependencies: - "@0xproject/assert" "^1.0.13" - "@0xproject/json-schemas" "^1.0.7" - "@0xproject/typescript-typings" "^3.0.2" - "@0xproject/utils" "^2.0.2" - ethereum-types "^1.0.11" - ethereumjs-util "^5.1.1" - ethers "4.0.0-beta.14" - lodash "^4.17.5" + npm-registry-client "7.0.9" "@babel/code-frame@^7.0.0", "@babel/code-frame@^7.0.0-beta.35": version "7.0.0" @@ -831,13 +604,6 @@ "@ledgerhq/hw-transport" "^4.24.0" u2f-api "0.2.7" -"@ledgerhq/hw-transport-u2f@^4.3.0": - version "4.31.0" - resolved "https://registry.yarnpkg.com/@ledgerhq/hw-transport-u2f/-/hw-transport-u2f-4.31.0.tgz#b3c97e7f8e42a3b43372853f33a713cb5c49efdc" - dependencies: - "@ledgerhq/hw-transport" "^4.24.0" - u2f-api "0.2.7" - "@ledgerhq/hw-transport@^4.24.0": version "4.24.0" resolved "https://registry.yarnpkg.com/@ledgerhq/hw-transport/-/hw-transport-4.24.0.tgz#8def925d8c2e1f73d15128d9e27ead729870be58" @@ -1719,10 +1485,6 @@ version "9.6.5" resolved "https://registry.yarnpkg.com/@types/node/-/node-9.6.5.tgz#ee700810fdf49ac1c399fc5980b7559b3e5a381d" -"@types/node@9.6.0": - version "9.6.0" - resolved "http://registry.npmjs.org/@types/node/-/node-9.6.0.tgz#d3480ee666df9784b1001a1872a2f6ccefb6c2d7" - "@types/node@^10.3.2": version "10.9.4" resolved "https://registry.yarnpkg.com/@types/node/-/node-10.9.4.tgz#0f4cb2dc7c1de6096055357f70179043c33e9897" @@ -1731,10 +1493,6 @@ version "10.5.7" resolved "https://registry.npmjs.org/@types/node/-/node-10.5.7.tgz#960d9feb3ade2233bcc9843c918d740b4f78a7cf" -"@types/node@^8.0.53": - version "8.10.36" - resolved "https://registry.yarnpkg.com/@types/node/-/node-8.10.36.tgz#eac05d576fbcd0b4ea3c912dc58c20475c08d9e4" - "@types/numeral@^0.0.22": version "0.0.22" resolved "https://registry.yarnpkg.com/@types/numeral/-/numeral-0.0.22.tgz#86bef1f0a2d743afdc2ef3168d45f2905e1a0b93" @@ -6158,13 +5916,6 @@ ethereum-common@^0.0.18: version "0.0.18" resolved "https://registry.yarnpkg.com/ethereum-common/-/ethereum-common-0.0.18.tgz#2fdc3576f232903358976eb39da783213ff9523f" -ethereum-types@^0.0.2: - version "0.0.2" - resolved "https://registry.yarnpkg.com/ethereum-types/-/ethereum-types-0.0.2.tgz#6ef6faf46a24697cbf66b6c8a0ecf2095ce58c38" - dependencies: - "@types/node" "^8.0.53" - bignumber.js "~4.1.0" - ethereumjs-abi@0.6.5, ethereumjs-abi@^0.6.5: version "0.6.5" resolved "https://registry.yarnpkg.com/ethereumjs-abi/-/ethereumjs-abi-0.6.5.tgz#5a637ef16ab43473fa72a29ad90871405b3f5241" @@ -6206,14 +5957,6 @@ ethereumjs-block@~1.2.2: ethereumjs-util "^4.0.1" merkle-patricia-tree "^2.1.2" -ethereumjs-blockstream@5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/ethereumjs-blockstream/-/ethereumjs-blockstream-5.0.0.tgz#63bfe9185757329a32822d5815562eb1dcd75d71" - dependencies: - immutable "3.8.2" - source-map-support "0.5.6" - uuid "3.2.1" - ethereumjs-blockstream@6.0.0: version "6.0.0" resolved "https://registry.yarnpkg.com/ethereumjs-blockstream/-/ethereumjs-blockstream-6.0.0.tgz#79d726d1f358935eb65195e91d40344c31e87eff" @@ -6314,36 +6057,6 @@ ethereumjs-wallet@0.6.0: utf8 "^2.1.1" uuid "^2.0.1" -ethers@3.0.22: - version "3.0.22" - resolved "https://registry.yarnpkg.com/ethers/-/ethers-3.0.22.tgz#7fab1ea16521705837aa43c15831877b2716b436" - dependencies: - aes-js "3.0.0" - bn.js "^4.4.0" - elliptic "6.3.3" - hash.js "^1.0.0" - inherits "2.0.1" - js-sha3 "0.5.7" - scrypt-js "2.0.3" - setimmediate "1.0.4" - uuid "2.0.1" - xmlhttprequest "1.8.0" - -ethers@4.0.0-beta.14: - version "4.0.0-beta.14" - resolved "https://registry.yarnpkg.com/ethers/-/ethers-4.0.0-beta.14.tgz#76aa9257b9c93a7604ff4dc11f2a445d07f6459d" - dependencies: - "@types/node" "^10.3.2" - aes-js "3.0.0" - bn.js "^4.4.0" - elliptic "6.3.3" - hash.js "1.1.3" - js-sha3 "0.5.7" - scrypt-js "2.0.3" - setimmediate "1.0.4" - uuid "2.0.1" - xmlhttprequest "1.8.0" - ethers@~4.0.4: version "4.0.4" resolved "https://registry.yarnpkg.com/ethers/-/ethers-4.0.4.tgz#d3f85e8b27f4b59537e06526439b0fb15b44dc65" @@ -9269,14 +8982,14 @@ js-sha3@0.5.7: version "0.5.7" resolved "https://registry.yarnpkg.com/js-sha3/-/js-sha3-0.5.7.tgz#0d4ffd8002d5333aabaf4a23eed2f6374c9f28e7" -js-sha3@0.7.0, js-sha3@^0.7.0: - version "0.7.0" - resolved "https://registry.yarnpkg.com/js-sha3/-/js-sha3-0.7.0.tgz#0a5c57b36f79882573b2d84051f8bb85dd1bd63a" - js-sha3@^0.3.1: version "0.3.1" resolved "https://registry.yarnpkg.com/js-sha3/-/js-sha3-0.3.1.tgz#86122802142f0828502a0d1dee1d95e253bb0243" +js-sha3@^0.7.0: + version "0.7.0" + resolved "https://registry.yarnpkg.com/js-sha3/-/js-sha3-0.7.0.tgz#0a5c57b36f79882573b2d84051f8bb85dd1bd63a" + js-tokens@^3.0.0, js-tokens@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b" @@ -9460,10 +9173,6 @@ jsonschema@*, jsonschema@1.2.4, jsonschema@^1.2.0: version "1.2.4" resolved "https://registry.yarnpkg.com/jsonschema/-/jsonschema-1.2.4.tgz#a46bac5d3506a254465bc548876e267c6d0d6464" -jsonschema@1.2.2: - version "1.2.2" - resolved "https://registry.yarnpkg.com/jsonschema/-/jsonschema-1.2.2.tgz#83ab9c63d65bf4d596f91d81195e78772f6452bc" - jsprim@^1.2.2: version "1.4.1" resolved "https://registry.yarnpkg.com/jsprim/-/jsprim-1.4.1.tgz#313e66bc1e5cc06e438bc1b7499c2e5c56acb6a2" @@ -10154,7 +9863,7 @@ lodash.uniq@^4.5.0: version "4.5.0" resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773" -lodash.values@4.3.0, lodash.values@^4.3.0: +lodash.values@^4.3.0: version "4.3.0" resolved "https://registry.yarnpkg.com/lodash.values/-/lodash.values-4.3.0.tgz#a3a6c2b0ebecc5c2cba1c17e6e620fe81b53d347" @@ -10164,10 +9873,6 @@ lodash.words@^3.0.0: dependencies: lodash._root "^3.0.0" -lodash@4.17.10, lodash@^4.17.10: - version "4.17.10" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.10.tgz#1b7793cf7259ea38fb3661d4d38b3260af8ae4e7" - lodash@=4.17.4: version "4.17.4" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae" @@ -10184,6 +9889,10 @@ lodash@^4.14.0, lodash@^4.17.4, lodash@^4.17.5, lodash@^4.2.1, lodash@^4.3.0, lo version "4.17.5" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.5.tgz#99a92d65c0272debe8c96b6057bc8fbfa3bed511" +lodash@^4.17.10: + version "4.17.10" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.10.tgz#1b7793cf7259ea38fb3661d4d38b3260af8ae4e7" + lodash@~1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/lodash/-/lodash-1.0.2.tgz#8f57560c83b59fc270bd3d561b690043430e2551" @@ -13950,10 +13659,6 @@ scrypt-async@^1.2.0: version "1.3.1" resolved "https://registry.yarnpkg.com/scrypt-async/-/scrypt-async-1.3.1.tgz#a11fd6fac981b4b823ee01dee0221169500ddae9" -scrypt-js@2.0.3: - version "2.0.3" - resolved "http://registry.npmjs.org/scrypt-js/-/scrypt-js-2.0.3.tgz#bb0040be03043da9a012a2cea9fc9f852cfc87d4" - scrypt-js@2.0.4: version "2.0.4" resolved "https://registry.yarnpkg.com/scrypt-js/-/scrypt-js-2.0.4.tgz#32f8c5149f0797672e551c07e230f834b6af5f16" @@ -16184,7 +15889,7 @@ v8flags@^2.0.2: dependencies: user-home "^1.1.1" -valid-url@1.0.9, valid-url@^1.0.9: +valid-url@^1.0.9: version "1.0.9" resolved "https://registry.yarnpkg.com/valid-url/-/valid-url-1.0.9.tgz#1c14479b40f1397a75782f115e4086447433a200" @@ -16631,16 +16336,6 @@ web3@0.20.2: xhr2 "*" xmlhttprequest "*" -web3@0.20.6: - version "0.20.6" - resolved "http://registry.npmjs.org/web3/-/web3-0.20.6.tgz#3e97306ae024fb24e10a3d75c884302562215120" - dependencies: - bignumber.js "git+https://github.com/frozeman/bignumber.js-nolookahead.git" - crypto-js "^3.1.4" - utf8 "^2.1.1" - xhr2 "*" - xmlhttprequest "*" - web3@^0.18.0: version "0.18.4" resolved "https://registry.yarnpkg.com/web3/-/web3-0.18.4.tgz#81ec1784145491f2eaa8955b31c06049e07c5e7d" -- cgit