aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
Diffstat (limited to 'packages')
-rw-r--r--packages/0x.js/CHANGELOG.md5
-rw-r--r--packages/0x.js/package.json16
-rw-r--r--packages/abi-gen/CHANGELOG.md4
-rw-r--r--packages/abi-gen/package.json4
-rw-r--r--packages/assert/package.json6
-rw-r--r--packages/connect/package.json8
-rw-r--r--packages/contracts/package.json16
-rw-r--r--packages/contracts/test/exchange/core.ts481
-rw-r--r--packages/contracts/test/exchange/helpers.ts30
-rw-r--r--packages/contracts/test/exchange/wrapper.ts211
-rw-r--r--packages/contracts/util/exchange_wrapper.ts60
-rw-r--r--packages/contracts/util/formatters.ts100
-rw-r--r--packages/contracts/util/order.ts106
-rw-r--r--packages/contracts/util/order_factory.ts45
-rw-r--r--packages/contracts/util/signed_order_utils.ts49
-rw-r--r--packages/contracts/util/types.ts33
-rw-r--r--packages/deployer/package.json6
-rw-r--r--packages/dev-utils/CHANGELOG.md5
-rw-r--r--packages/dev-utils/package.json6
-rw-r--r--packages/json-schemas/package.json4
-rw-r--r--packages/subproviders/CHANGELOG.md4
-rw-r--r--packages/subproviders/README.md4
-rw-r--r--packages/subproviders/package.json10
-rw-r--r--packages/testnet-faucets/package.json8
-rw-r--r--packages/testnet-faucets/src/ts/dispatch_queue.ts54
-rw-r--r--packages/testnet-faucets/src/ts/dispense_asset_tasks.ts44
-rw-r--r--packages/testnet-faucets/src/ts/error_reporter.ts3
-rw-r--r--packages/testnet-faucets/src/ts/ether_request_queue.ts27
-rw-r--r--packages/testnet-faucets/src/ts/handler.ts97
-rw-r--r--packages/testnet-faucets/src/ts/request_queue.ts51
-rw-r--r--packages/testnet-faucets/src/ts/rpc_urls.ts4
-rw-r--r--packages/testnet-faucets/src/ts/zrx_request_queue.ts43
-rw-r--r--packages/types/CHANGELOG.md2
-rw-r--r--packages/types/package.json2
-rw-r--r--packages/utils/package.json4
-rw-r--r--packages/web3-wrapper/package.json6
-rw-r--r--packages/website/less/all.less41
-rw-r--r--packages/website/package.json8
-rw-r--r--packages/website/public/images/landing/project_logos/amadeus.pngbin0 -> 6156 bytes
-rw-r--r--packages/website/public/images/landing/project_logos/ddex.pngbin0 -> 5504 bytes
-rw-r--r--packages/website/public/images/landing/project_logos/decent_ex.pngbin0 -> 5100 bytes
-rw-r--r--packages/website/public/images/landing/project_logos/dextroid.pngbin0 -> 5609 bytes
-rw-r--r--packages/website/public/images/landing/project_logos/ercdex.pngbin0 -> 5726 bytes
-rw-r--r--packages/website/public/images/landing/project_logos/ethfinex-top.pngbin4376 -> 0 bytes
-rw-r--r--packages/website/public/images/landing/project_logos/ethfinex.pngbin0 -> 5486 bytes
-rw-r--r--packages/website/public/images/landing/project_logos/idt.pngbin0 -> 3154 bytes
-rw-r--r--packages/website/public/images/landing/project_logos/open_relay.pngbin0 -> 6149 bytes
-rw-r--r--packages/website/public/images/landing/project_logos/paradex.pngbin0 -> 5725 bytes
-rw-r--r--packages/website/public/images/landing/project_logos/paradex_top.pngbin5109 -> 0 bytes
-rw-r--r--packages/website/public/images/landing/project_logos/radar_relay.pngbin0 -> 5748 bytes
-rw-r--r--packages/website/public/images/landing/project_logos/radar_relay_top.pngbin4898 -> 0 bytes
-rw-r--r--packages/website/ts/components/token_balances.tsx40
-rw-r--r--packages/website/ts/components/top_bar/top_bar.tsx10
-rw-r--r--packages/website/ts/components/top_bar/top_bar_menu_item.tsx18
-rw-r--r--packages/website/ts/pages/landing/landing.tsx160
-rw-r--r--packages/website/ts/utils/configs.ts24
-rw-r--r--packages/website/ts/utils/constants.ts9
-rw-r--r--packages/website/ts/utils/utils.ts11
58 files changed, 956 insertions, 923 deletions
diff --git a/packages/0x.js/CHANGELOG.md b/packages/0x.js/CHANGELOG.md
index 54c06444a..fa5bd6d4d 100644
--- a/packages/0x.js/CHANGELOG.md
+++ b/packages/0x.js/CHANGELOG.md
@@ -1,5 +1,10 @@
# CHANGELOG
+## v0.32.1 - _February 7, 2018_
+
+ * Reorganized `BlockParamLiteral` export into `@0xproject/types` package (#355)
+ * Now using `abi-gen` package to generate ContractEventArgs types (#371)
+
## v0.32.0 - _February 5, 2018_
* Add `zeroEx.etherToken.getContractAddressIfExists` (#350)
diff --git a/packages/0x.js/package.json b/packages/0x.js/package.json
index de18a1b2e..a42d3b9dd 100644
--- a/packages/0x.js/package.json
+++ b/packages/0x.js/package.json
@@ -1,6 +1,6 @@
{
"name": "0x.js",
- "version": "0.32.0",
+ "version": "0.32.1",
"description": "A javascript library for interacting with the 0x protocol",
"keywords": [
"0x.js",
@@ -42,8 +42,8 @@
"node": ">=6.0.0"
},
"devDependencies": {
- "@0xproject/abi-gen": "^0.1.7",
- "@0xproject/dev-utils": "^0.0.10",
+ "@0xproject/abi-gen": "^0.2.0",
+ "@0xproject/dev-utils": "^0.0.11",
"@0xproject/tslint-config": "^0.4.7",
"@types/bintrees": "^1.0.2",
"@types/jsonschema": "^1.1.1",
@@ -81,11 +81,11 @@
"webpack": "^3.1.0"
},
"dependencies": {
- "@0xproject/assert": "^0.0.16",
- "@0xproject/json-schemas": "^0.7.8",
- "@0xproject/types": "^0.1.9",
- "@0xproject/utils": "^0.3.0",
- "@0xproject/web3-wrapper": "^0.1.10",
+ "@0xproject/assert": "^0.0.17",
+ "@0xproject/json-schemas": "^0.7.9",
+ "@0xproject/types": "^0.2.0",
+ "@0xproject/utils": "^0.3.1",
+ "@0xproject/web3-wrapper": "^0.1.11",
"bintrees": "^1.0.2",
"bn.js": "^4.11.8",
"ethereumjs-abi": "^0.6.4",
diff --git a/packages/abi-gen/CHANGELOG.md b/packages/abi-gen/CHANGELOG.md
index 570c76bdd..ac6d58e9c 100644
--- a/packages/abi-gen/CHANGELOG.md
+++ b/packages/abi-gen/CHANGELOG.md
@@ -1,9 +1,9 @@
# CHANGELOG
-## v0.2.0 - _???_
+## v0.2.0 - _February 7, 2018_
* Added CLI options for explicit specifying location of partials and main template (#346)
-* Added CLI option to specify networkId, adding support for the JSON artifact format found in @0xproject/contracts
+* Added CLI option to specify networkId, adding support for the JSON artifact format found in @0xproject/contracts (#388)
## v0.1.0 - _January 11, 2018_
diff --git a/packages/abi-gen/package.json b/packages/abi-gen/package.json
index 10bd7e712..17810a7f1 100644
--- a/packages/abi-gen/package.json
+++ b/packages/abi-gen/package.json
@@ -1,6 +1,6 @@
{
"name": "@0xproject/abi-gen",
- "version": "0.1.7",
+ "version": "0.2.0",
"description": "Generate contract wrappers from ABI and handlebars templates",
"main": "lib/index.js",
"types": "lib/index.d.ts",
@@ -23,7 +23,7 @@
},
"homepage": "https://github.com/0xProject/0x.js/packages/abi-gen/README.md",
"dependencies": {
- "@0xproject/utils": "^0.3.0",
+ "@0xproject/utils": "^0.3.1",
"chalk": "^2.3.0",
"glob": "^7.1.2",
"handlebars": "^4.0.11",
diff --git a/packages/assert/package.json b/packages/assert/package.json
index b8da740d6..7de27121f 100644
--- a/packages/assert/package.json
+++ b/packages/assert/package.json
@@ -1,6 +1,6 @@
{
"name": "@0xproject/assert",
- "version": "0.0.16",
+ "version": "0.0.17",
"description": "Provides a standard way of performing type and schema validation across 0x projects",
"main": "lib/src/index.js",
"types": "lib/src/index.d.ts",
@@ -38,8 +38,8 @@
"typescript": "2.7.1"
},
"dependencies": {
- "@0xproject/json-schemas": "^0.7.8",
- "@0xproject/utils": "^0.3.0",
+ "@0xproject/json-schemas": "^0.7.9",
+ "@0xproject/utils": "^0.3.1",
"lodash": "^4.17.4",
"valid-url": "^1.0.9"
}
diff --git a/packages/connect/package.json b/packages/connect/package.json
index d892e2d04..26ec44ae0 100644
--- a/packages/connect/package.json
+++ b/packages/connect/package.json
@@ -1,6 +1,6 @@
{
"name": "@0xproject/connect",
- "version": "0.5.5",
+ "version": "0.5.6",
"description": "A javascript library for interacting with the standard relayer api",
"keywords": [
"connect",
@@ -37,9 +37,9 @@
},
"homepage": "https://github.com/0xProject/0x.js/packages/connect/README.md",
"dependencies": {
- "@0xproject/assert": "^0.0.16",
- "@0xproject/json-schemas": "^0.7.8",
- "@0xproject/utils": "^0.3.0",
+ "@0xproject/assert": "^0.0.17",
+ "@0xproject/json-schemas": "^0.7.9",
+ "@0xproject/utils": "^0.3.1",
"isomorphic-fetch": "^2.2.1",
"lodash": "^4.17.4",
"query-string": "^5.0.1",
diff --git a/packages/contracts/package.json b/packages/contracts/package.json
index af7441d85..0bc5080c7 100644
--- a/packages/contracts/package.json
+++ b/packages/contracts/package.json
@@ -1,7 +1,7 @@
{
"private": true,
"name": "contracts",
- "version": "2.1.9",
+ "version": "2.1.10",
"description": "Smart contract components of 0x protocol",
"main": "index.js",
"directories": {
@@ -33,9 +33,9 @@
},
"homepage": "https://github.com/0xProject/0x.js/packages/contracts/README.md",
"devDependencies": {
- "@0xproject/dev-utils": "^0.0.10",
+ "@0xproject/dev-utils": "^0.0.11",
"@0xproject/tslint-config": "^0.4.7",
- "@0xproject/types": "^0.1.9",
+ "@0xproject/types": "^0.2.0",
"@types/bluebird": "^3.5.3",
"@types/lodash": "^4.14.86",
"@types/node": "^8.0.53",
@@ -59,11 +59,11 @@
"yargs": "^10.0.3"
},
"dependencies": {
- "0x.js": "^0.32.0",
- "@0xproject/deployer": "^0.0.6",
- "@0xproject/json-schemas": "^0.7.8",
- "@0xproject/utils": "^0.3.0",
- "@0xproject/web3-wrapper": "^0.1.10",
+ "0x.js": "^0.32.1",
+ "@0xproject/deployer": "^0.0.7",
+ "@0xproject/json-schemas": "^0.7.9",
+ "@0xproject/utils": "^0.3.1",
+ "@0xproject/web3-wrapper": "^0.1.11",
"bluebird": "^3.5.0",
"bn.js": "^4.11.8",
"ethereumjs-abi": "^0.6.4",
diff --git a/packages/contracts/test/exchange/core.ts b/packages/contracts/test/exchange/core.ts
index 5cedaddc9..9cfc68418 100644
--- a/packages/contracts/test/exchange/core.ts
+++ b/packages/contracts/test/exchange/core.ts
@@ -3,6 +3,7 @@ import {
LogErrorContractEventArgs,
LogFillContractEventArgs,
LogWithDecodedArgs,
+ SignedOrder,
TransactionReceiptWithDecodedLogs,
ZeroEx,
} from '0x.js';
@@ -20,7 +21,6 @@ import { Balances } from '../../util/balances';
import { constants } from '../../util/constants';
import { crypto } from '../../util/crypto';
import { ExchangeWrapper } from '../../util/exchange_wrapper';
-import { Order } from '../../util/order';
import { OrderFactory } from '../../util/order_factory';
import { BalancesByOwner, ContractName, ExchangeContractErrs } from '../../util/types';
import { chaiSetup } from '../utils/chai_setup';
@@ -46,7 +46,7 @@ describe('Exchange', () => {
let exchange: ExchangeContract;
let tokenTransferProxy: TokenTransferProxyContract;
- let order: Order;
+ let signedOrder: SignedOrder;
let balances: BalancesByOwner;
let exWrapper: ExchangeWrapper;
let dmyBalances: Balances;
@@ -84,14 +84,14 @@ describe('Exchange', () => {
exchangeContractAddress: exchange.address,
maker,
feeRecipient,
- makerToken: rep.address,
- takerToken: dgd.address,
+ makerTokenAddress: rep.address,
+ takerTokenAddress: dgd.address,
makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
makerFee: ZeroEx.toBaseUnitAmount(new BigNumber(1), 18),
takerFee: ZeroEx.toBaseUnitAmount(new BigNumber(1), 18),
};
- orderFactory = new OrderFactory(web3Wrapper, defaultOrderParams);
+ orderFactory = new OrderFactory(zeroEx, defaultOrderParams);
dmyBalances = new Balances([rep, dgd, zrx], [maker, taker, feeRecipient]);
await Promise.all([
rep.approve.sendTransactionAsync(tokenTransferProxy.address, INITIAL_ALLOWANCE, {
@@ -147,80 +147,85 @@ describe('Exchange', () => {
describe('fillOrder', () => {
beforeEach(async () => {
balances = await dmyBalances.getAsync();
- order = await orderFactory.newSignedOrderAsync();
+ signedOrder = await orderFactory.newSignedOrderAsync();
});
it('should create an unfillable order', async () => {
- order = await orderFactory.newSignedOrderAsync({
+ signedOrder = await orderFactory.newSignedOrderAsync({
makerTokenAmount: new BigNumber(1001),
takerTokenAmount: new BigNumber(3),
});
- const filledTakerTokenAmountBefore = await zeroEx.exchange.getFilledTakerAmountAsync(order.params
- .orderHashHex as string);
+ const filledTakerTokenAmountBefore = await zeroEx.exchange.getFilledTakerAmountAsync(
+ ZeroEx.getOrderHashHex(signedOrder),
+ );
expect(filledTakerTokenAmountBefore).to.be.bignumber.equal(0);
const fillTakerTokenAmount1 = new BigNumber(2);
- await exWrapper.fillOrderAsync(order, taker, {
+ await exWrapper.fillOrderAsync(signedOrder, taker, {
fillTakerTokenAmount: fillTakerTokenAmount1,
});
- const filledTakerTokenAmountAfter1 = await zeroEx.exchange.getFilledTakerAmountAsync(order.params
- .orderHashHex as string);
+ const filledTakerTokenAmountAfter1 = await zeroEx.exchange.getFilledTakerAmountAsync(
+ ZeroEx.getOrderHashHex(signedOrder),
+ );
expect(filledTakerTokenAmountAfter1).to.be.bignumber.equal(fillTakerTokenAmount1);
const fillTakerTokenAmount2 = new BigNumber(1);
- await exWrapper.fillOrderAsync(order, taker, {
+ await exWrapper.fillOrderAsync(signedOrder, taker, {
fillTakerTokenAmount: fillTakerTokenAmount2,
});
- const filledTakerTokenAmountAfter2 = await zeroEx.exchange.getFilledTakerAmountAsync(order.params
- .orderHashHex as string);
+ const filledTakerTokenAmountAfter2 = await zeroEx.exchange.getFilledTakerAmountAsync(
+ ZeroEx.getOrderHashHex(signedOrder),
+ );
expect(filledTakerTokenAmountAfter2).to.be.bignumber.equal(filledTakerTokenAmountAfter1);
});
it('should transfer the correct amounts when makerTokenAmount === takerTokenAmount', async () => {
- order = await orderFactory.newSignedOrderAsync({
+ signedOrder = await orderFactory.newSignedOrderAsync({
makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
});
- const filledTakerTokenAmountBefore = await zeroEx.exchange.getFilledTakerAmountAsync(order.params
- .orderHashHex as string);
+ const filledTakerTokenAmountBefore = await zeroEx.exchange.getFilledTakerAmountAsync(
+ ZeroEx.getOrderHashHex(signedOrder),
+ );
expect(filledTakerTokenAmountBefore).to.be.bignumber.equal(0);
- const fillTakerTokenAmount = order.params.takerTokenAmount.div(2);
- await exWrapper.fillOrderAsync(order, taker, { fillTakerTokenAmount });
+ const fillTakerTokenAmount = signedOrder.takerTokenAmount.div(2);
+ await exWrapper.fillOrderAsync(signedOrder, taker, { fillTakerTokenAmount });
- const filledTakerTokenAmountAfter = await zeroEx.exchange.getFilledTakerAmountAsync(order.params
- .orderHashHex as string);
+ const filledTakerTokenAmountAfter = await zeroEx.exchange.getFilledTakerAmountAsync(
+ ZeroEx.getOrderHashHex(signedOrder),
+ );
expect(filledTakerTokenAmountAfter).to.be.bignumber.equal(fillTakerTokenAmount);
const newBalances = await dmyBalances.getAsync();
const fillMakerTokenAmount = fillTakerTokenAmount
- .times(order.params.makerTokenAmount)
- .dividedToIntegerBy(order.params.takerTokenAmount);
- const paidMakerFee = order.params.makerFee
+ .times(signedOrder.makerTokenAmount)
+ .dividedToIntegerBy(signedOrder.takerTokenAmount);
+ const paidMakerFee = signedOrder.makerFee
.times(fillMakerTokenAmount)
- .dividedToIntegerBy(order.params.makerTokenAmount);
- const paidTakerFee = order.params.takerFee
+ .dividedToIntegerBy(signedOrder.makerTokenAmount);
+ const paidTakerFee = signedOrder.takerFee
.times(fillMakerTokenAmount)
- .dividedToIntegerBy(order.params.makerTokenAmount);
- expect(newBalances[maker][order.params.makerToken]).to.be.bignumber.equal(
- balances[maker][order.params.makerToken].minus(fillMakerTokenAmount),
+ .dividedToIntegerBy(signedOrder.makerTokenAmount);
+ expect(newBalances[maker][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
+ balances[maker][signedOrder.makerTokenAddress].minus(fillMakerTokenAmount),
);
- expect(newBalances[maker][order.params.takerToken]).to.be.bignumber.equal(
- balances[maker][order.params.takerToken].add(fillTakerTokenAmount),
+ expect(newBalances[maker][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
+ balances[maker][signedOrder.takerTokenAddress].add(fillTakerTokenAmount),
);
expect(newBalances[maker][zrx.address]).to.be.bignumber.equal(
balances[maker][zrx.address].minus(paidMakerFee),
);
- expect(newBalances[taker][order.params.takerToken]).to.be.bignumber.equal(
- balances[taker][order.params.takerToken].minus(fillTakerTokenAmount),
+ expect(newBalances[taker][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
+ balances[taker][signedOrder.takerTokenAddress].minus(fillTakerTokenAmount),
);
- expect(newBalances[taker][order.params.makerToken]).to.be.bignumber.equal(
- balances[taker][order.params.makerToken].add(fillMakerTokenAmount),
+ expect(newBalances[taker][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
+ balances[taker][signedOrder.makerTokenAddress].add(fillMakerTokenAmount),
);
expect(newBalances[taker][zrx.address]).to.be.bignumber.equal(
balances[taker][zrx.address].minus(paidTakerFee),
@@ -231,47 +236,49 @@ describe('Exchange', () => {
});
it('should transfer the correct amounts when makerTokenAmount > takerTokenAmount', async () => {
- order = await orderFactory.newSignedOrderAsync({
+ signedOrder = await orderFactory.newSignedOrderAsync({
makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
});
- const filledTakerTokenAmountBefore = await zeroEx.exchange.getFilledTakerAmountAsync(order.params
- .orderHashHex as string);
+ const filledTakerTokenAmountBefore = await zeroEx.exchange.getFilledTakerAmountAsync(
+ ZeroEx.getOrderHashHex(signedOrder),
+ );
expect(filledTakerTokenAmountBefore).to.be.bignumber.equal(0);
- const fillTakerTokenAmount = order.params.takerTokenAmount.div(2);
- await exWrapper.fillOrderAsync(order, taker, { fillTakerTokenAmount });
+ const fillTakerTokenAmount = signedOrder.takerTokenAmount.div(2);
+ await exWrapper.fillOrderAsync(signedOrder, taker, { fillTakerTokenAmount });
- const filledTakerTokenAmountAfter = await zeroEx.exchange.getFilledTakerAmountAsync(order.params
- .orderHashHex as string);
+ const filledTakerTokenAmountAfter = await zeroEx.exchange.getFilledTakerAmountAsync(
+ ZeroEx.getOrderHashHex(signedOrder),
+ );
expect(filledTakerTokenAmountAfter).to.be.bignumber.equal(fillTakerTokenAmount);
const newBalances = await dmyBalances.getAsync();
const fillMakerTokenAmount = fillTakerTokenAmount
- .times(order.params.makerTokenAmount)
- .dividedToIntegerBy(order.params.takerTokenAmount);
- const paidMakerFee = order.params.makerFee
+ .times(signedOrder.makerTokenAmount)
+ .dividedToIntegerBy(signedOrder.takerTokenAmount);
+ const paidMakerFee = signedOrder.makerFee
.times(fillMakerTokenAmount)
- .dividedToIntegerBy(order.params.makerTokenAmount);
- const paidTakerFee = order.params.takerFee
+ .dividedToIntegerBy(signedOrder.makerTokenAmount);
+ const paidTakerFee = signedOrder.takerFee
.times(fillMakerTokenAmount)
- .dividedToIntegerBy(order.params.makerTokenAmount);
- expect(newBalances[maker][order.params.makerToken]).to.be.bignumber.equal(
- balances[maker][order.params.makerToken].minus(fillMakerTokenAmount),
+ .dividedToIntegerBy(signedOrder.makerTokenAmount);
+ expect(newBalances[maker][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
+ balances[maker][signedOrder.makerTokenAddress].minus(fillMakerTokenAmount),
);
- expect(newBalances[maker][order.params.takerToken]).to.be.bignumber.equal(
- balances[maker][order.params.takerToken].add(fillTakerTokenAmount),
+ expect(newBalances[maker][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
+ balances[maker][signedOrder.takerTokenAddress].add(fillTakerTokenAmount),
);
expect(newBalances[maker][zrx.address]).to.be.bignumber.equal(
balances[maker][zrx.address].minus(paidMakerFee),
);
- expect(newBalances[taker][order.params.takerToken]).to.be.bignumber.equal(
- balances[taker][order.params.takerToken].minus(fillTakerTokenAmount),
+ expect(newBalances[taker][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
+ balances[taker][signedOrder.takerTokenAddress].minus(fillTakerTokenAmount),
);
- expect(newBalances[taker][order.params.makerToken]).to.be.bignumber.equal(
- balances[taker][order.params.makerToken].add(fillMakerTokenAmount),
+ expect(newBalances[taker][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
+ balances[taker][signedOrder.makerTokenAddress].add(fillMakerTokenAmount),
);
expect(newBalances[taker][zrx.address]).to.be.bignumber.equal(
balances[taker][zrx.address].minus(paidTakerFee),
@@ -282,47 +289,49 @@ describe('Exchange', () => {
});
it('should transfer the correct amounts when makerTokenAmount < takerTokenAmount', async () => {
- order = await orderFactory.newSignedOrderAsync({
+ signedOrder = await orderFactory.newSignedOrderAsync({
makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
});
- const filledTakerTokenAmountBefore = await zeroEx.exchange.getFilledTakerAmountAsync(order.params
- .orderHashHex as string);
+ const filledTakerTokenAmountBefore = await zeroEx.exchange.getFilledTakerAmountAsync(
+ ZeroEx.getOrderHashHex(signedOrder),
+ );
expect(filledTakerTokenAmountBefore).to.be.bignumber.equal(0);
- const fillTakerTokenAmount = order.params.takerTokenAmount.div(2);
- await exWrapper.fillOrderAsync(order, taker, { fillTakerTokenAmount });
+ const fillTakerTokenAmount = signedOrder.takerTokenAmount.div(2);
+ await exWrapper.fillOrderAsync(signedOrder, taker, { fillTakerTokenAmount });
- const filledTakerTokenAmountAfter = await zeroEx.exchange.getFilledTakerAmountAsync(order.params
- .orderHashHex as string);
+ const filledTakerTokenAmountAfter = await zeroEx.exchange.getFilledTakerAmountAsync(
+ ZeroEx.getOrderHashHex(signedOrder),
+ );
expect(filledTakerTokenAmountAfter).to.be.bignumber.equal(fillTakerTokenAmount);
const newBalances = await dmyBalances.getAsync();
const fillMakerTokenAmount = fillTakerTokenAmount
- .times(order.params.makerTokenAmount)
- .dividedToIntegerBy(order.params.takerTokenAmount);
- const paidMakerFee = order.params.makerFee
+ .times(signedOrder.makerTokenAmount)
+ .dividedToIntegerBy(signedOrder.takerTokenAmount);
+ const paidMakerFee = signedOrder.makerFee
.times(fillMakerTokenAmount)
- .dividedToIntegerBy(order.params.makerTokenAmount);
- const paidTakerFee = order.params.takerFee
+ .dividedToIntegerBy(signedOrder.makerTokenAmount);
+ const paidTakerFee = signedOrder.takerFee
.times(fillMakerTokenAmount)
- .dividedToIntegerBy(order.params.makerTokenAmount);
- expect(newBalances[maker][order.params.makerToken]).to.be.bignumber.equal(
- balances[maker][order.params.makerToken].minus(fillMakerTokenAmount),
+ .dividedToIntegerBy(signedOrder.makerTokenAmount);
+ expect(newBalances[maker][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
+ balances[maker][signedOrder.makerTokenAddress].minus(fillMakerTokenAmount),
);
- expect(newBalances[maker][order.params.takerToken]).to.be.bignumber.equal(
- balances[maker][order.params.takerToken].add(fillTakerTokenAmount),
+ expect(newBalances[maker][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
+ balances[maker][signedOrder.takerTokenAddress].add(fillTakerTokenAmount),
);
expect(newBalances[maker][zrx.address]).to.be.bignumber.equal(
balances[maker][zrx.address].minus(paidMakerFee),
);
- expect(newBalances[taker][order.params.takerToken]).to.be.bignumber.equal(
- balances[taker][order.params.takerToken].minus(fillTakerTokenAmount),
+ expect(newBalances[taker][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
+ balances[taker][signedOrder.takerTokenAddress].minus(fillTakerTokenAmount),
);
- expect(newBalances[taker][order.params.makerToken]).to.be.bignumber.equal(
- balances[taker][order.params.makerToken].add(fillMakerTokenAmount),
+ expect(newBalances[taker][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
+ balances[taker][signedOrder.makerTokenAddress].add(fillMakerTokenAmount),
);
expect(newBalances[taker][zrx.address]).to.be.bignumber.equal(
balances[taker][zrx.address].minus(paidTakerFee),
@@ -333,49 +342,51 @@ describe('Exchange', () => {
});
it('should transfer the correct amounts when taker is specified and order is claimed by taker', async () => {
- order = await orderFactory.newSignedOrderAsync({
+ signedOrder = await orderFactory.newSignedOrderAsync({
taker,
makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
});
- const filledTakerTokenAmountBefore = await zeroEx.exchange.getFilledTakerAmountAsync(order.params
- .orderHashHex as string);
+ const filledTakerTokenAmountBefore = await zeroEx.exchange.getFilledTakerAmountAsync(
+ ZeroEx.getOrderHashHex(signedOrder),
+ );
expect(filledTakerTokenAmountBefore).to.be.bignumber.equal(0);
- const fillTakerTokenAmount = order.params.takerTokenAmount.div(2);
- await exWrapper.fillOrderAsync(order, taker, { fillTakerTokenAmount });
+ const fillTakerTokenAmount = signedOrder.takerTokenAmount.div(2);
+ await exWrapper.fillOrderAsync(signedOrder, taker, { fillTakerTokenAmount });
- const filledTakerTokenAmountAfter = await zeroEx.exchange.getFilledTakerAmountAsync(order.params
- .orderHashHex as string);
+ const filledTakerTokenAmountAfter = await zeroEx.exchange.getFilledTakerAmountAsync(
+ ZeroEx.getOrderHashHex(signedOrder),
+ );
const expectedFillAmountTAfter = fillTakerTokenAmount.add(filledTakerTokenAmountBefore);
expect(filledTakerTokenAmountAfter).to.be.bignumber.equal(expectedFillAmountTAfter);
const newBalances = await dmyBalances.getAsync();
const fillMakerTokenAmount = fillTakerTokenAmount
- .times(order.params.makerTokenAmount)
- .dividedToIntegerBy(order.params.takerTokenAmount);
- const paidMakerFee = order.params.makerFee
+ .times(signedOrder.makerTokenAmount)
+ .dividedToIntegerBy(signedOrder.takerTokenAmount);
+ const paidMakerFee = signedOrder.makerFee
.times(fillMakerTokenAmount)
- .dividedToIntegerBy(order.params.makerTokenAmount);
- const paidTakerFee = order.params.takerFee
+ .dividedToIntegerBy(signedOrder.makerTokenAmount);
+ const paidTakerFee = signedOrder.takerFee
.times(fillMakerTokenAmount)
- .dividedToIntegerBy(order.params.makerTokenAmount);
- expect(newBalances[maker][order.params.makerToken]).to.be.bignumber.equal(
- balances[maker][order.params.makerToken].minus(fillMakerTokenAmount),
+ .dividedToIntegerBy(signedOrder.makerTokenAmount);
+ expect(newBalances[maker][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
+ balances[maker][signedOrder.makerTokenAddress].minus(fillMakerTokenAmount),
);
- expect(newBalances[maker][order.params.takerToken]).to.be.bignumber.equal(
- balances[maker][order.params.takerToken].add(fillTakerTokenAmount),
+ expect(newBalances[maker][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
+ balances[maker][signedOrder.takerTokenAddress].add(fillTakerTokenAmount),
);
expect(newBalances[maker][zrx.address]).to.be.bignumber.equal(
balances[maker][zrx.address].minus(paidMakerFee),
);
- expect(newBalances[taker][order.params.takerToken]).to.be.bignumber.equal(
- balances[taker][order.params.takerToken].minus(fillTakerTokenAmount),
+ expect(newBalances[taker][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
+ balances[taker][signedOrder.takerTokenAddress].minus(fillTakerTokenAmount),
);
- expect(newBalances[taker][order.params.makerToken]).to.be.bignumber.equal(
- balances[taker][order.params.makerToken].add(fillMakerTokenAmount),
+ expect(newBalances[taker][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
+ balances[taker][signedOrder.makerTokenAddress].add(fillMakerTokenAmount),
);
expect(newBalances[taker][zrx.address]).to.be.bignumber.equal(
balances[taker][zrx.address].minus(paidTakerFee),
@@ -386,141 +397,141 @@ describe('Exchange', () => {
});
it('should fill remaining value if fillTakerTokenAmount > remaining takerTokenAmount', async () => {
- const fillTakerTokenAmount = order.params.takerTokenAmount.div(2);
- await exWrapper.fillOrderAsync(order, taker, { fillTakerTokenAmount });
+ const fillTakerTokenAmount = signedOrder.takerTokenAmount.div(2);
+ await exWrapper.fillOrderAsync(signedOrder, taker, { fillTakerTokenAmount });
- const res = await exWrapper.fillOrderAsync(order, taker, {
- fillTakerTokenAmount: order.params.takerTokenAmount,
+ const res = await exWrapper.fillOrderAsync(signedOrder, taker, {
+ fillTakerTokenAmount: signedOrder.takerTokenAmount,
});
const log = res.logs[0] as LogWithDecodedArgs<LogFillContractEventArgs>;
expect(log.args.filledTakerTokenAmount).to.be.bignumber.equal(
- order.params.takerTokenAmount.minus(fillTakerTokenAmount),
+ signedOrder.takerTokenAmount.minus(fillTakerTokenAmount),
);
const newBalances = await dmyBalances.getAsync();
- expect(newBalances[maker][order.params.makerToken]).to.be.bignumber.equal(
- balances[maker][order.params.makerToken].minus(order.params.makerTokenAmount),
+ expect(newBalances[maker][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
+ balances[maker][signedOrder.makerTokenAddress].minus(signedOrder.makerTokenAmount),
);
- expect(newBalances[maker][order.params.takerToken]).to.be.bignumber.equal(
- balances[maker][order.params.takerToken].add(order.params.takerTokenAmount),
+ expect(newBalances[maker][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
+ balances[maker][signedOrder.takerTokenAddress].add(signedOrder.takerTokenAmount),
);
expect(newBalances[maker][zrx.address]).to.be.bignumber.equal(
- balances[maker][zrx.address].minus(order.params.makerFee),
+ balances[maker][zrx.address].minus(signedOrder.makerFee),
);
- expect(newBalances[taker][order.params.takerToken]).to.be.bignumber.equal(
- balances[taker][order.params.takerToken].minus(order.params.takerTokenAmount),
+ expect(newBalances[taker][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
+ balances[taker][signedOrder.takerTokenAddress].minus(signedOrder.takerTokenAmount),
);
- expect(newBalances[taker][order.params.makerToken]).to.be.bignumber.equal(
- balances[taker][order.params.makerToken].add(order.params.makerTokenAmount),
+ expect(newBalances[taker][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
+ balances[taker][signedOrder.makerTokenAddress].add(signedOrder.makerTokenAmount),
);
expect(newBalances[taker][zrx.address]).to.be.bignumber.equal(
- balances[taker][zrx.address].minus(order.params.takerFee),
+ balances[taker][zrx.address].minus(signedOrder.takerFee),
);
expect(newBalances[feeRecipient][zrx.address]).to.be.bignumber.equal(
- balances[feeRecipient][zrx.address].add(order.params.makerFee.add(order.params.takerFee)),
+ balances[feeRecipient][zrx.address].add(signedOrder.makerFee.add(signedOrder.takerFee)),
);
});
it('should log 1 event with the correct arguments when order has a feeRecipient', async () => {
const divisor = 2;
- const res = await exWrapper.fillOrderAsync(order, taker, {
- fillTakerTokenAmount: order.params.takerTokenAmount.div(divisor),
+ const res = await exWrapper.fillOrderAsync(signedOrder, taker, {
+ fillTakerTokenAmount: signedOrder.takerTokenAmount.div(divisor),
});
expect(res.logs).to.have.length(1);
const logArgs = (res.logs[0] as LogWithDecodedArgs<LogFillContractEventArgs>).args;
- const expectedFilledMakerTokenAmount = order.params.makerTokenAmount.div(divisor);
- const expectedFilledTakerTokenAmount = order.params.takerTokenAmount.div(divisor);
- const expectedFeeMPaid = order.params.makerFee.div(divisor);
- const expectedFeeTPaid = order.params.takerFee.div(divisor);
- const tokensHashBuff = crypto.solSHA3([order.params.makerToken, order.params.takerToken]);
+ const expectedFilledMakerTokenAmount = signedOrder.makerTokenAmount.div(divisor);
+ const expectedFilledTakerTokenAmount = signedOrder.takerTokenAmount.div(divisor);
+ const expectedFeeMPaid = signedOrder.makerFee.div(divisor);
+ const expectedFeeTPaid = signedOrder.takerFee.div(divisor);
+ const tokensHashBuff = crypto.solSHA3([signedOrder.makerTokenAddress, signedOrder.takerTokenAddress]);
const expectedTokens = ethUtil.bufferToHex(tokensHashBuff);
- expect(order.params.maker).to.be.equal(logArgs.maker);
+ expect(signedOrder.maker).to.be.equal(logArgs.maker);
expect(taker).to.be.equal(logArgs.taker);
- expect(order.params.feeRecipient).to.be.equal(logArgs.feeRecipient);
- expect(order.params.makerToken).to.be.equal(logArgs.makerToken);
- expect(order.params.takerToken).to.be.equal(logArgs.takerToken);
+ expect(signedOrder.feeRecipient).to.be.equal(logArgs.feeRecipient);
+ expect(signedOrder.makerTokenAddress).to.be.equal(logArgs.makerToken);
+ expect(signedOrder.takerTokenAddress).to.be.equal(logArgs.takerToken);
expect(expectedFilledMakerTokenAmount).to.be.bignumber.equal(logArgs.filledMakerTokenAmount);
expect(expectedFilledTakerTokenAmount).to.be.bignumber.equal(logArgs.filledTakerTokenAmount);
expect(expectedFeeMPaid).to.be.bignumber.equal(logArgs.paidMakerFee);
expect(expectedFeeTPaid).to.be.bignumber.equal(logArgs.paidTakerFee);
expect(expectedTokens).to.be.equal(logArgs.tokens);
- expect(order.params.orderHashHex).to.be.equal(logArgs.orderHash);
+ expect(ZeroEx.getOrderHashHex(signedOrder)).to.be.equal(logArgs.orderHash);
});
it('should log 1 event with the correct arguments when order has no feeRecipient', async () => {
- order = await orderFactory.newSignedOrderAsync({
+ signedOrder = await orderFactory.newSignedOrderAsync({
feeRecipient: ZeroEx.NULL_ADDRESS,
});
const divisor = 2;
- const res = await exWrapper.fillOrderAsync(order, taker, {
- fillTakerTokenAmount: order.params.takerTokenAmount.div(divisor),
+ const res = await exWrapper.fillOrderAsync(signedOrder, taker, {
+ fillTakerTokenAmount: signedOrder.takerTokenAmount.div(divisor),
});
expect(res.logs).to.have.length(1);
const logArgs = (res.logs[0] as LogWithDecodedArgs<LogFillContractEventArgs>).args;
- const expectedFilledMakerTokenAmount = order.params.makerTokenAmount.div(divisor);
- const expectedFilledTakerTokenAmount = order.params.takerTokenAmount.div(divisor);
+ const expectedFilledMakerTokenAmount = signedOrder.makerTokenAmount.div(divisor);
+ const expectedFilledTakerTokenAmount = signedOrder.takerTokenAmount.div(divisor);
const expectedFeeMPaid = new BigNumber(0);
const expectedFeeTPaid = new BigNumber(0);
- const tokensHashBuff = crypto.solSHA3([order.params.makerToken, order.params.takerToken]);
+ const tokensHashBuff = crypto.solSHA3([signedOrder.makerTokenAddress, signedOrder.takerTokenAddress]);
const expectedTokens = ethUtil.bufferToHex(tokensHashBuff);
- expect(order.params.maker).to.be.equal(logArgs.maker);
+ expect(signedOrder.maker).to.be.equal(logArgs.maker);
expect(taker).to.be.equal(logArgs.taker);
- expect(order.params.feeRecipient).to.be.equal(logArgs.feeRecipient);
- expect(order.params.makerToken).to.be.equal(logArgs.makerToken);
- expect(order.params.takerToken).to.be.equal(logArgs.takerToken);
+ expect(signedOrder.feeRecipient).to.be.equal(logArgs.feeRecipient);
+ expect(signedOrder.makerTokenAddress).to.be.equal(logArgs.makerToken);
+ expect(signedOrder.takerTokenAddress).to.be.equal(logArgs.takerToken);
expect(expectedFilledMakerTokenAmount).to.be.bignumber.equal(logArgs.filledMakerTokenAmount);
expect(expectedFilledTakerTokenAmount).to.be.bignumber.equal(logArgs.filledTakerTokenAmount);
expect(expectedFeeMPaid).to.be.bignumber.equal(logArgs.paidMakerFee);
expect(expectedFeeTPaid).to.be.bignumber.equal(logArgs.paidTakerFee);
expect(expectedTokens).to.be.equal(logArgs.tokens);
- expect(order.params.orderHashHex).to.be.equal(logArgs.orderHash);
+ expect(ZeroEx.getOrderHashHex(signedOrder)).to.be.equal(logArgs.orderHash);
});
it('should throw when taker is specified and order is claimed by other', async () => {
- order = await orderFactory.newSignedOrderAsync({
+ signedOrder = await orderFactory.newSignedOrderAsync({
taker: feeRecipient,
makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
});
- return expect(exWrapper.fillOrderAsync(order, taker)).to.be.rejectedWith(constants.REVERT);
+ return expect(exWrapper.fillOrderAsync(signedOrder, taker)).to.be.rejectedWith(constants.REVERT);
});
it('should throw if signature is invalid', async () => {
- order = await orderFactory.newSignedOrderAsync({
+ signedOrder = await orderFactory.newSignedOrderAsync({
makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(10), 18),
});
- order.params.r = ethUtil.bufferToHex(ethUtil.sha3('invalidR'));
- order.params.s = ethUtil.bufferToHex(ethUtil.sha3('invalidS'));
- return expect(exWrapper.fillOrderAsync(order, taker)).to.be.rejectedWith(constants.REVERT);
+ signedOrder.ecSignature.r = ethUtil.bufferToHex(ethUtil.sha3('invalidR'));
+ signedOrder.ecSignature.s = ethUtil.bufferToHex(ethUtil.sha3('invalidS'));
+ return expect(exWrapper.fillOrderAsync(signedOrder, taker)).to.be.rejectedWith(constants.REVERT);
});
it('should throw if makerTokenAmount is 0', async () => {
- order = await orderFactory.newSignedOrderAsync({
+ signedOrder = await orderFactory.newSignedOrderAsync({
makerTokenAmount: new BigNumber(0),
});
- return expect(exWrapper.fillOrderAsync(order, taker)).to.be.rejectedWith(constants.REVERT);
+ return expect(exWrapper.fillOrderAsync(signedOrder, taker)).to.be.rejectedWith(constants.REVERT);
});
it('should throw if takerTokenAmount is 0', async () => {
- order = await orderFactory.newSignedOrderAsync({
+ signedOrder = await orderFactory.newSignedOrderAsync({
takerTokenAmount: new BigNumber(0),
});
- return expect(exWrapper.fillOrderAsync(order, taker)).to.be.rejectedWith(constants.REVERT);
+ return expect(exWrapper.fillOrderAsync(signedOrder, taker)).to.be.rejectedWith(constants.REVERT);
});
it('should throw if fillTakerTokenAmount is 0', async () => {
- order = await orderFactory.newSignedOrderAsync();
+ signedOrder = await orderFactory.newSignedOrderAsync();
return expect(
- exWrapper.fillOrderAsync(order, taker, {
+ exWrapper.fillOrderAsync(signedOrder, taker, {
fillTakerTokenAmount: new BigNumber(0),
}),
).to.be.rejectedWith(constants.REVERT);
@@ -528,23 +539,23 @@ describe('Exchange', () => {
it('should not change balances if maker balances are too low to fill order and \
shouldThrowOnInsufficientBalanceOrAllowance = false', async () => {
- order = await orderFactory.newSignedOrderAsync({
+ signedOrder = await orderFactory.newSignedOrderAsync({
makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100000), 18),
});
- await exWrapper.fillOrderAsync(order, taker);
+ await exWrapper.fillOrderAsync(signedOrder, taker);
const newBalances = await dmyBalances.getAsync();
expect(newBalances).to.be.deep.equal(balances);
});
it('should throw if maker balances are too low to fill order and \
shouldThrowOnInsufficientBalanceOrAllowance = true', async () => {
- order = await orderFactory.newSignedOrderAsync({
+ signedOrder = await orderFactory.newSignedOrderAsync({
makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100000), 18),
});
return expect(
- exWrapper.fillOrderAsync(order, taker, {
+ exWrapper.fillOrderAsync(signedOrder, taker, {
shouldThrowOnInsufficientBalanceOrAllowance: true,
}),
).to.be.rejectedWith(constants.REVERT);
@@ -552,23 +563,23 @@ describe('Exchange', () => {
it('should not change balances if taker balances are too low to fill order and \
shouldThrowOnInsufficientBalanceOrAllowance = false', async () => {
- order = await orderFactory.newSignedOrderAsync({
+ signedOrder = await orderFactory.newSignedOrderAsync({
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100000), 18),
});
- await exWrapper.fillOrderAsync(order, taker);
+ await exWrapper.fillOrderAsync(signedOrder, taker);
const newBalances = await dmyBalances.getAsync();
expect(newBalances).to.be.deep.equal(balances);
});
it('should throw if taker balances are too low to fill order and \
shouldThrowOnInsufficientBalanceOrAllowance = true', async () => {
- order = await orderFactory.newSignedOrderAsync({
+ signedOrder = await orderFactory.newSignedOrderAsync({
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100000), 18),
});
return expect(
- exWrapper.fillOrderAsync(order, taker, {
+ exWrapper.fillOrderAsync(signedOrder, taker, {
shouldThrowOnInsufficientBalanceOrAllowance: true,
}),
).to.be.rejectedWith(constants.REVERT);
@@ -577,7 +588,7 @@ describe('Exchange', () => {
it('should not change balances if maker allowances are too low to fill order and \
shouldThrowOnInsufficientBalanceOrAllowance = false', async () => {
await rep.approve.sendTransactionAsync(tokenTransferProxy.address, new BigNumber(0), { from: maker });
- await exWrapper.fillOrderAsync(order, taker);
+ await exWrapper.fillOrderAsync(signedOrder, taker);
await rep.approve.sendTransactionAsync(tokenTransferProxy.address, INITIAL_ALLOWANCE, {
from: maker,
});
@@ -590,7 +601,7 @@ describe('Exchange', () => {
shouldThrowOnInsufficientBalanceOrAllowance = true', async () => {
await rep.approve.sendTransactionAsync(tokenTransferProxy.address, new BigNumber(0), { from: maker });
expect(
- exWrapper.fillOrderAsync(order, taker, {
+ exWrapper.fillOrderAsync(signedOrder, taker, {
shouldThrowOnInsufficientBalanceOrAllowance: true,
}),
).to.be.rejectedWith(constants.REVERT);
@@ -602,7 +613,7 @@ describe('Exchange', () => {
it('should not change balances if taker allowances are too low to fill order and \
shouldThrowOnInsufficientBalanceOrAllowance = false', async () => {
await dgd.approve.sendTransactionAsync(tokenTransferProxy.address, new BigNumber(0), { from: taker });
- await exWrapper.fillOrderAsync(order, taker);
+ await exWrapper.fillOrderAsync(signedOrder, taker);
await dgd.approve.sendTransactionAsync(tokenTransferProxy.address, INITIAL_ALLOWANCE, {
from: taker,
});
@@ -615,7 +626,7 @@ describe('Exchange', () => {
shouldThrowOnInsufficientBalanceOrAllowance = true', async () => {
await dgd.approve.sendTransactionAsync(tokenTransferProxy.address, new BigNumber(0), { from: taker });
expect(
- exWrapper.fillOrderAsync(order, taker, {
+ exWrapper.fillOrderAsync(signedOrder, taker, {
shouldThrowOnInsufficientBalanceOrAllowance: true,
}),
).to.be.rejectedWith(constants.REVERT);
@@ -624,54 +635,54 @@ describe('Exchange', () => {
});
});
- it('should not change balances if makerToken is ZRX, makerTokenAmount + makerFee > maker balance, \
+ it('should not change balances if makerTokenAddress is ZRX, makerTokenAmount + makerFee > maker balance, \
and shouldThrowOnInsufficientBalanceOrAllowance = false', async () => {
const makerZRXBalance = new BigNumber(balances[maker][zrx.address]);
- order = await orderFactory.newSignedOrderAsync({
- makerToken: zrx.address,
+ signedOrder = await orderFactory.newSignedOrderAsync({
+ makerTokenAddress: zrx.address,
makerTokenAmount: makerZRXBalance,
makerFee: new BigNumber(1),
});
- await exWrapper.fillOrderAsync(order, taker);
+ await exWrapper.fillOrderAsync(signedOrder, taker);
const newBalances = await dmyBalances.getAsync();
expect(newBalances).to.be.deep.equal(balances);
});
- it('should not change balances if makerToken is ZRX, makerTokenAmount + makerFee > maker allowance, \
+ it('should not change balances if makerTokenAddress is ZRX, makerTokenAmount + makerFee > maker allowance, \
and shouldThrowOnInsufficientBalanceOrAllowance = false', async () => {
const makerZRXAllowance = await zrx.allowance(maker, tokenTransferProxy.address);
- order = await orderFactory.newSignedOrderAsync({
- makerToken: zrx.address,
+ signedOrder = await orderFactory.newSignedOrderAsync({
+ makerTokenAddress: zrx.address,
makerTokenAmount: new BigNumber(makerZRXAllowance),
makerFee: new BigNumber(1),
});
- await exWrapper.fillOrderAsync(order, taker);
+ await exWrapper.fillOrderAsync(signedOrder, taker);
const newBalances = await dmyBalances.getAsync();
expect(newBalances).to.be.deep.equal(balances);
});
- it('should not change balances if takerToken is ZRX, takerTokenAmount + takerFee > taker balance, \
+ it('should not change balances if takerTokenAddress is ZRX, takerTokenAmount + takerFee > taker balance, \
and shouldThrowOnInsufficientBalanceOrAllowance = false', async () => {
const takerZRXBalance = new BigNumber(balances[taker][zrx.address]);
- order = await orderFactory.newSignedOrderAsync({
- takerToken: zrx.address,
+ signedOrder = await orderFactory.newSignedOrderAsync({
+ takerTokenAddress: zrx.address,
takerTokenAmount: takerZRXBalance,
takerFee: new BigNumber(1),
});
- await exWrapper.fillOrderAsync(order, taker);
+ await exWrapper.fillOrderAsync(signedOrder, taker);
const newBalances = await dmyBalances.getAsync();
expect(newBalances).to.be.deep.equal(balances);
});
- it('should not change balances if takerToken is ZRX, takerTokenAmount + takerFee > taker allowance, \
+ it('should not change balances if takerTokenAddress is ZRX, takerTokenAmount + takerFee > taker allowance, \
and shouldThrowOnInsufficientBalanceOrAllowance = false', async () => {
const takerZRXAllowance = await zrx.allowance(taker, tokenTransferProxy.address);
- order = await orderFactory.newSignedOrderAsync({
- takerToken: zrx.address,
+ signedOrder = await orderFactory.newSignedOrderAsync({
+ takerTokenAddress: zrx.address,
takerTokenAmount: new BigNumber(takerZRXAllowance),
takerFee: new BigNumber(1),
});
- await exWrapper.fillOrderAsync(order, taker);
+ await exWrapper.fillOrderAsync(signedOrder, taker);
const newBalances = await dmyBalances.getAsync();
expect(newBalances).to.be.deep.equal(balances);
});
@@ -683,33 +694,33 @@ describe('Exchange', () => {
from: taker,
});
- order = await orderFactory.newSignedOrderAsync({
- takerToken: maliciousToken.address,
+ signedOrder = await orderFactory.newSignedOrderAsync({
+ takerTokenAddress: maliciousToken.address,
});
return expect(
- exWrapper.fillOrderAsync(order, taker, {
+ exWrapper.fillOrderAsync(signedOrder, taker, {
shouldThrowOnInsufficientBalanceOrAllowance: false,
}),
).to.be.rejectedWith(constants.REVERT);
});
it('should not change balances if an order is expired', async () => {
- order = await orderFactory.newSignedOrderAsync({
- expirationTimestampInSec: new BigNumber(Math.floor((Date.now() - 10000) / 1000)),
+ signedOrder = await orderFactory.newSignedOrderAsync({
+ expirationUnixTimestampSec: new BigNumber(Math.floor((Date.now() - 10000) / 1000)),
});
- await exWrapper.fillOrderAsync(order, taker);
+ await exWrapper.fillOrderAsync(signedOrder, taker);
const newBalances = await dmyBalances.getAsync();
expect(newBalances).to.be.deep.equal(balances);
});
it('should log an error event if an order is expired', async () => {
- order = await orderFactory.newSignedOrderAsync({
- expirationTimestampInSec: new BigNumber(Math.floor((Date.now() - 10000) / 1000)),
+ signedOrder = await orderFactory.newSignedOrderAsync({
+ expirationUnixTimestampSec: new BigNumber(Math.floor((Date.now() - 10000) / 1000)),
});
- const res = await exWrapper.fillOrderAsync(order, taker);
+ const res = await exWrapper.fillOrderAsync(signedOrder, taker);
expect(res.logs).to.have.length(1);
const log = res.logs[0] as LogWithDecodedArgs<LogErrorContractEventArgs>;
const errCode = log.args.errorId.toNumber();
@@ -717,10 +728,10 @@ describe('Exchange', () => {
});
it('should log an error event if no value is filled', async () => {
- order = await orderFactory.newSignedOrderAsync({});
- await exWrapper.fillOrderAsync(order, taker);
+ signedOrder = await orderFactory.newSignedOrderAsync({});
+ await exWrapper.fillOrderAsync(signedOrder, taker);
- const res = await exWrapper.fillOrderAsync(order, taker);
+ const res = await exWrapper.fillOrderAsync(signedOrder, taker);
expect(res.logs).to.have.length(1);
const log = res.logs[0] as LogWithDecodedArgs<LogErrorContractEventArgs>;
const errCode = log.args.errorId.toNumber();
@@ -731,43 +742,43 @@ describe('Exchange', () => {
describe('cancelOrder', () => {
beforeEach(async () => {
balances = await dmyBalances.getAsync();
- order = await orderFactory.newSignedOrderAsync();
+ signedOrder = await orderFactory.newSignedOrderAsync();
});
it('should throw if not sent by maker', async () => {
- return expect(exWrapper.cancelOrderAsync(order, taker)).to.be.rejectedWith(constants.REVERT);
+ return expect(exWrapper.cancelOrderAsync(signedOrder, taker)).to.be.rejectedWith(constants.REVERT);
});
it('should throw if makerTokenAmount is 0', async () => {
- order = await orderFactory.newSignedOrderAsync({
+ signedOrder = await orderFactory.newSignedOrderAsync({
makerTokenAmount: new BigNumber(0),
});
- return expect(exWrapper.cancelOrderAsync(order, maker)).to.be.rejectedWith(constants.REVERT);
+ return expect(exWrapper.cancelOrderAsync(signedOrder, maker)).to.be.rejectedWith(constants.REVERT);
});
it('should throw if takerTokenAmount is 0', async () => {
- order = await orderFactory.newSignedOrderAsync({
+ signedOrder = await orderFactory.newSignedOrderAsync({
takerTokenAmount: new BigNumber(0),
});
- return expect(exWrapper.cancelOrderAsync(order, maker)).to.be.rejectedWith(constants.REVERT);
+ return expect(exWrapper.cancelOrderAsync(signedOrder, maker)).to.be.rejectedWith(constants.REVERT);
});
it('should throw if cancelTakerTokenAmount is 0', async () => {
- order = await orderFactory.newSignedOrderAsync();
+ signedOrder = await orderFactory.newSignedOrderAsync();
return expect(
- exWrapper.cancelOrderAsync(order, maker, {
+ exWrapper.cancelOrderAsync(signedOrder, maker, {
cancelTakerTokenAmount: new BigNumber(0),
}),
).to.be.rejectedWith(constants.REVERT);
});
it('should be able to cancel a full order', async () => {
- await exWrapper.cancelOrderAsync(order, maker);
- await exWrapper.fillOrderAsync(order, taker, {
- fillTakerTokenAmount: order.params.takerTokenAmount.div(2),
+ await exWrapper.cancelOrderAsync(signedOrder, maker);
+ await exWrapper.fillOrderAsync(signedOrder, taker, {
+ fillTakerTokenAmount: signedOrder.takerTokenAmount.div(2),
});
const newBalances = await dmyBalances.getAsync();
@@ -775,43 +786,43 @@ describe('Exchange', () => {
});
it('should be able to cancel part of an order', async () => {
- const cancelTakerTokenAmount = order.params.takerTokenAmount.div(2);
- await exWrapper.cancelOrderAsync(order, maker, {
+ const cancelTakerTokenAmount = signedOrder.takerTokenAmount.div(2);
+ await exWrapper.cancelOrderAsync(signedOrder, maker, {
cancelTakerTokenAmount,
});
- const res = await exWrapper.fillOrderAsync(order, taker, {
- fillTakerTokenAmount: order.params.takerTokenAmount,
+ const res = await exWrapper.fillOrderAsync(signedOrder, taker, {
+ fillTakerTokenAmount: signedOrder.takerTokenAmount,
});
const log = res.logs[0] as LogWithDecodedArgs<LogFillContractEventArgs>;
expect(log.args.filledTakerTokenAmount).to.be.bignumber.equal(
- order.params.takerTokenAmount.minus(cancelTakerTokenAmount),
+ signedOrder.takerTokenAmount.minus(cancelTakerTokenAmount),
);
const newBalances = await dmyBalances.getAsync();
const cancelMakerTokenAmount = cancelTakerTokenAmount
- .times(order.params.makerTokenAmount)
- .dividedToIntegerBy(order.params.takerTokenAmount);
- const paidMakerFee = order.params.makerFee
+ .times(signedOrder.makerTokenAmount)
+ .dividedToIntegerBy(signedOrder.takerTokenAmount);
+ const paidMakerFee = signedOrder.makerFee
.times(cancelMakerTokenAmount)
- .dividedToIntegerBy(order.params.makerTokenAmount);
- const paidTakerFee = order.params.takerFee
+ .dividedToIntegerBy(signedOrder.makerTokenAmount);
+ const paidTakerFee = signedOrder.takerFee
.times(cancelMakerTokenAmount)
- .dividedToIntegerBy(order.params.makerTokenAmount);
- expect(newBalances[maker][order.params.makerToken]).to.be.bignumber.equal(
- balances[maker][order.params.makerToken].minus(cancelMakerTokenAmount),
+ .dividedToIntegerBy(signedOrder.makerTokenAmount);
+ expect(newBalances[maker][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
+ balances[maker][signedOrder.makerTokenAddress].minus(cancelMakerTokenAmount),
);
- expect(newBalances[maker][order.params.takerToken]).to.be.bignumber.equal(
- balances[maker][order.params.takerToken].add(cancelTakerTokenAmount),
+ expect(newBalances[maker][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
+ balances[maker][signedOrder.takerTokenAddress].add(cancelTakerTokenAmount),
);
expect(newBalances[maker][zrx.address]).to.be.bignumber.equal(
balances[maker][zrx.address].minus(paidMakerFee),
);
- expect(newBalances[taker][order.params.takerToken]).to.be.bignumber.equal(
- balances[taker][order.params.takerToken].minus(cancelTakerTokenAmount),
+ expect(newBalances[taker][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
+ balances[taker][signedOrder.takerTokenAddress].minus(cancelTakerTokenAmount),
);
- expect(newBalances[taker][order.params.makerToken]).to.be.bignumber.equal(
- balances[taker][order.params.makerToken].add(cancelMakerTokenAmount),
+ expect(newBalances[taker][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
+ balances[taker][signedOrder.makerTokenAddress].add(cancelMakerTokenAmount),
);
expect(newBalances[taker][zrx.address]).to.be.bignumber.equal(
balances[taker][zrx.address].minus(paidTakerFee),
@@ -823,32 +834,32 @@ describe('Exchange', () => {
it('should log 1 event with correct arguments', async () => {
const divisor = 2;
- const res = await exWrapper.cancelOrderAsync(order, maker, {
- cancelTakerTokenAmount: order.params.takerTokenAmount.div(divisor),
+ const res = await exWrapper.cancelOrderAsync(signedOrder, maker, {
+ cancelTakerTokenAmount: signedOrder.takerTokenAmount.div(divisor),
});
expect(res.logs).to.have.length(1);
const log = res.logs[0] as LogWithDecodedArgs<LogCancelContractEventArgs>;
const logArgs = log.args;
- const expectedCancelledMakerTokenAmount = order.params.makerTokenAmount.div(divisor);
- const expectedCancelledTakerTokenAmount = order.params.takerTokenAmount.div(divisor);
- const tokensHashBuff = crypto.solSHA3([order.params.makerToken, order.params.takerToken]);
+ const expectedCancelledMakerTokenAmount = signedOrder.makerTokenAmount.div(divisor);
+ const expectedCancelledTakerTokenAmount = signedOrder.takerTokenAmount.div(divisor);
+ const tokensHashBuff = crypto.solSHA3([signedOrder.makerTokenAddress, signedOrder.takerTokenAddress]);
const expectedTokens = ethUtil.bufferToHex(tokensHashBuff);
- expect(order.params.maker).to.be.equal(logArgs.maker);
- expect(order.params.feeRecipient).to.be.equal(logArgs.feeRecipient);
- expect(order.params.makerToken).to.be.equal(logArgs.makerToken);
- expect(order.params.takerToken).to.be.equal(logArgs.takerToken);
+ expect(signedOrder.maker).to.be.equal(logArgs.maker);
+ expect(signedOrder.feeRecipient).to.be.equal(logArgs.feeRecipient);
+ expect(signedOrder.makerTokenAddress).to.be.equal(logArgs.makerToken);
+ expect(signedOrder.takerTokenAddress).to.be.equal(logArgs.takerToken);
expect(expectedCancelledMakerTokenAmount).to.be.bignumber.equal(logArgs.cancelledMakerTokenAmount);
expect(expectedCancelledTakerTokenAmount).to.be.bignumber.equal(logArgs.cancelledTakerTokenAmount);
expect(expectedTokens).to.be.equal(logArgs.tokens);
- expect(order.params.orderHashHex).to.be.equal(logArgs.orderHash);
+ expect(ZeroEx.getOrderHashHex(signedOrder)).to.be.equal(logArgs.orderHash);
});
it('should not log events if no value is cancelled', async () => {
- await exWrapper.cancelOrderAsync(order, maker);
+ await exWrapper.cancelOrderAsync(signedOrder, maker);
- const res = await exWrapper.cancelOrderAsync(order, maker);
+ const res = await exWrapper.cancelOrderAsync(signedOrder, maker);
expect(res.logs).to.have.length(1);
const log = res.logs[0] as LogWithDecodedArgs<LogErrorContractEventArgs>;
const errCode = log.args.errorId.toNumber();
@@ -856,11 +867,11 @@ describe('Exchange', () => {
});
it('should not log events if order is expired', async () => {
- order = await orderFactory.newSignedOrderAsync({
- expirationTimestampInSec: new BigNumber(Math.floor((Date.now() - 10000) / 1000)),
+ signedOrder = await orderFactory.newSignedOrderAsync({
+ expirationUnixTimestampSec: new BigNumber(Math.floor((Date.now() - 10000) / 1000)),
});
- const res = await exWrapper.cancelOrderAsync(order, maker);
+ const res = await exWrapper.cancelOrderAsync(signedOrder, maker);
expect(res.logs).to.have.length(1);
const log = res.logs[0] as LogWithDecodedArgs<LogErrorContractEventArgs>;
const errCode = log.args.errorId.toNumber();
diff --git a/packages/contracts/test/exchange/helpers.ts b/packages/contracts/test/exchange/helpers.ts
index 33bf8b803..5fe00225e 100644
--- a/packages/contracts/test/exchange/helpers.ts
+++ b/packages/contracts/test/exchange/helpers.ts
@@ -1,4 +1,4 @@
-import { ZeroEx } from '0x.js';
+import { SignedOrder, ZeroEx } from '0x.js';
import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils';
import { BigNumber } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
@@ -8,7 +8,6 @@ import ethUtil = require('ethereumjs-util');
import { ExchangeContract } from '../../src/contract_wrappers/generated/exchange';
import { constants } from '../../util/constants';
import { ExchangeWrapper } from '../../util/exchange_wrapper';
-import { Order } from '../../util/order';
import { OrderFactory } from '../../util/order_factory';
import { ContractName } from '../../util/types';
import { chaiSetup } from '../utils/chai_setup';
@@ -25,7 +24,7 @@ describe('Exchange', () => {
let maker: string;
let feeRecipient: string;
- let order: Order;
+ let signedOrder: SignedOrder;
let exchangeWrapper: ExchangeWrapper;
let orderFactory: OrderFactory;
@@ -58,8 +57,8 @@ describe('Exchange', () => {
makerFee: ZeroEx.toBaseUnitAmount(new BigNumber(1), 18),
takerFee: ZeroEx.toBaseUnitAmount(new BigNumber(1), 18),
};
- orderFactory = new OrderFactory(web3Wrapper, defaultOrderParams);
- order = await orderFactory.newSignedOrderAsync();
+ orderFactory = new OrderFactory(zeroEx, defaultOrderParams);
+ signedOrder = await orderFactory.newSignedOrderAsync();
});
beforeEach(async () => {
@@ -70,28 +69,31 @@ describe('Exchange', () => {
});
describe('getOrderHash', () => {
it('should output the correct orderHash', async () => {
- const orderHashHex = await exchangeWrapper.getOrderHashAsync(order);
- expect(order.params.orderHashHex).to.be.equal(orderHashHex);
+ const orderHashHex = await exchangeWrapper.getOrderHashAsync(signedOrder);
+ expect(ZeroEx.getOrderHashHex(signedOrder)).to.be.equal(orderHashHex);
});
});
describe('isValidSignature', () => {
beforeEach(async () => {
- order = await orderFactory.newSignedOrderAsync();
+ signedOrder = await orderFactory.newSignedOrderAsync();
});
it('should return true with a valid signature', async () => {
- const success = await exchangeWrapper.isValidSignatureAsync(order);
- const isValidSignature = order.isValidSignature();
+ const success = await exchangeWrapper.isValidSignatureAsync(signedOrder);
+ const orderHashHex = ZeroEx.getOrderHashHex(signedOrder);
+ const isValidSignature = ZeroEx.isValidSignature(orderHashHex, signedOrder.ecSignature, signedOrder.maker);
expect(isValidSignature).to.be.true();
expect(success).to.be.true();
});
it('should return false with an invalid signature', async () => {
- order.params.r = ethUtil.bufferToHex(ethUtil.sha3('invalidR'));
- order.params.s = ethUtil.bufferToHex(ethUtil.sha3('invalidS'));
- const success = await exchangeWrapper.isValidSignatureAsync(order);
- expect(order.isValidSignature()).to.be.false();
+ signedOrder.ecSignature.r = ethUtil.bufferToHex(ethUtil.sha3('invalidR'));
+ signedOrder.ecSignature.s = ethUtil.bufferToHex(ethUtil.sha3('invalidS'));
+ const success = await exchangeWrapper.isValidSignatureAsync(signedOrder);
+ const orderHashHex = ZeroEx.getOrderHashHex(signedOrder);
+ const isValidSignature = ZeroEx.isValidSignature(orderHashHex, signedOrder.ecSignature, signedOrder.maker);
+ expect(isValidSignature).to.be.false();
expect(success).to.be.false();
});
});
diff --git a/packages/contracts/test/exchange/wrapper.ts b/packages/contracts/test/exchange/wrapper.ts
index b1851a55c..bf5a89222 100644
--- a/packages/contracts/test/exchange/wrapper.ts
+++ b/packages/contracts/test/exchange/wrapper.ts
@@ -1,4 +1,4 @@
-import { ZeroEx } from '0x.js';
+import { SignedOrder, ZeroEx } from '0x.js';
import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils';
import { BigNumber } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
@@ -13,7 +13,6 @@ import { TokenTransferProxyContract } from '../../src/contract_wrappers/generate
import { Balances } from '../../util/balances';
import { constants } from '../../util/constants';
import { ExchangeWrapper } from '../../util/exchange_wrapper';
-import { Order } from '../../util/order';
import { OrderFactory } from '../../util/order_factory';
import { BalancesByOwner, ContractName } from '../../util/types';
import { chaiSetup } from '../utils/chai_setup';
@@ -76,15 +75,15 @@ describe('Exchange', () => {
exchangeContractAddress: exchange.address,
maker,
feeRecipient,
- makerToken: rep.address,
- takerToken: dgd.address,
+ makerTokenAddress: rep.address,
+ takerTokenAddress: dgd.address,
makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
makerFee: ZeroEx.toBaseUnitAmount(new BigNumber(1), 18),
takerFee: ZeroEx.toBaseUnitAmount(new BigNumber(1), 18),
};
- orderFactory = new OrderFactory(web3Wrapper, defaultOrderParams);
+ orderFactory = new OrderFactory(zeroEx, defaultOrderParams);
dmyBalances = new Balances([rep, dgd, zrx], [maker, taker, feeRecipient]);
await Promise.all([
rep.approve.sendTransactionAsync(tokenTransferProxy.address, INIT_ALLOW, { from: maker }),
@@ -113,38 +112,38 @@ describe('Exchange', () => {
});
it('should transfer the correct amounts', async () => {
- const order = await orderFactory.newSignedOrderAsync({
+ const signedOrder = await orderFactory.newSignedOrderAsync({
makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
});
- const fillTakerTokenAmount = order.params.takerTokenAmount.div(2);
- await exWrapper.fillOrKillOrderAsync(order, taker, {
+ const fillTakerTokenAmount = signedOrder.takerTokenAmount.div(2);
+ await exWrapper.fillOrKillOrderAsync(signedOrder, taker, {
fillTakerTokenAmount,
});
const newBalances = await dmyBalances.getAsync();
const fillMakerTokenAmount = fillTakerTokenAmount
- .times(order.params.makerTokenAmount)
- .dividedToIntegerBy(order.params.takerTokenAmount);
- const makerFee = order.params.makerFee
+ .times(signedOrder.makerTokenAmount)
+ .dividedToIntegerBy(signedOrder.takerTokenAmount);
+ const makerFee = signedOrder.makerFee
.times(fillMakerTokenAmount)
- .dividedToIntegerBy(order.params.makerTokenAmount);
- const takerFee = order.params.takerFee
+ .dividedToIntegerBy(signedOrder.makerTokenAmount);
+ const takerFee = signedOrder.takerFee
.times(fillMakerTokenAmount)
- .dividedToIntegerBy(order.params.makerTokenAmount);
- expect(newBalances[maker][order.params.makerToken]).to.be.bignumber.equal(
- balances[maker][order.params.makerToken].minus(fillMakerTokenAmount),
+ .dividedToIntegerBy(signedOrder.makerTokenAmount);
+ expect(newBalances[maker][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
+ balances[maker][signedOrder.makerTokenAddress].minus(fillMakerTokenAmount),
);
- expect(newBalances[maker][order.params.takerToken]).to.be.bignumber.equal(
- balances[maker][order.params.takerToken].add(fillTakerTokenAmount),
+ expect(newBalances[maker][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
+ balances[maker][signedOrder.takerTokenAddress].add(fillTakerTokenAmount),
);
expect(newBalances[maker][zrx.address]).to.be.bignumber.equal(balances[maker][zrx.address].minus(makerFee));
- expect(newBalances[taker][order.params.takerToken]).to.be.bignumber.equal(
- balances[taker][order.params.takerToken].minus(fillTakerTokenAmount),
+ expect(newBalances[taker][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
+ balances[taker][signedOrder.takerTokenAddress].minus(fillTakerTokenAmount),
);
- expect(newBalances[taker][order.params.makerToken]).to.be.bignumber.equal(
- balances[taker][order.params.makerToken].add(fillMakerTokenAmount),
+ expect(newBalances[taker][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
+ balances[taker][signedOrder.makerTokenAddress].add(fillMakerTokenAmount),
);
expect(newBalances[taker][zrx.address]).to.be.bignumber.equal(balances[taker][zrx.address].minus(takerFee));
expect(newBalances[feeRecipient][zrx.address]).to.be.bignumber.equal(
@@ -152,30 +151,30 @@ describe('Exchange', () => {
);
});
- it('should throw if an order is expired', async () => {
- const order = await orderFactory.newSignedOrderAsync({
- expirationTimestampInSec: new BigNumber(Math.floor((Date.now() - 10000) / 1000)),
+ it('should throw if an signedOrder is expired', async () => {
+ const signedOrder = await orderFactory.newSignedOrderAsync({
+ expirationUnixTimestampSec: new BigNumber(Math.floor((Date.now() - 10000) / 1000)),
});
- return expect(exWrapper.fillOrKillOrderAsync(order, taker)).to.be.rejectedWith(constants.REVERT);
+ return expect(exWrapper.fillOrKillOrderAsync(signedOrder, taker)).to.be.rejectedWith(constants.REVERT);
});
it('should throw if entire fillTakerTokenAmount not filled', async () => {
- const order = await orderFactory.newSignedOrderAsync();
+ const signedOrder = await orderFactory.newSignedOrderAsync();
const from = taker;
- await exWrapper.fillOrderAsync(order, from, {
- fillTakerTokenAmount: order.params.takerTokenAmount.div(2),
+ await exWrapper.fillOrderAsync(signedOrder, from, {
+ fillTakerTokenAmount: signedOrder.takerTokenAmount.div(2),
});
- return expect(exWrapper.fillOrKillOrderAsync(order, taker)).to.be.rejectedWith(constants.REVERT);
+ return expect(exWrapper.fillOrKillOrderAsync(signedOrder, taker)).to.be.rejectedWith(constants.REVERT);
});
});
describe('batch functions', () => {
- let orders: Order[];
+ let signedOrders: SignedOrder[];
beforeEach(async () => {
- orders = await Promise.all([
+ signedOrders = await Promise.all([
orderFactory.newSignedOrderAsync(),
orderFactory.newSignedOrderAsync(),
orderFactory.newSignedOrderAsync(),
@@ -186,32 +185,32 @@ describe('Exchange', () => {
describe('batchFillOrders', () => {
it('should transfer the correct amounts', async () => {
const fillTakerTokenAmounts: BigNumber[] = [];
- const makerToken = rep.address;
- const takerToken = dgd.address;
- orders.forEach(order => {
- const fillTakerTokenAmount = order.params.takerTokenAmount.div(2);
+ const makerTokenAddress = rep.address;
+ const takerTokenAddress = dgd.address;
+ signedOrders.forEach(signedOrder => {
+ const fillTakerTokenAmount = signedOrder.takerTokenAmount.div(2);
const fillMakerTokenAmount = fillTakerTokenAmount
- .times(order.params.makerTokenAmount)
- .dividedToIntegerBy(order.params.takerTokenAmount);
- const makerFee = order.params.makerFee
+ .times(signedOrder.makerTokenAmount)
+ .dividedToIntegerBy(signedOrder.takerTokenAmount);
+ const makerFee = signedOrder.makerFee
.times(fillMakerTokenAmount)
- .dividedToIntegerBy(order.params.makerTokenAmount);
- const takerFee = order.params.takerFee
+ .dividedToIntegerBy(signedOrder.makerTokenAmount);
+ const takerFee = signedOrder.takerFee
.times(fillMakerTokenAmount)
- .dividedToIntegerBy(order.params.makerTokenAmount);
+ .dividedToIntegerBy(signedOrder.makerTokenAmount);
fillTakerTokenAmounts.push(fillTakerTokenAmount);
- balances[maker][makerToken] = balances[maker][makerToken].minus(fillMakerTokenAmount);
- balances[maker][takerToken] = balances[maker][takerToken].add(fillTakerTokenAmount);
+ balances[maker][makerTokenAddress] = balances[maker][makerTokenAddress].minus(fillMakerTokenAmount);
+ balances[maker][takerTokenAddress] = balances[maker][takerTokenAddress].add(fillTakerTokenAmount);
balances[maker][zrx.address] = balances[maker][zrx.address].minus(makerFee);
- balances[taker][makerToken] = balances[taker][makerToken].add(fillMakerTokenAmount);
- balances[taker][takerToken] = balances[taker][takerToken].minus(fillTakerTokenAmount);
+ balances[taker][makerTokenAddress] = balances[taker][makerTokenAddress].add(fillMakerTokenAmount);
+ balances[taker][takerTokenAddress] = balances[taker][takerTokenAddress].minus(fillTakerTokenAmount);
balances[taker][zrx.address] = balances[taker][zrx.address].minus(takerFee);
balances[feeRecipient][zrx.address] = balances[feeRecipient][zrx.address].add(
makerFee.add(takerFee),
);
});
- await exWrapper.batchFillOrdersAsync(orders, taker, {
+ await exWrapper.batchFillOrdersAsync(signedOrders, taker, {
fillTakerTokenAmounts,
});
@@ -223,32 +222,32 @@ describe('Exchange', () => {
describe('batchFillOrKillOrders', () => {
it('should transfer the correct amounts', async () => {
const fillTakerTokenAmounts: BigNumber[] = [];
- const makerToken = rep.address;
- const takerToken = dgd.address;
- orders.forEach(order => {
- const fillTakerTokenAmount = order.params.takerTokenAmount.div(2);
+ const makerTokenAddress = rep.address;
+ const takerTokenAddress = dgd.address;
+ signedOrders.forEach(signedOrder => {
+ const fillTakerTokenAmount = signedOrder.takerTokenAmount.div(2);
const fillMakerTokenAmount = fillTakerTokenAmount
- .times(order.params.makerTokenAmount)
- .dividedToIntegerBy(order.params.takerTokenAmount);
- const makerFee = order.params.makerFee
+ .times(signedOrder.makerTokenAmount)
+ .dividedToIntegerBy(signedOrder.takerTokenAmount);
+ const makerFee = signedOrder.makerFee
.times(fillMakerTokenAmount)
- .dividedToIntegerBy(order.params.makerTokenAmount);
- const takerFee = order.params.takerFee
+ .dividedToIntegerBy(signedOrder.makerTokenAmount);
+ const takerFee = signedOrder.takerFee
.times(fillMakerTokenAmount)
- .dividedToIntegerBy(order.params.makerTokenAmount);
+ .dividedToIntegerBy(signedOrder.makerTokenAmount);
fillTakerTokenAmounts.push(fillTakerTokenAmount);
- balances[maker][makerToken] = balances[maker][makerToken].minus(fillMakerTokenAmount);
- balances[maker][takerToken] = balances[maker][takerToken].add(fillTakerTokenAmount);
+ balances[maker][makerTokenAddress] = balances[maker][makerTokenAddress].minus(fillMakerTokenAmount);
+ balances[maker][takerTokenAddress] = balances[maker][takerTokenAddress].add(fillTakerTokenAmount);
balances[maker][zrx.address] = balances[maker][zrx.address].minus(makerFee);
- balances[taker][makerToken] = balances[taker][makerToken].add(fillMakerTokenAmount);
- balances[taker][takerToken] = balances[taker][takerToken].minus(fillTakerTokenAmount);
+ balances[taker][makerTokenAddress] = balances[taker][makerTokenAddress].add(fillMakerTokenAmount);
+ balances[taker][takerTokenAddress] = balances[taker][takerTokenAddress].minus(fillTakerTokenAmount);
balances[taker][zrx.address] = balances[taker][zrx.address].minus(takerFee);
balances[feeRecipient][zrx.address] = balances[feeRecipient][zrx.address].add(
makerFee.add(takerFee),
);
});
- await exWrapper.batchFillOrKillOrdersAsync(orders, taker, {
+ await exWrapper.batchFillOrKillOrdersAsync(signedOrders, taker, {
fillTakerTokenAmounts,
});
@@ -256,17 +255,17 @@ describe('Exchange', () => {
expect(newBalances).to.be.deep.equal(balances);
});
- it('should throw if a single order does not fill the expected amount', async () => {
+ it('should throw if a single signedOrder does not fill the expected amount', async () => {
const fillTakerTokenAmounts: BigNumber[] = [];
- orders.forEach(order => {
- const fillTakerTokenAmount = order.params.takerTokenAmount.div(2);
+ signedOrders.forEach(signedOrder => {
+ const fillTakerTokenAmount = signedOrder.takerTokenAmount.div(2);
fillTakerTokenAmounts.push(fillTakerTokenAmount);
});
- await exWrapper.fillOrKillOrderAsync(orders[0], taker);
+ await exWrapper.fillOrKillOrderAsync(signedOrders[0], taker);
return expect(
- exWrapper.batchFillOrKillOrdersAsync(orders, taker, {
+ exWrapper.batchFillOrKillOrdersAsync(signedOrders, taker, {
fillTakerTokenAmounts,
}),
).to.be.rejectedWith(constants.REVERT);
@@ -275,34 +274,34 @@ describe('Exchange', () => {
describe('fillOrdersUpTo', () => {
it('should stop when the entire fillTakerTokenAmount is filled', async () => {
- const fillTakerTokenAmount = orders[0].params.takerTokenAmount.plus(
- orders[1].params.takerTokenAmount.div(2),
+ const fillTakerTokenAmount = signedOrders[0].takerTokenAmount.plus(
+ signedOrders[1].takerTokenAmount.div(2),
);
- await exWrapper.fillOrdersUpToAsync(orders, taker, {
+ await exWrapper.fillOrdersUpToAsync(signedOrders, taker, {
fillTakerTokenAmount,
});
const newBalances = await dmyBalances.getAsync();
- const fillMakerTokenAmount = orders[0].params.makerTokenAmount.add(
- orders[1].params.makerTokenAmount.dividedToIntegerBy(2),
+ const fillMakerTokenAmount = signedOrders[0].makerTokenAmount.add(
+ signedOrders[1].makerTokenAmount.dividedToIntegerBy(2),
);
- const makerFee = orders[0].params.makerFee.add(orders[1].params.makerFee.dividedToIntegerBy(2));
- const takerFee = orders[0].params.takerFee.add(orders[1].params.takerFee.dividedToIntegerBy(2));
- expect(newBalances[maker][orders[0].params.makerToken]).to.be.bignumber.equal(
- balances[maker][orders[0].params.makerToken].minus(fillMakerTokenAmount),
+ const makerFee = signedOrders[0].makerFee.add(signedOrders[1].makerFee.dividedToIntegerBy(2));
+ const takerFee = signedOrders[0].takerFee.add(signedOrders[1].takerFee.dividedToIntegerBy(2));
+ expect(newBalances[maker][signedOrders[0].makerTokenAddress]).to.be.bignumber.equal(
+ balances[maker][signedOrders[0].makerTokenAddress].minus(fillMakerTokenAmount),
);
- expect(newBalances[maker][orders[0].params.takerToken]).to.be.bignumber.equal(
- balances[maker][orders[0].params.takerToken].add(fillTakerTokenAmount),
+ expect(newBalances[maker][signedOrders[0].takerTokenAddress]).to.be.bignumber.equal(
+ balances[maker][signedOrders[0].takerTokenAddress].add(fillTakerTokenAmount),
);
expect(newBalances[maker][zrx.address]).to.be.bignumber.equal(
balances[maker][zrx.address].minus(makerFee),
);
- expect(newBalances[taker][orders[0].params.takerToken]).to.be.bignumber.equal(
- balances[taker][orders[0].params.takerToken].minus(fillTakerTokenAmount),
+ expect(newBalances[taker][signedOrders[0].takerTokenAddress]).to.be.bignumber.equal(
+ balances[taker][signedOrders[0].takerTokenAddress].minus(fillTakerTokenAmount),
);
- expect(newBalances[taker][orders[0].params.makerToken]).to.be.bignumber.equal(
- balances[taker][orders[0].params.makerToken].add(fillMakerTokenAmount),
+ expect(newBalances[taker][signedOrders[0].makerTokenAddress]).to.be.bignumber.equal(
+ balances[taker][signedOrders[0].makerTokenAddress].add(fillMakerTokenAmount),
);
expect(newBalances[taker][zrx.address]).to.be.bignumber.equal(
balances[taker][zrx.address].minus(takerFee),
@@ -312,28 +311,28 @@ describe('Exchange', () => {
);
});
- it('should fill all orders if cannot fill entire fillTakerTokenAmount', async () => {
+ it('should fill all signedOrders if cannot fill entire fillTakerTokenAmount', async () => {
const fillTakerTokenAmount = ZeroEx.toBaseUnitAmount(new BigNumber(100000), 18);
- orders.forEach(order => {
- balances[maker][order.params.makerToken] = balances[maker][order.params.makerToken].minus(
- order.params.makerTokenAmount,
+ signedOrders.forEach(signedOrder => {
+ balances[maker][signedOrder.makerTokenAddress] = balances[maker][
+ signedOrder.makerTokenAddress
+ ].minus(signedOrder.makerTokenAmount);
+ balances[maker][signedOrder.takerTokenAddress] = balances[maker][signedOrder.takerTokenAddress].add(
+ signedOrder.takerTokenAmount,
);
- balances[maker][order.params.takerToken] = balances[maker][order.params.takerToken].add(
- order.params.takerTokenAmount,
+ balances[maker][zrx.address] = balances[maker][zrx.address].minus(signedOrder.makerFee);
+ balances[taker][signedOrder.makerTokenAddress] = balances[taker][signedOrder.makerTokenAddress].add(
+ signedOrder.makerTokenAmount,
);
- balances[maker][zrx.address] = balances[maker][zrx.address].minus(order.params.makerFee);
- balances[taker][order.params.makerToken] = balances[taker][order.params.makerToken].add(
- order.params.makerTokenAmount,
- );
- balances[taker][order.params.takerToken] = balances[taker][order.params.takerToken].minus(
- order.params.takerTokenAmount,
- );
- balances[taker][zrx.address] = balances[taker][zrx.address].minus(order.params.takerFee);
+ balances[taker][signedOrder.takerTokenAddress] = balances[taker][
+ signedOrder.takerTokenAddress
+ ].minus(signedOrder.takerTokenAmount);
+ balances[taker][zrx.address] = balances[taker][zrx.address].minus(signedOrder.takerFee);
balances[feeRecipient][zrx.address] = balances[feeRecipient][zrx.address].add(
- order.params.makerFee.add(order.params.takerFee),
+ signedOrder.makerFee.add(signedOrder.takerFee),
);
});
- await exWrapper.fillOrdersUpToAsync(orders, taker, {
+ await exWrapper.fillOrdersUpToAsync(signedOrders, taker, {
fillTakerTokenAmount,
});
@@ -341,15 +340,15 @@ describe('Exchange', () => {
expect(newBalances).to.be.deep.equal(balances);
});
- it('should throw when an order does not use the same takerToken', async () => {
- orders = await Promise.all([
+ it('should throw when an signedOrder does not use the same takerTokenAddress', async () => {
+ signedOrders = await Promise.all([
orderFactory.newSignedOrderAsync(),
- orderFactory.newSignedOrderAsync({ takerToken: zrx.address }),
+ orderFactory.newSignedOrderAsync({ takerTokenAddress: zrx.address }),
orderFactory.newSignedOrderAsync(),
]);
return expect(
- exWrapper.fillOrdersUpToAsync(orders, taker, {
+ exWrapper.fillOrdersUpToAsync(signedOrders, taker, {
fillTakerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(1000), 18),
}),
).to.be.rejectedWith(constants.REVERT);
@@ -357,13 +356,13 @@ describe('Exchange', () => {
});
describe('batchCancelOrders', () => {
- it('should be able to cancel multiple orders', async () => {
- const cancelTakerTokenAmounts = _.map(orders, order => order.params.takerTokenAmount);
- await exWrapper.batchCancelOrdersAsync(orders, maker, {
+ it('should be able to cancel multiple signedOrders', async () => {
+ const cancelTakerTokenAmounts = _.map(signedOrders, signedOrder => signedOrder.takerTokenAmount);
+ await exWrapper.batchCancelOrdersAsync(signedOrders, maker, {
cancelTakerTokenAmounts,
});
- await exWrapper.batchFillOrdersAsync(orders, taker, {
+ await exWrapper.batchFillOrdersAsync(signedOrders, taker, {
fillTakerTokenAmounts: cancelTakerTokenAmounts,
});
const newBalances = await dmyBalances.getAsync();
diff --git a/packages/contracts/util/exchange_wrapper.ts b/packages/contracts/util/exchange_wrapper.ts
index b749cd72e..03d04629d 100644
--- a/packages/contracts/util/exchange_wrapper.ts
+++ b/packages/contracts/util/exchange_wrapper.ts
@@ -1,4 +1,4 @@
-import { TransactionReceiptWithDecodedLogs, ZeroEx } from '0x.js';
+import { SignedOrder, TransactionReceiptWithDecodedLogs, ZeroEx } from '0x.js';
import { BigNumber } from '@0xproject/utils';
import * as _ from 'lodash';
import * as Web3 from 'web3';
@@ -6,7 +6,7 @@ import * as Web3 from 'web3';
import { ExchangeContract } from '../src/contract_wrappers/generated/exchange';
import { formatters } from './formatters';
-import { Order } from './order';
+import { signedOrderUtils } from './signed_order_utils';
export class ExchangeWrapper {
private _exchange: ExchangeContract;
@@ -16,7 +16,7 @@ export class ExchangeWrapper {
this._zeroEx = zeroEx;
}
public async fillOrderAsync(
- order: Order,
+ signedOrder: SignedOrder,
from: string,
opts: {
fillTakerTokenAmount?: BigNumber;
@@ -24,15 +24,19 @@ export class ExchangeWrapper {
} = {},
): Promise<TransactionReceiptWithDecodedLogs> {
const shouldThrowOnInsufficientBalanceOrAllowance = !!opts.shouldThrowOnInsufficientBalanceOrAllowance;
- const params = order.createFill(shouldThrowOnInsufficientBalanceOrAllowance, opts.fillTakerTokenAmount);
+ const params = signedOrderUtils.createFill(
+ signedOrder,
+ shouldThrowOnInsufficientBalanceOrAllowance,
+ opts.fillTakerTokenAmount,
+ );
const txHash = await this._exchange.fillOrder.sendTransactionAsync(
params.orderAddresses,
params.orderValues,
params.fillTakerTokenAmount,
params.shouldThrowOnInsufficientBalanceOrAllowance,
- params.v as number,
- params.r as string,
- params.s as string,
+ params.v,
+ params.r,
+ params.s,
{ from },
);
const tx = await this._zeroEx.awaitTransactionMinedAsync(txHash);
@@ -41,11 +45,11 @@ export class ExchangeWrapper {
return tx;
}
public async cancelOrderAsync(
- order: Order,
+ signedOrder: SignedOrder,
from: string,
opts: { cancelTakerTokenAmount?: BigNumber } = {},
): Promise<TransactionReceiptWithDecodedLogs> {
- const params = order.createCancel(opts.cancelTakerTokenAmount);
+ const params = signedOrderUtils.createCancel(signedOrder, opts.cancelTakerTokenAmount);
const txHash = await this._exchange.cancelOrder.sendTransactionAsync(
params.orderAddresses,
params.orderValues,
@@ -58,19 +62,23 @@ export class ExchangeWrapper {
return tx;
}
public async fillOrKillOrderAsync(
- order: Order,
+ signedOrder: SignedOrder,
from: string,
opts: { fillTakerTokenAmount?: BigNumber } = {},
): Promise<TransactionReceiptWithDecodedLogs> {
const shouldThrowOnInsufficientBalanceOrAllowance = true;
- const params = order.createFill(shouldThrowOnInsufficientBalanceOrAllowance, opts.fillTakerTokenAmount);
+ const params = signedOrderUtils.createFill(
+ signedOrder,
+ shouldThrowOnInsufficientBalanceOrAllowance,
+ opts.fillTakerTokenAmount,
+ );
const txHash = await this._exchange.fillOrKillOrder.sendTransactionAsync(
params.orderAddresses,
params.orderValues,
params.fillTakerTokenAmount,
- params.v as number,
- params.r as string,
- params.s as string,
+ params.v,
+ params.r,
+ params.s,
{ from },
);
const tx = await this._zeroEx.awaitTransactionMinedAsync(txHash);
@@ -79,7 +87,7 @@ export class ExchangeWrapper {
return tx;
}
public async batchFillOrdersAsync(
- orders: Order[],
+ orders: SignedOrder[],
from: string,
opts: {
fillTakerTokenAmounts?: BigNumber[];
@@ -108,7 +116,7 @@ export class ExchangeWrapper {
return tx;
}
public async batchFillOrKillOrdersAsync(
- orders: Order[],
+ orders: SignedOrder[],
from: string,
opts: { fillTakerTokenAmounts?: BigNumber[]; shouldThrowOnInsufficientBalanceOrAllowance?: boolean } = {},
): Promise<TransactionReceiptWithDecodedLogs> {
@@ -133,7 +141,7 @@ export class ExchangeWrapper {
return tx;
}
public async fillOrdersUpToAsync(
- orders: Order[],
+ orders: SignedOrder[],
from: string,
opts: { fillTakerTokenAmount: BigNumber; shouldThrowOnInsufficientBalanceOrAllowance?: boolean },
): Promise<TransactionReceiptWithDecodedLogs> {
@@ -159,7 +167,7 @@ export class ExchangeWrapper {
return tx;
}
public async batchCancelOrdersAsync(
- orders: Order[],
+ orders: SignedOrder[],
from: string,
opts: { cancelTakerTokenAmounts?: BigNumber[] } = {},
): Promise<TransactionReceiptWithDecodedLogs> {
@@ -175,19 +183,19 @@ export class ExchangeWrapper {
_.each(tx.logs, log => wrapLogBigNumbers(log));
return tx;
}
- public async getOrderHashAsync(order: Order): Promise<string> {
+ public async getOrderHashAsync(signedOrder: SignedOrder): Promise<string> {
const shouldThrowOnInsufficientBalanceOrAllowance = false;
- const params = order.createFill(shouldThrowOnInsufficientBalanceOrAllowance);
+ const params = signedOrderUtils.getOrderAddressesAndValues(signedOrder);
const orderHash = await this._exchange.getOrderHash(params.orderAddresses, params.orderValues);
return orderHash;
}
- public async isValidSignatureAsync(order: Order): Promise<boolean> {
+ public async isValidSignatureAsync(signedOrder: SignedOrder): Promise<boolean> {
const isValidSignature = await this._exchange.isValidSignature(
- order.params.maker,
- order.params.orderHashHex as string,
- order.params.v as number,
- order.params.r as string,
- order.params.s as string,
+ signedOrder.maker,
+ ZeroEx.getOrderHashHex(signedOrder),
+ signedOrder.ecSignature.v,
+ signedOrder.ecSignature.r,
+ signedOrder.ecSignature.s,
);
return isValidSignature;
}
diff --git a/packages/contracts/util/formatters.ts b/packages/contracts/util/formatters.ts
index e16fe8d45..8e0dfb09e 100644
--- a/packages/contracts/util/formatters.ts
+++ b/packages/contracts/util/formatters.ts
@@ -1,12 +1,12 @@
+import { SignedOrder } from '0x.js';
import { BigNumber } from '@0xproject/utils';
import * as _ from 'lodash';
-import { Order } from './order';
import { BatchCancelOrders, BatchFillOrders, FillOrdersUpTo } from './types';
export const formatters = {
createBatchFill(
- orders: Order[],
+ signedOrders: SignedOrder[],
shouldThrowOnInsufficientBalanceOrAllowance: boolean,
fillTakerTokenAmounts: BigNumber[] = [],
) {
@@ -19,33 +19,33 @@ export const formatters = {
r: [],
s: [],
};
- _.forEach(orders, order => {
+ _.forEach(signedOrders, signedOrder => {
batchFill.orderAddresses.push([
- order.params.maker,
- order.params.taker,
- order.params.makerToken,
- order.params.takerToken,
- order.params.feeRecipient,
+ signedOrder.maker,
+ signedOrder.taker,
+ signedOrder.makerTokenAddress,
+ signedOrder.takerTokenAddress,
+ signedOrder.feeRecipient,
]);
batchFill.orderValues.push([
- order.params.makerTokenAmount,
- order.params.takerTokenAmount,
- order.params.makerFee,
- order.params.takerFee,
- order.params.expirationTimestampInSec,
- order.params.salt,
+ signedOrder.makerTokenAmount,
+ signedOrder.takerTokenAmount,
+ signedOrder.makerFee,
+ signedOrder.takerFee,
+ signedOrder.expirationUnixTimestampSec,
+ signedOrder.salt,
]);
- batchFill.v.push(order.params.v as number);
- batchFill.r.push(order.params.r as string);
- batchFill.s.push(order.params.s as string);
- if (fillTakerTokenAmounts.length < orders.length) {
- batchFill.fillTakerTokenAmounts.push(order.params.takerTokenAmount);
+ batchFill.v.push(signedOrder.ecSignature.v);
+ batchFill.r.push(signedOrder.ecSignature.r);
+ batchFill.s.push(signedOrder.ecSignature.s);
+ if (fillTakerTokenAmounts.length < signedOrders.length) {
+ batchFill.fillTakerTokenAmounts.push(signedOrder.takerTokenAmount);
}
});
return batchFill;
},
createFillUpTo(
- orders: Order[],
+ signedOrders: SignedOrder[],
shouldThrowOnInsufficientBalanceOrAllowance: boolean,
fillTakerTokenAmount: BigNumber,
) {
@@ -58,52 +58,52 @@ export const formatters = {
r: [],
s: [],
};
- orders.forEach(order => {
+ signedOrders.forEach(signedOrder => {
fillUpTo.orderAddresses.push([
- order.params.maker,
- order.params.taker,
- order.params.makerToken,
- order.params.takerToken,
- order.params.feeRecipient,
+ signedOrder.maker,
+ signedOrder.taker,
+ signedOrder.makerTokenAddress,
+ signedOrder.takerTokenAddress,
+ signedOrder.feeRecipient,
]);
fillUpTo.orderValues.push([
- order.params.makerTokenAmount,
- order.params.takerTokenAmount,
- order.params.makerFee,
- order.params.takerFee,
- order.params.expirationTimestampInSec,
- order.params.salt,
+ signedOrder.makerTokenAmount,
+ signedOrder.takerTokenAmount,
+ signedOrder.makerFee,
+ signedOrder.takerFee,
+ signedOrder.expirationUnixTimestampSec,
+ signedOrder.salt,
]);
- fillUpTo.v.push(order.params.v as number);
- fillUpTo.r.push(order.params.r as string);
- fillUpTo.s.push(order.params.s as string);
+ fillUpTo.v.push(signedOrder.ecSignature.v);
+ fillUpTo.r.push(signedOrder.ecSignature.r);
+ fillUpTo.s.push(signedOrder.ecSignature.s);
});
return fillUpTo;
},
- createBatchCancel(orders: Order[], cancelTakerTokenAmounts: BigNumber[] = []) {
+ createBatchCancel(signedOrders: SignedOrder[], cancelTakerTokenAmounts: BigNumber[] = []) {
const batchCancel: BatchCancelOrders = {
orderAddresses: [],
orderValues: [],
cancelTakerTokenAmounts,
};
- orders.forEach(order => {
+ signedOrders.forEach(signedOrder => {
batchCancel.orderAddresses.push([
- order.params.maker,
- order.params.taker,
- order.params.makerToken,
- order.params.takerToken,
- order.params.feeRecipient,
+ signedOrder.maker,
+ signedOrder.taker,
+ signedOrder.makerTokenAddress,
+ signedOrder.takerTokenAddress,
+ signedOrder.feeRecipient,
]);
batchCancel.orderValues.push([
- order.params.makerTokenAmount,
- order.params.takerTokenAmount,
- order.params.makerFee,
- order.params.takerFee,
- order.params.expirationTimestampInSec,
- order.params.salt,
+ signedOrder.makerTokenAmount,
+ signedOrder.takerTokenAmount,
+ signedOrder.makerFee,
+ signedOrder.takerFee,
+ signedOrder.expirationUnixTimestampSec,
+ signedOrder.salt,
]);
- if (cancelTakerTokenAmounts.length < orders.length) {
- batchCancel.cancelTakerTokenAmounts.push(order.params.takerTokenAmount);
+ if (cancelTakerTokenAmounts.length < signedOrders.length) {
+ batchCancel.cancelTakerTokenAmounts.push(signedOrder.takerTokenAmount);
}
});
return batchCancel;
diff --git a/packages/contracts/util/order.ts b/packages/contracts/util/order.ts
deleted file mode 100644
index 57bb2bcbf..000000000
--- a/packages/contracts/util/order.ts
+++ /dev/null
@@ -1,106 +0,0 @@
-import { BigNumber } from '@0xproject/utils';
-import { Web3Wrapper } from '@0xproject/web3-wrapper';
-import ethUtil = require('ethereumjs-util');
-import * as _ from 'lodash';
-
-import { crypto } from './crypto';
-import { OrderParams } from './types';
-
-export class Order {
- public params: OrderParams;
- private _web3Wrapper: Web3Wrapper;
- constructor(web3Wrapper: Web3Wrapper, params: OrderParams) {
- this.params = params;
- this._web3Wrapper = web3Wrapper;
- }
- public isValidSignature() {
- const { v, r, s } = this.params;
- if (_.isUndefined(v) || _.isUndefined(r) || _.isUndefined(s)) {
- throw new Error('Cannot call isValidSignature on unsigned order');
- }
- const orderHash = this._getOrderHash();
- const msgHash = ethUtil.hashPersonalMessage(ethUtil.toBuffer(orderHash));
- try {
- const pubKey = ethUtil.ecrecover(msgHash, v, ethUtil.toBuffer(r), ethUtil.toBuffer(s));
- const recoveredAddress = ethUtil.bufferToHex(ethUtil.pubToAddress(pubKey));
- return recoveredAddress === this.params.maker;
- } catch (err) {
- return false;
- }
- }
- public async signAsync() {
- const orderHash = this._getOrderHash();
- const signature = await this._web3Wrapper.signTransactionAsync(this.params.maker, orderHash);
- const { v, r, s } = ethUtil.fromRpcSig(signature);
- this.params = _.assign(this.params, {
- orderHashHex: orderHash,
- v,
- r: ethUtil.bufferToHex(r),
- s: ethUtil.bufferToHex(s),
- });
- }
- public createFill(shouldThrowOnInsufficientBalanceOrAllowance?: boolean, fillTakerTokenAmount?: BigNumber) {
- const fill = {
- orderAddresses: [
- this.params.maker,
- this.params.taker,
- this.params.makerToken,
- this.params.takerToken,
- this.params.feeRecipient,
- ],
- orderValues: [
- this.params.makerTokenAmount,
- this.params.takerTokenAmount,
- this.params.makerFee,
- this.params.takerFee,
- this.params.expirationTimestampInSec,
- this.params.salt,
- ],
- fillTakerTokenAmount: fillTakerTokenAmount || this.params.takerTokenAmount,
- shouldThrowOnInsufficientBalanceOrAllowance: !!shouldThrowOnInsufficientBalanceOrAllowance,
- v: this.params.v,
- r: this.params.r,
- s: this.params.s,
- };
- return fill;
- }
- public createCancel(cancelTakerTokenAmount?: BigNumber) {
- const cancel = {
- orderAddresses: [
- this.params.maker,
- this.params.taker,
- this.params.makerToken,
- this.params.takerToken,
- this.params.feeRecipient,
- ],
- orderValues: [
- this.params.makerTokenAmount,
- this.params.takerTokenAmount,
- this.params.makerFee,
- this.params.takerFee,
- this.params.expirationTimestampInSec,
- this.params.salt,
- ],
- cancelTakerTokenAmount: cancelTakerTokenAmount || this.params.takerTokenAmount,
- };
- return cancel;
- }
- private _getOrderHash(): string {
- const orderHash = crypto.solSHA3([
- this.params.exchangeContractAddress,
- this.params.maker,
- this.params.taker,
- this.params.makerToken,
- this.params.takerToken,
- this.params.feeRecipient,
- this.params.makerTokenAmount,
- this.params.takerTokenAmount,
- this.params.makerFee,
- this.params.takerFee,
- this.params.expirationTimestampInSec,
- this.params.salt,
- ]);
- const orderHashHex = ethUtil.bufferToHex(orderHash);
- return orderHashHex;
- }
-}
diff --git a/packages/contracts/util/order_factory.ts b/packages/contracts/util/order_factory.ts
index 2b50f13e8..8ba5df24a 100644
--- a/packages/contracts/util/order_factory.ts
+++ b/packages/contracts/util/order_factory.ts
@@ -1,32 +1,37 @@
-import { ZeroEx } from '0x.js';
+import { Order, SignedOrder, ZeroEx } from '0x.js';
import { BigNumber } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as _ from 'lodash';
-import { Order } from './order';
-import { DefaultOrderParams, OptionalOrderParams, OrderParams } from './types';
+import { DefaultOrderParams } from './types';
export class OrderFactory {
- private _defaultOrderParams: DefaultOrderParams;
- private _web3Wrapper: Web3Wrapper;
- constructor(web3Wrapper: Web3Wrapper, defaultOrderParams: DefaultOrderParams) {
+ private _defaultOrderParams: Partial<Order>;
+ private _zeroEx: ZeroEx;
+ constructor(zeroEx: ZeroEx, defaultOrderParams: Partial<Order>) {
this._defaultOrderParams = defaultOrderParams;
- this._web3Wrapper = web3Wrapper;
+ this._zeroEx = zeroEx;
}
- public async newSignedOrderAsync(customOrderParams: OptionalOrderParams = {}): Promise<Order> {
+ public async newSignedOrderAsync(customOrderParams: Partial<Order> = {}): Promise<SignedOrder> {
const randomExpiration = new BigNumber(Math.floor((Date.now() + Math.random() * 100000000000) / 1000));
- const orderParams: OrderParams = _.assign(
- {},
- {
- expirationTimestampInSec: randomExpiration,
- salt: ZeroEx.generatePseudoRandomSalt(),
- taker: ZeroEx.NULL_ADDRESS,
- },
- this._defaultOrderParams,
- customOrderParams,
+ const order = ({
+ expirationUnixTimestampSec: randomExpiration,
+ salt: ZeroEx.generatePseudoRandomSalt(),
+ taker: ZeroEx.NULL_ADDRESS,
+ ...this._defaultOrderParams,
+ ...customOrderParams,
+ } as any) as Order;
+ const orderHashHex = ZeroEx.getOrderHashHex(order);
+ const shouldAddPersonalMessagePrefix = false;
+ const ecSignature = await this._zeroEx.signOrderHashAsync(
+ orderHashHex,
+ order.maker,
+ shouldAddPersonalMessagePrefix,
);
- const order = new Order(this._web3Wrapper, orderParams);
- await order.signAsync();
- return order;
+ const signedOrder = {
+ ...order,
+ ecSignature,
+ };
+ return signedOrder;
}
}
diff --git a/packages/contracts/util/signed_order_utils.ts b/packages/contracts/util/signed_order_utils.ts
new file mode 100644
index 000000000..fc2f800cd
--- /dev/null
+++ b/packages/contracts/util/signed_order_utils.ts
@@ -0,0 +1,49 @@
+import { SignedOrder } from '0x.js';
+import { BigNumber } from '@0xproject/utils';
+import { Web3Wrapper } from '@0xproject/web3-wrapper';
+import ethUtil = require('ethereumjs-util');
+import * as _ from 'lodash';
+
+import { crypto } from './crypto';
+
+export const signedOrderUtils = {
+ createFill: (
+ signedOrder: SignedOrder,
+ shouldThrowOnInsufficientBalanceOrAllowance?: boolean,
+ fillTakerTokenAmount?: BigNumber,
+ ) => {
+ const fill = {
+ ...signedOrderUtils.getOrderAddressesAndValues(signedOrder),
+ fillTakerTokenAmount: fillTakerTokenAmount || signedOrder.takerTokenAmount,
+ shouldThrowOnInsufficientBalanceOrAllowance: !!shouldThrowOnInsufficientBalanceOrAllowance,
+ ...signedOrder.ecSignature,
+ };
+ return fill;
+ },
+ createCancel(signedOrder: SignedOrder, cancelTakerTokenAmount?: BigNumber) {
+ const cancel = {
+ ...signedOrderUtils.getOrderAddressesAndValues(signedOrder),
+ cancelTakerTokenAmount: cancelTakerTokenAmount || signedOrder.takerTokenAmount,
+ };
+ return cancel;
+ },
+ getOrderAddressesAndValues(signedOrder: SignedOrder) {
+ return {
+ orderAddresses: [
+ signedOrder.maker,
+ signedOrder.taker,
+ signedOrder.makerTokenAddress,
+ signedOrder.takerTokenAddress,
+ signedOrder.feeRecipient,
+ ],
+ orderValues: [
+ signedOrder.makerTokenAmount,
+ signedOrder.takerTokenAmount,
+ signedOrder.makerFee,
+ signedOrder.takerFee,
+ signedOrder.expirationUnixTimestampSec,
+ signedOrder.salt,
+ ],
+ };
+ },
+};
diff --git a/packages/contracts/util/types.ts b/packages/contracts/util/types.ts
index 38fd33161..65bc26f79 100644
--- a/packages/contracts/util/types.ts
+++ b/packages/contracts/util/types.ts
@@ -49,39 +49,6 @@ export interface DefaultOrderParams {
takerFee: BigNumber;
}
-export interface OptionalOrderParams {
- exchangeContractAddress?: string;
- maker?: string;
- taker?: string;
- feeRecipient?: string;
- makerToken?: string;
- takerToken?: string;
- makerTokenAmount?: BigNumber;
- takerTokenAmount?: BigNumber;
- makerFee?: BigNumber;
- takerFee?: BigNumber;
- expirationTimestampInSec?: BigNumber;
-}
-
-export interface OrderParams {
- exchangeContractAddress: string;
- maker: string;
- taker: string;
- feeRecipient: string;
- makerToken: string;
- takerToken: string;
- makerTokenAmount: BigNumber;
- takerTokenAmount: BigNumber;
- makerFee: BigNumber;
- takerFee: BigNumber;
- expirationTimestampInSec: BigNumber;
- salt: BigNumber;
- orderHashHex?: string;
- v?: number;
- r?: string;
- s?: string;
-}
-
export interface TransactionDataParams {
name: string;
abi: Web3.AbiDefinition[];
diff --git a/packages/deployer/package.json b/packages/deployer/package.json
index 49e0ec26a..6564d89eb 100644
--- a/packages/deployer/package.json
+++ b/packages/deployer/package.json
@@ -1,6 +1,6 @@
{
"name": "@0xproject/deployer",
- "version": "0.0.6",
+ "version": "0.0.7",
"description": "Smart contract deployer of 0x protocol",
"main": "lib/src/index.js",
"types": "lib/src/index.d.ts",
@@ -34,8 +34,8 @@
"web3-typescript-typings": "^0.9.9"
},
"dependencies": {
- "@0xproject/utils": "^0.3.0",
- "@0xproject/web3-wrapper": "^0.1.10",
+ "@0xproject/utils": "^0.3.1",
+ "@0xproject/web3-wrapper": "^0.1.11",
"lodash": "^4.17.4",
"solc": "^0.4.18",
"web3": "^0.20.0",
diff --git a/packages/dev-utils/CHANGELOG.md b/packages/dev-utils/CHANGELOG.md
new file mode 100644
index 000000000..00c022e8b
--- /dev/null
+++ b/packages/dev-utils/CHANGELOG.md
@@ -0,0 +1,5 @@
+# CHANGELOG
+
+## v0.0.11 - _February 7, 2018_
+
+ * Updated `types-ethereumjs-util` dev dependency (#352)
diff --git a/packages/dev-utils/package.json b/packages/dev-utils/package.json
index 2a1fe26f2..4ebb9c7c8 100644
--- a/packages/dev-utils/package.json
+++ b/packages/dev-utils/package.json
@@ -1,6 +1,6 @@
{
"name": "@0xproject/dev-utils",
- "version": "0.0.10",
+ "version": "0.0.11",
"description": "0x dev TS utils",
"main": "lib/index.js",
"types": "lib/index.d.ts",
@@ -21,7 +21,7 @@
"homepage": "https://github.com/0xProject/0x.js/packages/dev-utils/README.md",
"devDependencies": {
"@0xproject/tslint-config": "^0.4.7",
- "@0xproject/types": "^0.1.9",
+ "@0xproject/types": "^0.2.0",
"@types/lodash": "^4.14.86",
"npm-run-all": "^4.1.2",
"shx": "^0.2.2",
@@ -31,7 +31,7 @@
"typescript": "2.7.1"
},
"dependencies": {
- "@0xproject/utils": "^0.3.0",
+ "@0xproject/utils": "^0.3.1",
"ethereumjs-util": "^5.1.2",
"lodash": "^4.17.4",
"request-promise-native": "^1.0.5",
diff --git a/packages/json-schemas/package.json b/packages/json-schemas/package.json
index 02a8c1994..270b4d4e0 100644
--- a/packages/json-schemas/package.json
+++ b/packages/json-schemas/package.json
@@ -1,6 +1,6 @@
{
"name": "@0xproject/json-schemas",
- "version": "0.7.8",
+ "version": "0.7.9",
"description": "0x-related json schemas",
"main": "lib/src/index.js",
"types": "lib/src/index.d.ts",
@@ -29,7 +29,7 @@
},
"devDependencies": {
"@0xproject/tslint-config": "^0.4.7",
- "@0xproject/utils": "^0.3.0",
+ "@0xproject/utils": "^0.3.1",
"@types/lodash.foreach": "^4.5.3",
"@types/lodash.values": "^4.3.3",
"@types/mocha": "^2.2.42",
diff --git a/packages/subproviders/CHANGELOG.md b/packages/subproviders/CHANGELOG.md
index 908272406..7876b2a4f 100644
--- a/packages/subproviders/CHANGELOG.md
+++ b/packages/subproviders/CHANGELOG.md
@@ -1,11 +1,11 @@
# CHANGELOG
-## v0.4.1 - _Febuary 2, 2018_
+## v0.4.0 - _February 7, 2018_
* Added NonceTrackerSubprovider (#355)
* InjectedWeb3Subprovider accepts a Provider in the constructor, previously it was a Web3 object (#363)
-## v0.3.5 - _January 28, 2018_
+## v0.3.6 - _January 28, 2018_
* Return a transaction hash from `_sendTransactionAsync` (#303)
diff --git a/packages/subproviders/README.md b/packages/subproviders/README.md
index 0d8f85910..954729713 100644
--- a/packages/subproviders/README.md
+++ b/packages/subproviders/README.md
@@ -20,10 +20,10 @@ import {
LedgerSubprovider,
} from '@0xproject/subproviders';
-const ledgerSubprovider = new LedgerSubprovider(
+const ledgerSubprovider = new LedgerSubprovider({
networkId,
ledgerEthereumClientFactoryAsync,
-);
+});
const accounts = await ledgerSubprovider.getAccountsAsync();
```
diff --git a/packages/subproviders/package.json b/packages/subproviders/package.json
index 76f7ab089..7cb721cdd 100644
--- a/packages/subproviders/package.json
+++ b/packages/subproviders/package.json
@@ -1,6 +1,6 @@
{
"name": "@0xproject/subproviders",
- "version": "0.3.6",
+ "version": "0.4.0",
"main": "lib/src/index.js",
"types": "lib/src/index.d.ts",
"license": "Apache-2.0",
@@ -18,8 +18,8 @@
"test:integration": "run-s clean build run_mocha_integration"
},
"dependencies": {
- "@0xproject/assert": "^0.0.16",
- "@0xproject/utils": "^0.3.0",
+ "@0xproject/assert": "^0.0.17",
+ "@0xproject/utils": "^0.3.1",
"bn.js": "^4.11.8",
"es6-promisify": "^5.0.0",
"ethereumjs-tx": "^1.3.3",
@@ -33,8 +33,8 @@
},
"devDependencies": {
"@0xproject/tslint-config": "^0.4.7",
- "@0xproject/types": "^0.1.9",
- "@0xproject/utils": "^0.3.0",
+ "@0xproject/types": "^0.2.0",
+ "@0xproject/utils": "^0.3.1",
"@types/lodash": "^4.14.86",
"@types/mocha": "^2.2.42",
"@types/node": "^8.0.53",
diff --git a/packages/testnet-faucets/package.json b/packages/testnet-faucets/package.json
index 3f052d91f..75b780d93 100644
--- a/packages/testnet-faucets/package.json
+++ b/packages/testnet-faucets/package.json
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@0xproject/testnet-faucets",
- "version": "1.0.10",
+ "version": "1.0.11",
"description": "A faucet micro-service that dispenses test ERC20 tokens or Ether",
"main": "server.js",
"scripts": {
@@ -15,9 +15,9 @@
"author": "Fabio Berger",
"license": "Apache-2.0",
"dependencies": {
- "0x.js": "^0.32.0",
- "@0xproject/utils": "^0.3.0",
- "@0xproject/subproviders": "^0.3.6",
+ "0x.js": "^0.32.1",
+ "@0xproject/subproviders": "^0.4.0",
+ "@0xproject/utils": "^0.3.1",
"body-parser": "^1.17.1",
"ethereumjs-tx": "^1.3.3",
"ethereumjs-util": "^5.1.1",
diff --git a/packages/testnet-faucets/src/ts/dispatch_queue.ts b/packages/testnet-faucets/src/ts/dispatch_queue.ts
new file mode 100644
index 000000000..672511619
--- /dev/null
+++ b/packages/testnet-faucets/src/ts/dispatch_queue.ts
@@ -0,0 +1,54 @@
+import { intervalUtils } from '@0xproject/utils';
+import * as _ from 'lodash';
+
+import { errorReporter } from './error_reporter';
+import { utils } from './utils';
+
+const MAX_QUEUE_SIZE = 500;
+const DEFAULT_QUEUE_INTERVAL_MS = 1000;
+
+export class DispatchQueue {
+ private _queueIntervalMs: number;
+ private _queue: Array<() => Promise<void>>;
+ private _queueIntervalIdIfExists?: NodeJS.Timer;
+ constructor() {
+ this._queueIntervalMs = DEFAULT_QUEUE_INTERVAL_MS;
+ this._queue = [];
+ this._start();
+ }
+ public add(taskAsync: () => Promise<void>): boolean {
+ if (this.isFull()) {
+ return false;
+ }
+ this._queue.push(taskAsync);
+ return true;
+ }
+ public size(): number {
+ return this._queue.length;
+ }
+ public isFull(): boolean {
+ return this.size() >= MAX_QUEUE_SIZE;
+ }
+ public stop() {
+ if (!_.isUndefined(this._queueIntervalIdIfExists)) {
+ intervalUtils.clearAsyncExcludingInterval(this._queueIntervalIdIfExists);
+ }
+ }
+ private _start() {
+ this._queueIntervalIdIfExists = intervalUtils.setAsyncExcludingInterval(
+ async () => {
+ const taskAsync = this._queue.shift();
+ if (_.isUndefined(taskAsync)) {
+ return Promise.resolve();
+ }
+ await taskAsync();
+ },
+ this._queueIntervalMs,
+ (err: Error) => {
+ utils.consoleLog(`Unexpected err: ${err} - ${JSON.stringify(err)}`);
+ // tslint:disable-next-line:no-floating-promises
+ errorReporter.reportAsync(err);
+ },
+ );
+ }
+}
diff --git a/packages/testnet-faucets/src/ts/dispense_asset_tasks.ts b/packages/testnet-faucets/src/ts/dispense_asset_tasks.ts
new file mode 100644
index 000000000..9aa47463c
--- /dev/null
+++ b/packages/testnet-faucets/src/ts/dispense_asset_tasks.ts
@@ -0,0 +1,44 @@
+import { ZeroEx } from '0x.js';
+import { BigNumber, promisify } from '@0xproject/utils';
+import * as _ from 'lodash';
+import * as Web3 from 'web3';
+
+import { configs } from './configs';
+import { errorReporter } from './error_reporter';
+import { utils } from './utils';
+
+const DISPENSE_AMOUNT_ETHER = 0.1;
+const DISPENSE_AMOUNT_TOKEN = 0.1;
+
+export const dispenseAssetTasks = {
+ dispenseEtherTask(recipientAddress: string, web3: Web3) {
+ return async () => {
+ utils.consoleLog(`Processing ETH ${recipientAddress}`);
+ const sendTransactionAsync = promisify(web3.eth.sendTransaction);
+ const txHash = await sendTransactionAsync({
+ from: configs.DISPENSER_ADDRESS,
+ to: recipientAddress,
+ value: web3.toWei(DISPENSE_AMOUNT_ETHER, 'ether'),
+ });
+ utils.consoleLog(`Sent ${DISPENSE_AMOUNT_ETHER} ETH to ${recipientAddress} tx: ${txHash}`);
+ };
+ },
+ dispenseTokenTask(recipientAddress: string, tokenSymbol: string, zeroEx: ZeroEx) {
+ return async () => {
+ utils.consoleLog(`Processing ${tokenSymbol} ${recipientAddress}`);
+ const amountToDispense = new BigNumber(DISPENSE_AMOUNT_TOKEN);
+ const token = await zeroEx.tokenRegistry.getTokenBySymbolIfExistsAsync(tokenSymbol);
+ if (_.isUndefined(token)) {
+ throw new Error(`Unsupported asset type: ${tokenSymbol}`);
+ }
+ const baseUnitAmount = ZeroEx.toBaseUnitAmount(amountToDispense, token.decimals);
+ const txHash = await zeroEx.token.transferAsync(
+ token.address,
+ configs.DISPENSER_ADDRESS,
+ recipientAddress,
+ baseUnitAmount,
+ );
+ utils.consoleLog(`Sent ${amountToDispense} ZRX to ${recipientAddress} tx: ${txHash}`);
+ };
+ },
+};
diff --git a/packages/testnet-faucets/src/ts/error_reporter.ts b/packages/testnet-faucets/src/ts/error_reporter.ts
index 6865d3893..7fd76bde5 100644
--- a/packages/testnet-faucets/src/ts/error_reporter.ts
+++ b/packages/testnet-faucets/src/ts/error_reporter.ts
@@ -9,9 +9,7 @@ export const errorReporter = {
rollbar.init(configs.ROLLBAR_ACCESS_KEY, {
environment: configs.ENVIRONMENT,
});
-
rollbar.handleUncaughtExceptions(configs.ROLLBAR_ACCESS_KEY);
-
process.on('unhandledRejection', async (err: Error) => {
utils.consoleLog(`Uncaught exception ${err}. Stack: ${err.stack}`);
await this.reportAsync(err);
@@ -22,7 +20,6 @@ export const errorReporter = {
if (configs.ENVIRONMENT === 'development') {
return; // Do not log development environment errors
}
-
return new Promise((resolve, reject) => {
rollbar.handleError(err, req, (rollbarErr: Error) => {
if (rollbarErr) {
diff --git a/packages/testnet-faucets/src/ts/ether_request_queue.ts b/packages/testnet-faucets/src/ts/ether_request_queue.ts
deleted file mode 100644
index 710d49f39..000000000
--- a/packages/testnet-faucets/src/ts/ether_request_queue.ts
+++ /dev/null
@@ -1,27 +0,0 @@
-import { promisify } from '@0xproject/utils';
-import * as _ from 'lodash';
-
-import { configs } from './configs';
-import { errorReporter } from './error_reporter';
-import { RequestQueue } from './request_queue';
-import { utils } from './utils';
-
-const DISPENSE_AMOUNT_ETHER = 0.1;
-
-export class EtherRequestQueue extends RequestQueue {
- protected async _processNextRequestFireAndForgetAsync(recipientAddress: string) {
- utils.consoleLog(`Processing ETH ${recipientAddress}`);
- const sendTransactionAsync = promisify(this._web3.eth.sendTransaction);
- try {
- const txHash = await sendTransactionAsync({
- from: configs.DISPENSER_ADDRESS,
- to: recipientAddress,
- value: this._web3.toWei(DISPENSE_AMOUNT_ETHER, 'ether'),
- });
- utils.consoleLog(`Sent ${DISPENSE_AMOUNT_ETHER} ETH to ${recipientAddress} tx: ${txHash}`);
- } catch (err) {
- utils.consoleLog(`Unexpected err: ${err} - ${JSON.stringify(err)}`);
- await errorReporter.reportAsync(err);
- }
- }
-}
diff --git a/packages/testnet-faucets/src/ts/handler.ts b/packages/testnet-faucets/src/ts/handler.ts
index d96b90802..5ed9ce628 100644
--- a/packages/testnet-faucets/src/ts/handler.ts
+++ b/packages/testnet-faucets/src/ts/handler.ts
@@ -1,5 +1,4 @@
import { Order, SignedOrder, ZeroEx } from '0x.js';
-import { NonceTrackerSubprovider } from '@0xproject/subproviders';
import { BigNumber } from '@0xproject/utils';
import * as express from 'express';
import * as _ from 'lodash';
@@ -10,17 +9,23 @@ import * as Web3 from 'web3';
// we are not running in a browser env.
// Filed issue: https://github.com/ethereum/web3.js/issues/844
(global as any).XMLHttpRequest = undefined;
+import { NonceTrackerSubprovider } from '@0xproject/subproviders';
import ProviderEngine = require('web3-provider-engine');
import HookedWalletSubprovider = require('web3-provider-engine/subproviders/hooked-wallet');
import RpcSubprovider = require('web3-provider-engine/subproviders/rpc');
import { configs } from './configs';
-import { EtherRequestQueue } from './ether_request_queue';
+import { DispatchQueue } from './dispatch_queue';
+import { dispenseAssetTasks } from './dispense_asset_tasks';
import { idManagement } from './id_management';
-import { RequestQueue } from './request_queue';
import { rpcUrls } from './rpc_urls';
import { utils } from './utils';
-import { ZRXRequestQueue } from './zrx_request_queue';
+
+interface NetworkConfig {
+ dispatchQueue: DispatchQueue;
+ web3: Web3;
+ zeroEx: ZeroEx;
+}
interface ItemByNetworkId<T> {
[networkId: string]: T;
@@ -35,30 +40,7 @@ enum RequestedAssetType {
const FIVE_DAYS_IN_MS = 4.32e8; // TODO: make this configurable
export class Handler {
- private _zeroExByNetworkId: ItemByNetworkId<ZeroEx> = {};
- private _etherRequestQueueByNetworkId: ItemByNetworkId<RequestQueue> = {};
- private _zrxRequestQueueByNetworkId: ItemByNetworkId<RequestQueue> = {};
- private static _dispenseAsset(
- req: express.Request,
- res: express.Response,
- requestQueueByNetworkId: ItemByNetworkId<RequestQueue>,
- requestedAssetType: RequestedAssetType,
- ) {
- const requestQueue = _.get(requestQueueByNetworkId, req.params.networkId);
- if (_.isUndefined(requestQueue)) {
- res.status(400).send('UNSUPPORTED_NETWORK_ID');
- return;
- }
- const didAddToQueue = requestQueue.add(req.params.recipient);
- if (!didAddToQueue) {
- res.status(503).send('QUEUE_IS_FULL');
- return;
- }
- utils.consoleLog(
- `Added ${req.params.recipient} to queue: ${requestedAssetType} networkId: ${req.params.networkId}`,
- );
- res.status(200).end();
- }
+ private _networkConfigByNetworkId: ItemByNetworkId<NetworkConfig> = {};
private static _createProviderEngine(rpcUrl: string) {
const engine = new ProviderEngine();
engine.addProvider(new NonceTrackerSubprovider());
@@ -79,35 +61,31 @@ export class Handler {
networkId: +networkId,
};
const zeroEx = new ZeroEx(web3.currentProvider, zeroExConfig);
- this._zeroExByNetworkId[networkId] = zeroEx;
- this._etherRequestQueueByNetworkId[networkId] = new EtherRequestQueue(web3);
- this._zrxRequestQueueByNetworkId[networkId] = new ZRXRequestQueue(web3, zeroEx);
+ const dispatchQueue = new DispatchQueue();
+ this._networkConfigByNetworkId[networkId] = {
+ dispatchQueue,
+ web3,
+ zeroEx,
+ };
});
}
public getQueueInfo(req: express.Request, res: express.Response) {
res.setHeader('Content-Type', 'application/json');
const queueInfo = _.mapValues(rpcUrls, (rpcUrl: string, networkId: string) => {
- const etherRequestQueue = this._etherRequestQueueByNetworkId[networkId];
- const zrxRequestQueue = this._zrxRequestQueueByNetworkId[networkId];
+ const dispatchQueue = this._networkConfigByNetworkId[networkId].dispatchQueue;
return {
- ether: {
- full: etherRequestQueue.isFull(),
- size: etherRequestQueue.size(),
- },
- zrx: {
- full: zrxRequestQueue.isFull(),
- size: zrxRequestQueue.size(),
- },
+ full: dispatchQueue.isFull(),
+ size: dispatchQueue.size(),
};
});
const payload = JSON.stringify(queueInfo);
res.status(200).send(payload);
}
public dispenseEther(req: express.Request, res: express.Response) {
- Handler._dispenseAsset(req, res, this._etherRequestQueueByNetworkId, RequestedAssetType.ETH);
+ this._dispenseAsset(req, res, RequestedAssetType.ETH);
}
public dispenseZRX(req: express.Request, res: express.Response) {
- Handler._dispenseAsset(req, res, this._zrxRequestQueueByNetworkId, RequestedAssetType.ZRX);
+ this._dispenseAsset(req, res, RequestedAssetType.ZRX);
}
public async dispenseWETHOrder(req: express.Request, res: express.Response) {
await this._dispenseOrder(req, res, RequestedAssetType.WETH);
@@ -115,12 +93,41 @@ export class Handler {
public async dispenseZRXOrder(req: express.Request, res: express.Response, next: express.NextFunction) {
await this._dispenseOrder(req, res, RequestedAssetType.ZRX);
}
+ private _dispenseAsset(req: express.Request, res: express.Response, requestedAssetType: RequestedAssetType) {
+ const networkId = req.params.networkId;
+ const recipient = req.params.recipient;
+ const networkConfig = this._networkConfigByNetworkId[networkId];
+ let dispenserTask;
+ switch (requestedAssetType) {
+ case RequestedAssetType.ETH:
+ dispenserTask = dispenseAssetTasks.dispenseEtherTask(recipient, networkConfig.web3);
+ break;
+ case RequestedAssetType.WETH:
+ case RequestedAssetType.ZRX:
+ dispenserTask = dispenseAssetTasks.dispenseTokenTask(
+ recipient,
+ requestedAssetType,
+ networkConfig.zeroEx,
+ );
+ break;
+ default:
+ throw new Error(`Unsupported asset type: ${requestedAssetType}`);
+ }
+ const didAddToQueue = networkConfig.dispatchQueue.add(dispenserTask);
+ if (!didAddToQueue) {
+ res.status(503).send('QUEUE_IS_FULL');
+ return;
+ }
+ utils.consoleLog(`Added ${recipient} to queue: ${requestedAssetType} networkId: ${networkId}`);
+ res.status(200).end();
+ }
private async _dispenseOrder(req: express.Request, res: express.Response, requestedAssetType: RequestedAssetType) {
- const zeroEx = _.get(this._zeroExByNetworkId, req.params.networkId);
- if (_.isUndefined(zeroEx)) {
+ const networkConfig = _.get(this._networkConfigByNetworkId, req.params.networkId);
+ if (_.isUndefined(networkConfig)) {
res.status(400).send('UNSUPPORTED_NETWORK_ID');
return;
}
+ const zeroEx = networkConfig.zeroEx;
res.setHeader('Content-Type', 'application/json');
const makerTokenAddress = await zeroEx.tokenRegistry.getTokenAddressBySymbolIfExistsAsync(requestedAssetType);
if (_.isUndefined(makerTokenAddress)) {
diff --git a/packages/testnet-faucets/src/ts/request_queue.ts b/packages/testnet-faucets/src/ts/request_queue.ts
deleted file mode 100644
index f128528a5..000000000
--- a/packages/testnet-faucets/src/ts/request_queue.ts
+++ /dev/null
@@ -1,51 +0,0 @@
-import * as _ from 'lodash';
-import * as timers from 'timers';
-
-// HACK: web3 leaks XMLHttpRequest into the global scope and causes requests to hang
-// because they are using the wrong XHR package.
-// Filed issue: https://github.com/ethereum/web3.js/issues/844
-// tslint:disable-next-line:ordered-imports
-import * as Web3 from 'web3';
-
-const MAX_QUEUE_SIZE = 500;
-const DEFAULT_QUEUE_INTERVAL_MS = 1000;
-
-export class RequestQueue {
- protected _queueIntervalMs: number;
- protected _queue: string[];
- protected _queueIntervalId?: NodeJS.Timer;
- protected _web3: Web3;
- constructor(web3: any) {
- this._queueIntervalMs = DEFAULT_QUEUE_INTERVAL_MS;
- this._queue = [];
- this._web3 = web3;
- this._start();
- }
- public add(recipientAddress: string): boolean {
- if (this.isFull()) {
- return false;
- }
- this._queue.push(recipientAddress);
- return true;
- }
- public size(): number {
- return this._queue.length;
- }
- public isFull(): boolean {
- return this.size() >= MAX_QUEUE_SIZE;
- }
- protected _start() {
- this._queueIntervalId = timers.setInterval(() => {
- const recipientAddress = this._queue.shift();
- if (_.isUndefined(recipientAddress)) {
- return;
- }
- // tslint:disable-next-line:no-floating-promises
- this._processNextRequestFireAndForgetAsync(recipientAddress);
- }, this._queueIntervalMs);
- }
- // tslint:disable-next-line:prefer-function-over-method
- protected async _processNextRequestFireAndForgetAsync(recipientAddress: string) {
- throw new Error('Expected processNextRequestFireAndForgetAsync to be implemented by a subclass');
- }
-}
diff --git a/packages/testnet-faucets/src/ts/rpc_urls.ts b/packages/testnet-faucets/src/ts/rpc_urls.ts
index 25a3b938f..f8a57e171 100644
--- a/packages/testnet-faucets/src/ts/rpc_urls.ts
+++ b/packages/testnet-faucets/src/ts/rpc_urls.ts
@@ -1,8 +1,8 @@
import { configs } from './configs';
const productionRpcUrls = {
- '2': `https://ropsten.infura.io/${configs.INFURA_API_KEY}`,
- '3': `https://rinkeby.infura.io/${configs.INFURA_API_KEY}`,
+ '3': `https://ropsten.infura.io/${configs.INFURA_API_KEY}`,
+ '4': `https://rinkeby.infura.io/${configs.INFURA_API_KEY}`,
'42': `https://kovan.infura.io/${configs.INFURA_API_KEY}`,
};
diff --git a/packages/testnet-faucets/src/ts/zrx_request_queue.ts b/packages/testnet-faucets/src/ts/zrx_request_queue.ts
deleted file mode 100644
index 3659f4856..000000000
--- a/packages/testnet-faucets/src/ts/zrx_request_queue.ts
+++ /dev/null
@@ -1,43 +0,0 @@
-import { ZeroEx } from '0x.js';
-import { BigNumber } from '@0xproject/utils';
-import * as _ from 'lodash';
-
-import { configs } from './configs';
-import { errorReporter } from './error_reporter';
-import { RequestQueue } from './request_queue';
-import { utils } from './utils';
-
-// HACK: web3 leaks XMLHttpRequest into the global scope and causes requests to hang
-// because they are using the wrong XHR package.
-// Filed issue: https://github.com/ethereum/web3.js/issues/844
-// tslint:disable-next-line:ordered-imports
-import * as Web3 from 'web3';
-
-const DISPENSE_AMOUNT_ZRX = new BigNumber(0.1);
-const QUEUE_INTERVAL_MS = 5000;
-
-export class ZRXRequestQueue extends RequestQueue {
- private _zeroEx: ZeroEx;
- constructor(web3: Web3, zeroEx: ZeroEx) {
- super(web3);
- this._queueIntervalMs = QUEUE_INTERVAL_MS;
- this._zeroEx = zeroEx;
- }
- protected async _processNextRequestFireAndForgetAsync(recipientAddress: string) {
- utils.consoleLog(`Processing ZRX ${recipientAddress}`);
- const baseUnitAmount = ZeroEx.toBaseUnitAmount(DISPENSE_AMOUNT_ZRX, 18);
- try {
- const zrxTokenAddress = this._zeroEx.exchange.getZRXTokenAddress();
- const txHash = await this._zeroEx.token.transferAsync(
- zrxTokenAddress,
- configs.DISPENSER_ADDRESS,
- recipientAddress,
- baseUnitAmount,
- );
- utils.consoleLog(`Sent ${DISPENSE_AMOUNT_ZRX} ZRX to ${recipientAddress} tx: ${txHash}`);
- } catch (err) {
- utils.consoleLog(`Unexpected err: ${err} - ${JSON.stringify(err)}`);
- await errorReporter.reportAsync(err);
- }
- }
-}
diff --git a/packages/types/CHANGELOG.md b/packages/types/CHANGELOG.md
index e75d0ddcb..316d92713 100644
--- a/packages/types/CHANGELOG.md
+++ b/packages/types/CHANGELOG.md
@@ -1,5 +1,5 @@
# CHANGELOG
-## vx.x.x
+## v0.2.0 - _February 7, 2018_
* Added BlockLiteralParam and BlockParam, refactored out of 0x.js types. (#355)
diff --git a/packages/types/package.json b/packages/types/package.json
index 6d8e93cfd..6b5d7f82e 100644
--- a/packages/types/package.json
+++ b/packages/types/package.json
@@ -1,6 +1,6 @@
{
"name": "@0xproject/types",
- "version": "0.1.9",
+ "version": "0.2.0",
"description": "0x types",
"main": "lib/index.js",
"types": "lib/index.d.ts",
diff --git a/packages/utils/package.json b/packages/utils/package.json
index 2a434d79a..f25295754 100644
--- a/packages/utils/package.json
+++ b/packages/utils/package.json
@@ -1,6 +1,6 @@
{
"name": "@0xproject/utils",
- "version": "0.3.0",
+ "version": "0.3.1",
"description": "0x TS utils",
"main": "lib/index.js",
"types": "lib/index.d.ts",
@@ -21,7 +21,7 @@
"homepage": "https://github.com/0xProject/0x.js/packages/utils/README.md",
"devDependencies": {
"@0xproject/tslint-config": "^0.4.7",
- "@0xproject/types": "^0.1.9",
+ "@0xproject/types": "^0.2.0",
"@types/lodash": "^4.14.86",
"npm-run-all": "^4.1.2",
"shx": "^0.2.2",
diff --git a/packages/web3-wrapper/package.json b/packages/web3-wrapper/package.json
index 33d2fde20..49342ed92 100644
--- a/packages/web3-wrapper/package.json
+++ b/packages/web3-wrapper/package.json
@@ -1,6 +1,6 @@
{
"name": "@0xproject/web3-wrapper",
- "version": "0.1.10",
+ "version": "0.1.11",
"description": "Wraps around web3 and gives a nicer interface",
"main": "lib/index.js",
"types": "lib/index.d.ts",
@@ -21,7 +21,7 @@
"homepage": "https://github.com/0xProject/0x.js/packages/web3-wrapper/README.md",
"devDependencies": {
"@0xproject/tslint-config": "^0.4.7",
- "@0xproject/types": "^0.1.9",
+ "@0xproject/types": "^0.2.0",
"@types/lodash": "^4.14.86",
"npm-run-all": "^4.1.2",
"shx": "^0.2.2",
@@ -30,7 +30,7 @@
"web3-typescript-typings": "^0.9.9"
},
"dependencies": {
- "@0xproject/utils": "^0.3.0",
+ "@0xproject/utils": "^0.3.1",
"lodash": "^4.17.4",
"web3": "^0.20.0"
}
diff --git a/packages/website/less/all.less b/packages/website/less/all.less
index 5212df959..7f2a8fc67 100644
--- a/packages/website/less/all.less
+++ b/packages/website/less/all.less
@@ -21,14 +21,19 @@ a {
}
#landing {
- .h1, .h2, .h3, .h4 {
+ .h1,
+ .h2,
+ .h3,
+ .h4 {
font-family: 'Roboto Mono';
}
}
-
#portal {
- h1, h2, h3, h4 {
+ h1,
+ h2,
+ h3,
+ h4 {
font-weight: 100;
}
}
@@ -55,13 +60,13 @@ a {
* Source: https://davidwalsh.name/osx-overflow
*/
::-webkit-scrollbar {
- -webkit-appearance: none;
- width: 7px;
+ -webkit-appearance: none;
+ width: 7px;
}
::-webkit-scrollbar-thumb {
- border-radius: 4px;
- background-color: rgba(0, 0, 0, .5);
- -webkit-box-shadow: 0 0 1px rgba(255, 255, 255, .5);
+ border-radius: 4px;
+ background-color: rgba(0, 0, 0, 0.5);
+ -webkit-box-shadow: 0 0 1px rgba(255, 255, 255, 0.5);
}
// Hack: For some reason the animation applied to the material-ui textfield causes the overflow
@@ -87,18 +92,24 @@ code {
&.hljs {
background-color: #dde4e9 !important; // blue gray
- border-left: 5px solid #0091EA !important; // colors.lightBlueA700
+ border-left: 5px solid #0091ea !important; // colors.lightBlueA700
padding: 30px;
}
}
#wiki {
- p, blockquote, ul, ol, dl, li, table, pre {
+ p,
+ blockquote,
+ ol,
+ dl,
+ li,
+ table,
+ pre {
margin: 15px 0;
}
- ol, ul {
- padding-bottom: 20px;
+ li {
+ margin: 5px 0;
}
table {
@@ -127,10 +138,12 @@ code {
margin: 0;
padding: 6px 13px;
}
- table tr th :first-child, table tr td :first-child {
+ table tr th :first-child,
+ table tr td :first-child {
margin-top: 0;
}
- table tr th :last-child, table tr td :last-child {
+ table tr th :last-child,
+ table tr td :last-child {
margin-bottom: 0;
}
}
diff --git a/packages/website/package.json b/packages/website/package.json
index f7d0ab978..c8fc78474 100644
--- a/packages/website/package.json
+++ b/packages/website/package.json
@@ -1,6 +1,6 @@
{
"name": "@0xproject/website",
- "version": "0.0.12",
+ "version": "0.0.13",
"private": true,
"description": "Website and 0x portal dapp",
"scripts": {
@@ -18,9 +18,9 @@
"author": "Fabio Berger",
"license": "Apache-2.0",
"dependencies": {
- "0x.js": "^0.32.0",
- "@0xproject/subproviders": "^0.3.6",
- "@0xproject/utils": "^0.3.0",
+ "0x.js": "^0.32.1",
+ "@0xproject/subproviders": "^0.4.0",
+ "@0xproject/utils": "^0.3.1",
"accounting": "^0.4.1",
"basscss": "^8.0.3",
"blockies": "^0.0.2",
diff --git a/packages/website/public/images/landing/project_logos/amadeus.png b/packages/website/public/images/landing/project_logos/amadeus.png
new file mode 100644
index 000000000..e3926b79f
--- /dev/null
+++ b/packages/website/public/images/landing/project_logos/amadeus.png
Binary files differ
diff --git a/packages/website/public/images/landing/project_logos/ddex.png b/packages/website/public/images/landing/project_logos/ddex.png
new file mode 100644
index 000000000..a1a8def26
--- /dev/null
+++ b/packages/website/public/images/landing/project_logos/ddex.png
Binary files differ
diff --git a/packages/website/public/images/landing/project_logos/decent_ex.png b/packages/website/public/images/landing/project_logos/decent_ex.png
new file mode 100644
index 000000000..1fac76947
--- /dev/null
+++ b/packages/website/public/images/landing/project_logos/decent_ex.png
Binary files differ
diff --git a/packages/website/public/images/landing/project_logos/dextroid.png b/packages/website/public/images/landing/project_logos/dextroid.png
new file mode 100644
index 000000000..5fdcd7f8e
--- /dev/null
+++ b/packages/website/public/images/landing/project_logos/dextroid.png
Binary files differ
diff --git a/packages/website/public/images/landing/project_logos/ercdex.png b/packages/website/public/images/landing/project_logos/ercdex.png
new file mode 100644
index 000000000..1367837e0
--- /dev/null
+++ b/packages/website/public/images/landing/project_logos/ercdex.png
Binary files differ
diff --git a/packages/website/public/images/landing/project_logos/ethfinex-top.png b/packages/website/public/images/landing/project_logos/ethfinex-top.png
deleted file mode 100644
index 5eda914ca..000000000
--- a/packages/website/public/images/landing/project_logos/ethfinex-top.png
+++ /dev/null
Binary files differ
diff --git a/packages/website/public/images/landing/project_logos/ethfinex.png b/packages/website/public/images/landing/project_logos/ethfinex.png
new file mode 100644
index 000000000..5aa0c556f
--- /dev/null
+++ b/packages/website/public/images/landing/project_logos/ethfinex.png
Binary files differ
diff --git a/packages/website/public/images/landing/project_logos/idt.png b/packages/website/public/images/landing/project_logos/idt.png
new file mode 100644
index 000000000..859c289d2
--- /dev/null
+++ b/packages/website/public/images/landing/project_logos/idt.png
Binary files differ
diff --git a/packages/website/public/images/landing/project_logos/open_relay.png b/packages/website/public/images/landing/project_logos/open_relay.png
new file mode 100644
index 000000000..fa1853df6
--- /dev/null
+++ b/packages/website/public/images/landing/project_logos/open_relay.png
Binary files differ
diff --git a/packages/website/public/images/landing/project_logos/paradex.png b/packages/website/public/images/landing/project_logos/paradex.png
new file mode 100644
index 000000000..7948eb938
--- /dev/null
+++ b/packages/website/public/images/landing/project_logos/paradex.png
Binary files differ
diff --git a/packages/website/public/images/landing/project_logos/paradex_top.png b/packages/website/public/images/landing/project_logos/paradex_top.png
deleted file mode 100644
index 3fe9472b9..000000000
--- a/packages/website/public/images/landing/project_logos/paradex_top.png
+++ /dev/null
Binary files differ
diff --git a/packages/website/public/images/landing/project_logos/radar_relay.png b/packages/website/public/images/landing/project_logos/radar_relay.png
new file mode 100644
index 000000000..af0e610f8
--- /dev/null
+++ b/packages/website/public/images/landing/project_logos/radar_relay.png
Binary files differ
diff --git a/packages/website/public/images/landing/project_logos/radar_relay_top.png b/packages/website/public/images/landing/project_logos/radar_relay_top.png
deleted file mode 100644
index 737159959..000000000
--- a/packages/website/public/images/landing/project_logos/radar_relay_top.png
+++ /dev/null
Binary files differ
diff --git a/packages/website/ts/components/token_balances.tsx b/packages/website/ts/components/token_balances.tsx
index dfb62bbb3..894edf0a8 100644
--- a/packages/website/ts/components/token_balances.tsx
+++ b/packages/website/ts/components/token_balances.tsx
@@ -118,7 +118,8 @@ export class TokenBalances extends React.Component<TokenBalancesProps, TokenBala
if (nextProps.userEtherBalance !== this.props.userEtherBalance) {
if (this.state.isBalanceSpinnerVisible) {
const receivedAmount = nextProps.userEtherBalance.minus(this.props.userEtherBalance);
- this.props.dispatcher.showFlashMessage(`Received ${receivedAmount.toString(10)} Kovan Ether`);
+ const networkName = constants.NETWORK_NAME_BY_ID[this.props.networkId];
+ this.props.dispatcher.showFlashMessage(`Received ${receivedAmount.toString(10)} ${networkName} Ether`);
}
this.setState({
isBalanceSpinnerVisible: false,
@@ -176,13 +177,14 @@ export class TokenBalances extends React.Component<TokenBalancesProps, TokenBala
onTouchTap={this._onDharmaDialogToggle.bind(this, false)}
/>,
];
+ const isTestNetwork = utils.isTestNetwork(this.props.networkId);
const isKovanTestNetwork = this.props.networkId === constants.NETWORK_ID_KOVAN;
const dharmaButtonColumnStyle = {
paddingLeft: 3,
display: isKovanTestNetwork ? 'table-cell' : 'none',
};
const stubColumnStyle = {
- display: isKovanTestNetwork ? 'none' : 'table-cell',
+ display: isTestNetwork ? 'none' : 'table-cell',
};
const allTokenRowHeight = _.size(this.props.tokenByAddress) * TOKEN_TABLE_ROW_HEIGHT;
const tokenTableHeight =
@@ -201,10 +203,10 @@ export class TokenBalances extends React.Component<TokenBalancesProps, TokenBala
smart contract so you can start trading that token.';
return (
<div className="lg-px4 md-px4 sm-px1 pb2">
- <h3>{isKovanTestNetwork ? 'Test ether' : 'Ether'}</h3>
+ <h3>{isTestNetwork ? 'Test ether' : 'Ether'}</h3>
<Divider />
<div className="pt2 pb2">
- {isKovanTestNetwork
+ {isTestNetwork
? 'In order to try out the 0x Portal Dapp, request some test ether to pay for \
gas costs. It might take a bit of time for the test ether to show up.'
: 'Ether must be converted to Ether Tokens in order to be tradable via 0x. \
@@ -216,7 +218,7 @@ export class TokenBalances extends React.Component<TokenBalancesProps, TokenBala
<TableHeaderColumn>Currency</TableHeaderColumn>
<TableHeaderColumn>Balance</TableHeaderColumn>
<TableRowColumn className="sm-hide xs-hide" style={stubColumnStyle} />
- {isKovanTestNetwork && (
+ {isTestNetwork && (
<TableHeaderColumn style={{ paddingLeft: 3 }}>
{isSmallScreen ? 'Faucet' : 'Request from faucet'}
</TableHeaderColumn>
@@ -243,7 +245,7 @@ export class TokenBalances extends React.Component<TokenBalancesProps, TokenBala
)}
</TableRowColumn>
<TableRowColumn className="sm-hide xs-hide" style={stubColumnStyle} />
- {isKovanTestNetwork && (
+ {isTestNetwork && (
<TableRowColumn style={{ paddingLeft: 3 }}>
<LifeCycleRaisedButton
labelReady="Request"
@@ -267,7 +269,7 @@ export class TokenBalances extends React.Component<TokenBalancesProps, TokenBala
</Table>
<div className="clearfix" style={{ paddingBottom: 1 }}>
<div className="col col-10">
- <h3 className="pt2">{isKovanTestNetwork ? 'Test tokens' : 'Tokens'}</h3>
+ <h3 className="pt2">{isTestNetwork ? 'Test tokens' : 'Tokens'}</h3>
</div>
<div className="col col-1 pt3 align-right">
<FloatingActionButton mini={true} zDepth={0} onClick={this._onAddTokenClicked.bind(this)}>
@@ -282,7 +284,7 @@ export class TokenBalances extends React.Component<TokenBalancesProps, TokenBala
</div>
<Divider />
<div className="pt2 pb2">
- {isKovanTestNetwork
+ {isTestNetwork
? "Mint some test tokens you'd like to use to generate or fill an order using 0x."
: "Set trading permissions for a token you'd like to start trading."}
</div>
@@ -362,8 +364,13 @@ export class TokenBalances extends React.Component<TokenBalancesProps, TokenBala
EtherscanLinkSuffixes.Address,
);
const isMintable =
- _.includes(configs.SYMBOLS_OF_MINTABLE_TOKENS, token.symbol) &&
- this.props.networkId !== constants.NETWORK_ID_MAINNET;
+ (_.includes(configs.SYMBOLS_OF_MINTABLE_KOVAN_TOKENS, token.symbol) &&
+ this.props.networkId === constants.NETWORK_ID_BY_NAME[Networks.Kovan]) ||
+ (_.includes(configs.SYMBOLS_OF_MINTABLE_RINKEBY_ROPSTEN_TOKENS, token.symbol) &&
+ _.includes(
+ [constants.NETWORK_ID_BY_NAME[Networks.Rinkeby], constants.NETWORK_ID_BY_NAME[Networks.Ropsten]],
+ this.props.networkId,
+ ));
return (
<TableRow key={token.address} style={{ height: TOKEN_TABLE_ROW_HEIGHT }}>
<TableRowColumn colSpan={tokenColSpan}>
@@ -413,7 +420,7 @@ export class TokenBalances extends React.Component<TokenBalancesProps, TokenBala
/>
)}
{token.symbol === ZRX_TOKEN_SYMBOL &&
- this.props.networkId === constants.NETWORK_ID_KOVAN && (
+ utils.isTestNetwork(this.props.networkId) && (
<LifeCycleRaisedButton
labelReady="Request"
labelLoading="Sending..."
@@ -498,9 +505,8 @@ export class TokenBalances extends React.Component<TokenBalancesProps, TokenBala
case BalanceErrs.incorrectNetworkForFaucet:
return (
<div>
- Our faucet can only send test Ether to addresses on the {Networks.Kovan} testnet (networkId{' '}
- {constants.NETWORK_ID_KOVAN}). Please make sure you are connected to the {Networks.Kovan}{' '}
- testnet and try requesting ether again.
+ Our faucet can only send test Ether to addresses on testnets. Please make sure you are connected
+ to a testnet and try requesting again.
</div>
);
@@ -589,7 +595,7 @@ export class TokenBalances extends React.Component<TokenBalancesProps, TokenBala
// If on another network other then the testnet our faucet serves test ether
// from, we must show user an error message
- if (this.props.blockchain.networkId !== constants.NETWORK_ID_KOVAN) {
+ if (!utils.isTestNetwork(this.props.blockchain.networkId)) {
this.setState({
errorType: BalanceErrs.incorrectNetworkForFaucet,
});
@@ -599,7 +605,9 @@ export class TokenBalances extends React.Component<TokenBalancesProps, TokenBala
await utils.sleepAsync(ARTIFICIAL_FAUCET_REQUEST_DELAY);
const segment = isEtherRequest ? 'ether' : 'zrx';
- const response = await fetch(`${constants.URL_ETHER_FAUCET}/${segment}/${this.props.userAddress}`);
+ const response = await fetch(
+ `${constants.URL_TESTNET_FAUCET}/${segment}/${this.props.userAddress}?networkId=${this.props.networkId}`,
+ );
const responseBody = await response.text();
if (response.status !== constants.SUCCESS_STATUS) {
utils.consoleLog(`Unexpected status code: ${response.status} -> ${responseBody}`);
diff --git a/packages/website/ts/components/top_bar/top_bar.tsx b/packages/website/ts/components/top_bar/top_bar.tsx
index 1a0691e83..b1367be4f 100644
--- a/packages/website/ts/components/top_bar/top_bar.tsx
+++ b/packages/website/ts/components/top_bar/top_bar.tsx
@@ -169,12 +169,21 @@ export class TopBar extends React.Component<TopBarProps, TopBarState> {
path={`${WebsitePaths.Wiki}`}
style={styles.menuItem}
isNightVersion={isNightVersion}
+ isExternal={false}
+ />
+ <TopBarMenuItem
+ title="Blog"
+ path={constants.URL_BLOG}
+ style={styles.menuItem}
+ isNightVersion={isNightVersion}
+ isExternal={true}
/>
<TopBarMenuItem
title="About"
path={`${WebsitePaths.About}`}
style={styles.menuItem}
isNightVersion={isNightVersion}
+ isExternal={false}
/>
<TopBarMenuItem
title="Portal DApp"
@@ -183,6 +192,7 @@ export class TopBar extends React.Component<TopBarProps, TopBarState> {
style={styles.menuItem}
className={`${isFullWidthPage && 'md-hide'}`}
isNightVersion={isNightVersion}
+ isExternal={false}
/>
</div>
</div>
diff --git a/packages/website/ts/components/top_bar/top_bar_menu_item.tsx b/packages/website/ts/components/top_bar/top_bar_menu_item.tsx
index 96ee86142..983050abc 100644
--- a/packages/website/ts/components/top_bar/top_bar_menu_item.tsx
+++ b/packages/website/ts/components/top_bar/top_bar_menu_item.tsx
@@ -11,6 +11,7 @@ interface TopBarMenuItemProps {
title: string;
path?: string;
isPrimary?: boolean;
+ isExternal: boolean;
style?: React.CSSProperties;
className?: string;
isNightVersion?: boolean;
@@ -43,9 +44,20 @@ export class TopBarMenuItem extends React.Component<TopBarMenuItemProps, TopBarM
className={`center ${this.props.className}`}
style={{ ...this.props.style, ...primaryStyles, color: menuItemColor }}
>
- <Link to={this.props.path} className="text-decoration-none" style={{ color: linkColor }}>
- {this.props.title}
- </Link>
+ {this.props.isExternal ? (
+ <a
+ className="text-decoration-none"
+ style={{ color: linkColor }}
+ target="_blank"
+ href={this.props.path}
+ >
+ {this.props.title}
+ </a>
+ ) : (
+ <Link to={this.props.path} className="text-decoration-none" style={{ color: linkColor }}>
+ {this.props.title}
+ </Link>
+ )}
</div>
);
}
diff --git a/packages/website/ts/pages/landing/landing.tsx b/packages/website/ts/pages/landing/landing.tsx
index b0c622fb4..d4c934459 100644
--- a/packages/website/ts/pages/landing/landing.tsx
+++ b/packages/website/ts/pages/landing/landing.tsx
@@ -65,17 +65,17 @@ const boxContents: BoxContent[] = [
},
];
-const projects: Project[] = [
+const relayersAndDappProjects: Project[] = [
{
- logoFileName: 'ethfinex-top.png',
+ logoFileName: 'ethfinex.png',
projectUrl: constants.PROJECT_URL_ETHFINEX,
},
{
- logoFileName: 'radar_relay_top.png',
+ logoFileName: 'radar_relay.png',
projectUrl: constants.PROJECT_URL_RADAR_RELAY,
},
{
- logoFileName: 'paradex_top.png',
+ logoFileName: 'paradex.png',
projectUrl: constants.PROJECT_URL_PARADEX,
},
{
@@ -132,6 +132,57 @@ const projects: Project[] = [
},
];
+const relayerProjects: Project[] = [
+ {
+ logoFileName: 'ethfinex.png',
+ projectUrl: constants.PROJECT_URL_ETHFINEX,
+ },
+ {
+ logoFileName: 'radar_relay.png',
+ projectUrl: constants.PROJECT_URL_RADAR_RELAY,
+ },
+ {
+ logoFileName: 'paradex.png',
+ projectUrl: constants.PROJECT_URL_PARADEX,
+ },
+ {
+ logoFileName: 'the_ocean.png',
+ projectUrl: constants.PROJECT_URL_0CEAN,
+ },
+ {
+ logoFileName: 'dydx.png',
+ projectUrl: constants.PROJECT_URL_DYDX,
+ },
+ {
+ logoFileName: 'amadeus.png',
+ projectUrl: constants.PROJECT_URL_AMADEUS,
+ },
+ {
+ logoFileName: 'ddex.png',
+ projectUrl: constants.PROJECT_URL_DDEX,
+ },
+ {
+ logoFileName: 'decent_ex.png',
+ projectUrl: constants.PROJECT_URL_DECENT_EX,
+ },
+ {
+ logoFileName: 'dextroid.png',
+ projectUrl: constants.PROJECT_URL_DEXTROID,
+ },
+ {
+ logoFileName: 'ercdex.png',
+ projectUrl: constants.PROJECT_URL_ERC_DEX,
+ },
+ {
+ logoFileName: 'open_relay.png',
+ projectUrl: constants.PROJECT_URL_OPEN_RELAY,
+ },
+ {
+ logoFileName: 'idt.png',
+ projectUrl: constants.PROJECT_URL_IDT,
+ },
+];
+
export interface LandingProps {
location: Location;
}
@@ -167,9 +218,10 @@ export class Landing extends React.Component<LandingProps, LandingState> {
style={{ backgroundColor: colors.heroGrey, position: 'relative' }}
/>
{this._renderHero()}
- {this._renderProjects()}
+ {this._renderProjects(relayersAndDappProjects, 'Projects building on 0x', colors.projectsGrey, false)}
{this._renderTokenizationSection()}
{this._renderProtocolSection()}
+ {this._renderProjects(relayerProjects, 'Relayers building on 0x', colors.heroGrey, true)}
{this._renderInfoBoxes()}
{this._renderBuildingBlocksSection()}
{this._renderUseCases()}
@@ -259,11 +311,25 @@ export class Landing extends React.Component<LandingProps, LandingState> {
</div>
);
}
- private _renderProjects() {
+ private _renderProjects(projects: Project[], title: string, backgroundColor: string, isTitleCenter: boolean) {
const isSmallScreen = this.state.screenWidth === ScreenWidths.Sm;
const isMediumScreen = this.state.screenWidth === ScreenWidths.Md;
const projectList = _.map(projects, (project: Project, i: number) => {
- const colWidth = isSmallScreen ? 3 : isMediumScreen ? 4 : 2 - i % 2;
+ const isRelayersOnly = projects.length === 12;
+ let colWidth: number;
+ switch (this.state.screenWidth) {
+ case ScreenWidths.Sm:
+ colWidth = 4;
+ break;
+
+ case ScreenWidths.Md:
+ colWidth = 3;
+ break;
+
+ case ScreenWidths.Lg:
+ colWidth = isRelayersOnly ? 2 : 2 - i % 2;
+ break;
+ }
return (
<div key={`project-${project.logoFileName}`} className={`col col-${colWidth} center`}>
<div>
@@ -285,10 +351,10 @@ export class Landing extends React.Component<LandingProps, LandingState> {
letterSpacing: 3,
};
return (
- <div className="clearfix py4" style={{ backgroundColor: colors.projectsGrey }}>
+ <div className={`clearfix py4 ${isTitleCenter && 'center'}`} style={{ backgroundColor }}>
<div className="mx-auto max-width-4 clearfix sm-px3">
- <div className="h4 pb3 md-pl3 sm-pl2" style={titleStyle}>
- Projects building on 0x
+ <div className="h4 pb3 lg-pl0 md-pl3 sm-pl2" style={titleStyle}>
+ {title}
</div>
<div className="clearfix">{projectList}</div>
<div
@@ -319,7 +385,7 @@ export class Landing extends React.Component<LandingProps, LandingState> {
<div className="clearfix lg-py4 md-py4 sm-pb4 sm-pt2" style={{ backgroundColor: colors.grey100 }}>
<div className="mx-auto max-width-4 py4 clearfix">
{isSmallScreen && this._renderTokenCloud()}
- <div className="col lg-col-6 md-col-6 col-12">
+ <div className="col lg-col-6 md-col-6 col-12" style={{ color: colors.darkestGrey }}>
<div className="mx-auto" style={{ maxWidth: 385, paddingTop: 7 }}>
<div className="lg-h1 md-h1 sm-h2 sm-center sm-pt3" style={{ fontFamily: 'Roboto Mono' }}>
The world's value is becoming tokenized
@@ -358,16 +424,15 @@ export class Landing extends React.Component<LandingProps, LandingState> {
private _renderProtocolSection() {
const isSmallScreen = this.state.screenWidth === ScreenWidths.Sm;
return (
- <div className="clearfix lg-py4 md-py4 sm-pt4" style={{ backgroundColor: colors.heroGrey }}>
- <div className="mx-auto max-width-4 lg-py4 md-py4 sm-pt4 clearfix">
+ <div className="clearfix pt4" style={{ backgroundColor: colors.heroGrey }}>
+ <div className="mx-auto max-width-4 pt4 clearfix">
<div className="col lg-col-6 md-col-6 col-12 sm-center">
<img src="/images/landing/relayer_diagram.png" height={isSmallScreen ? 326 : 426} />
</div>
<div
- className="col lg-col-6 md-col-6 col-12 lg-pr3 md-pr3 sm-mx-auto"
+ className="col lg-col-6 md-col-6 col-12 lg-pr3 md-pr3 sm-mx-auto lg-pt4 md-pt4 lg-mt3 md-mt3"
style={{
color: colors.beigeWhite,
- paddingTop: 8,
maxWidth: isSmallScreen ? 'none' : 445,
}}
>
@@ -388,57 +453,6 @@ export class Landing extends React.Component<LandingProps, LandingState> {
eliminating blockchain bloat. Relayers help broadcast orders and collect a fee each time
they facilitate a trade. Anyone can build a relayer.
</div>
- <div
- className="pt3 sm-mx-auto sm-px3"
- style={{
- color: colors.landingLinkGrey,
- maxWidth: isSmallScreen ? 412 : 'none',
- }}
- >
- <div className="flex" style={{ fontSize: 18 }}>
- <div
- className="lg-h4 md-h4 sm-h5"
- style={{
- letterSpacing: isSmallScreen ? 1 : 3,
- fontFamily: 'Roboto Mono',
- }}
- >
- RELAYERS BUILDING ON 0X
- </div>
- <div className="h5" style={{ marginLeft: isSmallScreen ? 26 : 49 }}>
- <Link
- to={`${WebsitePaths.Wiki}#List-of-Projects-Using-0x-Protocol`}
- className="text-decoration-none underline"
- style={{
- color: colors.landingLinkGrey,
- fontFamily: 'Roboto Mono',
- }}
- >
- view all
- </Link>
- </div>
- </div>
- <div className="lg-flex md-flex sm-clearfix pt3" style={{ opacity: 0.4 }}>
- <div className="col col-4 sm-center">
- <img
- src="/images/landing/ethfinex.png"
- style={{ height: isSmallScreen ? 85 : 107 }}
- />
- </div>
- <div className="col col-4 center">
- <img
- src="/images/landing/radar_relay.png"
- style={{ height: isSmallScreen ? 85 : 107 }}
- />
- </div>
- <div className="col col-4 sm-center" style={{ textAlign: 'right' }}>
- <img
- src="/images/landing/paradex.png"
- style={{ height: isSmallScreen ? 85 : 107 }}
- />
- </div>
- </div>
- </div>
</div>
</div>
</div>
@@ -551,7 +565,7 @@ export class Landing extends React.Component<LandingProps, LandingState> {
fontFamily: 'Roboto Mono',
fontSize: 13.5,
fontWeight: 400,
- opacity: 0.75,
+ color: colors.darkestGrey,
}}
>
{assetType.title}
@@ -587,9 +601,19 @@ export class Landing extends React.Component<LandingProps, LandingState> {
</div>
);
});
+ const titleStyle: React.CSSProperties = {
+ fontFamily: 'Roboto Mono',
+ color: colors.grey,
+ textTransform: 'uppercase',
+ fontWeight: 300,
+ letterSpacing: 3,
+ };
return (
<div className="clearfix" style={{ backgroundColor: colors.heroGrey }}>
- <div className="mx-auto py4 sm-mt2 clearfix" style={{ maxWidth: '60em' }}>
+ <div className="center pb3 pt4" style={titleStyle}>
+ Benefits of 0x
+ </div>
+ <div className="mx-auto pb4 sm-mt2 clearfix" style={{ maxWidth: '60em' }}>
{boxes}
</div>
</div>
diff --git a/packages/website/ts/utils/configs.ts b/packages/website/ts/utils/configs.ts
index 874ad04c2..69773eae7 100644
--- a/packages/website/ts/utils/configs.ts
+++ b/packages/website/ts/utils/configs.ts
@@ -124,5 +124,27 @@ export const configs = {
[4]: [`https://rinkeby.infura.io/${INFURA_API_KEY}`],
} as PublicNodeUrlsByNetworkId,
SHOULD_DEPRECATE_OLD_WETH_TOKEN: true,
- SYMBOLS_OF_MINTABLE_TOKENS: ['MKR', 'MLN', 'GNT', 'DGD', 'REP'],
+ SYMBOLS_OF_MINTABLE_KOVAN_TOKENS: ['MKR', 'MLN', 'GNT', 'DGD', 'REP'],
+ SYMBOLS_OF_MINTABLE_RINKEBY_ROPSTEN_TOKENS: [
+ 'TKN0',
+ 'TKN1',
+ 'TKN2',
+ 'TKN3',
+ 'TKN4',
+ 'TKN5',
+ 'TKN6',
+ 'TKN7',
+ 'TKN8',
+ 'TKN9',
+ 'TKN10',
+ 'TKN11',
+ 'TKN12',
+ 'TKN13',
+ 'TKN14',
+ 'TKN15',
+ 'TKN16',
+ 'TKN17',
+ 'TKN18',
+ 'TKN19',
+ ],
};
diff --git a/packages/website/ts/utils/constants.ts b/packages/website/ts/utils/constants.ts
index 26a793f38..6af821dbe 100644
--- a/packages/website/ts/utils/constants.ts
+++ b/packages/website/ts/utils/constants.ts
@@ -48,6 +48,12 @@ export const constants = {
TESTNET_NAME: 'Kovan',
TYPES_SECTION_NAME: 'types',
PROJECT_URL_ETHFINEX: 'https://www.bitfinex.com/ethfinex',
+ PROJECT_URL_AMADEUS: 'http://amadeusrelay.org',
+ PROJECT_URL_DDEX: 'https://ddex.io',
+ PROJECT_URL_DECENT_EX: 'https://decent.exchange',
+ PROJECT_URL_DEXTROID: 'https://www.dextroid.io',
+ PROJECT_URL_ERC_DEX: 'https://ercdex.com',
+ PROJECT_URL_OPEN_RELAY: 'https://openrelay.xyz',
PROJECT_URL_RADAR_RELAY: 'https://radarrelay.com',
PROJECT_URL_PARADEX: 'https://paradex.io',
PROJECT_URL_DYDX: 'https://dydx.exchange',
@@ -63,13 +69,14 @@ export const constants = {
PROJECT_URL_AUGUR: 'https://augur.net',
PROJECT_URL_AUCTUS: 'https://auctus.org',
PROJECT_URL_OPEN_ANX: 'https://www.openanx.org',
+ PROJECT_URL_IDT: 'https://kinalpha.com',
URL_ANGELLIST: 'https://angel.co/0xproject/jobs',
URL_BIGNUMBERJS_GITHUB: 'http://mikemcl.github.io/bignumber.js',
URL_BITLY_API: 'https://api-ssl.bitly.com',
URL_BLOG: 'https://blog.0xproject.com/latest',
URL_DISCOURSE_FORUM: 'https://forum.0xproject.com',
URL_FIREFOX_U2F_ADDON: 'https://addons.mozilla.org/en-US/firefox/addon/u2f-support-add-on/',
- URL_ETHER_FAUCET: 'https://faucet.0xproject.com',
+ URL_TESTNET_FAUCET: 'https://faucet.0xproject.com',
URL_GITHUB_ORG: 'https://github.com/0xProject',
URL_GITHUB_WIKI: 'https://github.com/0xProject/wiki',
URL_METAMASK_CHROME_STORE: 'https://chrome.google.com/webstore/detail/metamask/nkbihfbeogaeaoehlefnkodbefgpgknn',
diff --git a/packages/website/ts/utils/utils.ts b/packages/website/ts/utils/utils.ts
index 68eb7c813..c38f84c92 100644
--- a/packages/website/ts/utils/utils.ts
+++ b/packages/website/ts/utils/utils.ts
@@ -279,4 +279,15 @@ export const utils = {
isTestRpc(nodeVersion: string): boolean {
return _.includes(nodeVersion, 'TestRPC');
},
+ isTestNetwork(networkId: number): boolean {
+ const isTestNetwork = _.includes(
+ [
+ constants.NETWORK_ID_BY_NAME[Networks.Kovan],
+ constants.NETWORK_ID_BY_NAME[Networks.Rinkeby],
+ constants.NETWORK_ID_BY_NAME[Networks.Ropsten],
+ ],
+ networkId,
+ );
+ return isTestNetwork;
+ },
};