aboutsummaryrefslogtreecommitdiffstats
path: root/packages/order-watcher
diff options
context:
space:
mode:
authorBrandon Millman <brandon.millman@gmail.com>2018-05-24 05:16:32 +0800
committerBrandon Millman <brandon.millman@gmail.com>2018-05-24 05:16:32 +0800
commit3fe94891d3569a4615f4aa32d47f0065b5957fe9 (patch)
tree83d4e4ccf7748d2100aa935c457de0a893eaec9c /packages/order-watcher
parentd0abc60176dba3116cb3986d298ab5164c1fe49c (diff)
parentf6b81f588d98e09e7a5806902d94e2892d029481 (diff)
downloaddexon-sol-tools-3fe94891d3569a4615f4aa32d47f0065b5957fe9.tar
dexon-sol-tools-3fe94891d3569a4615f4aa32d47f0065b5957fe9.tar.gz
dexon-sol-tools-3fe94891d3569a4615f4aa32d47f0065b5957fe9.tar.bz2
dexon-sol-tools-3fe94891d3569a4615f4aa32d47f0065b5957fe9.tar.lz
dexon-sol-tools-3fe94891d3569a4615f4aa32d47f0065b5957fe9.tar.xz
dexon-sol-tools-3fe94891d3569a4615f4aa32d47f0065b5957fe9.tar.zst
dexon-sol-tools-3fe94891d3569a4615f4aa32d47f0065b5957fe9.zip
Merge branch 'v2-prototype' into feature/website/wallet-flex-box
* v2-prototype: (95 commits) Add missing dep to website Upgrade solidity parser Fix trace test Fix linter issues Move contract utils Fix prettier Fix NameResolver Fix prettier Remove 0x.js as a dependency from website Enable 0x.js tests Fix small bug in order-utils Address feedback Fix Tslint error caused by "PromiseLike" value Fix Tslint error caused by "PromiseLike" value Update dogfood url fix contract-wrappers version Parse compiler.json in SolCompilerArtifactsAdapter Fix TokenTransferProxy artifact name since it's now suffixed with _v1 Update yarn.lock Fix signature verification test ...
Diffstat (limited to 'packages/order-watcher')
-rw-r--r--packages/order-watcher/CHANGELOG.json10
-rw-r--r--packages/order-watcher/CHANGELOG.md14
-rw-r--r--packages/order-watcher/package.json36
-rw-r--r--packages/order-watcher/src/order_watcher/order_watcher.ts4
-rw-r--r--packages/order-watcher/src/utils/utils.ts3
-rw-r--r--packages/order-watcher/test/expiration_watcher_test.ts33
-rw-r--r--packages/order-watcher/test/global_hooks.ts3
-rw-r--r--packages/order-watcher/test/order_watcher_test.ts4
-rw-r--r--packages/order-watcher/test/utils/web3_wrapper.ts5
9 files changed, 76 insertions, 36 deletions
diff --git a/packages/order-watcher/CHANGELOG.json b/packages/order-watcher/CHANGELOG.json
index 87f40bcb7..dde78445a 100644
--- a/packages/order-watcher/CHANGELOG.json
+++ b/packages/order-watcher/CHANGELOG.json
@@ -1,5 +1,15 @@
[
{
+ "timestamp": 1527008794,
+ "version": "0.0.2",
+ "changes": [
+ {
+ "note": "Dependencies updated"
+ }
+ ]
+ },
+ {
+ "timestamp": 1527008794,
"version": "0.0.1",
"changes": [
{
diff --git a/packages/order-watcher/CHANGELOG.md b/packages/order-watcher/CHANGELOG.md
new file mode 100644
index 000000000..999d62f44
--- /dev/null
+++ b/packages/order-watcher/CHANGELOG.md
@@ -0,0 +1,14 @@
+<!--
+This file is auto-generated using the monorepo-scripts package. Don't edit directly.
+Edit the package's CHANGELOG.json file only.
+-->
+
+CHANGELOG
+
+## v0.0.2 - _May 22, 2018_
+
+ * Dependencies updated
+
+## v0.0.1 - _May 22, 2018_
+
+ * Moved OrderWatcher out of 0x.js package (#579)
diff --git a/packages/order-watcher/package.json b/packages/order-watcher/package.json
index d65d3f175..c84858bfd 100644
--- a/packages/order-watcher/package.json
+++ b/packages/order-watcher/package.json
@@ -1,6 +1,6 @@
{
"name": "@0xproject/order-watcher",
- "version": "0.0.1",
+ "version": "0.0.2",
"description": "An order watcher daemon that watches for order validity",
"keywords": [
"0x",
@@ -28,7 +28,7 @@
},
"config": {
"compact_artifacts": "Exchange DummyToken ZRXToken Token EtherToken TokenTransferProxy TokenRegistry",
- "contracts": "Exchange DummyToken ZRXToken Token WETH9 TokenTransferProxy MultiSigWallet MultiSigWalletWithTimeLock MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress MaliciousToken TokenRegistry Arbitrage EtherDelta AccountLevels",
+ "contracts": "Exchange DummyToken ZRXToken Token WETH9 TokenTransferProxy_v1 MultiSigWallet MultiSigWalletWithTimeLock MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress MaliciousToken TokenRegistry Arbitrage EtherDelta AccountLevels",
"postpublish": {
"assets": [
"packages/order-watcher/_bundles/index.js",
@@ -45,12 +45,12 @@
"node": ">=6.0.0"
},
"devDependencies": {
- "@0xproject/abi-gen": "^0.2.13",
- "@0xproject/dev-utils": "^0.4.1",
- "@0xproject/migrations": "^0.0.5",
- "@0xproject/monorepo-scripts": "^0.1.19",
- "@0xproject/sol-compiler": "^0.4.3",
- "@0xproject/tslint-config": "^0.4.17",
+ "@0xproject/abi-gen": "^0.3.0",
+ "@0xproject/dev-utils": "^0.4.2",
+ "@0xproject/migrations": "^0.0.6",
+ "@0xproject/monorepo-scripts": "^0.1.20",
+ "@0xproject/sol-compiler": "^0.5.0",
+ "@0xproject/tslint-config": "^0.4.18",
"@types/bintrees": "^1.0.2",
"@types/lodash": "4.14.104",
"@types/mocha": "^2.2.42",
@@ -76,16 +76,16 @@
"typescript": "2.7.1"
},
"dependencies": {
- "@0xproject/assert": "^0.2.9",
- "@0xproject/base-contract": "^0.3.1",
- "@0xproject/contract-wrappers": "^0.0.1",
- "@0xproject/fill-scenarios": "^0.0.1",
- "@0xproject/json-schemas": "^0.7.23",
- "@0xproject/order-utils": "^0.0.4",
- "@0xproject/types": "^0.6.3",
- "@0xproject/typescript-typings": "^0.3.1",
- "@0xproject/utils": "^0.6.1",
- "@0xproject/web3-wrapper": "^0.6.3",
+ "@0xproject/assert": "^0.2.10",
+ "@0xproject/base-contract": "^0.3.2",
+ "@0xproject/contract-wrappers": "^0.0.2",
+ "@0xproject/fill-scenarios": "^0.0.2",
+ "@0xproject/json-schemas": "^0.7.24",
+ "@0xproject/order-utils": "^0.0.5",
+ "@0xproject/types": "^0.7.0",
+ "@0xproject/typescript-typings": "^0.3.2",
+ "@0xproject/utils": "^0.6.2",
+ "@0xproject/web3-wrapper": "^0.6.4",
"bintrees": "^1.0.2",
"ethers": "^3.0.15",
"lodash": "^4.17.4"
diff --git a/packages/order-watcher/src/order_watcher/order_watcher.ts b/packages/order-watcher/src/order_watcher/order_watcher.ts
index 3c93d6293..29936a066 100644
--- a/packages/order-watcher/src/order_watcher/order_watcher.ts
+++ b/packages/order-watcher/src/order_watcher/order_watcher.ts
@@ -60,6 +60,7 @@ interface OrderStateByOrderHash {
[orderHash: string]: OrderState;
}
+// tslint:disable-next-line:custom-no-magic-numbers
const DEFAULT_CLEANUP_JOB_INTERVAL_MS = 1000 * 60 * 60; // 1h
/**
@@ -130,7 +131,8 @@ export class OrderWatcher {
assert.isValidSignature(orderHash, signedOrder.ecSignature, signedOrder.maker);
this._orderByOrderHash[orderHash] = signedOrder;
this._addToDependentOrderHashes(signedOrder, orderHash);
- const expirationUnixTimestampMs = signedOrder.expirationUnixTimestampSec.times(1000);
+ const milisecondsInASecond = 1000;
+ const expirationUnixTimestampMs = signedOrder.expirationUnixTimestampSec.times(milisecondsInASecond);
this._expirationWatcher.addOrder(orderHash, expirationUnixTimestampMs);
}
/**
diff --git a/packages/order-watcher/src/utils/utils.ts b/packages/order-watcher/src/utils/utils.ts
index af1125632..d34f6b99f 100644
--- a/packages/order-watcher/src/utils/utils.ts
+++ b/packages/order-watcher/src/utils/utils.ts
@@ -5,7 +5,8 @@ export const utils = {
return new Error(`Unexpected switch value: ${value} encountered for ${name}`);
},
getCurrentUnixTimestampSec(): BigNumber {
- return new BigNumber(Date.now() / 1000).round();
+ const milisecondsInASecond = 1000;
+ return new BigNumber(Date.now() / milisecondsInASecond).round();
},
getCurrentUnixTimestampMs(): BigNumber {
return new BigNumber(Date.now());
diff --git a/packages/order-watcher/test/expiration_watcher_test.ts b/packages/order-watcher/test/expiration_watcher_test.ts
index 8b006f58a..ef15bf006 100644
--- a/packages/order-watcher/test/expiration_watcher_test.ts
+++ b/packages/order-watcher/test/expiration_watcher_test.ts
@@ -22,6 +22,7 @@ import { provider, web3Wrapper } from './utils/web3_wrapper';
chaiSetup.configure();
const expect = chai.expect;
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
+const MILISECONDS_IN_SECOND = 1000;
describe('ExpirationWatcher', () => {
let contractWrappers: ContractWrappers;
@@ -84,13 +85,13 @@ describe('ExpirationWatcher', () => {
expirationUnixTimestampSec,
);
const orderHash = getOrderHashHex(signedOrder);
- expirationWatcher.addOrder(orderHash, signedOrder.expirationUnixTimestampSec.times(1000));
+ expirationWatcher.addOrder(orderHash, signedOrder.expirationUnixTimestampSec.times(MILISECONDS_IN_SECOND));
const callbackAsync = callbackErrorReporter.reportNoErrorCallbackErrors(done)((hash: string) => {
expect(hash).to.be.equal(orderHash);
expect(utils.getCurrentUnixTimestampSec()).to.be.bignumber.gte(expirationUnixTimestampSec);
});
expirationWatcher.subscribe(callbackAsync);
- timer.tick(orderLifetimeSec * 1000);
+ timer.tick(orderLifetimeSec * MILISECONDS_IN_SECOND);
})().catch(done);
});
it("doesn't emit events before order expires", (done: DoneCallback) => {
@@ -106,13 +107,13 @@ describe('ExpirationWatcher', () => {
expirationUnixTimestampSec,
);
const orderHash = getOrderHashHex(signedOrder);
- expirationWatcher.addOrder(orderHash, signedOrder.expirationUnixTimestampSec.times(1000));
+ expirationWatcher.addOrder(orderHash, signedOrder.expirationUnixTimestampSec.times(MILISECONDS_IN_SECOND));
const callbackAsync = callbackErrorReporter.reportNoErrorCallbackErrors(done)(async (hash: string) => {
done(new Error('Emitted expiration went before the order actually expired'));
});
expirationWatcher.subscribe(callbackAsync);
const notEnoughTime = orderLifetimeSec - 1;
- timer.tick(notEnoughTime * 1000);
+ timer.tick(notEnoughTime * MILISECONDS_IN_SECOND);
done();
})().catch(done);
});
@@ -140,8 +141,14 @@ describe('ExpirationWatcher', () => {
);
const orderHash1 = getOrderHashHex(signedOrder1);
const orderHash2 = getOrderHashHex(signedOrder2);
- expirationWatcher.addOrder(orderHash2, signedOrder2.expirationUnixTimestampSec.times(1000));
- expirationWatcher.addOrder(orderHash1, signedOrder1.expirationUnixTimestampSec.times(1000));
+ expirationWatcher.addOrder(
+ orderHash2,
+ signedOrder2.expirationUnixTimestampSec.times(MILISECONDS_IN_SECOND),
+ );
+ expirationWatcher.addOrder(
+ orderHash1,
+ signedOrder1.expirationUnixTimestampSec.times(MILISECONDS_IN_SECOND),
+ );
const expirationOrder = [orderHash1, orderHash2];
const expectToBeCalledOnce = false;
const callbackAsync = callbackErrorReporter.reportNoErrorCallbackErrors(done, expectToBeCalledOnce)(
@@ -154,7 +161,7 @@ describe('ExpirationWatcher', () => {
},
);
expirationWatcher.subscribe(callbackAsync);
- timer.tick(order2Lifetime * 1000);
+ timer.tick(order2Lifetime * MILISECONDS_IN_SECOND);
})().catch(done);
});
it('emits events in correct order when expirations are equal', (done: DoneCallback) => {
@@ -181,8 +188,14 @@ describe('ExpirationWatcher', () => {
);
const orderHash1 = getOrderHashHex(signedOrder1);
const orderHash2 = getOrderHashHex(signedOrder2);
- expirationWatcher.addOrder(orderHash1, signedOrder1.expirationUnixTimestampSec.times(1000));
- expirationWatcher.addOrder(orderHash2, signedOrder2.expirationUnixTimestampSec.times(1000));
+ expirationWatcher.addOrder(
+ orderHash1,
+ signedOrder1.expirationUnixTimestampSec.times(MILISECONDS_IN_SECOND),
+ );
+ expirationWatcher.addOrder(
+ orderHash2,
+ signedOrder2.expirationUnixTimestampSec.times(MILISECONDS_IN_SECOND),
+ );
const expirationOrder = orderHash1 < orderHash2 ? [orderHash1, orderHash2] : [orderHash2, orderHash1];
const expectToBeCalledOnce = false;
const callbackAsync = callbackErrorReporter.reportNoErrorCallbackErrors(done, expectToBeCalledOnce)(
@@ -195,7 +208,7 @@ describe('ExpirationWatcher', () => {
},
);
expirationWatcher.subscribe(callbackAsync);
- timer.tick(order2Lifetime * 1000);
+ timer.tick(order2Lifetime * MILISECONDS_IN_SECOND);
})().catch(done);
});
});
diff --git a/packages/order-watcher/test/global_hooks.ts b/packages/order-watcher/test/global_hooks.ts
index 03eab0e13..d4d033dd4 100644
--- a/packages/order-watcher/test/global_hooks.ts
+++ b/packages/order-watcher/test/global_hooks.ts
@@ -9,7 +9,8 @@ import { provider } from './utils/web3_wrapper';
before('migrate contracts', async function(): Promise<void> {
// HACK: Since the migrations take longer then our global mocha timeout limit
// we manually increase it for this before hook.
- this.timeout(20000);
+ const mochaTestTimeoutMs = 20000;
+ this.timeout(mochaTestTimeoutMs);
const txDefaults = {
gas: devConstants.GAS_ESTIMATE,
from: devConstants.TESTRPC_FIRST_ADDRESS,
diff --git a/packages/order-watcher/test/order_watcher_test.ts b/packages/order-watcher/test/order_watcher_test.ts
index dc8e544b1..0d33e7ea2 100644
--- a/packages/order-watcher/test/order_watcher_test.ts
+++ b/packages/order-watcher/test/order_watcher_test.ts
@@ -269,8 +269,8 @@ describe('OrderWatcher', () => {
});
it('should trigger the callback when orders backing ZRX allowance changes', (done: DoneCallback) => {
(async () => {
- const makerFee = Web3Wrapper.toBaseUnitAmount(new BigNumber(2), 18);
- const takerFee = Web3Wrapper.toBaseUnitAmount(new BigNumber(0), 18);
+ const makerFee = Web3Wrapper.toBaseUnitAmount(new BigNumber(2), decimals);
+ const takerFee = Web3Wrapper.toBaseUnitAmount(new BigNumber(0), decimals);
signedOrder = await fillScenarios.createFillableSignedOrderWithFeesAsync(
makerToken.address,
takerToken.address,
diff --git a/packages/order-watcher/test/utils/web3_wrapper.ts b/packages/order-watcher/test/utils/web3_wrapper.ts
index b0ccfa546..71a0dc1c2 100644
--- a/packages/order-watcher/test/utils/web3_wrapper.ts
+++ b/packages/order-watcher/test/utils/web3_wrapper.ts
@@ -2,8 +2,7 @@ import { devConstants, web3Factory } from '@0xproject/dev-utils';
import { Provider } from '@0xproject/types';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
-const web3 = web3Factory.create({ shouldUseInProcessGanache: true });
-const provider: Provider = web3.currentProvider;
-const web3Wrapper = new Web3Wrapper(web3.currentProvider);
+const provider: Provider = web3Factory.getRpcProvider({ shouldUseInProcessGanache: true });
+const web3Wrapper = new Web3Wrapper(provider);
export { provider, web3Wrapper };