aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-05-23 04:02:21 +0800
committerFabio Berger <me@fabioberger.com>2018-05-23 04:02:21 +0800
commit2b793f372abc444702406539588f2101d9dc5307 (patch)
tree5d407c63d4fc5ebaa9537bf0bca2346c684a1a82
parent9119ee14b6d49b2c339b786f92913ff8a93ff610 (diff)
parent4cfeb6b8ace9c1613ac0581bd6ea52ff183701f9 (diff)
downloaddexon-sol-tools-2b793f372abc444702406539588f2101d9dc5307.tar
dexon-sol-tools-2b793f372abc444702406539588f2101d9dc5307.tar.gz
dexon-sol-tools-2b793f372abc444702406539588f2101d9dc5307.tar.bz2
dexon-sol-tools-2b793f372abc444702406539588f2101d9dc5307.tar.lz
dexon-sol-tools-2b793f372abc444702406539588f2101d9dc5307.tar.xz
dexon-sol-tools-2b793f372abc444702406539588f2101d9dc5307.tar.zst
dexon-sol-tools-2b793f372abc444702406539588f2101d9dc5307.zip
Merge branch 'v2-prototype' into refactor/contracts/remove0xjsDep
* v2-prototype: Fix tslint issues Add `are` to boolean naming conventions Fix tslint Fix the tsutils version, fixing ts typings issue Rename some variables in multi_sig_with_time_lock.ts Remove extra awaitTransactionMinedAsync calls Update artifacts Update yarn.lock Fix warnings in Metacoin Upgrade UglifyJS to include ES6 support Add CancelOrder and MatchOrder types Add missing return types Ignore classnames linter rule Apply changes to test/exchange/match_orders.ts Fix some unhandled promise rejections Add awaitTransactionMinedAsync after every sent transaction Add missing blockchainLifecycle calls to contracts tests # Conflicts: # packages/contracts/src/utils/exchange_wrapper.ts # packages/contracts/test/asset_proxy/proxies.ts # packages/contracts/test/exchange/dispatcher.ts # packages/contracts/test/multi_sig_with_time_lock.ts
-rw-r--r--packages/contract_templates/contract.handlebars1
-rw-r--r--packages/contracts/src/utils/constants.ts1
-rw-r--r--packages/contracts/src/utils/erc20_wrapper.ts8
-rw-r--r--packages/contracts/src/utils/erc721_wrapper.ts10
-rw-r--r--packages/contracts/src/utils/exchange_wrapper.ts4
-rw-r--r--packages/contracts/src/utils/formatters.ts8
-rw-r--r--packages/contracts/src/utils/order_utils.ts6
-rw-r--r--packages/contracts/src/utils/types.ts12
-rw-r--r--packages/contracts/test/asset_proxy/authorizable.ts53
-rw-r--r--packages/contracts/test/asset_proxy/proxies.ts95
-rw-r--r--packages/contracts/test/ether_token.ts13
-rw-r--r--packages/contracts/test/exchange/core.ts68
-rw-r--r--packages/contracts/test/exchange/dispatcher.ts169
-rw-r--r--packages/contracts/test/exchange/libs.ts6
-rw-r--r--packages/contracts/test/exchange/match_orders.ts24
-rw-r--r--packages/contracts/test/exchange/signature_validator.ts14
-rw-r--r--packages/contracts/test/exchange/transactions.ts11
-rw-r--r--packages/contracts/test/exchange/wrapper.ts60
-rw-r--r--packages/contracts/test/libraries/lib_bytes.ts6
-rw-r--r--packages/contracts/test/multi_sig_with_time_lock.ts54
-rw-r--r--packages/contracts/test/token_registry.ts29
-rw-r--r--packages/contracts/test/unlimited_allowance_token.ts11
-rw-r--r--packages/contracts/test/utils/match_order_tester.ts17
-rw-r--r--packages/contracts/test/zrx_token.ts6
-rw-r--r--packages/metacoin/contracts/Metacoin.sol6
-rw-r--r--packages/tslint-config/rules/booleanNamingRule.ts2
-rw-r--r--packages/website/package.json1
-rw-r--r--packages/website/ts/components/portal/menu.tsx4
-rw-r--r--packages/website/ts/components/portal/portal.tsx4
-rw-r--r--packages/website/webpack.config.js12
-rw-r--r--yarn.lock32
31 files changed, 526 insertions, 221 deletions
diff --git a/packages/contract_templates/contract.handlebars b/packages/contract_templates/contract.handlebars
index ed11ac8d2..41f46695b 100644
--- a/packages/contract_templates/contract.handlebars
+++ b/packages/contract_templates/contract.handlebars
@@ -31,6 +31,7 @@ export enum {{contractName}}Events {
{{/if}}
// tslint:disable:no-parameter-reassignment
+// tslint:disable-next-line:class-name
export class {{contractName}}Contract extends BaseContract {
{{#each methods}}
{{#this.constant}}
diff --git a/packages/contracts/src/utils/constants.ts b/packages/contracts/src/utils/constants.ts
index e45e51c04..41968f547 100644
--- a/packages/contracts/src/utils/constants.ts
+++ b/packages/contracts/src/utils/constants.ts
@@ -20,6 +20,7 @@ export const constants = {
INVALID_OPCODE: 'invalid opcode',
REVERT: 'revert',
TESTRPC_NETWORK_ID: 50,
+ AWAIT_TRANSACTION_MINED_MS: 100,
MAX_ETHERTOKEN_WITHDRAW_GAS: 43000,
MAX_TOKEN_TRANSFERFROM_GAS: 80000,
MAX_TOKEN_APPROVE_GAS: 60000,
diff --git a/packages/contracts/src/utils/erc20_wrapper.ts b/packages/contracts/src/utils/erc20_wrapper.ts
index f12571b48..0303649a5 100644
--- a/packages/contracts/src/utils/erc20_wrapper.ts
+++ b/packages/contracts/src/utils/erc20_wrapper.ts
@@ -23,7 +23,7 @@ export class ERC20Wrapper {
}
public async deployDummyTokensAsync(): Promise<DummyERC20TokenContract[]> {
this._dummyTokenContracts = await Promise.all(
- _.times(constants.NUM_DUMMY_ERC20_TO_DEPLOY, () =>
+ _.times(constants.NUM_DUMMY_ERC20_TO_DEPLOY, async () =>
DummyERC20TokenContract.deployFrom0xArtifactAsync(
artifacts.DummyERC20Token,
this._provider,
@@ -45,7 +45,7 @@ export class ERC20Wrapper {
);
return this._proxyContract;
}
- public async setBalancesAndAllowancesAsync() {
+ public async setBalancesAndAllowancesAsync(): Promise<void> {
this._validateDummyTokenContractsExistOrThrow();
this._validateProxyContractExistsOrThrow();
const setBalancePromises: Array<Promise<string>> = [];
@@ -103,12 +103,12 @@ export class ERC20Wrapper {
const tokenAddresses = _.map(this._dummyTokenContracts, dummyTokenContract => dummyTokenContract.address);
return tokenAddresses;
}
- private _validateDummyTokenContractsExistOrThrow() {
+ private _validateDummyTokenContractsExistOrThrow(): void {
if (_.isUndefined(this._dummyTokenContracts)) {
throw new Error('Dummy ERC20 tokens not yet deployed, please call "deployDummyTokensAsync"');
}
}
- private _validateProxyContractExistsOrThrow() {
+ private _validateProxyContractExistsOrThrow(): void {
if (_.isUndefined(this._proxyContract)) {
throw new Error('ERC20 proxy contract not yet deployed, please call "deployProxyAsync"');
}
diff --git a/packages/contracts/src/utils/erc721_wrapper.ts b/packages/contracts/src/utils/erc721_wrapper.ts
index bf8953a49..aee796e4b 100644
--- a/packages/contracts/src/utils/erc721_wrapper.ts
+++ b/packages/contracts/src/utils/erc721_wrapper.ts
@@ -25,7 +25,7 @@ export class ERC721Wrapper {
}
public async deployDummyTokensAsync(): Promise<DummyERC721TokenContract[]> {
this._dummyTokenContracts = await Promise.all(
- _.times(constants.NUM_DUMMY_ERC721_TO_DEPLOY, () =>
+ _.times(constants.NUM_DUMMY_ERC721_TO_DEPLOY, async () =>
DummyERC721TokenContract.deployFrom0xArtifactAsync(
artifacts.DummyERC721Token,
this._provider,
@@ -45,7 +45,7 @@ export class ERC721Wrapper {
);
return this._proxyContract;
}
- public async setBalancesAndAllowancesAsync() {
+ public async setBalancesAndAllowancesAsync(): Promise<void> {
this._validateDummyTokenContractsExistOrThrow();
this._validateProxyContractExistsOrThrow();
const setBalancePromises: Array<Promise<string>> = [];
@@ -125,17 +125,17 @@ export class ERC721Wrapper {
const tokenAddresses = _.map(this._dummyTokenContracts, dummyTokenContract => dummyTokenContract.address);
return tokenAddresses;
}
- private _validateDummyTokenContractsExistOrThrow() {
+ private _validateDummyTokenContractsExistOrThrow(): void {
if (_.isUndefined(this._dummyTokenContracts)) {
throw new Error('Dummy ERC721 tokens not yet deployed, please call "deployDummyTokensAsync"');
}
}
- private _validateProxyContractExistsOrThrow() {
+ private _validateProxyContractExistsOrThrow(): void {
if (_.isUndefined(this._proxyContract)) {
throw new Error('ERC721 proxy contract not yet deployed, please call "deployProxyAsync"');
}
}
- private _validateBalancesAndAllowancesSetOrThrow() {
+ private _validateBalancesAndAllowancesSetOrThrow(): void {
if (_.keys(this._initialTokenIdsByOwner).length === 0) {
throw new Error(
'Dummy ERC721 balances and allowances not yet set, please call "setBalancesAndAllowancesAsync"',
diff --git a/packages/contracts/src/utils/exchange_wrapper.ts b/packages/contracts/src/utils/exchange_wrapper.ts
index 98d5e27f9..17445ff75 100644
--- a/packages/contracts/src/utils/exchange_wrapper.ts
+++ b/packages/contracts/src/utils/exchange_wrapper.ts
@@ -244,8 +244,8 @@ export class ExchangeWrapper {
const tx = await this._getTxWithDecodedExchangeLogsAsync(txHash);
return tx;
}
- private async _getTxWithDecodedExchangeLogsAsync(txHash: string) {
- const tx = await Web3Wrapper.awaitTransactionMinedAsync(txHash);
+ private async _getTxWithDecodedExchangeLogsAsync(txHash: string): Promise<TransactionReceiptWithDecodedLogs> {
+ const tx = await Web3Wrapper.awaitTransactionMinedAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
tx.logs = _.filter(tx.logs, log => log.address === this._exchange.address);
tx.logs = _.map(tx.logs, log => this._logDecoder.decodeLogOrThrow(log));
return tx;
diff --git a/packages/contracts/src/utils/formatters.ts b/packages/contracts/src/utils/formatters.ts
index e706c15b5..bfa48d6f1 100644
--- a/packages/contracts/src/utils/formatters.ts
+++ b/packages/contracts/src/utils/formatters.ts
@@ -5,7 +5,7 @@ import { orderUtils } from './order_utils';
import { BatchCancelOrders, BatchFillOrders, MarketBuyOrders, MarketSellOrders, SignedOrder } from './types';
export const formatters = {
- createBatchFill(signedOrders: SignedOrder[], takerAssetFillAmounts: BigNumber[] = []) {
+ createBatchFill(signedOrders: SignedOrder[], takerAssetFillAmounts: BigNumber[] = []): BatchFillOrders {
const batchFill: BatchFillOrders = {
orders: [],
signatures: [],
@@ -21,7 +21,7 @@ export const formatters = {
});
return batchFill;
},
- createMarketSellOrders(signedOrders: SignedOrder[], takerAssetFillAmount: BigNumber) {
+ createMarketSellOrders(signedOrders: SignedOrder[], takerAssetFillAmount: BigNumber): MarketSellOrders {
const marketSellOrders: MarketSellOrders = {
orders: [],
signatures: [],
@@ -34,7 +34,7 @@ export const formatters = {
});
return marketSellOrders;
},
- createMarketBuyOrders(signedOrders: SignedOrder[], makerAssetFillAmount: BigNumber) {
+ createMarketBuyOrders(signedOrders: SignedOrder[], makerAssetFillAmount: BigNumber): MarketBuyOrders {
const marketBuyOrders: MarketBuyOrders = {
orders: [],
signatures: [],
@@ -47,7 +47,7 @@ export const formatters = {
});
return marketBuyOrders;
},
- createBatchCancel(signedOrders: SignedOrder[]) {
+ createBatchCancel(signedOrders: SignedOrder[]): BatchCancelOrders {
const batchCancel: BatchCancelOrders = {
orders: [],
};
diff --git a/packages/contracts/src/utils/order_utils.ts b/packages/contracts/src/utils/order_utils.ts
index 7a482ad9e..8adc6b735 100644
--- a/packages/contracts/src/utils/order_utils.ts
+++ b/packages/contracts/src/utils/order_utils.ts
@@ -4,7 +4,7 @@ import ethUtil = require('ethereumjs-util');
import * as _ from 'lodash';
import { crypto } from './crypto';
-import { OrderStruct, SignatureType, SignedOrder, UnsignedOrder } from './types';
+import { CancelOrder, MatchOrder, OrderStruct, SignatureType, SignedOrder, UnsignedOrder } from './types';
export const orderUtils = {
createFill: (signedOrder: SignedOrder, takerAssetFillAmount?: BigNumber) => {
@@ -15,7 +15,7 @@ export const orderUtils = {
};
return fill;
},
- createCancel(signedOrder: SignedOrder, takerAssetCancelAmount?: BigNumber) {
+ createCancel(signedOrder: SignedOrder, takerAssetCancelAmount?: BigNumber): CancelOrder {
const cancel = {
order: orderUtils.getOrderStruct(signedOrder),
takerAssetCancelAmount: takerAssetCancelAmount || signedOrder.takerAssetAmount,
@@ -80,7 +80,7 @@ export const orderUtils = {
const orderHashHex = `0x${orderHashBuff.toString('hex')}`;
return orderHashHex;
},
- createMatchOrders(signedOrderLeft: SignedOrder, signedOrderRight: SignedOrder) {
+ createMatchOrders(signedOrderLeft: SignedOrder, signedOrderRight: SignedOrder): MatchOrder {
const fill = {
left: orderUtils.getOrderStruct(signedOrderLeft),
right: orderUtils.getOrderStruct(signedOrderRight),
diff --git a/packages/contracts/src/utils/types.ts b/packages/contracts/src/utils/types.ts
index 8d81adece..ef86b4f38 100644
--- a/packages/contracts/src/utils/types.ts
+++ b/packages/contracts/src/utils/types.ts
@@ -197,3 +197,15 @@ export interface ProxyData {
tokenAddress?: string;
data?: any;
}
+
+export interface CancelOrder {
+ order: OrderStruct;
+ takerAssetCancelAmount: BigNumber;
+}
+
+export interface MatchOrder {
+ left: OrderStruct;
+ right: OrderStruct;
+ leftSignature: string;
+ rightSignature: string;
+}
diff --git a/packages/contracts/test/asset_proxy/authorizable.ts b/packages/contracts/test/asset_proxy/authorizable.ts
index 636b9096b..52e9ea87f 100644
--- a/packages/contracts/test/asset_proxy/authorizable.ts
+++ b/packages/contracts/test/asset_proxy/authorizable.ts
@@ -20,6 +20,12 @@ describe('Authorizable', () => {
let address: string;
let authorizable: MixinAuthorizableContract;
before(async () => {
+ await blockchainLifecycle.startAsync();
+ });
+ after(async () => {
+ await blockchainLifecycle.revertAsync();
+ });
+ before(async () => {
const accounts = await web3Wrapper.getAvailableAddressesAsync();
owner = address = accounts[0];
notOwner = accounts[1];
@@ -42,12 +48,18 @@ describe('Authorizable', () => {
).to.be.rejectedWith(constants.REVERT);
});
it('should allow owner to add an authorized address', async () => {
- await authorizable.addAuthorizedAddress.sendTransactionAsync(address, { from: owner });
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await authorizable.addAuthorizedAddress.sendTransactionAsync(address, { from: owner }),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
const isAuthorized = await authorizable.authorized.callAsync(address);
expect(isAuthorized).to.be.true();
});
it('should throw if owner attempts to authorize a duplicate address', async () => {
- await authorizable.addAuthorizedAddress.sendTransactionAsync(address, { from: owner });
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await authorizable.addAuthorizedAddress.sendTransactionAsync(address, { from: owner }),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
return expect(
authorizable.addAuthorizedAddress.sendTransactionAsync(address, { from: owner }),
).to.be.rejectedWith(constants.REVERT);
@@ -56,7 +68,10 @@ describe('Authorizable', () => {
describe('removeAuthorizedAddress', () => {
it('should throw if not called by owner', async () => {
- await authorizable.addAuthorizedAddress.sendTransactionAsync(address, { from: owner });
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await authorizable.addAuthorizedAddress.sendTransactionAsync(address, { from: owner }),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
return expect(
authorizable.removeAuthorizedAddress.sendTransactionAsync(address, {
from: notOwner,
@@ -65,10 +80,16 @@ describe('Authorizable', () => {
});
it('should allow owner to remove an authorized address', async () => {
- await authorizable.addAuthorizedAddress.sendTransactionAsync(address, { from: owner });
- await authorizable.removeAuthorizedAddress.sendTransactionAsync(address, {
- from: owner,
- });
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await authorizable.addAuthorizedAddress.sendTransactionAsync(address, { from: owner }),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await authorizable.removeAuthorizedAddress.sendTransactionAsync(address, {
+ from: owner,
+ }),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
const isAuthorized = await authorizable.authorized.callAsync(address);
expect(isAuthorized).to.be.false();
});
@@ -86,16 +107,22 @@ describe('Authorizable', () => {
it('should return all authorized addresses', async () => {
const initial = await authorizable.getAuthorizedAddresses.callAsync();
expect(initial).to.have.length(0);
- await authorizable.addAuthorizedAddress.sendTransactionAsync(address, {
- from: owner,
- });
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await authorizable.addAuthorizedAddress.sendTransactionAsync(address, {
+ from: owner,
+ }),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
const afterAdd = await authorizable.getAuthorizedAddresses.callAsync();
expect(afterAdd).to.have.length(1);
expect(afterAdd).to.include(address);
- await authorizable.removeAuthorizedAddress.sendTransactionAsync(address, {
- from: owner,
- });
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await authorizable.removeAuthorizedAddress.sendTransactionAsync(address, {
+ from: owner,
+ }),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
const afterRemove = await authorizable.getAuthorizedAddresses.callAsync();
expect(afterRemove).to.have.length(0);
});
diff --git a/packages/contracts/test/asset_proxy/proxies.ts b/packages/contracts/test/asset_proxy/proxies.ts
index 3c72968d3..4ee38db80 100644
--- a/packages/contracts/test/asset_proxy/proxies.ts
+++ b/packages/contracts/test/asset_proxy/proxies.ts
@@ -37,6 +37,12 @@ describe('Asset Transfer Proxies', () => {
let erc721MakerTokenId: BigNumber;
before(async () => {
+ await blockchainLifecycle.startAsync();
+ });
+ after(async () => {
+ await blockchainLifecycle.revertAsync();
+ });
+ before(async () => {
const accounts = await web3Wrapper.getAvailableAddressesAsync();
const usedAddresses = ([owner, notAuthorized, exchangeAddress, makerAddress, takerAddress] = accounts);
@@ -46,18 +52,24 @@ describe('Asset Transfer Proxies', () => {
[zrxToken] = await erc20Wrapper.deployDummyTokensAsync();
erc20Proxy = await erc20Wrapper.deployProxyAsync();
await erc20Wrapper.setBalancesAndAllowancesAsync();
- await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(exchangeAddress, {
- from: owner,
- });
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(exchangeAddress, {
+ from: owner,
+ }),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
[erc721Token] = await erc721Wrapper.deployDummyTokensAsync();
erc721Proxy = await erc721Wrapper.deployProxyAsync();
await erc721Wrapper.setBalancesAndAllowancesAsync();
const erc721Balances = await erc721Wrapper.getBalancesAsync();
erc721MakerTokenId = erc721Balances[makerAddress][erc721Token.address][0];
- await erc721Proxy.addAuthorizedAddress.sendTransactionAsync(exchangeAddress, {
- from: owner,
- });
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await erc721Proxy.addAuthorizedAddress.sendTransactionAsync(exchangeAddress, {
+ from: owner,
+ }),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
});
beforeEach(async () => {
await blockchainLifecycle.startAsync();
@@ -73,12 +85,15 @@ describe('Asset Transfer Proxies', () => {
// Perform a transfer from makerAddress to takerAddress
const erc20Balances = await erc20Wrapper.getBalancesAsync();
const amount = new BigNumber(10);
- await erc20Proxy.transferFrom.sendTransactionAsync(
- encodedProxyMetadata,
- makerAddress,
- takerAddress,
- amount,
- { from: exchangeAddress },
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await erc20Proxy.transferFrom.sendTransactionAsync(
+ encodedProxyMetadata,
+ makerAddress,
+ takerAddress,
+ amount,
+ { from: exchangeAddress },
+ ),
+ constants.AWAIT_TRANSACTION_MINED_MS,
);
// Verify transfer was successful
const newBalances = await erc20Wrapper.getBalancesAsync();
@@ -96,12 +111,15 @@ describe('Asset Transfer Proxies', () => {
// Perform a transfer from makerAddress to takerAddress
const erc20Balances = await erc20Wrapper.getBalancesAsync();
const amount = new BigNumber(0);
- await erc20Proxy.transferFrom.sendTransactionAsync(
- encodedProxyMetadata,
- makerAddress,
- takerAddress,
- amount,
- { from: exchangeAddress },
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await erc20Proxy.transferFrom.sendTransactionAsync(
+ encodedProxyMetadata,
+ makerAddress,
+ takerAddress,
+ amount,
+ { from: exchangeAddress },
+ ),
+ constants.AWAIT_TRANSACTION_MINED_MS,
);
// Verify transfer was successful
const newBalances = await erc20Wrapper.getBalancesAsync();
@@ -119,9 +137,12 @@ describe('Asset Transfer Proxies', () => {
// Create allowance less than transfer amount. Set allowance on proxy.
const allowance = new BigNumber(0);
const transferAmount = new BigNumber(10);
- await zrxToken.approve.sendTransactionAsync(erc20Proxy.address, allowance, {
- from: makerAddress,
- });
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await zrxToken.approve.sendTransactionAsync(erc20Proxy.address, allowance, {
+ from: makerAddress,
+ }),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
// Perform a transfer; expect this to fail.
return expect(
erc20Proxy.transferFrom.sendTransactionAsync(
@@ -172,7 +193,7 @@ describe('Asset Transfer Proxies', () => {
amounts,
{ from: exchangeAddress },
);
- const res = await web3Wrapper.awaitTransactionMinedAsync(txHash);
+ const res = await web3Wrapper.awaitTransactionMinedAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
const newBalances = await erc20Wrapper.getBalancesAsync();
expect(res.logs.length).to.equal(numTransfers);
@@ -193,7 +214,7 @@ describe('Asset Transfer Proxies', () => {
const toAddresses = _.times(numTransfers, () => takerAddress);
const amounts = _.times(numTransfers, () => amount);
- expect(
+ return expect(
erc20Proxy.batchTransferFrom.sendTransactionAsync(
assetMetadata,
fromAddresses,
@@ -225,12 +246,15 @@ describe('Asset Transfer Proxies', () => {
// Perform a transfer from makerAddress to takerAddress
const erc20Balances = await erc20Wrapper.getBalancesAsync();
const amount = new BigNumber(1);
- await erc721Proxy.transferFrom.sendTransactionAsync(
- encodedProxyMetadata,
- makerAddress,
- takerAddress,
- amount,
- { from: exchangeAddress },
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await erc721Proxy.transferFrom.sendTransactionAsync(
+ encodedProxyMetadata,
+ makerAddress,
+ takerAddress,
+ amount,
+ { from: exchangeAddress },
+ ),
+ constants.AWAIT_TRANSACTION_MINED_MS,
);
// Verify transfer was successful
const newOwnerMakerAsset = await erc721Token.ownerOf.callAsync(erc721MakerTokenId);
@@ -290,9 +314,12 @@ describe('Asset Transfer Proxies', () => {
erc721MakerTokenId,
);
// Remove transfer approval for makerAddress.
- await erc721Token.setApprovalForAll.sendTransactionAsync(erc721Proxy.address, false, {
- from: makerAddress,
- });
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await erc721Token.setApprovalForAll.sendTransactionAsync(erc721Proxy.address, false, {
+ from: makerAddress,
+ }),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
// Perform a transfer; expect this to fail.
const amount = new BigNumber(1);
return expect(
@@ -349,7 +376,7 @@ describe('Asset Transfer Proxies', () => {
amounts,
{ from: exchangeAddress },
);
- const res = await web3Wrapper.awaitTransactionMinedAsync(txHash);
+ const res = await web3Wrapper.awaitTransactionMinedAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
expect(res.logs.length).to.equal(numTransfers);
const newOwnerMakerAssetA = await erc721Token.ownerOf.callAsync(makerTokenIdA);
@@ -371,7 +398,7 @@ describe('Asset Transfer Proxies', () => {
const toAddresses = _.times(numTransfers, () => takerAddress);
const amounts = _.times(numTransfers, () => new BigNumber(1));
- expect(
+ return expect(
erc721Proxy.batchTransferFrom.sendTransactionAsync(
assetMetadata,
fromAddresses,
diff --git a/packages/contracts/test/ether_token.ts b/packages/contracts/test/ether_token.ts
index a71d96cb8..4c85147df 100644
--- a/packages/contracts/test/ether_token.ts
+++ b/packages/contracts/test/ether_token.ts
@@ -21,6 +21,13 @@ describe('EtherToken', () => {
const gasPrice = Web3Wrapper.toBaseUnitAmount(new BigNumber(20), 9);
let zeroEx: ZeroEx;
let etherTokenAddress: string;
+
+ before(async () => {
+ await blockchainLifecycle.startAsync();
+ });
+ after(async () => {
+ await blockchainLifecycle.revertAsync();
+ });
before(async () => {
const accounts = await web3Wrapper.getAvailableAddressesAsync();
account = accounts[0];
@@ -55,7 +62,7 @@ describe('EtherToken', () => {
const ethToDeposit = new BigNumber(Web3Wrapper.toWei(new BigNumber(1)));
const txHash = await zeroEx.etherToken.depositAsync(etherTokenAddress, ethToDeposit, account);
- const receipt = await zeroEx.awaitTransactionMinedAsync(txHash);
+ const receipt = await zeroEx.awaitTransactionMinedAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
const ethSpentOnGas = gasPrice.times(receipt.gasUsed);
const finalEthBalance = await web3Wrapper.getBalanceInWeiAsync(account);
@@ -86,7 +93,7 @@ describe('EtherToken', () => {
const txHash = await zeroEx.etherToken.withdrawAsync(etherTokenAddress, ethTokensToWithdraw, account, {
gasLimit: constants.MAX_ETHERTOKEN_WITHDRAW_GAS,
});
- const receipt = await zeroEx.awaitTransactionMinedAsync(txHash);
+ const receipt = await zeroEx.awaitTransactionMinedAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
const ethSpentOnGas = gasPrice.times(receipt.gasUsed);
const finalEthBalance = await web3Wrapper.getBalanceInWeiAsync(account);
@@ -113,7 +120,7 @@ describe('EtherToken', () => {
gasPrice,
});
- const receipt = await zeroEx.awaitTransactionMinedAsync(txHash);
+ const receipt = await zeroEx.awaitTransactionMinedAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
const ethSpentOnGas = gasPrice.times(receipt.gasUsed);
const finalEthBalance = await web3Wrapper.getBalanceInWeiAsync(account);
diff --git a/packages/contracts/test/exchange/core.ts b/packages/contracts/test/exchange/core.ts
index a8a402555..a54ec7692 100644
--- a/packages/contracts/test/exchange/core.ts
+++ b/packages/contracts/test/exchange/core.ts
@@ -63,6 +63,12 @@ describe('Exchange core', () => {
let zeroEx: ZeroEx;
before(async () => {
+ await blockchainLifecycle.startAsync();
+ });
+ after(async () => {
+ await blockchainLifecycle.revertAsync();
+ });
+ before(async () => {
const accounts = await web3Wrapper.getAvailableAddressesAsync();
const usedAddresses = ([owner, makerAddress, takerAddress, feeRecipientAddress] = accounts);
@@ -94,12 +100,18 @@ describe('Exchange core', () => {
await exchangeWrapper.registerAssetProxyAsync(AssetProxyId.ERC20, erc20Proxy.address, owner);
await exchangeWrapper.registerAssetProxyAsync(AssetProxyId.ERC721, erc721Proxy.address, owner);
- await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, {
- from: owner,
- });
- await erc721Proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, {
- from: owner,
- });
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, {
+ from: owner,
+ }),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await erc721Proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, {
+ from: owner,
+ }),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
defaultMakerAssetAddress = erc20TokenA.address;
defaultTakerAssetAddress = erc20TokenB.address;
@@ -521,23 +533,39 @@ describe('Exchange core', () => {
});
it('should throw if maker allowances are too low to fill order', async () => {
- await erc20TokenA.approve.sendTransactionAsync(erc20Proxy.address, new BigNumber(0), {
- from: makerAddress,
- });
- expect(exchangeWrapper.fillOrderAsync(signedOrder, takerAddress)).to.be.rejectedWith(constants.REVERT);
- await erc20TokenA.approve.sendTransactionAsync(erc20Proxy.address, constants.INITIAL_ERC20_ALLOWANCE, {
- from: makerAddress,
- });
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await erc20TokenA.approve.sendTransactionAsync(erc20Proxy.address, new BigNumber(0), {
+ from: makerAddress,
+ }),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
+ await expect(exchangeWrapper.fillOrderAsync(signedOrder, takerAddress)).to.be.rejectedWith(
+ constants.REVERT,
+ );
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await erc20TokenA.approve.sendTransactionAsync(erc20Proxy.address, constants.INITIAL_ERC20_ALLOWANCE, {
+ from: makerAddress,
+ }),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
});
it('should throw if taker allowances are too low to fill order', async () => {
- await erc20TokenB.approve.sendTransactionAsync(erc20Proxy.address, new BigNumber(0), {
- from: takerAddress,
- });
- expect(exchangeWrapper.fillOrderAsync(signedOrder, takerAddress)).to.be.rejectedWith(constants.REVERT);
- await erc20TokenB.approve.sendTransactionAsync(erc20Proxy.address, constants.INITIAL_ERC20_ALLOWANCE, {
- from: takerAddress,
- });
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await erc20TokenB.approve.sendTransactionAsync(erc20Proxy.address, new BigNumber(0), {
+ from: takerAddress,
+ }),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
+ await expect(exchangeWrapper.fillOrderAsync(signedOrder, takerAddress)).to.be.rejectedWith(
+ constants.REVERT,
+ );
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await erc20TokenB.approve.sendTransactionAsync(erc20Proxy.address, constants.INITIAL_ERC20_ALLOWANCE, {
+ from: takerAddress,
+ }),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
});
it('should not change erc20Balances if an order is expired', async () => {
diff --git a/packages/contracts/test/exchange/dispatcher.ts b/packages/contracts/test/exchange/dispatcher.ts
index 3a09eb122..a2238bd10 100644
--- a/packages/contracts/test/exchange/dispatcher.ts
+++ b/packages/contracts/test/exchange/dispatcher.ts
@@ -36,6 +36,12 @@ describe('AssetProxyDispatcher', () => {
let erc721Wrapper: ERC721Wrapper;
before(async () => {
+ await blockchainLifecycle.startAsync();
+ });
+ after(async () => {
+ await blockchainLifecycle.revertAsync();
+ });
+ before(async () => {
// Setup accounts & addresses
const accounts = await web3Wrapper.getAvailableAddressesAsync();
const usedAddresses = ([owner, notOwner, makerAddress, takerAddress] = accounts);
@@ -55,12 +61,18 @@ describe('AssetProxyDispatcher', () => {
provider,
txDefaults,
);
- await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(assetProxyDispatcher.address, {
- from: owner,
- });
- await erc721Proxy.addAuthorizedAddress.sendTransactionAsync(assetProxyDispatcher.address, {
- from: owner,
- });
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(assetProxyDispatcher.address, {
+ from: owner,
+ }),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await erc721Proxy.addAuthorizedAddress.sendTransactionAsync(assetProxyDispatcher.address, {
+ from: owner,
+ }),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
});
beforeEach(async () => {
await blockchainLifecycle.startAsync();
@@ -71,11 +83,14 @@ describe('AssetProxyDispatcher', () => {
describe('registerAssetProxy', () => {
it('should record proxy upon registration', async () => {
const prevProxyAddress = constants.NULL_ADDRESS;
- await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
- AssetProxyId.ERC20,
- erc20Proxy.address,
- prevProxyAddress,
- { from: owner },
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
+ AssetProxyId.ERC20,
+ erc20Proxy.address,
+ prevProxyAddress,
+ { from: owner },
+ ),
+ constants.AWAIT_TRANSACTION_MINED_MS,
);
const proxyAddress = await assetProxyDispatcher.getAssetProxy.callAsync(AssetProxyId.ERC20);
expect(proxyAddress).to.be.equal(erc20Proxy.address);
@@ -84,21 +99,27 @@ describe('AssetProxyDispatcher', () => {
it('should be able to record multiple proxies', async () => {
// Record first proxy
const prevERC20ProxyAddress = constants.NULL_ADDRESS;
- await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
- AssetProxyId.ERC20,
- erc20Proxy.address,
- prevERC20ProxyAddress,
- { from: owner },
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
+ AssetProxyId.ERC20,
+ erc20Proxy.address,
+ prevERC20ProxyAddress,
+ { from: owner },
+ ),
+ constants.AWAIT_TRANSACTION_MINED_MS,
);
let proxyAddress = await assetProxyDispatcher.getAssetProxy.callAsync(AssetProxyId.ERC20);
expect(proxyAddress).to.be.equal(erc20Proxy.address);
// Record another proxy
const prevERC721ProxyAddress = constants.NULL_ADDRESS;
- await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
- AssetProxyId.ERC721,
- erc721Proxy.address,
- prevERC721ProxyAddress,
- { from: owner },
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
+ AssetProxyId.ERC721,
+ erc721Proxy.address,
+ prevERC721ProxyAddress,
+ { from: owner },
+ ),
+ constants.AWAIT_TRANSACTION_MINED_MS,
);
proxyAddress = await assetProxyDispatcher.getAssetProxy.callAsync(AssetProxyId.ERC721);
expect(proxyAddress).to.be.equal(erc721Proxy.address);
@@ -107,11 +128,14 @@ describe('AssetProxyDispatcher', () => {
it('should replace proxy address upon re-registration', async () => {
// Initial registration
const prevProxyAddress = constants.NULL_ADDRESS;
- await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
- AssetProxyId.ERC20,
- erc20Proxy.address,
- prevProxyAddress,
- { from: owner },
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
+ AssetProxyId.ERC20,
+ erc20Proxy.address,
+ prevProxyAddress,
+ { from: owner },
+ ),
+ constants.AWAIT_TRANSACTION_MINED_MS,
);
let proxyAddress = await assetProxyDispatcher.getAssetProxy.callAsync(AssetProxyId.ERC20);
expect(proxyAddress).to.be.equal(erc20Proxy.address);
@@ -124,11 +148,14 @@ describe('AssetProxyDispatcher', () => {
// Register new ERC20 Transfer Proxy contract
const newAddress = newErc20TransferProxy.address;
const currentAddress = erc20Proxy.address;
- await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
- AssetProxyId.ERC20,
- newAddress,
- currentAddress,
- { from: owner },
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
+ AssetProxyId.ERC20,
+ newAddress,
+ currentAddress,
+ { from: owner },
+ ),
+ constants.AWAIT_TRANSACTION_MINED_MS,
);
// Verify new asset proxy has replaced initial version
proxyAddress = await assetProxyDispatcher.getAssetProxy.callAsync(AssetProxyId.ERC20);
@@ -138,11 +165,14 @@ describe('AssetProxyDispatcher', () => {
it('should throw if registering with incorrect "currentAssetProxyAddress" field', async () => {
// Initial registration
const prevProxyAddress = constants.NULL_ADDRESS;
- await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
- AssetProxyId.ERC20,
- erc20Proxy.address,
- prevProxyAddress,
- { from: owner },
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
+ AssetProxyId.ERC20,
+ erc20Proxy.address,
+ prevProxyAddress,
+ { from: owner },
+ ),
+ constants.AWAIT_TRANSACTION_MINED_MS,
);
const proxyAddress = await assetProxyDispatcher.getAssetProxy.callAsync(AssetProxyId.ERC20);
expect(proxyAddress).to.be.equal(erc20Proxy.address);
@@ -160,21 +190,27 @@ describe('AssetProxyDispatcher', () => {
it('should be able to reset proxy address to NULL', async () => {
// Initial registration
const prevProxyAddress = constants.NULL_ADDRESS;
- await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
- AssetProxyId.ERC20,
- erc20Proxy.address,
- prevProxyAddress,
- { from: owner },
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
+ AssetProxyId.ERC20,
+ erc20Proxy.address,
+ prevProxyAddress,
+ { from: owner },
+ ),
+ constants.AWAIT_TRANSACTION_MINED_MS,
);
const proxyAddress = await assetProxyDispatcher.getAssetProxy.callAsync(AssetProxyId.ERC20);
expect(proxyAddress).to.be.equal(erc20Proxy.address);
// The following transaction will reset the proxy address
const newProxyAddress = constants.NULL_ADDRESS;
- await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
- AssetProxyId.ERC20,
- newProxyAddress,
- erc20Proxy.address,
- { from: owner },
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
+ AssetProxyId.ERC20,
+ newProxyAddress,
+ erc20Proxy.address,
+ { from: owner },
+ ),
+ constants.AWAIT_TRANSACTION_MINED_MS,
);
const finalProxyAddress = await assetProxyDispatcher.getAssetProxy.callAsync(AssetProxyId.ERC20);
expect(finalProxyAddress).to.be.equal(newProxyAddress);
@@ -208,11 +244,14 @@ describe('AssetProxyDispatcher', () => {
describe('getAssetProxy', () => {
it('should return correct address of registered proxy', async () => {
const prevProxyAddress = constants.NULL_ADDRESS;
- await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
- AssetProxyId.ERC20,
- erc20Proxy.address,
- prevProxyAddress,
- { from: owner },
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
+ AssetProxyId.ERC20,
+ erc20Proxy.address,
+ prevProxyAddress,
+ { from: owner },
+ ),
+ constants.AWAIT_TRANSACTION_MINED_MS,
);
const proxyAddress = await assetProxyDispatcher.getAssetProxy.callAsync(AssetProxyId.ERC20);
expect(proxyAddress).to.be.equal(erc20Proxy.address);
@@ -228,23 +267,29 @@ describe('AssetProxyDispatcher', () => {
it('should dispatch transfer to registered proxy', async () => {
// Register ERC20 proxy
const prevProxyAddress = constants.NULL_ADDRESS;
- await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
- AssetProxyId.ERC20,
- erc20Proxy.address,
- prevProxyAddress,
- { from: owner },
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await assetProxyDispatcher.registerAssetProxy.sendTransactionAsync(
+ AssetProxyId.ERC20,
+ erc20Proxy.address,
+ prevProxyAddress,
+ { from: owner },
+ ),
+ constants.AWAIT_TRANSACTION_MINED_MS,
);
// Construct metadata for ERC20 proxy
const encodedProxyMetadata = assetProxyUtils.encodeERC20ProxyData(zrxToken.address);
// Perform a transfer from makerAddress to takerAddress
const erc20Balances = await erc20Wrapper.getBalancesAsync();
const amount = new BigNumber(10);
- await assetProxyDispatcher.publicDispatchTransferFrom.sendTransactionAsync(
- encodedProxyMetadata,
- makerAddress,
- takerAddress,
- amount,
- { from: owner },
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await assetProxyDispatcher.publicDispatchTransferFrom.sendTransactionAsync(
+ encodedProxyMetadata,
+ makerAddress,
+ takerAddress,
+ amount,
+ { from: owner },
+ ),
+ constants.AWAIT_TRANSACTION_MINED_MS,
);
// Verify transfer was successful
const newBalances = await erc20Wrapper.getBalancesAsync();
diff --git a/packages/contracts/test/exchange/libs.ts b/packages/contracts/test/exchange/libs.ts
index 9af5916dd..5c530a9b1 100644
--- a/packages/contracts/test/exchange/libs.ts
+++ b/packages/contracts/test/exchange/libs.ts
@@ -25,6 +25,12 @@ describe('Exchange libs', () => {
let libs: TestLibsContract;
before(async () => {
+ await blockchainLifecycle.startAsync();
+ });
+ after(async () => {
+ await blockchainLifecycle.revertAsync();
+ });
+ before(async () => {
const accounts = await web3Wrapper.getAvailableAddressesAsync();
const makerAddress = accounts[0];
libs = await TestLibsContract.deployFrom0xArtifactAsync(artifacts.TestLibs, provider, txDefaults);
diff --git a/packages/contracts/test/exchange/match_orders.ts b/packages/contracts/test/exchange/match_orders.ts
index bdf4f54fb..9f8f6db44 100644
--- a/packages/contracts/test/exchange/match_orders.ts
+++ b/packages/contracts/test/exchange/match_orders.ts
@@ -78,6 +78,12 @@ describe('matchOrders', () => {
let matchOrderTester: MatchOrderTester;
before(async () => {
+ await blockchainLifecycle.startAsync();
+ });
+ after(async () => {
+ await blockchainLifecycle.revertAsync();
+ });
+ before(async () => {
// Create accounts
const accounts = await web3Wrapper.getAvailableAddressesAsync();
const usedAddresses = ([
@@ -114,12 +120,18 @@ describe('matchOrders', () => {
await exchangeWrapper.registerAssetProxyAsync(AssetProxyId.ERC20, erc20Proxy.address, owner);
await exchangeWrapper.registerAssetProxyAsync(AssetProxyId.ERC721, erc721Proxy.address, owner);
// Authorize ERC20 and ERC721 trades by exchange
- await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, {
- from: owner,
- });
- await erc721Proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, {
- from: owner,
- });
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, {
+ from: owner,
+ }),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await erc721Proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, {
+ from: owner,
+ }),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
// Set default addresses
defaultERC20MakerAssetAddress = erc20TokenA.address;
defaultERC20TakerAssetAddress = erc20TokenB.address;
diff --git a/packages/contracts/test/exchange/signature_validator.ts b/packages/contracts/test/exchange/signature_validator.ts
index 7dac28c17..91614c666 100644
--- a/packages/contracts/test/exchange/signature_validator.ts
+++ b/packages/contracts/test/exchange/signature_validator.ts
@@ -25,6 +25,12 @@ describe('MixinSignatureValidator', () => {
let signatureValidator: TestSignatureValidatorContract;
before(async () => {
+ await blockchainLifecycle.startAsync();
+ });
+ after(async () => {
+ await blockchainLifecycle.revertAsync();
+ });
+ before(async () => {
const accounts = await web3Wrapper.getAvailableAddressesAsync();
const makerAddress = accounts[0];
signatureValidator = await TestSignatureValidatorContract.deployFrom0xArtifactAsync(
@@ -60,12 +66,12 @@ describe('MixinSignatureValidator', () => {
it('should return true with a valid signature', async () => {
const orderHashHex = orderUtils.getOrderHashHex(signedOrder);
- const success = await signatureValidator.publicIsValidSignature.callAsync(
+ const isValidSignature = await signatureValidator.publicIsValidSignature.callAsync(
orderHashHex,
signedOrder.makerAddress,
signedOrder.signature,
);
- expect(success).to.be.true();
+ expect(isValidSignature).to.be.true();
});
it('should return false with an invalid signature', async () => {
@@ -79,12 +85,12 @@ describe('MixinSignatureValidator', () => {
const invalidSigHex = `0x${invalidSigBuff.toString('hex')}`;
signedOrder.signature = invalidSigHex;
const orderHashHex = orderUtils.getOrderHashHex(signedOrder);
- const success = await signatureValidator.publicIsValidSignature.callAsync(
+ const isValidSignature = await signatureValidator.publicIsValidSignature.callAsync(
orderHashHex,
signedOrder.makerAddress,
signedOrder.signature,
);
- expect(success).to.be.false();
+ expect(isValidSignature).to.be.false();
});
});
});
diff --git a/packages/contracts/test/exchange/transactions.ts b/packages/contracts/test/exchange/transactions.ts
index cd18b60ed..42e2429bb 100644
--- a/packages/contracts/test/exchange/transactions.ts
+++ b/packages/contracts/test/exchange/transactions.ts
@@ -58,6 +58,12 @@ describe('Exchange transactions', () => {
let defaultTakerTokenAddress: string;
before(async () => {
+ await blockchainLifecycle.startAsync();
+ });
+ after(async () => {
+ await blockchainLifecycle.revertAsync();
+ });
+ before(async () => {
const accounts = await web3Wrapper.getAvailableAddressesAsync();
const usedAddresses = ([owner, senderAddress, makerAddress, takerAddress, feeRecipientAddress] = accounts);
@@ -76,7 +82,10 @@ describe('Exchange transactions', () => {
exchangeWrapper = new ExchangeWrapper(exchange);
await exchangeWrapper.registerAssetProxyAsync(AssetProxyId.ERC20, erc20Proxy.address, owner);
- await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, { from: owner });
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, { from: owner }),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
defaultMakerTokenAddress = erc20TokenA.address;
defaultTakerTokenAddress = erc20TokenB.address;
diff --git a/packages/contracts/test/exchange/wrapper.ts b/packages/contracts/test/exchange/wrapper.ts
index 4ff530874..99f23a5db 100644
--- a/packages/contracts/test/exchange/wrapper.ts
+++ b/packages/contracts/test/exchange/wrapper.ts
@@ -54,6 +54,12 @@ describe('Exchange wrappers', () => {
let defaultTakerAssetAddress: string;
before(async () => {
+ await blockchainLifecycle.startAsync();
+ });
+ after(async () => {
+ await blockchainLifecycle.revertAsync();
+ });
+ before(async () => {
const accounts = await web3Wrapper.getAvailableAddressesAsync();
const usedAddresses = ([owner, makerAddress, takerAddress, feeRecipientAddress] = accounts);
@@ -81,12 +87,18 @@ describe('Exchange wrappers', () => {
await exchangeWrapper.registerAssetProxyAsync(AssetProxyId.ERC20, erc20Proxy.address, owner);
await exchangeWrapper.registerAssetProxyAsync(AssetProxyId.ERC721, erc721Proxy.address, owner);
- await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, {
- from: owner,
- });
- await erc721Proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, {
- from: owner,
- });
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await erc20Proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, {
+ from: owner,
+ }),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await erc721Proxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, {
+ from: owner,
+ }),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
defaultMakerAssetAddress = erc20TokenA.address;
defaultTakerAssetAddress = erc20TokenB.address;
@@ -244,13 +256,19 @@ describe('Exchange wrappers', () => {
it('should not change erc20Balances if maker allowances are too low to fill order', async () => {
const signedOrder = orderFactory.newSignedOrder();
- await erc20TokenA.approve.sendTransactionAsync(erc20Proxy.address, new BigNumber(0), {
- from: makerAddress,
- });
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await erc20TokenA.approve.sendTransactionAsync(erc20Proxy.address, new BigNumber(0), {
+ from: makerAddress,
+ }),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
await exchangeWrapper.fillOrderNoThrowAsync(signedOrder, takerAddress);
- await erc20TokenA.approve.sendTransactionAsync(erc20Proxy.address, constants.INITIAL_ERC20_ALLOWANCE, {
- from: makerAddress,
- });
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await erc20TokenA.approve.sendTransactionAsync(erc20Proxy.address, constants.INITIAL_ERC20_ALLOWANCE, {
+ from: makerAddress,
+ }),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
const newBalances = await erc20Wrapper.getBalancesAsync();
expect(newBalances).to.be.deep.equal(erc20Balances);
@@ -258,13 +276,19 @@ describe('Exchange wrappers', () => {
it('should not change erc20Balances if taker allowances are too low to fill order', async () => {
const signedOrder = orderFactory.newSignedOrder();
- await erc20TokenB.approve.sendTransactionAsync(erc20Proxy.address, new BigNumber(0), {
- from: takerAddress,
- });
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await erc20TokenB.approve.sendTransactionAsync(erc20Proxy.address, new BigNumber(0), {
+ from: takerAddress,
+ }),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
await exchangeWrapper.fillOrderNoThrowAsync(signedOrder, takerAddress);
- await erc20TokenB.approve.sendTransactionAsync(erc20Proxy.address, constants.INITIAL_ERC20_ALLOWANCE, {
- from: takerAddress,
- });
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await erc20TokenB.approve.sendTransactionAsync(erc20Proxy.address, constants.INITIAL_ERC20_ALLOWANCE, {
+ from: takerAddress,
+ }),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
const newBalances = await erc20Wrapper.getBalancesAsync();
expect(newBalances).to.be.deep.equal(erc20Balances);
diff --git a/packages/contracts/test/libraries/lib_bytes.ts b/packages/contracts/test/libraries/lib_bytes.ts
index d0e553939..ce3adbdae 100644
--- a/packages/contracts/test/libraries/lib_bytes.ts
+++ b/packages/contracts/test/libraries/lib_bytes.ts
@@ -33,6 +33,12 @@ describe('LibBytes', () => {
const testUint256 = new BigNumber(testBytes32, 16);
before(async () => {
+ await blockchainLifecycle.startAsync();
+ });
+ after(async () => {
+ await blockchainLifecycle.revertAsync();
+ });
+ before(async () => {
// Setup accounts & addresses
const accounts = await web3Wrapper.getAvailableAddressesAsync();
owner = accounts[0];
diff --git a/packages/contracts/test/multi_sig_with_time_lock.ts b/packages/contracts/test/multi_sig_with_time_lock.ts
index 771bae8af..6f18de3e7 100644
--- a/packages/contracts/test/multi_sig_with_time_lock.ts
+++ b/packages/contracts/test/multi_sig_with_time_lock.ts
@@ -44,6 +44,12 @@ describe('MultiSigWalletWithTimeLock', () => {
describe('changeTimeLock', () => {
describe('initially non-time-locked', async () => {
+ before(async () => {
+ await blockchainLifecycle.startAsync();
+ });
+ after(async () => {
+ await blockchainLifecycle.revertAsync();
+ });
before('deploy a wallet', async () => {
multiSig = await MultiSigWalletWithTimeLockContract.deployFrom0xArtifactAsync(
artifacts.MultiSigWalletWithTimeLock,
@@ -73,8 +79,11 @@ describe('MultiSigWalletWithTimeLock', () => {
args: [SECONDS_TIME_LOCKED.toNumber()],
};
const txHash = await multiSigWrapper.submitTransactionAsync(destination, from, dataParams);
- const subRes = await web3Wrapper.awaitTransactionMinedAsync(txHash);
- const log = abiDecoder.tryToDecodeLogOrNoop(subRes.logs[0]) as LogWithDecodedArgs<
+ const txReceipt = await web3Wrapper.awaitTransactionMinedAsync(
+ txHash,
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
+ const log = abiDecoder.tryToDecodeLogOrNoop(txReceipt.logs[0]) as LogWithDecodedArgs<
SubmissionContractEventArgs
>;
@@ -93,14 +102,17 @@ describe('MultiSigWalletWithTimeLock', () => {
args: [SECONDS_TIME_LOCKED.toNumber()],
};
let txHash = await multiSigWrapper.submitTransactionAsync(destination, from, dataParams);
- const subRes = await web3Wrapper.awaitTransactionMinedAsync(txHash);
- const log = abiDecoder.tryToDecodeLogOrNoop(subRes.logs[0]) as LogWithDecodedArgs<
+ const txReceipt = await web3Wrapper.awaitTransactionMinedAsync(
+ txHash,
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
+ const log = abiDecoder.tryToDecodeLogOrNoop(txReceipt.logs[0]) as LogWithDecodedArgs<
SubmissionContractEventArgs
>;
txId = log.args.transactionId;
txHash = await multiSig.confirmTransaction.sendTransactionAsync(txId, { from: owners[1] });
- const res = await web3Wrapper.awaitTransactionMinedAsync(txHash);
+ const res = await web3Wrapper.awaitTransactionMinedAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
expect(res.logs).to.have.length(2);
const blockNum = await web3Wrapper.getBlockNumberAsync();
@@ -120,18 +132,22 @@ describe('MultiSigWalletWithTimeLock', () => {
args: [SECONDS_TIME_LOCKED.toNumber()],
};
let txHash = await multiSigWrapper.submitTransactionAsync(destination, from, dataParams);
- const subRes = await web3Wrapper.awaitTransactionMinedAsync(txHash);
- const log = abiDecoder.tryToDecodeLogOrNoop(subRes.logs[0]) as LogWithDecodedArgs<
+ const txReceipt = await web3Wrapper.awaitTransactionMinedAsync(
+ txHash,
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
+ const log = abiDecoder.tryToDecodeLogOrNoop(txReceipt.logs[0]) as LogWithDecodedArgs<
SubmissionContractEventArgs
>;
txId = log.args.transactionId;
txHash = await multiSig.confirmTransaction.sendTransactionAsync(txId, { from: owners[1] });
+ await web3Wrapper.awaitTransactionMinedAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
expect(initialSecondsTimeLocked).to.be.equal(0);
txHash = await multiSig.executeTransaction.sendTransactionAsync(txId, { from: owners[0] });
- const res = await web3Wrapper.awaitTransactionMinedAsync(txHash);
+ const res = await web3Wrapper.awaitTransactionMinedAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
expect(res.logs).to.have.length(2);
const secondsTimeLocked = new BigNumber(await multiSig.secondsTimeLocked.callAsync());
@@ -139,6 +155,12 @@ describe('MultiSigWalletWithTimeLock', () => {
});
});
describe('initially time-locked', async () => {
+ before(async () => {
+ await blockchainLifecycle.startAsync();
+ });
+ after(async () => {
+ await blockchainLifecycle.revertAsync();
+ });
before('deploy a wallet', async () => {
multiSig = await MultiSigWalletWithTimeLockContract.deployFrom0xArtifactAsync(
artifacts.MultiSigWalletWithTimeLock,
@@ -160,16 +182,19 @@ describe('MultiSigWalletWithTimeLock', () => {
args: [newSecondsTimeLocked],
};
let txHash = await multiSigWrapper.submitTransactionAsync(destination, from, dataParams);
- const subRes = await web3Wrapper.awaitTransactionMinedAsync(txHash);
- const log = abiDecoder.tryToDecodeLogOrNoop(subRes.logs[0]) as LogWithDecodedArgs<
+ let txReceipt = await web3Wrapper.awaitTransactionMinedAsync(
+ txHash,
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
+ const log = abiDecoder.tryToDecodeLogOrNoop(txReceipt.logs[0]) as LogWithDecodedArgs<
SubmissionContractEventArgs
>;
txId = log.args.transactionId;
txHash = await multiSig.confirmTransaction.sendTransactionAsync(txId, {
from: owners[1],
});
- const confRes = await web3Wrapper.awaitTransactionMinedAsync(txHash);
- expect(confRes.logs).to.have.length(2);
+ txReceipt = await web3Wrapper.awaitTransactionMinedAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
+ expect(txReceipt.logs).to.have.length(2);
});
const newSecondsTimeLocked = 0;
it('should throw if it has enough confirmations but is not past the time lock', async () => {
@@ -180,7 +205,10 @@ describe('MultiSigWalletWithTimeLock', () => {
it('should execute if it has enough confirmations and is past the time lock', async () => {
await web3Wrapper.increaseTimeAsync(SECONDS_TIME_LOCKED.toNumber());
- await multiSig.executeTransaction.sendTransactionAsync(txId, { from: owners[0] });
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await multiSig.executeTransaction.sendTransactionAsync(txId, { from: owners[0] }),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
const secondsTimeLocked = new BigNumber(await multiSig.secondsTimeLocked.callAsync());
expect(secondsTimeLocked).to.be.bignumber.equal(newSecondsTimeLocked);
diff --git a/packages/contracts/test/token_registry.ts b/packages/contracts/test/token_registry.ts
index f2c0f5bc7..49d4f3901 100644
--- a/packages/contracts/test/token_registry.ts
+++ b/packages/contracts/test/token_registry.ts
@@ -24,6 +24,12 @@ describe('TokenRegistry', () => {
let tokenReg: TokenRegistryContract;
let tokenRegWrapper: TokenRegWrapper;
before(async () => {
+ await blockchainLifecycle.startAsync();
+ });
+ after(async () => {
+ await blockchainLifecycle.revertAsync();
+ });
+ before(async () => {
const accounts = await web3Wrapper.getAvailableAddressesAsync();
owner = accounts[0];
notOwner = accounts[1];
@@ -136,9 +142,12 @@ describe('TokenRegistry', () => {
});
it('should change the token name when called by owner', async () => {
- await tokenReg.setTokenName.sendTransactionAsync(token1.address, token2.name, {
- from: owner,
- });
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await tokenReg.setTokenName.sendTransactionAsync(token1.address, token2.name, {
+ from: owner,
+ }),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
const [newData, oldData] = await Promise.all([
tokenRegWrapper.getTokenByNameAsync(token2.name),
tokenRegWrapper.getTokenByNameAsync(token1.name),
@@ -175,7 +184,10 @@ describe('TokenRegistry', () => {
});
it('should change the token symbol when called by owner', async () => {
- await tokenReg.setTokenSymbol.sendTransactionAsync(token1.address, token2.symbol, { from: owner });
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await tokenReg.setTokenSymbol.sendTransactionAsync(token1.address, token2.symbol, { from: owner }),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
const [newData, oldData] = await Promise.all([
tokenRegWrapper.getTokenBySymbolAsync(token2.symbol),
tokenRegWrapper.getTokenBySymbolAsync(token1.symbol),
@@ -216,9 +228,12 @@ describe('TokenRegistry', () => {
it('should remove token metadata when called by owner', async () => {
const index = new BigNumber(0);
- await tokenReg.removeToken.sendTransactionAsync(token1.address, index, {
- from: owner,
- });
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await tokenReg.removeToken.sendTransactionAsync(token1.address, index, {
+ from: owner,
+ }),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
const tokenData = await tokenRegWrapper.getTokenMetaDataAsync(token1.address);
expect(tokenData).to.be.deep.equal(nullToken);
});
diff --git a/packages/contracts/test/unlimited_allowance_token.ts b/packages/contracts/test/unlimited_allowance_token.ts
index 147f77ab1..e831301e1 100644
--- a/packages/contracts/test/unlimited_allowance_token.ts
+++ b/packages/contracts/test/unlimited_allowance_token.ts
@@ -28,6 +28,12 @@ describe('UnlimitedAllowanceToken', () => {
let token: DummyERC20TokenContract;
before(async () => {
+ await blockchainLifecycle.startAsync();
+ });
+ after(async () => {
+ await blockchainLifecycle.revertAsync();
+ });
+ before(async () => {
const accounts = await web3Wrapper.getAvailableAddressesAsync();
owner = accounts[0];
spender = accounts[1];
@@ -40,7 +46,10 @@ describe('UnlimitedAllowanceToken', () => {
constants.DUMMY_TOKEN_DECIMALS,
constants.DUMMY_TOKEN_TOTAL_SUPPLY,
);
- await token.mint.sendTransactionAsync(MAX_MINT_VALUE, { from: owner });
+ await web3Wrapper.awaitTransactionMinedAsync(
+ await token.mint.sendTransactionAsync(MAX_MINT_VALUE, { from: owner }),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
tokenAddress = token.address;
});
beforeEach(async () => {
diff --git a/packages/contracts/test/utils/match_order_tester.ts b/packages/contracts/test/utils/match_order_tester.ts
index 6dbd7bfbc..43196728c 100644
--- a/packages/contracts/test/utils/match_order_tester.ts
+++ b/packages/contracts/test/utils/match_order_tester.ts
@@ -55,10 +55,10 @@ export class MatchOrderTester {
realERC20BalancesByOwner: ERC20BalancesByOwner,
expectedNewERC721TokenIdsByOwner: ERC721TokenIdsByOwner,
realERC721TokenIdsByOwner: ERC721TokenIdsByOwner,
- ) {
+ ): boolean {
// ERC20 Balances
- const erc20BalancesMatch = _.isEqual(expectedNewERC20BalancesByOwner, realERC20BalancesByOwner);
- if (!erc20BalancesMatch) {
+ const doesErc20BalancesMatch = _.isEqual(expectedNewERC20BalancesByOwner, realERC20BalancesByOwner);
+ if (!doesErc20BalancesMatch) {
return false;
}
// ERC721 Token Ids
@@ -75,8 +75,11 @@ export class MatchOrderTester {
_.sortBy(tokenIds);
});
});
- const erc721TokenIdsMatch = _.isEqual(sortedExpectedNewERC721TokenIdsByOwner, sortedNewERC721TokenIdsByOwner);
- return erc721TokenIdsMatch;
+ const doesErc721TokenIdsMatch = _.isEqual(
+ sortedExpectedNewERC721TokenIdsByOwner,
+ sortedNewERC721TokenIdsByOwner,
+ );
+ return doesErc721TokenIdsMatch;
}
/// @dev Constructs new MatchOrderTester.
/// @param exchangeWrapper Used to call to the Exchange.
@@ -156,13 +159,13 @@ export class MatchOrderTester {
expectedTransferAmounts,
);
// Assert our expected balances are equal to the actual balances
- const expectedBalancesMatchRealBalances = MatchOrderTester._compareExpectedAndRealBalances(
+ const didExpectedBalancesMatchRealBalances = MatchOrderTester._compareExpectedAndRealBalances(
expectedERC20BalancesByOwner,
newERC20BalancesByOwner,
expectedERC721TokenIdsByOwner,
newERC721TokenIdsByOwner,
);
- expect(expectedBalancesMatchRealBalances).to.be.true();
+ expect(didExpectedBalancesMatchRealBalances).to.be.true();
return [newERC20BalancesByOwner, newERC721TokenIdsByOwner];
}
/// @dev Calculates expected transfer amounts between order makers, fee recipients, and
diff --git a/packages/contracts/test/zrx_token.ts b/packages/contracts/test/zrx_token.ts
index d621d9065..e632364ef 100644
--- a/packages/contracts/test/zrx_token.ts
+++ b/packages/contracts/test/zrx_token.ts
@@ -27,6 +27,12 @@ describe('ZRXToken', () => {
let zrxAddress: string;
before(async () => {
+ await blockchainLifecycle.startAsync();
+ });
+ after(async () => {
+ await blockchainLifecycle.revertAsync();
+ });
+ before(async () => {
const accounts = await web3Wrapper.getAvailableAddressesAsync();
owner = accounts[0];
spender = accounts[1];
diff --git a/packages/metacoin/contracts/Metacoin.sol b/packages/metacoin/contracts/Metacoin.sol
index ac212b32e..dc67e6242 100644
--- a/packages/metacoin/contracts/Metacoin.sol
+++ b/packages/metacoin/contracts/Metacoin.sol
@@ -1,4 +1,4 @@
-pragma solidity ^0.4.21;
+pragma solidity ^0.4.24;
pragma experimental ABIEncoderV2;
contract Metacoin {
@@ -16,7 +16,7 @@ contract Metacoin {
uint32 callback;
}
- function Metacoin() public {
+ constructor () public {
balances[msg.sender] = 10000;
}
@@ -24,7 +24,7 @@ contract Metacoin {
if (balances[msg.sender] < transferData.amount) return false;
balances[msg.sender] -= transferData.amount;
balances[transferData.to] += transferData.amount;
- Transfer(msg.sender, transferData.to, transferData.amount);
+ emit Transfer(msg.sender, transferData.to, transferData.amount);
return true;
}
diff --git a/packages/tslint-config/rules/booleanNamingRule.ts b/packages/tslint-config/rules/booleanNamingRule.ts
index f673afc6a..a8e1dc390 100644
--- a/packages/tslint-config/rules/booleanNamingRule.ts
+++ b/packages/tslint-config/rules/booleanNamingRule.ts
@@ -2,7 +2,7 @@ import * as _ from 'lodash';
import * as Lint from 'tslint';
import * as ts from 'typescript';
-const VALID_BOOLEAN_PREFIXES = ['is', 'does', 'should', 'was', 'has', 'can', 'did', 'would'];
+const VALID_BOOLEAN_PREFIXES = ['is', 'does', 'should', 'was', 'has', 'can', 'did', 'would', 'are'];
export class Rule extends Lint.Rules.TypedRule {
public static FAILURE_STRING = `Boolean variable names should begin with: ${VALID_BOOLEAN_PREFIXES.join(', ')}`;
diff --git a/packages/website/package.json b/packages/website/package.json
index 3ef66d269..8b34cd743 100644
--- a/packages/website/package.json
+++ b/packages/website/package.json
@@ -88,6 +88,7 @@
"tslint": "5.8.0",
"tslint-config-0xproject": "^0.0.2",
"typescript": "2.7.1",
+ "uglifyjs-webpack-plugin": "^1.2.5",
"webpack": "^3.1.0",
"webpack-dev-middleware": "^1.10.0",
"webpack-dev-server": "^2.5.0"
diff --git a/packages/website/ts/components/portal/menu.tsx b/packages/website/ts/components/portal/menu.tsx
index e8353a3b0..6a3301549 100644
--- a/packages/website/ts/components/portal/menu.tsx
+++ b/packages/website/ts/components/portal/menu.tsx
@@ -61,13 +61,13 @@ export const Menu: React.StatelessComponent<MenuProps> = (props: MenuProps) => {
return (
<div>
{_.map(props.menuItemEntries, entry => {
- const selected = entry.to === props.selectedPath;
+ const isSelected = entry.to === props.selectedPath;
return (
<MenuItem key={entry.to} to={entry.to}>
<MenuItemLabel
title={entry.labelText}
iconName={entry.iconName}
- selected={selected}
+ selected={isSelected}
theme={props.theme}
/>
</MenuItem>
diff --git a/packages/website/ts/components/portal/portal.tsx b/packages/website/ts/components/portal/portal.tsx
index b992204a7..1bd318c28 100644
--- a/packages/website/ts/components/portal/portal.tsx
+++ b/packages/website/ts/components/portal/portal.tsx
@@ -466,8 +466,8 @@ export class Portal extends React.Component<PortalProps, PortalState> {
this.props.dispatcher.updateScreenWidth(newScreenWidth);
}
private _isSmallScreen(): boolean {
- const result = this.props.screenWidth === ScreenWidths.Sm;
- return result;
+ const isSmallScreen = this.props.screenWidth === ScreenWidths.Sm;
+ return isSmallScreen;
}
}
diff --git a/packages/website/webpack.config.js b/packages/website/webpack.config.js
index e28e9e064..f9abeb27c 100644
--- a/packages/website/webpack.config.js
+++ b/packages/website/webpack.config.js
@@ -1,5 +1,6 @@
const path = require('path');
const webpack = require('webpack');
+const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
module.exports = {
entry: ['./ts/index.tsx'],
@@ -76,9 +77,14 @@ module.exports = {
NODE_ENV: JSON.stringify(process.env.NODE_ENV),
},
}),
- new webpack.optimize.UglifyJsPlugin({
- mangle: {
- except: ['BigNumber'],
+ // TODO: Revert to webpack bundled version with webpack v4.
+ // The v3 series bundled version does not support ES6 and
+ // fails to build.
+ new UglifyJsPlugin({
+ uglifyOptions: {
+ mangle: {
+ reserved: ['BigNumber'],
+ },
},
}),
]
diff --git a/yarn.lock b/yarn.lock
index ac2432d98..0b95aca58 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2569,7 +2569,7 @@ commander@2.12.2:
version "2.12.2"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.12.2.tgz#0f5946c427ed9ec0d91a46bb9def53e54650e555"
-commander@2.13.0:
+commander@2.13.0, commander@~2.13.0:
version "2.13.0"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.13.0.tgz#6964bca67685df7c1f1430c584f07d7597885b9c"
@@ -3753,7 +3753,7 @@ envinfo@^4.4.2:
version "4.4.2"
resolved "https://registry.yarnpkg.com/envinfo/-/envinfo-4.4.2.tgz#472c49f3a8b9bca73962641ce7cb692bf623cd1c"
-errno@^0.1.1, errno@^0.1.3, errno@~0.1.1:
+errno@^0.1.1, errno@^0.1.3, errno@~0.1.1, errno@~0.1.7:
version "0.1.7"
resolved "https://registry.yarnpkg.com/errno/-/errno-0.1.7.tgz#4684d71779ad39af177e3f007996f7c67c852618"
dependencies:
@@ -11748,6 +11748,13 @@ ua-parser-js@^0.7.9:
version "0.7.17"
resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.17.tgz#e9ec5f9498b9ec910e7ae3ac626a805c4d09ecac"
+uglify-es@^3.3.4:
+ version "3.3.9"
+ resolved "https://registry.yarnpkg.com/uglify-es/-/uglify-es-3.3.9.tgz#0c1c4f0700bed8dbc124cdb304d2592ca203e677"
+ dependencies:
+ commander "~2.13.0"
+ source-map "~0.6.1"
+
uglify-js@^2.6, uglify-js@^2.8.29:
version "2.8.29"
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.8.29.tgz#29c5733148057bb4e1f75df35b7a9cb72e6a59dd"
@@ -11769,6 +11776,19 @@ uglifyjs-webpack-plugin@^0.4.6:
uglify-js "^2.8.29"
webpack-sources "^1.0.1"
+uglifyjs-webpack-plugin@^1.2.5:
+ version "1.2.5"
+ resolved "https://registry.yarnpkg.com/uglifyjs-webpack-plugin/-/uglifyjs-webpack-plugin-1.2.5.tgz#2ef8387c8f1a903ec5e44fa36f9f3cbdcea67641"
+ dependencies:
+ cacache "^10.0.4"
+ find-cache-dir "^1.0.0"
+ schema-utils "^0.4.5"
+ serialize-javascript "^1.4.0"
+ source-map "^0.6.1"
+ uglify-es "^3.3.4"
+ webpack-sources "^1.1.0"
+ worker-farm "^1.5.2"
+
uid-number@^0.0.6:
version "0.0.6"
resolved "https://registry.yarnpkg.com/uid-number/-/uid-number-0.0.6.tgz#0ea10e8035e8eb5b8e4449f06da1c730663baa81"
@@ -12628,7 +12648,7 @@ webpack-node-externals@^1.6.0:
version "1.7.2"
resolved "https://registry.yarnpkg.com/webpack-node-externals/-/webpack-node-externals-1.7.2.tgz#6e1ee79ac67c070402ba700ef033a9b8d52ac4e3"
-webpack-sources@^1.0.1:
+webpack-sources@^1.0.1, webpack-sources@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-1.1.0.tgz#a101ebae59d6507354d71d8013950a3a8b7a5a54"
dependencies:
@@ -12765,6 +12785,12 @@ wordwrap@~0.0.2:
version "0.0.3"
resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.3.tgz#a3d5da6cd5c0bc0008d37234bbaf1bed63059107"
+worker-farm@^1.5.2:
+ version "1.6.0"
+ resolved "https://registry.yarnpkg.com/worker-farm/-/worker-farm-1.6.0.tgz#aecc405976fab5a95526180846f0dba288f3a4a0"
+ dependencies:
+ errno "~0.1.7"
+
wrap-ansi@^2.0.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-2.1.0.tgz#d8fc3d284dd05794fe84973caecdd1cf824fdd85"