Merge branch 'development' of github.com:0xProject/0x-monorepo into instant-callback-done

This commit is contained in:
Daniel Pyrathon 2019-05-27 18:54:46 -07:00
commit fdb9a664f5
188 changed files with 5207 additions and 652 deletions

View File

@ -124,6 +124,7 @@ jobs:
- repo-{{ .Environment.CIRCLE_SHA1 }}
- run: yarn wsrun test:circleci @0x/contracts-test-utils
- run: yarn wsrun test:circleci @0x/abi-gen
- run: yarn wsrun test:circleci @0x/asset-buyer
- run: yarn wsrun test:circleci @0x/contract-artifacts
- run: yarn wsrun test:circleci @0x/assert
- run: yarn wsrun test:circleci @0x/base-contract
@ -149,6 +150,10 @@ jobs:
key: coverage-assert-{{ .Environment.CIRCLE_SHA1 }}
paths:
- ~/repo/packages/assert/coverage/lcov.info
- save_cache:
key: coverage-asset-buyer-{{ .Environment.CIRCLE_SHA1 }}
paths:
- ~/repo/packages/asset-buyer/coverage/lcov.info
- save_cache:
key: coverage-base-contract-{{ .Environment.CIRCLE_SHA1 }}
paths:
@ -327,6 +332,9 @@ jobs:
- restore_cache:
keys:
- coverage-assert-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
keys:
- coverage-asset-buyer-{{ .Environment.CIRCLE_SHA1 }}
- restore_cache:
keys:
- coverage-base-contract-{{ .Environment.CIRCLE_SHA1 }}

View File

@ -1,4 +1,31 @@
[
{
"timestamp": 1558712885,
"version": "2.1.5",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1557961111,
"version": "2.1.4",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1557799313,
"version": "2.1.3",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "2.1.2",
"changes": [
@ -6,7 +33,8 @@
"note": "Update tests to use contract-built-in `awaitTransactionSuccessAsync`",
"pr": 1797
}
]
],
"timestamp": 1557507213
},
{
"version": "2.1.1",

View File

@ -5,6 +5,22 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v2.1.5 - _May 24, 2019_
* Dependencies updated
## v2.1.4 - _May 15, 2019_
* Dependencies updated
## v2.1.3 - _May 14, 2019_
* Dependencies updated
## v2.1.2 - _May 10, 2019_
* Update tests to use contract-built-in `awaitTransactionSuccessAsync` (#1797)
## v2.1.1 - _April 11, 2019_
* Dependencies updated

View File

@ -1,6 +1,6 @@
{
"name": "@0x/contracts-asset-proxy",
"version": "2.1.1",
"version": "2.1.5",
"engines": {
"node": ">=6.12"
},
@ -47,11 +47,11 @@
},
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/protocol/README.md",
"devDependencies": {
"@0x/abi-gen": "^2.0.9",
"@0x/contracts-gen": "^1.0.8",
"@0x/contracts-test-utils": "^3.1.2",
"@0x/dev-utils": "^2.2.1",
"@0x/sol-compiler": "^3.1.6",
"@0x/abi-gen": "^2.0.10",
"@0x/contracts-gen": "^1.0.9",
"@0x/contracts-test-utils": "^3.1.7",
"@0x/dev-utils": "^2.2.3",
"@0x/sol-compiler": "^3.1.8",
"@0x/tslint-config": "^3.0.1",
"@types/lodash": "4.14.104",
"@types/node": "*",
@ -68,16 +68,16 @@
"typescript": "3.0.1"
},
"dependencies": {
"@0x/base-contract": "^5.0.5",
"@0x/contracts-erc1155": "^1.1.1",
"@0x/contracts-erc20": "^2.2.0",
"@0x/contracts-erc721": "^2.1.1",
"@0x/contracts-utils": "^3.1.1",
"@0x/order-utils": "^7.2.0",
"@0x/base-contract": "^5.1.0",
"@0x/contracts-erc1155": "^1.1.6",
"@0x/contracts-erc20": "^2.2.5",
"@0x/contracts-erc721": "^2.1.6",
"@0x/contracts-utils": "^3.1.6",
"@0x/order-utils": "^8.1.1",
"@0x/types": "^2.2.2",
"@0x/typescript-typings": "^4.2.2",
"@0x/utils": "^4.3.1",
"@0x/web3-wrapper": "^6.0.5",
"@0x/utils": "^4.3.3",
"@0x/web3-wrapper": "^6.0.6",
"ethereum-types": "^2.1.2",
"lodash": "^4.17.11"
},

View File

@ -1,4 +1,40 @@
[
{
"timestamp": 1558712885,
"version": "2.0.4",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1557961111,
"version": "2.0.3",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1557799313,
"version": "2.0.2",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1557507213,
"version": "2.0.1",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "2.0.0",
"changes": [

View File

@ -5,6 +5,22 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v2.0.4 - _May 24, 2019_
* Dependencies updated
## v2.0.3 - _May 15, 2019_
* Dependencies updated
## v2.0.2 - _May 14, 2019_
* Dependencies updated
## v2.0.1 - _May 10, 2019_
* Dependencies updated
## v2.0.0 - _April 11, 2019_
* Make `decodeOrdersFromFillData`, `getCoordinatorApprovalHash`, and `getTransactionHash` public (#1729)

View File

@ -1,6 +1,6 @@
{
"name": "@0x/contracts-coordinator",
"version": "2.0.0",
"version": "2.0.4",
"engines": {
"node": ">=6.12"
},
@ -47,11 +47,11 @@
},
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/extensions/README.md",
"devDependencies": {
"@0x/abi-gen": "^2.0.9",
"@0x/contracts-gen": "^1.0.8",
"@0x/contracts-test-utils": "^3.1.2",
"@0x/dev-utils": "^2.2.1",
"@0x/sol-compiler": "^3.1.6",
"@0x/abi-gen": "^2.0.10",
"@0x/contracts-gen": "^1.0.9",
"@0x/contracts-test-utils": "^3.1.7",
"@0x/dev-utils": "^2.2.3",
"@0x/sol-compiler": "^3.1.8",
"@0x/tslint-config": "^3.0.1",
"@types/lodash": "4.14.104",
"@types/node": "*",
@ -68,17 +68,17 @@
"typescript": "3.0.1"
},
"dependencies": {
"@0x/base-contract": "^5.0.5",
"@0x/contracts-asset-proxy": "^2.1.1",
"@0x/contracts-erc20": "^2.2.0",
"@0x/base-contract": "^5.1.0",
"@0x/contracts-asset-proxy": "^2.1.5",
"@0x/contracts-erc20": "^2.2.5",
"@0x/contracts-exchange": "1.0.2",
"@0x/contracts-exchange-libs": "^2.1.1",
"@0x/contracts-utils": "^3.1.1",
"@0x/order-utils": "^7.2.0",
"@0x/contracts-exchange-libs": "^2.1.6",
"@0x/contracts-utils": "^3.1.6",
"@0x/order-utils": "^8.1.1",
"@0x/types": "^2.2.2",
"@0x/typescript-typings": "^4.2.2",
"@0x/utils": "^4.3.1",
"@0x/web3-wrapper": "^6.0.5",
"@0x/utils": "^4.3.3",
"@0x/web3-wrapper": "^6.0.6",
"ethereum-types": "^2.1.2",
"ethereumjs-util": "^5.1.1",
"lodash": "^4.17.11"

View File

@ -1,4 +1,40 @@
[
{
"timestamp": 1558712885,
"version": "1.1.6",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1557961111,
"version": "1.1.5",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "1.1.4",
"changes": [
{
"note": "Dependencies updated"
}
],
"timestamp": 1557799313
},
{
"timestamp": 1557507213,
"version": "1.1.2",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "1.1.1",
"changes": [

View File

@ -5,6 +5,22 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v1.1.6 - _May 24, 2019_
* Dependencies updated
## v1.1.5 - _May 15, 2019_
* Dependencies updated
## v1.1.4 - _May 14, 2019_
* Dependencies updated
## v1.1.2 - _May 10, 2019_
* Dependencies updated
## v1.1.1 - _April 11, 2019_
* Dependencies updated

View File

@ -1,6 +1,6 @@
{
"name": "@0x/contracts-erc1155",
"version": "1.1.1",
"version": "1.1.6",
"engines": {
"node": ">=6.12"
},
@ -47,10 +47,10 @@
},
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/tokens/README.md",
"devDependencies": {
"@0x/abi-gen": "^2.0.9",
"@0x/contracts-gen": "^1.0.8",
"@0x/dev-utils": "^2.2.1",
"@0x/sol-compiler": "^3.1.6",
"@0x/abi-gen": "^2.0.10",
"@0x/contracts-gen": "^1.0.9",
"@0x/dev-utils": "^2.2.3",
"@0x/sol-compiler": "^3.1.8",
"@0x/tslint-config": "^3.0.1",
"@types/lodash": "4.14.104",
"@types/node": "*",
@ -67,13 +67,13 @@
"typescript": "3.0.1"
},
"dependencies": {
"@0x/base-contract": "^5.0.5",
"@0x/contracts-test-utils": "^3.1.2",
"@0x/contracts-utils": "^3.1.1",
"@0x/base-contract": "^5.1.0",
"@0x/contracts-test-utils": "^3.1.7",
"@0x/contracts-utils": "^3.1.6",
"@0x/types": "^2.2.2",
"@0x/typescript-typings": "^4.2.2",
"@0x/utils": "^4.3.1",
"@0x/web3-wrapper": "^6.0.5",
"@0x/utils": "^4.3.3",
"@0x/web3-wrapper": "^6.0.6",
"ethereum-types": "^2.1.2",
"lodash": "^4.17.11"
},

View File

@ -1,4 +1,40 @@
[
{
"timestamp": 1558712885,
"version": "2.2.5",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1557961111,
"version": "2.2.4",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "2.2.3",
"changes": [
{
"note": "Dependencies updated"
}
],
"timestamp": 1557799313
},
{
"timestamp": 1557507213,
"version": "2.2.1",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "2.2.0",
"changes": [

View File

@ -5,6 +5,22 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v2.2.5 - _May 24, 2019_
* Dependencies updated
## v2.2.4 - _May 15, 2019_
* Dependencies updated
## v2.2.3 - _May 14, 2019_
* Dependencies updated
## v2.2.1 - _May 10, 2019_
* Dependencies updated
## v2.2.0 - _April 11, 2019_
* Added UntransferrableDummyERC20Token (#1714)

View File

@ -1,6 +1,6 @@
{
"name": "@0x/contracts-erc20",
"version": "2.2.0",
"version": "2.2.5",
"engines": {
"node": ">=6.12"
},
@ -47,11 +47,11 @@
},
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/tokens/README.md",
"devDependencies": {
"@0x/abi-gen": "^2.0.9",
"@0x/contracts-gen": "^1.0.8",
"@0x/contracts-test-utils": "^3.1.2",
"@0x/dev-utils": "^2.2.1",
"@0x/sol-compiler": "^3.1.6",
"@0x/abi-gen": "^2.0.10",
"@0x/contracts-gen": "^1.0.9",
"@0x/contracts-test-utils": "^3.1.7",
"@0x/dev-utils": "^2.2.3",
"@0x/sol-compiler": "^3.1.8",
"@0x/tslint-config": "^3.0.1",
"@types/lodash": "4.14.104",
"@types/node": "*",
@ -68,13 +68,12 @@
"typescript": "3.0.1"
},
"dependencies": {
"@0x/base-contract": "^5.0.5",
"@0x/contracts-exchange-libs": "^2.1.1",
"@0x/contracts-utils": "^3.1.1",
"@0x/base-contract": "^5.1.0",
"@0x/contracts-utils": "^3.1.6",
"@0x/types": "^2.2.2",
"@0x/typescript-typings": "^4.2.2",
"@0x/utils": "^4.3.1",
"@0x/web3-wrapper": "^6.0.5",
"@0x/utils": "^4.3.3",
"@0x/web3-wrapper": "^6.0.6",
"ethereum-types": "^2.1.2",
"lodash": "^4.17.11"
},

View File

@ -1,4 +1,40 @@
[
{
"timestamp": 1558712885,
"version": "2.1.6",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1557961111,
"version": "2.1.5",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "2.1.4",
"changes": [
{
"note": "Dependencies updated"
}
],
"timestamp": 1557799313
},
{
"timestamp": 1557507213,
"version": "2.1.2",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "2.1.1",
"changes": [

View File

@ -5,6 +5,22 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v2.1.6 - _May 24, 2019_
* Dependencies updated
## v2.1.5 - _May 15, 2019_
* Dependencies updated
## v2.1.4 - _May 14, 2019_
* Dependencies updated
## v2.1.2 - _May 10, 2019_
* Dependencies updated
## v2.1.1 - _April 11, 2019_
* Dependencies updated

View File

@ -1,6 +1,6 @@
{
"name": "@0x/contracts-erc721",
"version": "2.1.1",
"version": "2.1.6",
"engines": {
"node": ">=6.12"
},
@ -47,11 +47,11 @@
},
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/tokens/README.md",
"devDependencies": {
"@0x/abi-gen": "^2.0.9",
"@0x/contracts-gen": "^1.0.8",
"@0x/contracts-test-utils": "^3.1.2",
"@0x/dev-utils": "^2.2.1",
"@0x/sol-compiler": "^3.1.6",
"@0x/abi-gen": "^2.0.10",
"@0x/contracts-gen": "^1.0.9",
"@0x/contracts-test-utils": "^3.1.7",
"@0x/dev-utils": "^2.2.3",
"@0x/sol-compiler": "^3.1.8",
"@0x/tslint-config": "^3.0.1",
"@types/lodash": "4.14.104",
"@types/node": "*",
@ -68,12 +68,12 @@
"typescript": "3.0.1"
},
"dependencies": {
"@0x/base-contract": "^5.0.5",
"@0x/contracts-utils": "^3.1.1",
"@0x/base-contract": "^5.1.0",
"@0x/contracts-utils": "^3.1.6",
"@0x/types": "^2.2.2",
"@0x/typescript-typings": "^4.2.2",
"@0x/utils": "^4.3.1",
"@0x/web3-wrapper": "^6.0.5",
"@0x/utils": "^4.3.3",
"@0x/web3-wrapper": "^6.0.6",
"ethereum-types": "^2.1.2",
"lodash": "^4.17.11"
},

View File

@ -1,4 +1,31 @@
[
{
"timestamp": 1558712885,
"version": "3.0.3",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1557961111,
"version": "3.0.2",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1557799313,
"version": "3.0.1",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "3.0.0",
"changes": [
@ -6,7 +33,8 @@
"note": "Update contracts to solidity ^0.5.5 and unpin dependencies",
"pr": 1796
}
]
],
"timestamp": 1557507213
},
{
"version": "2.1.1",

View File

@ -5,6 +5,22 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v3.0.3 - _May 24, 2019_
* Dependencies updated
## v3.0.2 - _May 15, 2019_
* Dependencies updated
## v3.0.1 - _May 14, 2019_
* Dependencies updated
## v3.0.0 - _May 10, 2019_
* Update contracts to solidity ^0.5.5 and unpin dependencies (#1796)
## v2.1.1 - _April 11, 2019_
* Dependencies updated

View File

@ -1,6 +1,6 @@
{
"name": "@0x/contracts-exchange-forwarder",
"version": "2.1.0",
"version": "3.0.3",
"engines": {
"node": ">=6.12"
},
@ -46,12 +46,12 @@
},
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/extensions/README.md",
"devDependencies": {
"@0x/abi-gen": "^2.0.9",
"@0x/contract-wrappers": "^9.0.0",
"@0x/contracts-gen": "^1.0.8",
"@0x/contracts-test-utils": "^3.1.2",
"@0x/dev-utils": "^2.2.1",
"@0x/sol-compiler": "^3.1.6",
"@0x/abi-gen": "^2.0.10",
"@0x/contract-wrappers": "^9.1.4",
"@0x/contracts-gen": "^1.0.9",
"@0x/contracts-test-utils": "^3.1.7",
"@0x/dev-utils": "^2.2.3",
"@0x/sol-compiler": "^3.1.8",
"@0x/tslint-config": "^3.0.1",
"@types/lodash": "4.14.104",
"@types/node": "*",
@ -68,18 +68,18 @@
"typescript": "3.0.1"
},
"dependencies": {
"@0x/base-contract": "^5.0.5",
"@0x/contracts-asset-proxy": "^2.1.1",
"@0x/contracts-erc20": "^2.2.0",
"@0x/contracts-erc721": "^2.1.0",
"@0x/contracts-exchange": "^2.1.1",
"@0x/contracts-exchange-libs": "^2.1.1",
"@0x/contracts-utils": "^3.1.1",
"@0x/order-utils": "^7.2.0",
"@0x/base-contract": "^5.1.0",
"@0x/contracts-asset-proxy": "^2.1.5",
"@0x/contracts-erc20": "^2.2.5",
"@0x/contracts-erc721": "^2.1.6",
"@0x/contracts-exchange": "^2.1.5",
"@0x/contracts-exchange-libs": "^2.1.6",
"@0x/contracts-utils": "^3.1.6",
"@0x/order-utils": "^8.1.1",
"@0x/types": "^2.2.2",
"@0x/typescript-typings": "^4.2.1",
"@0x/utils": "^4.3.1",
"@0x/web3-wrapper": "^6.0.5",
"@0x/utils": "^4.3.3",
"@0x/web3-wrapper": "^6.0.6",
"ethereum-types": "^2.1.2",
"lodash": "^4.17.11"
},

View File

@ -1,4 +1,40 @@
[
{
"timestamp": 1558712885,
"version": "2.1.6",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1557961111,
"version": "2.1.5",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "2.1.4",
"changes": [
{
"note": "Dependencies updated"
}
],
"timestamp": 1557799313
},
{
"timestamp": 1557507213,
"version": "2.1.2",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "2.1.1",
"changes": [

View File

@ -5,6 +5,22 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v2.1.6 - _May 24, 2019_
* Dependencies updated
## v2.1.5 - _May 15, 2019_
* Dependencies updated
## v2.1.4 - _May 14, 2019_
* Dependencies updated
## v2.1.2 - _May 10, 2019_
* Dependencies updated
## v2.1.1 - _April 11, 2019_
* Dependencies updated

View File

@ -30,6 +30,7 @@
"src/LibFillResults.sol",
"src/LibMath.sol",
"src/LibOrder.sol",
"src/LibTransactionDecoder.sol",
"test/TestLibs.sol"
]
}

View File

@ -0,0 +1,191 @@
/*
Copyright 2019 ZeroEx Intl.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
pragma solidity ^0.5.5;
pragma experimental "ABIEncoderV2";
import "@0x/contracts-exchange-libs/contracts/src/LibExchangeSelectors.sol";
import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
import "@0x/contracts-utils/contracts/src/LibBytes.sol";
contract LibTransactionDecoder is LibExchangeSelectors {
using LibBytes for bytes;
/// @dev Decodes the call data for an Exchange contract method call.
/// @param transactionData ABI-encoded calldata for an Exchange
/// contract method call.
/// @return The name of the function called, and the parameters it was
/// given. For single-order fills and cancels, the arrays will have
/// just one element.
function decodeZeroExTransactionData(bytes memory transactionData)
public
pure
returns(
string memory functionName,
LibOrder.Order[] memory orders,
uint256[] memory takerAssetFillAmounts,
bytes[] memory signatures
)
{
bytes4 functionSelector = transactionData.readBytes4(0);
if (functionSelector == BATCH_CANCEL_ORDERS_SELECTOR) {
functionName = "batchCancelOrders";
} else if (functionSelector == BATCH_FILL_ORDERS_SELECTOR) {
functionName = "batchFillOrders";
} else if (functionSelector == BATCH_FILL_ORDERS_NO_THROW_SELECTOR) {
functionName = "batchFillOrdersNoThrow";
} else if (functionSelector == BATCH_FILL_OR_KILL_ORDERS_SELECTOR) {
functionName = "batchFillOrKillOrders";
} else if (functionSelector == CANCEL_ORDER_SELECTOR) {
functionName = "cancelOrder";
} else if (functionSelector == FILL_ORDER_SELECTOR) {
functionName = "fillOrder";
} else if (functionSelector == FILL_ORDER_NO_THROW_SELECTOR) {
functionName = "fillOrderNoThrow";
} else if (functionSelector == FILL_OR_KILL_ORDER_SELECTOR) {
functionName = "fillOrKillOrder";
} else if (functionSelector == MARKET_BUY_ORDERS_SELECTOR) {
functionName = "marketBuyOrders";
} else if (functionSelector == MARKET_BUY_ORDERS_NO_THROW_SELECTOR) {
functionName = "marketBuyOrdersNoThrow";
} else if (functionSelector == MARKET_SELL_ORDERS_SELECTOR) {
functionName = "marketSellOrders";
} else if (functionSelector == MARKET_SELL_ORDERS_NO_THROW_SELECTOR) {
functionName = "marketSellOrdersNoThrow";
} else if (functionSelector == MATCH_ORDERS_SELECTOR) {
functionName = "matchOrders";
} else if (
functionSelector == CANCEL_ORDERS_UP_TO_SELECTOR ||
functionSelector == EXECUTE_TRANSACTION_SELECTOR
// TODO: add new noThrow cancel functions when https://github.com/0xProject/ZEIPs/issues/35 is merged.
) {
revert("UNIMPLEMENTED");
} else {
revert("UNKNOWN_FUNCTION_SELECTOR");
}
if (functionSelector == BATCH_CANCEL_ORDERS_SELECTOR) {
// solhint-disable-next-line indent
orders = abi.decode(transactionData.slice(4, transactionData.length), (LibOrder.Order[]));
takerAssetFillAmounts = new uint256[](0);
signatures = new bytes[](0);
} else if (
functionSelector == BATCH_FILL_OR_KILL_ORDERS_SELECTOR ||
functionSelector == BATCH_FILL_ORDERS_NO_THROW_SELECTOR ||
functionSelector == BATCH_FILL_ORDERS_SELECTOR
) {
(orders, takerAssetFillAmounts, signatures) = _makeReturnValuesForBatchFill(transactionData);
} else if (functionSelector == CANCEL_ORDER_SELECTOR) {
orders = new LibOrder.Order[](1);
orders[0] = abi.decode(transactionData.slice(4, transactionData.length), (LibOrder.Order));
takerAssetFillAmounts = new uint256[](0);
signatures = new bytes[](0);
} else if (
functionSelector == FILL_OR_KILL_ORDER_SELECTOR ||
functionSelector == FILL_ORDER_SELECTOR ||
functionSelector == FILL_ORDER_NO_THROW_SELECTOR
) {
(orders, takerAssetFillAmounts, signatures) = _makeReturnValuesForSingleOrderFill(transactionData);
} else if (
functionSelector == MARKET_BUY_ORDERS_SELECTOR ||
functionSelector == MARKET_BUY_ORDERS_NO_THROW_SELECTOR ||
functionSelector == MARKET_SELL_ORDERS_SELECTOR ||
functionSelector == MARKET_SELL_ORDERS_NO_THROW_SELECTOR
) {
(orders, takerAssetFillAmounts, signatures) = _makeReturnValuesForMarketFill(transactionData);
} else if (functionSelector == MATCH_ORDERS_SELECTOR) {
(
LibOrder.Order memory leftOrder,
LibOrder.Order memory rightOrder,
bytes memory leftSignature,
bytes memory rightSignature
) = abi.decode(
transactionData.slice(4, transactionData.length),
(LibOrder.Order, LibOrder.Order, bytes, bytes)
);
orders = new LibOrder.Order[](2);
orders[0] = leftOrder;
orders[1] = rightOrder;
takerAssetFillAmounts = new uint256[](2);
takerAssetFillAmounts[0] = leftOrder.takerAssetAmount;
takerAssetFillAmounts[1] = rightOrder.takerAssetAmount;
signatures = new bytes[](2);
signatures[0] = leftSignature;
signatures[1] = rightSignature;
}
}
function _makeReturnValuesForSingleOrderFill(bytes memory transactionData)
private
pure
returns(
LibOrder.Order[] memory orders,
uint256[] memory takerAssetFillAmounts,
bytes[] memory signatures
)
{
orders = new LibOrder.Order[](1);
takerAssetFillAmounts = new uint256[](1);
signatures = new bytes[](1);
// solhint-disable-next-line indent
(orders[0], takerAssetFillAmounts[0], signatures[0]) = abi.decode(
transactionData.slice(4, transactionData.length),
(LibOrder.Order, uint256, bytes)
);
}
function _makeReturnValuesForBatchFill(bytes memory transactionData)
private
pure
returns(
LibOrder.Order[] memory orders,
uint256[] memory takerAssetFillAmounts,
bytes[] memory signatures
)
{
// solhint-disable-next-line indent
(orders, takerAssetFillAmounts, signatures) = abi.decode(
transactionData.slice(4, transactionData.length),
// solhint-disable-next-line indent
(LibOrder.Order[], uint256[], bytes[])
);
}
function _makeReturnValuesForMarketFill(bytes memory transactionData)
private
pure
returns(
LibOrder.Order[] memory orders,
uint256[] memory takerAssetFillAmounts,
bytes[] memory signatures
)
{
takerAssetFillAmounts = new uint256[](1);
// solhint-disable-next-line indent
(orders, takerAssetFillAmounts[0], signatures) = abi.decode(
transactionData.slice(4, transactionData.length),
// solhint-disable-next-line indent
(LibOrder.Order[], uint256, bytes[])
);
}
}

View File

@ -1,6 +1,6 @@
{
"name": "@0x/contracts-exchange-libs",
"version": "2.1.1",
"version": "2.1.6",
"engines": {
"node": ">=6.12"
},
@ -34,7 +34,7 @@
"lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol"
},
"config": {
"abis": "./generated-artifacts/@(LibAbiEncoder|LibAssetProxyErrors|LibConstants|LibEIP712|LibFillResults|LibMath|LibOrder|TestLibs).json",
"abis": "./generated-artifacts/@(LibAbiEncoder|LibAssetProxyErrors|LibConstants|LibEIP712|LibFillResults|LibMath|LibOrder|LibTransactionDecoder|TestLibs).json",
"abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually."
},
"repository": {
@ -47,11 +47,11 @@
},
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/libs/README.md",
"devDependencies": {
"@0x/abi-gen": "^2.0.9",
"@0x/contracts-gen": "^1.0.8",
"@0x/contracts-test-utils": "^3.1.2",
"@0x/dev-utils": "^2.2.1",
"@0x/sol-compiler": "^3.1.6",
"@0x/abi-gen": "^2.0.10",
"@0x/contracts-gen": "^1.0.9",
"@0x/contracts-test-utils": "^3.1.7",
"@0x/dev-utils": "^2.2.3",
"@0x/sol-compiler": "^3.1.8",
"@0x/tslint-config": "^3.0.1",
"@types/lodash": "4.14.104",
"@types/node": "*",
@ -68,13 +68,13 @@
"typescript": "3.0.1"
},
"dependencies": {
"@0x/base-contract": "^5.0.5",
"@0x/contracts-utils": "^3.1.1",
"@0x/order-utils": "^7.2.0",
"@0x/base-contract": "^5.1.0",
"@0x/contracts-utils": "^3.1.6",
"@0x/order-utils": "^8.1.1",
"@0x/types": "^2.2.2",
"@0x/typescript-typings": "^4.2.2",
"@0x/utils": "^4.3.1",
"@0x/web3-wrapper": "^6.0.5",
"@0x/utils": "^4.3.3",
"@0x/web3-wrapper": "^6.0.6",
"ethereum-types": "^2.1.2",
"lodash": "^4.17.11"
},

View File

@ -12,6 +12,7 @@ import * as LibEIP712 from '../generated-artifacts/LibEIP712.json';
import * as LibFillResults from '../generated-artifacts/LibFillResults.json';
import * as LibMath from '../generated-artifacts/LibMath.json';
import * as LibOrder from '../generated-artifacts/LibOrder.json';
import * as LibTransactionDecoder from '../generated-artifacts/LibTransactionDecoder.json';
import * as TestLibs from '../generated-artifacts/TestLibs.json';
export const artifacts = {
LibAbiEncoder: LibAbiEncoder as ContractArtifact,
@ -21,5 +22,6 @@ export const artifacts = {
LibFillResults: LibFillResults as ContractArtifact,
LibMath: LibMath as ContractArtifact,
LibOrder: LibOrder as ContractArtifact,
LibTransactionDecoder: LibTransactionDecoder as ContractArtifact,
TestLibs: TestLibs as ContractArtifact,
};

View File

@ -10,4 +10,5 @@ export * from '../generated-wrappers/lib_e_i_p712';
export * from '../generated-wrappers/lib_fill_results';
export * from '../generated-wrappers/lib_math';
export * from '../generated-wrappers/lib_order';
export * from '../generated-wrappers/lib_transaction_decoder';
export * from '../generated-wrappers/test_libs';

View File

@ -0,0 +1,231 @@
import { chaiSetup, provider, txDefaults, web3Wrapper } from '@0x/contracts-test-utils';
import { BlockchainLifecycle } from '@0x/dev-utils';
import { Order } from '@0x/types';
import { BigNumber } from '@0x/utils';
import * as chai from 'chai';
import { artifacts, LibTransactionDecoderContract } from '../src';
chaiSetup.configure();
const expect = chai.expect;
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
type OrderWithoutExchange = Pick<Order, Exclude<keyof Order, 'exchangeAddress'>>;
const INPUTS: { order: OrderWithoutExchange; takerAssetFillAmount: BigNumber; signature: string } = {
order: {
makerAddress: '0xe36ea790bc9d7ab70c55260c66d52b1eca985f84',
takerAddress: '0x0000000000000000000000000000000000000000',
feeRecipientAddress: '0x78dc5d2d739606d31509c31d654056a45185ecb6',
senderAddress: '0x6ecbe1db9ef729cbe972c83fb886247691fb6beb',
makerAssetAmount: new BigNumber('100000000000000000000'),
takerAssetAmount: new BigNumber('200000000000000000000'),
makerFee: new BigNumber('1000000000000000000'),
takerFee: new BigNumber('1000000000000000000'),
expirationTimeSeconds: new BigNumber('1552396423'),
salt: new BigNumber('66097384406870180066678463045003379626790660770396923976862707230261946348951'),
makerAssetData: '0xf47261b000000000000000000000000034d402f14d58e001d8efbe6585051bf9706aa064',
takerAssetData: '0xf47261b000000000000000000000000025b8fe1de9daf8ba351890744ff28cf7dfa8f5e3',
},
takerAssetFillAmount: new BigNumber('100000000000000000000'),
signature:
'0x1ce8e3c600d933423172b5021158a6be2e818613ff8e762d70ef490c752fd98a626a215f09f169668990414de75a53da221c294a3002f796d004827258b641876e03',
};
const ENCODED_INPUTS: { [functionName: string]: string } = {
// It would be best to encode inputs as part of the test run, but that's
// not really possible in this case, because doing so would introduce a
// dependency on @0x/contracts-exchange, but of course that package already
// depends on @0x/contracts-exchange-libs (this package), so it would
// introduce a circular dependency.
//
// Values used in this object are declared along with the (commented out)
// code that generated them. Running that code depends on the following:
//
// import { artifacts as exchangeArtifacts, ExchangeContract } from '@0x/contracts-exchange';
// import { getContractAddressesForNetworkOrThrow, NetworkId } from '@0x/contract-addresses';
// const exchangeContract = new ExchangeContract(
// exchangeArtifacts.Exchange.compilerOutput.abi,
// getContractAddressesForNetworkOrThrow(NetworkId.Ganache).exchange,
// provider,
// );
//
batchCancelOrders:
// exchangeContract.batchCancelOrders.getABIEncodedTransactionData([
// INPUTS.order,
// INPUTS.order,
// ]),
'0x4ac147820000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000040000000000000000000000000e36ea790bc9d7ab70c55260c66d52b1eca985f84000000000000000000000000000000000000000000000000000000000000000000000000000000000000000078dc5d2d739606d31509c31d654056a45185ecb60000000000000000000000006ecbe1db9ef729cbe972c83fb886247691fb6beb0000000000000000000000000000000000000000000000056bc75e2d6310000000000000000000000000000000000000000000000000000ad78ebc5ac62000000000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000000000005c87b0879221cb37dcf690e02b0f9aecf44fcaa5ed9ce99697e86743795fa132596ff597000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001e00000000000000000000000000000000000000000000000000000000000000024f47261b000000000000000000000000034d402f14d58e001d8efbe6585051bf9706aa064000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024f47261b000000000000000000000000025b8fe1de9daf8ba351890744ff28cf7dfa8f5e300000000000000000000000000000000000000000000000000000000',
batchFillOrders:
// exchangeContract.batchFillOrders.getABIEncodedTransactionData(
// [INPUTS.order, INPUTS.order],
// [INPUTS.takerAssetFillAmount, INPUTS.takerAssetFillAmount],
// [INPUTS.signature, INPUTS.signature],
// ),
'0x297bb70b000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000360000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000040000000000000000000000000e36ea790bc9d7ab70c55260c66d52b1eca985f84000000000000000000000000000000000000000000000000000000000000000000000000000000000000000078dc5d2d739606d31509c31d654056a45185ecb60000000000000000000000006ecbe1db9ef729cbe972c83fb886247691fb6beb0000000000000000000000000000000000000000000000056bc75e2d6310000000000000000000000000000000000000000000000000000ad78ebc5ac62000000000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000000000005c87b0879221cb37dcf690e02b0f9aecf44fcaa5ed9ce99697e86743795fa132596ff597000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001e00000000000000000000000000000000000000000000000000000000000000024f47261b000000000000000000000000034d402f14d58e001d8efbe6585051bf9706aa064000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024f47261b000000000000000000000000025b8fe1de9daf8ba351890744ff28cf7dfa8f5e30000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000056bc75e2d631000000000000000000000000000000000000000000000000000056bc75e2d6310000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000421ce8e3c600d933423172b5021158a6be2e818613ff8e762d70ef490c752fd98a626a215f09f169668990414de75a53da221c294a3002f796d004827258b641876e03000000000000000000000000000000000000000000000000000000000000',
batchFillOrdersNoThrow:
// exchangeContract.batchFillOrdersNoThrow.getABIEncodedTransactionData(
// [INPUTS.order, INPUTS.order],
// [INPUTS.takerAssetFillAmount, INPUTS.takerAssetFillAmount],
// [INPUTS.signature, INPUTS.signature],
// ),
'0x50dde190000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000360000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000040000000000000000000000000e36ea790bc9d7ab70c55260c66d52b1eca985f84000000000000000000000000000000000000000000000000000000000000000000000000000000000000000078dc5d2d739606d31509c31d654056a45185ecb60000000000000000000000006ecbe1db9ef729cbe972c83fb886247691fb6beb0000000000000000000000000000000000000000000000056bc75e2d6310000000000000000000000000000000000000000000000000000ad78ebc5ac62000000000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000000000005c87b0879221cb37dcf690e02b0f9aecf44fcaa5ed9ce99697e86743795fa132596ff597000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001e00000000000000000000000000000000000000000000000000000000000000024f47261b000000000000000000000000034d402f14d58e001d8efbe6585051bf9706aa064000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024f47261b000000000000000000000000025b8fe1de9daf8ba351890744ff28cf7dfa8f5e30000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000056bc75e2d631000000000000000000000000000000000000000000000000000056bc75e2d6310000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000421ce8e3c600d933423172b5021158a6be2e818613ff8e762d70ef490c752fd98a626a215f09f169668990414de75a53da221c294a3002f796d004827258b641876e03000000000000000000000000000000000000000000000000000000000000',
batchFillOrKillOrders:
// exchangeContract.batchFillOrKillOrders.getABIEncodedTransactionData(
// [INPUTS.order, INPUTS.order],
// [INPUTS.takerAssetFillAmount, INPUTS.takerAssetFillAmount],
// [INPUTS.signature, INPUTS.signature],
// ),
'0x4d0ae546000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000360000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000040000000000000000000000000e36ea790bc9d7ab70c55260c66d52b1eca985f84000000000000000000000000000000000000000000000000000000000000000000000000000000000000000078dc5d2d739606d31509c31d654056a45185ecb60000000000000000000000006ecbe1db9ef729cbe972c83fb886247691fb6beb0000000000000000000000000000000000000000000000056bc75e2d6310000000000000000000000000000000000000000000000000000ad78ebc5ac62000000000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000000000005c87b0879221cb37dcf690e02b0f9aecf44fcaa5ed9ce99697e86743795fa132596ff597000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001e00000000000000000000000000000000000000000000000000000000000000024f47261b000000000000000000000000034d402f14d58e001d8efbe6585051bf9706aa064000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024f47261b000000000000000000000000025b8fe1de9daf8ba351890744ff28cf7dfa8f5e30000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000056bc75e2d631000000000000000000000000000000000000000000000000000056bc75e2d6310000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000421ce8e3c600d933423172b5021158a6be2e818613ff8e762d70ef490c752fd98a626a215f09f169668990414de75a53da221c294a3002f796d004827258b641876e03000000000000000000000000000000000000000000000000000000000000',
cancelOrder:
// exchangeContract.cancelOrder.getABIEncodedTransactionData(INPUTS.order),
'0xd46b02c30000000000000000000000000000000000000000000000000000000000000020000000000000000000000000e36ea790bc9d7ab70c55260c66d52b1eca985f84000000000000000000000000000000000000000000000000000000000000000000000000000000000000000078dc5d2d739606d31509c31d654056a45185ecb60000000000000000000000006ecbe1db9ef729cbe972c83fb886247691fb6beb0000000000000000000000000000000000000000000000056bc75e2d6310000000000000000000000000000000000000000000000000000ad78ebc5ac62000000000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000000000005c87b0879221cb37dcf690e02b0f9aecf44fcaa5ed9ce99697e86743795fa132596ff597000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001e00000000000000000000000000000000000000000000000000000000000000024f47261b000000000000000000000000034d402f14d58e001d8efbe6585051bf9706aa064000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024f47261b000000000000000000000000025b8fe1de9daf8ba351890744ff28cf7dfa8f5e300000000000000000000000000000000000000000000000000000000',
fillOrder:
// exchangeContract.fillOrder.getABIEncodedTransactionData(
// INPUTS.order,
// INPUTS.takerAssetFillAmount,
// INPUTS.signature,
// ),
'0xb4be83d500000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000056bc75e2d6310000000000000000000000000000000000000000000000000000000000000000002a0000000000000000000000000e36ea790bc9d7ab70c55260c66d52b1eca985f84000000000000000000000000000000000000000000000000000000000000000000000000000000000000000078dc5d2d739606d31509c31d654056a45185ecb60000000000000000000000006ecbe1db9ef729cbe972c83fb886247691fb6beb0000000000000000000000000000000000000000000000056bc75e2d6310000000000000000000000000000000000000000000000000000ad78ebc5ac62000000000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000000000005c87b0879221cb37dcf690e02b0f9aecf44fcaa5ed9ce99697e86743795fa132596ff597000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001e00000000000000000000000000000000000000000000000000000000000000024f47261b000000000000000000000000034d402f14d58e001d8efbe6585051bf9706aa064000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024f47261b000000000000000000000000025b8fe1de9daf8ba351890744ff28cf7dfa8f5e30000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000421ce8e3c600d933423172b5021158a6be2e818613ff8e762d70ef490c752fd98a626a215f09f169668990414de75a53da221c294a3002f796d004827258b641876e03000000000000000000000000000000000000000000000000000000000000',
fillOrderNoThrow:
// exchangeContract.fillOrderNoThrow.getABIEncodedTransactionData(
// INPUTS.order,
// INPUTS.takerAssetFillAmount,
// INPUTS.signature,
// ),
'0x3e228bae00000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000056bc75e2d6310000000000000000000000000000000000000000000000000000000000000000002a0000000000000000000000000e36ea790bc9d7ab70c55260c66d52b1eca985f84000000000000000000000000000000000000000000000000000000000000000000000000000000000000000078dc5d2d739606d31509c31d654056a45185ecb60000000000000000000000006ecbe1db9ef729cbe972c83fb886247691fb6beb0000000000000000000000000000000000000000000000056bc75e2d6310000000000000000000000000000000000000000000000000000ad78ebc5ac62000000000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000000000005c87b0879221cb37dcf690e02b0f9aecf44fcaa5ed9ce99697e86743795fa132596ff597000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001e00000000000000000000000000000000000000000000000000000000000000024f47261b000000000000000000000000034d402f14d58e001d8efbe6585051bf9706aa064000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024f47261b000000000000000000000000025b8fe1de9daf8ba351890744ff28cf7dfa8f5e30000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000421ce8e3c600d933423172b5021158a6be2e818613ff8e762d70ef490c752fd98a626a215f09f169668990414de75a53da221c294a3002f796d004827258b641876e03000000000000000000000000000000000000000000000000000000000000',
fillOrKillOrder:
// exchangeContract.fillOrKillOrder.getABIEncodedTransactionData(
// INPUTS.order,
// INPUTS.takerAssetFillAmount,
// INPUTS.signature,
// ),
'0x64a3bc1500000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000056bc75e2d6310000000000000000000000000000000000000000000000000000000000000000002a0000000000000000000000000e36ea790bc9d7ab70c55260c66d52b1eca985f84000000000000000000000000000000000000000000000000000000000000000000000000000000000000000078dc5d2d739606d31509c31d654056a45185ecb60000000000000000000000006ecbe1db9ef729cbe972c83fb886247691fb6beb0000000000000000000000000000000000000000000000056bc75e2d6310000000000000000000000000000000000000000000000000000ad78ebc5ac62000000000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000000000005c87b0879221cb37dcf690e02b0f9aecf44fcaa5ed9ce99697e86743795fa132596ff597000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001e00000000000000000000000000000000000000000000000000000000000000024f47261b000000000000000000000000034d402f14d58e001d8efbe6585051bf9706aa064000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024f47261b000000000000000000000000025b8fe1de9daf8ba351890744ff28cf7dfa8f5e30000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000421ce8e3c600d933423172b5021158a6be2e818613ff8e762d70ef490c752fd98a626a215f09f169668990414de75a53da221c294a3002f796d004827258b641876e03000000000000000000000000000000000000000000000000000000000000',
marketBuyOrders:
// exchangeContract.marketBuyOrders.getABIEncodedTransactionData(
// [INPUTS.order, INPUTS.order],
// INPUTS.takerAssetFillAmount,
// [INPUTS.signature, INPUTS.signature],
// ),
'0xe5fa431b00000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000056bc75e2d631000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000040000000000000000000000000e36ea790bc9d7ab70c55260c66d52b1eca985f84000000000000000000000000000000000000000000000000000000000000000000000000000000000000000078dc5d2d739606d31509c31d654056a45185ecb60000000000000000000000006ecbe1db9ef729cbe972c83fb886247691fb6beb0000000000000000000000000000000000000000000000056bc75e2d6310000000000000000000000000000000000000000000000000000ad78ebc5ac62000000000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000000000005c87b0879221cb37dcf690e02b0f9aecf44fcaa5ed9ce99697e86743795fa132596ff597000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001e00000000000000000000000000000000000000000000000000000000000000024f47261b000000000000000000000000034d402f14d58e001d8efbe6585051bf9706aa064000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024f47261b000000000000000000000000025b8fe1de9daf8ba351890744ff28cf7dfa8f5e30000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000421ce8e3c600d933423172b5021158a6be2e818613ff8e762d70ef490c752fd98a626a215f09f169668990414de75a53da221c294a3002f796d004827258b641876e03000000000000000000000000000000000000000000000000000000000000',
marketBuyOrdersNoThrow:
// exchangeContract.marketBuyOrdersNoThrow.getABIEncodedTransactionData(
// [INPUTS.order, INPUTS.order],
// INPUTS.takerAssetFillAmount,
// [INPUTS.signature, INPUTS.signature],
// ),
'0xa3e2038000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000056bc75e2d631000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000040000000000000000000000000e36ea790bc9d7ab70c55260c66d52b1eca985f84000000000000000000000000000000000000000000000000000000000000000000000000000000000000000078dc5d2d739606d31509c31d654056a45185ecb60000000000000000000000006ecbe1db9ef729cbe972c83fb886247691fb6beb0000000000000000000000000000000000000000000000056bc75e2d6310000000000000000000000000000000000000000000000000000ad78ebc5ac62000000000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000000000005c87b0879221cb37dcf690e02b0f9aecf44fcaa5ed9ce99697e86743795fa132596ff597000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001e00000000000000000000000000000000000000000000000000000000000000024f47261b000000000000000000000000034d402f14d58e001d8efbe6585051bf9706aa064000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024f47261b000000000000000000000000025b8fe1de9daf8ba351890744ff28cf7dfa8f5e30000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000421ce8e3c600d933423172b5021158a6be2e818613ff8e762d70ef490c752fd98a626a215f09f169668990414de75a53da221c294a3002f796d004827258b641876e03000000000000000000000000000000000000000000000000000000000000',
marketSellOrders:
// exchangeContract.marketSellOrders.getABIEncodedTransactionData(
// [INPUTS.order, INPUTS.order],
// INPUTS.takerAssetFillAmount,
// [INPUTS.signature, INPUTS.signature],
// ),
'0x7e1d980800000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000056bc75e2d631000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000040000000000000000000000000e36ea790bc9d7ab70c55260c66d52b1eca985f84000000000000000000000000000000000000000000000000000000000000000000000000000000000000000078dc5d2d739606d31509c31d654056a45185ecb60000000000000000000000006ecbe1db9ef729cbe972c83fb886247691fb6beb0000000000000000000000000000000000000000000000056bc75e2d6310000000000000000000000000000000000000000000000000000ad78ebc5ac62000000000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000000000005c87b0879221cb37dcf690e02b0f9aecf44fcaa5ed9ce99697e86743795fa132596ff597000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001e00000000000000000000000000000000000000000000000000000000000000024f47261b000000000000000000000000034d402f14d58e001d8efbe6585051bf9706aa064000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024f47261b000000000000000000000000025b8fe1de9daf8ba351890744ff28cf7dfa8f5e30000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000421ce8e3c600d933423172b5021158a6be2e818613ff8e762d70ef490c752fd98a626a215f09f169668990414de75a53da221c294a3002f796d004827258b641876e03000000000000000000000000000000000000000000000000000000000000',
marketSellOrdersNoThrow:
// exchangeContract.marketSellOrdersNoThrow.getABIEncodedTransactionData(
// [INPUTS.order, INPUTS.order],
// INPUTS.takerAssetFillAmount,
// [INPUTS.signature, INPUTS.signature],
// ),
'0xdd1c7d1800000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000056bc75e2d631000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000040000000000000000000000000e36ea790bc9d7ab70c55260c66d52b1eca985f84000000000000000000000000000000000000000000000000000000000000000000000000000000000000000078dc5d2d739606d31509c31d654056a45185ecb60000000000000000000000006ecbe1db9ef729cbe972c83fb886247691fb6beb0000000000000000000000000000000000000000000000056bc75e2d6310000000000000000000000000000000000000000000000000000ad78ebc5ac62000000000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000000000005c87b0879221cb37dcf690e02b0f9aecf44fcaa5ed9ce99697e86743795fa132596ff597000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001e00000000000000000000000000000000000000000000000000000000000000024f47261b000000000000000000000000034d402f14d58e001d8efbe6585051bf9706aa064000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024f47261b000000000000000000000000025b8fe1de9daf8ba351890744ff28cf7dfa8f5e30000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000421ce8e3c600d933423172b5021158a6be2e818613ff8e762d70ef490c752fd98a626a215f09f169668990414de75a53da221c294a3002f796d004827258b641876e03000000000000000000000000000000000000000000000000000000000000',
matchOrders:
// exchangeContract.matchOrders.getABIEncodedTransactionData(
// INPUTS.order,
// makeComplementaryOrder(INPUTS.order),
// INPUTS.signature,
// INPUTS.signature,
// ),
'0x3c28d86100000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000026000000000000000000000000000000000000000000000000000000000000002600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000078dc5d2d739606d31509c31d654056a45185ecb60000000000000000000000006ecbe1db9ef729cbe972c83fb886247691fb6beb00000000000000000000000000000000000000000000000ad78ebc5ac620000000000000000000000000000000000000000000000000000ad78ebc5ac62000000000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000000000005c87b0879221cb37dcf690e02b0f9aecf44fcaa5ed9ce99697e86743795fa132596ff597000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001800000000000000000000000000000000000000000000000000000000000000024f47261b000000000000000000000000025b8fe1de9daf8ba351890744ff28cf7dfa8f5e30000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000421ce8e3c600d933423172b5021158a6be2e818613ff8e762d70ef490c752fd98a626a215f09f169668990414de75a53da221c294a3002f796d004827258b641876e03000000000000000000000000000000000000000000000000000000000000',
};
describe('LibTransactionDecoder', () => {
let libTxDecoder: LibTransactionDecoderContract;
before(async () => {
await blockchainLifecycle.startAsync();
libTxDecoder = await LibTransactionDecoderContract.deployFrom0xArtifactAsync(
artifacts.LibTransactionDecoder,
provider,
txDefaults,
);
});
after(async () => {
await blockchainLifecycle.revertAsync();
});
it('should decode an Exchange.batchCancelOrders() transaction', async () => {
expect(
await libTxDecoder.decodeZeroExTransactionData.callAsync(ENCODED_INPUTS.batchCancelOrders),
).to.deep.equal(['batchCancelOrders', [INPUTS.order, INPUTS.order], [], []]);
});
for (const func of ['batchFillOrders', 'batchFillOrdersNoThrow', 'batchFillOrKillOrders']) {
it(`should decode an Exchange.${func}() transaction`, async () => {
expect(await libTxDecoder.decodeZeroExTransactionData.callAsync(ENCODED_INPUTS[func])).to.deep.equal([
func,
[INPUTS.order, INPUTS.order],
[INPUTS.takerAssetFillAmount, INPUTS.takerAssetFillAmount],
[INPUTS.signature, INPUTS.signature],
]);
});
}
it('should decode an Exchange.cancelOrder() transaction', async () => {
expect(await libTxDecoder.decodeZeroExTransactionData.callAsync(ENCODED_INPUTS.cancelOrder)).to.deep.equal([
'cancelOrder',
[INPUTS.order],
[],
[],
]);
});
for (const func of ['fillOrder', 'fillOrderNoThrow', 'fillOrKillOrder']) {
it(`should decode an Exchange.${func}() transaction`, async () => {
expect(await libTxDecoder.decodeZeroExTransactionData.callAsync(ENCODED_INPUTS[func])).to.deep.equal([
func,
[INPUTS.order],
[INPUTS.takerAssetFillAmount],
[INPUTS.signature],
]);
});
}
for (const func of ['marketBuyOrders', 'marketBuyOrdersNoThrow', 'marketSellOrders', 'marketSellOrdersNoThrow']) {
it(`should decode an Exchange.${func}() transaction`, async () => {
expect(await libTxDecoder.decodeZeroExTransactionData.callAsync(ENCODED_INPUTS[func])).to.deep.equal([
func,
[INPUTS.order, INPUTS.order],
[INPUTS.takerAssetFillAmount],
[INPUTS.signature, INPUTS.signature],
]);
});
}
it('should decode an Exchange.matchOrders() transaction', async () => {
function makeComplementaryOrder(order: OrderWithoutExchange): OrderWithoutExchange {
const complementaryOrder = order;
complementaryOrder.makerAddress = order.takerAddress;
complementaryOrder.takerAddress = order.makerAddress;
complementaryOrder.makerAssetData = order.takerAssetData;
complementaryOrder.takerAssetData = order.makerAssetData;
complementaryOrder.makerAssetAmount = order.takerAssetAmount;
complementaryOrder.takerAssetAmount = order.makerAssetAmount;
complementaryOrder.makerFee = order.takerFee;
complementaryOrder.takerFee = order.makerFee;
return complementaryOrder;
}
expect(await libTxDecoder.decodeZeroExTransactionData.callAsync(ENCODED_INPUTS.matchOrders)).to.deep.equal([
'matchOrders',
[INPUTS.order, makeComplementaryOrder(INPUTS.order)],
[INPUTS.order.takerAssetAmount, makeComplementaryOrder(INPUTS.order).takerAssetAmount],
[INPUTS.signature, INPUTS.signature],
]);
});
});

View File

@ -10,6 +10,7 @@
"generated-artifacts/LibFillResults.json",
"generated-artifacts/LibMath.json",
"generated-artifacts/LibOrder.json",
"generated-artifacts/LibTransactionDecoder.json",
"generated-artifacts/TestLibs.json"
],
"exclude": ["./deploy/solc/solc_bin"]

View File

@ -1,4 +1,40 @@
[
{
"timestamp": 1558712885,
"version": "2.1.5",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1557961111,
"version": "2.1.4",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1557799313,
"version": "2.1.3",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1557507213,
"version": "2.1.2",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "2.1.1",
"changes": [

View File

@ -5,6 +5,22 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v2.1.5 - _May 24, 2019_
* Dependencies updated
## v2.1.4 - _May 15, 2019_
* Dependencies updated
## v2.1.3 - _May 14, 2019_
* Dependencies updated
## v2.1.2 - _May 10, 2019_
* Dependencies updated
## v2.1.1 - _April 11, 2019_
* Dependencies updated

View File

@ -1,6 +1,6 @@
{
"name": "@0x/contracts-exchange",
"version": "2.1.1",
"version": "2.1.5",
"engines": {
"node": ">=6.12"
},
@ -47,11 +47,11 @@
},
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/protocol/README.md",
"devDependencies": {
"@0x/abi-gen": "^2.0.9",
"@0x/contracts-gen": "^1.0.8",
"@0x/contracts-test-utils": "^3.1.2",
"@0x/dev-utils": "^2.2.1",
"@0x/sol-compiler": "^3.1.6",
"@0x/abi-gen": "^2.0.10",
"@0x/contracts-gen": "^1.0.9",
"@0x/contracts-test-utils": "^3.1.7",
"@0x/dev-utils": "^2.2.3",
"@0x/sol-compiler": "^3.1.8",
"@0x/tslint-config": "^3.0.1",
"@types/lodash": "4.14.104",
"@types/node": "*",
@ -68,18 +68,18 @@
"typescript": "3.0.1"
},
"dependencies": {
"@0x/base-contract": "^5.0.5",
"@0x/contracts-asset-proxy": "^2.1.1",
"@0x/contracts-erc1155": "^1.1.1",
"@0x/contracts-erc20": "^2.2.0",
"@0x/contracts-erc721": "^2.1.1",
"@0x/contracts-exchange-libs": "^2.1.1",
"@0x/contracts-utils": "^3.1.1",
"@0x/order-utils": "^7.2.0",
"@0x/base-contract": "^5.1.0",
"@0x/contracts-asset-proxy": "^2.1.5",
"@0x/contracts-erc1155": "^1.1.6",
"@0x/contracts-erc20": "^2.2.5",
"@0x/contracts-erc721": "^2.1.6",
"@0x/contracts-exchange-libs": "^2.1.6",
"@0x/contracts-utils": "^3.1.6",
"@0x/order-utils": "^8.1.1",
"@0x/types": "^2.2.2",
"@0x/typescript-typings": "^4.2.2",
"@0x/utils": "^4.3.1",
"@0x/web3-wrapper": "^6.0.5",
"@0x/utils": "^4.3.3",
"@0x/web3-wrapper": "^6.0.6",
"ethereum-types": "^2.1.2",
"ethereumjs-util": "^5.1.1",
"lodash": "^4.17.11"

View File

@ -1,4 +1,40 @@
[
{
"timestamp": 1558712885,
"version": "3.1.5",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1557961111,
"version": "3.1.4",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1557799313,
"version": "3.1.3",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1557507213,
"version": "3.1.2",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "3.1.1",
"changes": [

View File

@ -5,6 +5,22 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v3.1.5 - _May 24, 2019_
* Dependencies updated
## v3.1.4 - _May 15, 2019_
* Dependencies updated
## v3.1.3 - _May 14, 2019_
* Dependencies updated
## v3.1.2 - _May 10, 2019_
* Dependencies updated
## v3.1.1 - _April 11, 2019_
* Dependencies updated

View File

@ -1,6 +1,6 @@
{
"name": "@0x/contracts-extensions",
"version": "3.1.1",
"version": "3.1.5",
"engines": {
"node": ">=6.12"
},
@ -47,12 +47,12 @@
},
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/extensions/README.md",
"devDependencies": {
"@0x/abi-gen": "^2.0.9",
"@0x/contract-wrappers": "^9.0.0",
"@0x/contracts-gen": "^1.0.8",
"@0x/contracts-test-utils": "^3.1.2",
"@0x/dev-utils": "^2.2.1",
"@0x/sol-compiler": "^3.1.6",
"@0x/abi-gen": "^2.0.10",
"@0x/contract-wrappers": "^9.1.4",
"@0x/contracts-gen": "^1.0.9",
"@0x/contracts-test-utils": "^3.1.7",
"@0x/dev-utils": "^2.2.3",
"@0x/sol-compiler": "^3.1.8",
"@0x/tslint-config": "^3.0.1",
"@types/lodash": "4.14.104",
"@types/node": "*",
@ -69,18 +69,18 @@
"typescript": "3.0.1"
},
"dependencies": {
"@0x/base-contract": "^5.0.5",
"@0x/contracts-asset-proxy": "^2.1.1",
"@0x/contracts-erc20": "^2.2.0",
"@0x/contracts-erc721": "^2.1.1",
"@0x/contracts-exchange": "^2.1.1",
"@0x/contracts-exchange-libs": "^2.1.1",
"@0x/contracts-utils": "^3.1.1",
"@0x/order-utils": "^7.2.0",
"@0x/base-contract": "^5.1.0",
"@0x/contracts-asset-proxy": "^2.1.5",
"@0x/contracts-erc20": "^2.2.5",
"@0x/contracts-erc721": "^2.1.6",
"@0x/contracts-exchange": "^2.1.5",
"@0x/contracts-exchange-libs": "^2.1.6",
"@0x/contracts-utils": "^3.1.6",
"@0x/order-utils": "^8.1.1",
"@0x/types": "^2.2.2",
"@0x/typescript-typings": "^4.2.2",
"@0x/utils": "^4.3.1",
"@0x/web3-wrapper": "^6.0.5",
"@0x/utils": "^4.3.3",
"@0x/web3-wrapper": "^6.0.6",
"ethereum-types": "^2.1.2",
"lodash": "^4.17.11"
},

View File

@ -1,4 +1,40 @@
[
{
"timestamp": 1558712885,
"version": "3.1.5",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1557961111,
"version": "3.1.4",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1557799313,
"version": "3.1.3",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1557507213,
"version": "3.1.2",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "3.1.1",
"changes": [

View File

@ -5,6 +5,22 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v3.1.5 - _May 24, 2019_
* Dependencies updated
## v3.1.4 - _May 15, 2019_
* Dependencies updated
## v3.1.3 - _May 14, 2019_
* Dependencies updated
## v3.1.2 - _May 10, 2019_
* Dependencies updated
## v3.1.1 - _April 11, 2019_
* Dependencies updated

View File

@ -1,6 +1,6 @@
{
"name": "@0x/contracts-multisig",
"version": "3.1.1",
"version": "3.1.5",
"engines": {
"node": ">=6.12"
},
@ -47,11 +47,11 @@
},
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/multisig/README.md",
"devDependencies": {
"@0x/abi-gen": "^2.0.9",
"@0x/contracts-gen": "^1.0.8",
"@0x/contracts-test-utils": "^3.1.2",
"@0x/dev-utils": "^2.2.1",
"@0x/sol-compiler": "^3.1.6",
"@0x/abi-gen": "^2.0.10",
"@0x/contracts-gen": "^1.0.9",
"@0x/contracts-test-utils": "^3.1.7",
"@0x/dev-utils": "^2.2.3",
"@0x/sol-compiler": "^3.1.8",
"@0x/tslint-config": "^3.0.1",
"@types/lodash": "4.14.104",
"@types/node": "*",
@ -68,14 +68,14 @@
"typescript": "3.0.1"
},
"dependencies": {
"@0x/base-contract": "^5.0.5",
"@0x/contracts-asset-proxy": "^2.1.1",
"@0x/contracts-erc20": "^2.2.0",
"@0x/base-contract": "^5.1.0",
"@0x/contracts-asset-proxy": "^2.1.5",
"@0x/contracts-erc20": "^2.2.5",
"@0x/contracts-utils": "2.0.1",
"@0x/types": "^2.2.2",
"@0x/typescript-typings": "^4.2.2",
"@0x/utils": "^4.3.1",
"@0x/web3-wrapper": "^6.0.5",
"@0x/utils": "^4.3.3",
"@0x/web3-wrapper": "^6.0.6",
"ethereum-types": "^2.1.2",
"lodash": "^4.17.11"
},

View File

@ -1,4 +1,40 @@
[
{
"timestamp": 1558712885,
"version": "3.1.7",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1557961111,
"version": "3.1.6",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "3.1.5",
"changes": [
{
"note": "Dependencies updated"
}
],
"timestamp": 1557799313
},
{
"timestamp": 1557507213,
"version": "3.1.3",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "3.1.2",
"changes": [

View File

@ -5,6 +5,22 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v3.1.7 - _May 24, 2019_
* Dependencies updated
## v3.1.6 - _May 15, 2019_
* Dependencies updated
## v3.1.5 - _May 14, 2019_
* Dependencies updated
## v3.1.3 - _May 10, 2019_
* Dependencies updated
## v3.1.2 - _April 11, 2019_
* Dependencies updated

View File

@ -1,6 +1,6 @@
{
"name": "@0x/contracts-test-utils",
"version": "3.1.2",
"version": "3.1.7",
"engines": {
"node": ">=6.12"
},
@ -41,19 +41,19 @@
"typescript": "3.0.1"
},
"dependencies": {
"@0x/abi-gen": "^2.0.9",
"@0x/dev-utils": "^2.2.1",
"@0x/order-utils": "^7.2.0",
"@0x/sol-compiler": "^3.1.6",
"@0x/sol-coverage": "^3.0.3",
"@0x/sol-profiler": "^3.1.5",
"@0x/sol-trace": "^2.0.11",
"@0x/subproviders": "^4.0.5",
"@0x/abi-gen": "^2.0.10",
"@0x/dev-utils": "^2.2.3",
"@0x/order-utils": "^8.1.1",
"@0x/sol-compiler": "^3.1.8",
"@0x/sol-coverage": "^3.0.5",
"@0x/sol-profiler": "^3.1.7",
"@0x/sol-trace": "^2.0.13",
"@0x/subproviders": "^4.1.0",
"@0x/tslint-config": "^3.0.1",
"@0x/types": "^2.2.2",
"@0x/typescript-typings": "^4.2.2",
"@0x/utils": "^4.3.1",
"@0x/web3-wrapper": "^6.0.5",
"@0x/utils": "^4.3.3",
"@0x/web3-wrapper": "^6.0.6",
"@types/bn.js": "^4.11.0",
"@types/js-combinatorics": "^0.5.29",
"@types/lodash": "4.14.104",

View File

@ -1,4 +1,40 @@
[
{
"timestamp": 1558712885,
"version": "3.1.6",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1557961111,
"version": "3.1.5",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "3.1.4",
"changes": [
{
"note": "Dependencies updated"
}
],
"timestamp": 1557799313
},
{
"timestamp": 1557507213,
"version": "3.1.2",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "3.1.1",
"changes": [

View File

@ -5,6 +5,22 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v3.1.6 - _May 24, 2019_
* Dependencies updated
## v3.1.5 - _May 15, 2019_
* Dependencies updated
## v3.1.4 - _May 14, 2019_
* Dependencies updated
## v3.1.2 - _May 10, 2019_
* Dependencies updated
## v3.1.1 - _April 11, 2019_
* Dependencies updated

View File

@ -1,6 +1,6 @@
{
"name": "@0x/contracts-utils",
"version": "3.1.1",
"version": "3.1.6",
"engines": {
"node": ">=6.12"
},
@ -47,11 +47,11 @@
},
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/utils/README.md",
"devDependencies": {
"@0x/abi-gen": "^2.0.9",
"@0x/contracts-gen": "^1.0.8",
"@0x/contracts-test-utils": "^3.1.2",
"@0x/dev-utils": "^2.2.1",
"@0x/sol-compiler": "^3.1.6",
"@0x/abi-gen": "^2.0.10",
"@0x/contracts-gen": "^1.0.9",
"@0x/contracts-test-utils": "^3.1.7",
"@0x/dev-utils": "^2.2.3",
"@0x/sol-compiler": "^3.1.8",
"@0x/tslint-config": "^3.0.1",
"@types/bn.js": "^4.11.0",
"@types/lodash": "4.14.104",
@ -69,12 +69,12 @@
"typescript": "3.0.1"
},
"dependencies": {
"@0x/base-contract": "^5.0.5",
"@0x/order-utils": "^7.2.0",
"@0x/base-contract": "^5.1.0",
"@0x/order-utils": "^8.1.1",
"@0x/types": "^2.2.2",
"@0x/typescript-typings": "^4.2.2",
"@0x/utils": "^4.3.1",
"@0x/web3-wrapper": "^6.0.5",
"@0x/utils": "^4.3.3",
"@0x/web3-wrapper": "^6.0.6",
"bn.js": "^4.11.8",
"ethereum-types": "^2.1.2",
"ethereumjs-util": "^5.1.1",

View File

@ -1,4 +1,40 @@
[
{
"timestamp": 1558712885,
"version": "6.0.10",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1557961111,
"version": "6.0.9",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1557799313,
"version": "6.0.8",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1557507213,
"version": "6.0.7",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "6.0.6",
"changes": [

View File

@ -5,6 +5,22 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v6.0.10 - _May 24, 2019_
* Dependencies updated
## v6.0.9 - _May 15, 2019_
* Dependencies updated
## v6.0.8 - _May 14, 2019_
* Dependencies updated
## v6.0.7 - _May 10, 2019_
* Dependencies updated
## v6.0.6 - _April 11, 2019_
* Dependencies updated

View File

@ -1,6 +1,6 @@
{
"name": "0x.js",
"version": "6.0.6",
"version": "6.0.10",
"engines": {
"node": ">=6.12"
},
@ -43,10 +43,10 @@
},
"license": "Apache-2.0",
"devDependencies": {
"@0x/abi-gen-wrappers": "^4.2.0",
"@0x/contract-addresses": "^2.3.1",
"@0x/dev-utils": "^2.2.1",
"@0x/migrations": "^4.1.1",
"@0x/abi-gen-wrappers": "^4.3.0",
"@0x/contract-addresses": "^2.3.3",
"@0x/dev-utils": "^2.2.3",
"@0x/migrations": "^4.1.6",
"@0x/tslint-config": "^3.0.1",
"@types/lodash": "4.14.104",
"@types/mocha": "^2.2.42",
@ -73,16 +73,16 @@
"webpack": "^4.20.2"
},
"dependencies": {
"@0x/assert": "^2.0.9",
"@0x/base-contract": "^5.0.5",
"@0x/contract-wrappers": "^9.0.0",
"@0x/order-utils": "^7.2.0",
"@0x/order-watcher": "^4.0.6",
"@0x/subproviders": "^4.0.5",
"@0x/assert": "^2.0.10",
"@0x/base-contract": "^5.1.0",
"@0x/contract-wrappers": "^9.1.4",
"@0x/order-utils": "^8.1.1",
"@0x/order-watcher": "^4.0.11",
"@0x/subproviders": "^4.1.0",
"@0x/types": "^2.2.2",
"@0x/typescript-typings": "^4.2.2",
"@0x/utils": "^4.3.1",
"@0x/web3-wrapper": "^6.0.5",
"@0x/utils": "^4.3.3",
"@0x/web3-wrapper": "^6.0.6",
"@types/web3-provider-engine": "^14.0.0",
"ethereum-types": "^2.1.2",
"ethers": "~4.0.4",

View File

@ -10,6 +10,9 @@ export {
export {
ContractWrappers,
CoordinatorWrapper,
CoordinatorServerCancellationResponse,
CoordinatorServerError,
DutchAuctionWrapper,
ERC20TokenWrapper,
ERC721TokenWrapper,

View File

@ -6,7 +6,8 @@
"note": "add `awaitTransactionSuccessAsync()` to `tx.handlebars`",
"pr": 1797
}
]
],
"timestamp": 1557507213
},
{
"version": "2.0.2",

View File

@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v2.1.0 - _May 10, 2019_
* add `awaitTransactionSuccessAsync()` to `tx.handlebars` (#1797)
## v2.0.2 - _April 11, 2019_
* Dependencies updated

View File

@ -1,6 +1,6 @@
{
"name": "@0x/abi-gen-templates",
"version": "2.0.2",
"version": "2.1.0",
"engines": {
"node": ">=6.12"
},

View File

@ -6,7 +6,8 @@
"note": "Update wrapper functions to expose `awaitTransactionSuccessAsync()` methods",
"pr": 1797
}
]
],
"timestamp": 1557507213
},
{
"version": "4.2.0",

View File

@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v4.3.0 - _May 10, 2019_
* Update wrapper functions to expose `awaitTransactionSuccessAsync()` methods (#1797)
## v4.2.0 - _April 11, 2019_
* Added IAssetProxy wrapper (#1714)

View File

@ -1,6 +1,6 @@
{
"name": "@0x/abi-gen-wrappers",
"version": "4.2.0",
"version": "4.3.0",
"engines": {
"node": ">=6.12"
},
@ -31,19 +31,19 @@
},
"homepage": "https://github.com/0xProject/0x-monorepo/packages/abi-gen-wrappers/README.md",
"devDependencies": {
"@0x/abi-gen": "^2.0.9",
"@0x/abi-gen-templates": "^2.0.2",
"@0x/abi-gen": "^2.0.10",
"@0x/abi-gen-templates": "^2.1.0",
"@0x/tslint-config": "^3.0.1",
"@0x/types": "^2.2.2",
"@0x/utils": "^4.3.1",
"@0x/web3-wrapper": "^6.0.5",
"@0x/utils": "^4.3.3",
"@0x/web3-wrapper": "^6.0.6",
"ethereum-types": "^2.1.2",
"ethers": "~4.0.4",
"lodash": "^4.17.11",
"shx": "^0.2.2"
},
"dependencies": {
"@0x/base-contract": "^5.0.5"
"@0x/base-contract": "^5.1.0"
},
"publishConfig": {
"access": "public"

View File

@ -1,4 +1,13 @@
[
{
"timestamp": 1557507213,
"version": "2.0.10",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "2.0.9",
"changes": [

View File

@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v2.0.10 - _May 10, 2019_
* Dependencies updated
## v2.0.9 - _April 11, 2019_
* Dependencies updated

View File

@ -1,6 +1,6 @@
{
"name": "@0x/abi-gen",
"version": "2.0.9",
"version": "2.0.10",
"engines": {
"node": ">=6.12"
},
@ -33,7 +33,7 @@
"homepage": "https://github.com/0xProject/0x-monorepo/packages/abi-gen/README.md",
"dependencies": {
"@0x/typescript-typings": "^4.2.2",
"@0x/utils": "^4.3.1",
"@0x/utils": "^4.3.3",
"chalk": "^2.3.0",
"ethereum-types": "^2.1.2",
"glob": "^7.1.2",

View File

@ -1,4 +1,13 @@
[
{
"timestamp": 1557507213,
"version": "2.0.10",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "2.0.9",
"changes": [

View File

@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v2.0.10 - _May 10, 2019_
* Dependencies updated
## v2.0.9 - _April 11, 2019_
* Dependencies updated

View File

@ -1,6 +1,6 @@
{
"name": "@0x/assert",
"version": "2.0.9",
"version": "2.0.10",
"engines": {
"node": ">=6.12"
},
@ -45,9 +45,9 @@
"typescript": "3.0.1"
},
"dependencies": {
"@0x/json-schemas": "^3.0.9",
"@0x/json-schemas": "^3.0.10",
"@0x/typescript-typings": "^4.2.2",
"@0x/utils": "^4.3.1",
"@0x/utils": "^4.3.3",
"lodash": "^4.17.11",
"valid-url": "^1.0.9"
},

View File

@ -1,4 +1,41 @@
[
{
"timestamp": 1558712885,
"version": "6.1.5",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1557961111,
"version": "6.1.4",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "6.1.3",
"changes": [
{
"note": "Convert `metaData.remainingTakerAssetAmount` to BigNumber if present in APIOrder",
"pr": 1810
}
],
"timestamp": 1557799313
},
{
"timestamp": 1557507213,
"version": "6.1.1",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "6.1.0",
"changes": [

View File

@ -5,6 +5,22 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v6.1.5 - _May 24, 2019_
* Dependencies updated
## v6.1.4 - _May 15, 2019_
* Dependencies updated
## v6.1.3 - _May 14, 2019_
* Convert `metaData.remainingTakerAssetAmount` to BigNumber if present in APIOrder (#1810)
## v6.1.1 - _May 10, 2019_
* Dependencies updated
## v6.1.0 - _April 11, 2019_
* Moved order_utils into `@0x/order-utils` package as `orderCalculationUtils` (#1714)

View File

View File

@ -1,6 +1,6 @@
{
"name": "@0x/asset-buyer",
"version": "6.1.0",
"version": "6.1.5",
"engines": {
"node": ">=6.12"
},
@ -37,16 +37,16 @@
},
"homepage": "https://github.com/0xProject/0x-monorepo/packages/asset-buyer/README.md",
"dependencies": {
"@0x/assert": "^2.0.9",
"@0x/connect": "^5.0.5",
"@0x/contract-wrappers": "^9.0.0",
"@0x/json-schemas": "^3.0.9",
"@0x/order-utils": "^7.2.0",
"@0x/subproviders": "^4.0.5",
"@0x/assert": "^2.0.10",
"@0x/connect": "^5.0.10",
"@0x/contract-wrappers": "^9.1.4",
"@0x/json-schemas": "^3.0.10",
"@0x/order-utils": "^8.1.1",
"@0x/subproviders": "^4.1.0",
"@0x/types": "^2.2.2",
"@0x/typescript-typings": "^4.2.2",
"@0x/utils": "^4.3.1",
"@0x/web3-wrapper": "^6.0.5",
"@0x/utils": "^4.3.3",
"@0x/web3-wrapper": "^6.0.6",
"ethereum-types": "^2.1.2",
"lodash": "^4.17.11"
},

View File

@ -1,6 +1,7 @@
import { HttpClient } from '@0x/connect';
import { orderCalculationUtils } from '@0x/order-utils';
import { APIOrder, AssetPairsResponse, OrderbookResponse } from '@0x/types';
import { BigNumber } from '@0x/utils';
import * as _ from 'lodash';
import {
@ -25,12 +26,14 @@ export class StandardRelayerAPIOrderProvider implements OrderProvider {
): SignedOrderWithRemainingFillableMakerAssetAmount[] {
const result = _.map(apiOrders, apiOrder => {
const { order, metaData } = apiOrder;
// calculate remainingFillableMakerAssetAmount from api metadata, else assume order is completely fillable
const remainingFillableTakerAssetAmount = _.get(
metaData,
'remainingTakerAssetAmount',
order.takerAssetAmount,
);
// The contents of metaData is not explicity defined in the spec
// We check for remainingTakerAssetAmount as a string and use this value if populated
const metaDataRemainingTakerAssetAmount = _.get(metaData, 'remainingTakerAssetAmount') as
| string
| undefined;
const remainingFillableTakerAssetAmount = metaDataRemainingTakerAssetAmount
? new BigNumber(metaDataRemainingTakerAssetAmount)
: order.takerAssetAmount;
const remainingFillableMakerAssetAmount = orderCalculationUtils.getMakerFillAmount(
order,
remainingFillableTakerAssetAmount,

View File

@ -6,7 +6,8 @@
"note": "Export `PromiseWithTransactionHash` type",
"pr": 1797
}
]
],
"timestamp": 1557507213
},
{
"version": "5.0.5",

View File

@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v5.1.0 - _May 10, 2019_
* Export `PromiseWithTransactionHash` type (#1797)
## v5.0.5 - _April 11, 2019_
* Dependencies updated

View File

@ -1,6 +1,6 @@
{
"name": "@0x/base-contract",
"version": "5.0.5",
"version": "5.1.0",
"engines": {
"node": ">=6.12"
},
@ -42,8 +42,8 @@
},
"dependencies": {
"@0x/typescript-typings": "^4.2.2",
"@0x/utils": "^4.3.1",
"@0x/web3-wrapper": "^6.0.5",
"@0x/utils": "^4.3.3",
"@0x/web3-wrapper": "^6.0.6",
"ethereum-types": "^2.1.2",
"ethers": "~4.0.4",
"lodash": "^4.17.11"

View File

@ -1,4 +1,40 @@
[
{
"timestamp": 1558712885,
"version": "5.0.10",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1557961111,
"version": "5.0.9",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "5.0.8",
"changes": [
{
"note": "Dependencies updated"
}
],
"timestamp": 1557799313
},
{
"timestamp": 1557507213,
"version": "5.0.6",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "5.0.5",
"changes": [

View File

@ -5,6 +5,22 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v5.0.10 - _May 24, 2019_
* Dependencies updated
## v5.0.9 - _May 15, 2019_
* Dependencies updated
## v5.0.8 - _May 14, 2019_
* Dependencies updated
## v5.0.6 - _May 10, 2019_
* Dependencies updated
## v5.0.5 - _April 11, 2019_
* Dependencies updated

View File

@ -1,6 +1,6 @@
{
"name": "@0x/connect",
"version": "5.0.5",
"version": "5.0.10",
"engines": {
"node": ">=6.12"
},
@ -45,12 +45,12 @@
},
"homepage": "https://github.com/0xProject/0x-monorepo/packages/connect/README.md",
"dependencies": {
"@0x/assert": "^2.0.9",
"@0x/json-schemas": "^3.0.9",
"@0x/order-utils": "^7.2.0",
"@0x/assert": "^2.0.10",
"@0x/json-schemas": "^3.0.10",
"@0x/order-utils": "^8.1.1",
"@0x/types": "^2.2.2",
"@0x/typescript-typings": "^4.2.2",
"@0x/utils": "^4.3.1",
"@0x/utils": "^4.3.3",
"lodash": "^4.17.11",
"query-string": "^6.0.0",
"sinon": "^4.0.0",

View File

@ -1,4 +1,14 @@
[
{
"version": "2.3.3",
"changes": [
{
"note": "Redeploy Coordinator contract",
"pr": 1812
}
],
"timestamp": 1557799313
},
{
"version": "2.3.1",
"changes": [

View File

@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v2.3.3 - _May 14, 2019_
* Redeploy Coordinator contract (#1812)
## v2.3.1 - _April 11, 2019_
* Dependencies updated

View File

@ -1,6 +1,6 @@
{
"name": "@0x/contract-addresses",
"version": "2.3.1",
"version": "2.3.3",
"engines": {
"node": ">=6.12"
},

View File

@ -36,7 +36,7 @@ const networkToAddresses: { [networkId: number]: ContractAddresses } = {
orderValidator: '0x9463e518dea6810309563c81d5266c1b1d149138',
dutchAuction: '0x07b32a653754945666cfca91168bb207323dfe67',
coordinatorRegistry: '0x45797531b873fd5e519477a070a955764c1a5b07',
coordinator: '0x24675738816c87ad37e712cc24f309a0c906187f',
coordinator: '0x25aae5b981ce6683cc5aeea1855d927e0b59066f',
},
3: {
erc20Proxy: '0xb1408f4c245a23c31b98d2c626777d4c0d766caa',
@ -49,7 +49,7 @@ const networkToAddresses: { [networkId: number]: ContractAddresses } = {
orderValidator: '0x90431a90516ab49af23a0530e04e8c7836e7122f',
dutchAuction: '0x2df6b59309f35ada230ec7d61d7d97355017a1df',
coordinatorRegistry: '0x403cc23e88c17c4652fb904784d1af640a6722d9',
coordinator: '0xc442300dcb4df1ff1db0173e77556dc559de6006',
coordinator: '0x25aae5b981ce6683cc5aeea1855d927e0b59066f',
},
4: {
exchange: '0xbce0b5f6eb618c565c3e5f5cd69652bbc279f44e',
@ -62,7 +62,7 @@ const networkToAddresses: { [networkId: number]: ContractAddresses } = {
orderValidator: '0x0c5173a51e26b29d6126c686756fb9fbef71f762',
dutchAuction: '0xdd7bd6437e67c422879364740ab5855fe3dc41f7',
coordinatorRegistry: '0x1084b6a398e47907bae43fec3ff4b677db6e4fee',
coordinator: '0xc05e6c01b83eeedecac2f7bab9367da4d4c108df',
coordinator: '0x25aae5b981ce6683cc5aeea1855d927e0b59066f',
},
42: {
erc20Proxy: '0xf1ec01d6236d3cd881a0bf0130ea25fe4234003e',
@ -75,7 +75,7 @@ const networkToAddresses: { [networkId: number]: ContractAddresses } = {
orderValidator: '0xb389da3d204b412df2f75c6afb3d0a7ce0bc283d',
dutchAuction: '0xe11667fb51f34c5367f40d7e379327ce32ee7150',
coordinatorRegistry: '0x09fb99968c016a3ff537bf58fb3d9fe55a7975d5',
coordinator: '0x04b2b090bad68b254881d7eb645a258ce66cc998',
coordinator: '0x25aae5b981ce6683cc5aeea1855d927e0b59066f',
},
// NetworkId 50 represents our Ganache snapshot generated from migrations.
50: {

View File

@ -1,4 +1,13 @@
[
{
"timestamp": 1557507213,
"version": "1.5.1",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "1.5.0",
"changes": [

View File

@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v1.5.1 - _May 10, 2019_
* Dependencies updated
## v1.5.0 - _April 11, 2019_
* Added artifact for `IAssetProxy` (#1714)

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
{
"name": "@0x/contract-artifacts",
"version": "1.5.0",
"version": "1.5.1",
"engines": {
"node": ">=6.12"
},

View File

@ -1,4 +1,46 @@
[
{
"timestamp": 1558712885,
"version": "9.1.4",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "9.1.3",
"changes": [
{
"note": "Fix decoding bug in `DutchAuctionWrapper.decodeDutchAuctionData`",
"pr": 1815
},
{
"note": "Fallback to eth_sign if eth_signedTypedData fails",
"pr": 1817
}
],
"timestamp": 1557961111
},
{
"version": "9.1.2",
"changes": [
{
"note": "Dependencies updated"
}
],
"timestamp": 1557799313
},
{
"version": "9.1.0",
"changes": [
{
"note": "Added CoordinatorWrapper to support orders with the Coordinator extension contract",
"pr": 1792
}
],
"timestamp": 1557507213
},
{
"version": "9.0.0",
"changes": [

View File

@ -5,6 +5,23 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v9.1.4 - _May 24, 2019_
* Dependencies updated
## v9.1.3 - _May 15, 2019_
* Fix decoding bug in `DutchAuctionWrapper.decodeDutchAuctionData` (#1815)
* Fallback to eth_sign if eth_signedTypedData fails (#1817)
## v9.1.2 - _May 14, 2019_
* Dependencies updated
## v9.1.0 - _May 10, 2019_
* Added CoordinatorWrapper to support orders with the Coordinator extension contract (#1792)
## v9.0.0 - _April 11, 2019_
* Added a simulation to transfer from maker to taker during `exchange.validateOrderFillableOrThrowAsync` (#1714)

View File

@ -1,6 +1,6 @@
{
"name": "@0x/contract-wrappers",
"version": "9.0.0",
"version": "9.1.4",
"description": "Smart TS wrappers for 0x smart contracts",
"keywords": [
"0xproject",
@ -38,14 +38,16 @@
"node": ">=6.0.0"
},
"devDependencies": {
"@0x/contracts-test-utils": "^3.1.2",
"@0x/dev-utils": "^2.2.1",
"@0x/fill-scenarios": "^3.0.5",
"@0x/migrations": "^4.1.1",
"@0x/subproviders": "^4.0.5",
"@0x/contracts-test-utils": "^3.1.7",
"@0x/coordinator-server": "0.1.1",
"@0x/dev-utils": "^2.2.3",
"@0x/fill-scenarios": "^3.0.10",
"@0x/migrations": "^4.1.6",
"@0x/subproviders": "^4.1.0",
"@0x/tslint-config": "^3.0.1",
"@types/lodash": "4.14.104",
"@types/mocha": "^2.2.42",
"@types/nock": "^10.0.1",
"@types/node": "*",
"@types/sinon": "^2.2.2",
"@types/uuid": "^3.4.3",
@ -56,6 +58,7 @@
"dirty-chai": "^2.0.1",
"make-promises-safe": "^1.1.0",
"mocha": "^4.1.0",
"nock": "^10.0.6",
"npm-run-all": "^4.1.2",
"nyc": "^11.0.1",
"opn-cli": "^3.1.0",
@ -68,21 +71,22 @@
"web3-provider-engine": "14.0.6"
},
"dependencies": {
"@0x/abi-gen-wrappers": "^4.2.0",
"@0x/assert": "^2.0.9",
"@0x/contract-addresses": "^2.3.1",
"@0x/contract-artifacts": "^1.5.0",
"@0x/json-schemas": "^3.0.9",
"@0x/order-utils": "^7.2.0",
"@0x/abi-gen-wrappers": "^4.3.0",
"@0x/assert": "^2.0.10",
"@0x/contract-addresses": "^2.3.3",
"@0x/contract-artifacts": "^1.5.1",
"@0x/json-schemas": "^3.0.10",
"@0x/order-utils": "^8.1.1",
"@0x/types": "^2.2.2",
"@0x/typescript-typings": "^4.2.2",
"@0x/utils": "^4.3.1",
"@0x/web3-wrapper": "^6.0.5",
"@0x/utils": "^4.3.3",
"@0x/web3-wrapper": "^6.0.6",
"ethereum-types": "^2.1.2",
"ethereumjs-abi": "0.6.5",
"ethereumjs-blockstream": "6.0.0",
"ethereumjs-util": "^5.1.1",
"ethers": "~4.0.4",
"http-status-codes": "^1.3.2",
"js-sha3": "^0.7.0",
"lodash": "^4.17.11",
"uuid": "^3.3.2"

View File

@ -1,4 +1,5 @@
import {
Coordinator,
DutchAuction,
ERC20Proxy,
ERC20Token,
@ -14,6 +15,7 @@ import { Web3Wrapper } from '@0x/web3-wrapper';
import { SupportedProvider } from 'ethereum-types';
import * as _ from 'lodash';
import { CoordinatorWrapper } from './contract_wrappers/coordinator_wrapper';
import { DutchAuctionWrapper } from './contract_wrappers/dutch_auction_wrapper';
import { ERC20ProxyWrapper } from './contract_wrappers/erc20_proxy_wrapper';
import { ERC20TokenWrapper } from './contract_wrappers/erc20_token_wrapper';
@ -73,6 +75,11 @@ export class ContractWrappers {
*/
public dutchAuction: DutchAuctionWrapper;
/**
* An instance of the CoordinatorWrapper class containing methods for interacting with the Coordinator extension contract.
*/
public coordinator: CoordinatorWrapper;
private readonly _web3Wrapper: Web3Wrapper;
/**
* Instantiates a new ContractWrappers instance.
@ -88,6 +95,7 @@ export class ContractWrappers {
};
this._web3Wrapper = new Web3Wrapper(supportedProvider, txDefaults);
const artifactsArray = [
Coordinator,
DutchAuction,
ERC20Proxy,
ERC20Token,
@ -155,6 +163,13 @@ export class ContractWrappers {
config.networkId,
contractAddresses.dutchAuction,
);
this.coordinator = new CoordinatorWrapper(
this._web3Wrapper,
config.networkId,
contractAddresses.coordinator,
contractAddresses.exchange,
contractAddresses.coordinatorRegistry,
);
}
/**
* Unsubscribes from all subscriptions for all contracts.

View File

@ -0,0 +1,856 @@
import { CoordinatorContract, CoordinatorRegistryContract, ExchangeContract } from '@0x/abi-gen-wrappers';
import { getContractAddressesForNetworkOrThrow } from '@0x/contract-addresses';
import { Coordinator, CoordinatorRegistry, Exchange } from '@0x/contract-artifacts';
import { schemas } from '@0x/json-schemas';
import { generatePseudoRandomSalt, signatureUtils } from '@0x/order-utils';
import { Order, SignedOrder, SignedZeroExTransaction, ZeroExTransaction } from '@0x/types';
import { BigNumber, fetchAsync } from '@0x/utils';
import { Web3Wrapper } from '@0x/web3-wrapper';
import { ContractAbi } from 'ethereum-types';
import * as HttpStatus from 'http-status-codes';
import { flatten } from 'lodash';
import { orderTxOptsSchema } from '../schemas/order_tx_opts_schema';
import { txOptsSchema } from '../schemas/tx_opts_schema';
import { CoordinatorTransaction, OrderTransactionOpts } from '../types';
import { assert } from '../utils/assert';
import {
CoordinatorServerApprovalRawResponse,
CoordinatorServerApprovalResponse,
CoordinatorServerCancellationResponse,
CoordinatorServerError,
CoordinatorServerErrorMsg,
CoordinatorServerResponse,
} from '../utils/coordinator_server_types';
import { decorators } from '../utils/decorators';
import { TransactionEncoder } from '../utils/transaction_encoder';
import { ContractWrapper } from './contract_wrapper';
/**
* This class includes all the functionality related to filling or cancelling orders through
* the 0x V2 Coordinator extension contract.
*/
export class CoordinatorWrapper extends ContractWrapper {
public abi: ContractAbi = Coordinator.compilerOutput.abi;
public networkId: number;
public address: string;
public exchangeAddress: string;
public registryAddress: string;
private readonly _contractInstance: CoordinatorContract;
private readonly _registryInstance: CoordinatorRegistryContract;
private readonly _exchangeInstance: ExchangeContract;
private readonly _transactionEncoder: TransactionEncoder;
private readonly _feeRecipientToEndpoint: { [feeRecipient: string]: string } = {};
/**
* Instantiate CoordinatorWrapper
* @param web3Wrapper Web3Wrapper instance to use.
* @param networkId Desired networkId.
* @param address The address of the Coordinator contract. If undefined, will
* default to the known address corresponding to the networkId.
* @param exchangeAddress The address of the Exchange contract. If undefined, will
* default to the known address corresponding to the networkId.
* @param registryAddress The address of the CoordinatorRegistry contract. If undefined, will
* default to the known address corresponding to the networkId.
*/
constructor(
web3Wrapper: Web3Wrapper,
networkId: number,
address?: string,
exchangeAddress?: string,
registryAddress?: string,
) {
super(web3Wrapper, networkId);
this.networkId = networkId;
const contractAddresses = getContractAddressesForNetworkOrThrow(networkId);
this.address = address === undefined ? contractAddresses.coordinator : address;
this.exchangeAddress = exchangeAddress === undefined ? contractAddresses.coordinator : exchangeAddress;
this.registryAddress = registryAddress === undefined ? contractAddresses.coordinatorRegistry : registryAddress;
this._contractInstance = new CoordinatorContract(
this.abi,
this.address,
this._web3Wrapper.getProvider(),
this._web3Wrapper.getContractDefaults(),
);
this._registryInstance = new CoordinatorRegistryContract(
CoordinatorRegistry.compilerOutput.abi,
this.registryAddress,
this._web3Wrapper.getProvider(),
this._web3Wrapper.getContractDefaults(),
);
this._exchangeInstance = new ExchangeContract(
Exchange.compilerOutput.abi,
this.exchangeAddress,
this._web3Wrapper.getProvider(),
this._web3Wrapper.getContractDefaults(),
);
this._transactionEncoder = new TransactionEncoder(this._exchangeInstance);
}
/**
* Fills a signed order with an amount denominated in baseUnits of the taker asset. Under-the-hood, this
* method uses the `feeRecipientAddress` of the order to look up the coordinator server endpoint registered in the
* coordinator registry contract. It requests a signature from that coordinator server before
* submitting the order and signature as a 0x transaction to the coordinator extension contract. The coordinator extension
* contract validates signatures and then fills the order via the Exchange contract.
* @param signedOrder An object that conforms to the SignedOrder interface.
* @param takerAssetFillAmount The amount of the order (in taker asset baseUnits) that you wish to fill.
* @param takerAddress The user Ethereum address who would like to fill this order. Must be available via the supplied
* Provider provided at instantiation.
* @param orderTransactionOpts Optional arguments this method accepts.
* @return Transaction hash.
*/
@decorators.asyncZeroExErrorHandler
public async fillOrderAsync(
signedOrder: SignedOrder,
takerAssetFillAmount: BigNumber,
takerAddress: string,
orderTransactionOpts: OrderTransactionOpts = { shouldValidate: true },
): Promise<string> {
assert.doesConformToSchema('signedOrder', signedOrder, schemas.signedOrderSchema);
assert.isValidBaseUnitAmount('takerAssetFillAmount', takerAssetFillAmount);
assert.isETHAddressHex('takerAddress', takerAddress);
assert.doesConformToSchema('orderTransactionOpts', orderTransactionOpts, orderTxOptsSchema, [txOptsSchema]);
await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper);
const data = this._transactionEncoder.fillOrderTx(signedOrder, takerAssetFillAmount);
const txHash = await this._handleFillsAsync(data, takerAddress, [signedOrder], orderTransactionOpts);
return txHash;
}
/**
* No-throw version of fillOrderAsync. This version will not throw if the fill fails. This allows the caller to save gas at the expense of not knowing the reason the fill failed.
* @param signedOrder An object that conforms to the SignedOrder interface.
* @param takerAssetFillAmount The amount of the order (in taker asset baseUnits) that you wish to fill.
* @param takerAddress The user Ethereum address who would like to fill this order.
* Must be available via the supplied Provider provided at instantiation.
* @param orderTransactionOpts Optional arguments this method accepts.
* @return Transaction hash.
*/
@decorators.asyncZeroExErrorHandler
public async fillOrderNoThrowAsync(
signedOrder: SignedOrder,
takerAssetFillAmount: BigNumber,
takerAddress: string,
orderTransactionOpts: OrderTransactionOpts = { shouldValidate: true },
): Promise<string> {
assert.doesConformToSchema('signedOrder', signedOrder, schemas.signedOrderSchema);
assert.isValidBaseUnitAmount('takerAssetFillAmount', takerAssetFillAmount);
assert.isETHAddressHex('takerAddress', takerAddress);
assert.doesConformToSchema('orderTransactionOpts', orderTransactionOpts, orderTxOptsSchema, [txOptsSchema]);
await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper);
const data = this._transactionEncoder.fillOrderNoThrowTx(signedOrder, takerAssetFillAmount);
const txHash = await this._handleFillsAsync(data, takerAddress, [signedOrder], orderTransactionOpts);
return txHash;
}
/**
* Attempts to fill a specific amount of an order. If the entire amount specified cannot be filled,
* the fill order is abandoned.
* @param signedOrder An object that conforms to the SignedOrder interface.
* @param takerAssetFillAmount The amount of the order (in taker asset baseUnits) that you wish to fill.
* @param takerAddress The user Ethereum address who would like to fill this order. Must be available via the supplied
* Provider provided at instantiation.
* @param orderTransactionOpts Optional arguments this method accepts.
* @return Transaction hash.
*/
@decorators.asyncZeroExErrorHandler
public async fillOrKillOrderAsync(
signedOrder: SignedOrder,
takerAssetFillAmount: BigNumber,
takerAddress: string,
orderTransactionOpts: OrderTransactionOpts = { shouldValidate: true },
): Promise<string> {
assert.doesConformToSchema('signedOrder', signedOrder, schemas.signedOrderSchema);
assert.isValidBaseUnitAmount('takerAssetFillAmount', takerAssetFillAmount);
assert.isETHAddressHex('takerAddress', takerAddress);
assert.doesConformToSchema('orderTransactionOpts', orderTransactionOpts, orderTxOptsSchema, [txOptsSchema]);
await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper);
const data = this._transactionEncoder.fillOrKillOrderTx(signedOrder, takerAssetFillAmount);
const txHash = await this._handleFillsAsync(data, takerAddress, [signedOrder], orderTransactionOpts);
return txHash;
}
/**
* Batch version of fillOrderAsync. Executes multiple fills atomically in a single transaction.
* Under-the-hood, this method uses the `feeRecipientAddress`s of the orders to looks up the coordinator server endpoints
* registered in the coordinator registry contract. It requests a signature from each coordinator server before
* submitting the orders and signatures as a 0x transaction to the coordinator extension contract, which validates the
* signatures and then fills the order through the Exchange contract.
* If any `feeRecipientAddress` in the batch is not registered to a coordinator server, the whole batch fails.
* @param signedOrders An array of signed orders to fill.
* @param takerAssetFillAmounts The amounts of the orders (in taker asset baseUnits) that you wish to fill.
* @param takerAddress The user Ethereum address who would like to fill these orders. Must be available via the supplied
* Provider provided at instantiation.
* @param orderTransactionOpts Optional arguments this method accepts.
* @return Transaction hash.
*/
@decorators.asyncZeroExErrorHandler
public async batchFillOrdersAsync(
signedOrders: SignedOrder[],
takerAssetFillAmounts: BigNumber[],
takerAddress: string,
orderTransactionOpts: OrderTransactionOpts = { shouldValidate: true },
): Promise<string> {
assert.doesConformToSchema('signedOrders', signedOrders, schemas.signedOrdersSchema);
for (const takerAssetFillAmount of takerAssetFillAmounts) {
assert.isBigNumber('takerAssetFillAmount', takerAssetFillAmount);
}
assert.isETHAddressHex('takerAddress', takerAddress);
assert.doesConformToSchema('orderTransactionOpts', orderTransactionOpts, orderTxOptsSchema, [txOptsSchema]);
await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper);
const data = this._transactionEncoder.batchFillOrdersTx(signedOrders, takerAssetFillAmounts);
const txHash = await this._handleFillsAsync(data, takerAddress, signedOrders, orderTransactionOpts);
return txHash;
}
/**
* No throw version of batchFillOrdersAsync
* @param signedOrders An array of signed orders to fill.
* @param takerAssetFillAmounts The amounts of the orders (in taker asset baseUnits) that you wish to fill.
* @param takerAddress The user Ethereum address who would like to fill these orders. Must be available via the supplied
* Provider provided at instantiation.
* @param orderTransactionOpts Optional arguments this method accepts.
* @return Transaction hash.
*/
@decorators.asyncZeroExErrorHandler
public async batchFillOrdersNoThrowAsync(
signedOrders: SignedOrder[],
takerAssetFillAmounts: BigNumber[],
takerAddress: string,
orderTransactionOpts: OrderTransactionOpts = { shouldValidate: true },
): Promise<string> {
assert.doesConformToSchema('signedOrders', signedOrders, schemas.signedOrdersSchema);
for (const takerAssetFillAmount of takerAssetFillAmounts) {
assert.isBigNumber('takerAssetFillAmount', takerAssetFillAmount);
}
assert.isETHAddressHex('takerAddress', takerAddress);
assert.doesConformToSchema('orderTransactionOpts', orderTransactionOpts, orderTxOptsSchema, [txOptsSchema]);
await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper);
const data = this._transactionEncoder.batchFillOrdersNoThrowTx(signedOrders, takerAssetFillAmounts);
const txHash = await this._handleFillsAsync(data, takerAddress, signedOrders, orderTransactionOpts);
return txHash;
}
/**
* Batch version of fillOrKillOrderAsync. Executes multiple fills atomically in a single transaction.
* @param signedOrders An array of signed orders to fill.
* @param takerAssetFillAmounts The amounts of the orders (in taker asset baseUnits) that you wish to fill.
* @param takerAddress The user Ethereum address who would like to fill these orders. Must be available via the supplied
* Provider provided at instantiation.
* @param orderTransactionOpts Optional arguments this method accepts.
* @return Transaction hash.
*/
@decorators.asyncZeroExErrorHandler
public async batchFillOrKillOrdersAsync(
signedOrders: SignedOrder[],
takerAssetFillAmounts: BigNumber[],
takerAddress: string,
orderTransactionOpts: OrderTransactionOpts = { shouldValidate: true },
): Promise<string> {
assert.doesConformToSchema('signedOrders', signedOrders, schemas.signedOrdersSchema);
for (const takerAssetFillAmount of takerAssetFillAmounts) {
assert.isBigNumber('takerAssetFillAmount', takerAssetFillAmount);
}
assert.isETHAddressHex('takerAddress', takerAddress);
assert.doesConformToSchema('orderTransactionOpts', orderTransactionOpts, orderTxOptsSchema, [txOptsSchema]);
await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper);
const data = this._transactionEncoder.batchFillOrKillOrdersTx(signedOrders, takerAssetFillAmounts);
const txHash = await this._handleFillsAsync(data, takerAddress, signedOrders, orderTransactionOpts);
return txHash;
}
/**
* Synchronously executes multiple calls to fillOrder until total amount of makerAsset is bought by taker.
* Under-the-hood, this method uses the `feeRecipientAddress`s of the orders to looks up the coordinator server endpoints
* registered in the coordinator registry contract. It requests a signature from each coordinator server before
* submitting the orders and signatures as a 0x transaction to the coordinator extension contract, which validates the
* signatures and then fills the order through the Exchange contract.
* If any `feeRecipientAddress` in the batch is not registered to a coordinator server, the whole batch fails.
* @param signedOrders An array of signed orders to fill.
* @param makerAssetFillAmount Maker asset fill amount.
* @param takerAddress The user Ethereum address who would like to fill these orders. Must be available via the supplied
* Provider provided at instantiation.
* @param orderTransactionOpts Optional arguments this method accepts.
* @return Transaction hash.
*/
@decorators.asyncZeroExErrorHandler
public async marketBuyOrdersAsync(
signedOrders: SignedOrder[],
makerAssetFillAmount: BigNumber,
takerAddress: string,
orderTransactionOpts: OrderTransactionOpts = { shouldValidate: true },
): Promise<string> {
assert.doesConformToSchema('signedOrders', signedOrders, schemas.signedOrdersSchema);
assert.isBigNumber('makerAssetFillAmount', makerAssetFillAmount);
assert.isETHAddressHex('takerAddress', takerAddress);
assert.doesConformToSchema('orderTransactionOpts', orderTransactionOpts, orderTxOptsSchema, [txOptsSchema]);
await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper);
const data = this._transactionEncoder.marketBuyOrdersTx(signedOrders, makerAssetFillAmount);
const txHash = await this._handleFillsAsync(data, takerAddress, signedOrders, orderTransactionOpts);
return txHash;
}
/**
* Synchronously executes multiple calls to fillOrder until total amount of makerAsset is bought by taker.
* Under-the-hood, this method uses the `feeRecipientAddress`s of the orders to looks up the coordinator server endpoints
* registered in the coordinator registry contract. It requests a signature from each coordinator server before
* submitting the orders and signatures as a 0x transaction to the coordinator extension contract, which validates the
* signatures and then fills the order through the Exchange contract.
* If any `feeRecipientAddress` in the batch is not registered to a coordinator server, the whole batch fails.
* @param signedOrders An array of signed orders to fill.
* @param takerAssetFillAmount Taker asset fill amount.
* @param takerAddress The user Ethereum address who would like to fill these orders. Must be available via the supplied
* Provider provided at instantiation.
* @param orderTransactionOpts Optional arguments this method accepts.
* @return Transaction hash.
*/
@decorators.asyncZeroExErrorHandler
public async marketSellOrdersAsync(
signedOrders: SignedOrder[],
takerAssetFillAmount: BigNumber,
takerAddress: string,
orderTransactionOpts: OrderTransactionOpts = { shouldValidate: true },
): Promise<string> {
assert.doesConformToSchema('signedOrders', signedOrders, schemas.signedOrdersSchema);
assert.isBigNumber('takerAssetFillAmount', takerAssetFillAmount);
assert.isETHAddressHex('takerAddress', takerAddress);
assert.doesConformToSchema('orderTransactionOpts', orderTransactionOpts, orderTxOptsSchema, [txOptsSchema]);
await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper);
const data = this._transactionEncoder.marketSellOrdersTx(signedOrders, takerAssetFillAmount);
const txHash = await this._handleFillsAsync(data, takerAddress, signedOrders, orderTransactionOpts);
return txHash;
}
/**
* No throw version of marketBuyOrdersAsync
* @param signedOrders An array of signed orders to fill.
* @param makerAssetFillAmount Maker asset fill amount.
* @param takerAddress The user Ethereum address who would like to fill these orders. Must be available via the supplied
* Provider provided at instantiation.
* @param orderTransactionOpts Optional arguments this method accepts.
* @return Transaction hash.
*/
@decorators.asyncZeroExErrorHandler
public async marketBuyOrdersNoThrowAsync(
signedOrders: SignedOrder[],
makerAssetFillAmount: BigNumber,
takerAddress: string,
orderTransactionOpts: OrderTransactionOpts = { shouldValidate: true },
): Promise<string> {
assert.doesConformToSchema('signedOrders', signedOrders, schemas.signedOrdersSchema);
assert.isBigNumber('makerAssetFillAmount', makerAssetFillAmount);
assert.isETHAddressHex('takerAddress', takerAddress);
assert.doesConformToSchema('orderTransactionOpts', orderTransactionOpts, orderTxOptsSchema, [txOptsSchema]);
await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper);
const data = this._transactionEncoder.marketBuyOrdersNoThrowTx(signedOrders, makerAssetFillAmount);
const txHash = await this._handleFillsAsync(data, takerAddress, signedOrders, orderTransactionOpts);
return txHash;
}
/**
* No throw version of marketSellOrdersAsync
* @param signedOrders An array of signed orders to fill.
* @param takerAssetFillAmount Taker asset fill amount.
* @param takerAddress The user Ethereum address who would like to fill these orders. Must be available via the supplied
* Provider provided at instantiation.
* @param orderTransactionOpts Optional arguments this method accepts.
* @return Transaction hash.
*/
@decorators.asyncZeroExErrorHandler
public async marketSellOrdersNoThrowAsync(
signedOrders: SignedOrder[],
takerAssetFillAmount: BigNumber,
takerAddress: string,
orderTransactionOpts: OrderTransactionOpts = { shouldValidate: true },
): Promise<string> {
assert.doesConformToSchema('signedOrders', signedOrders, schemas.signedOrdersSchema);
assert.isBigNumber('takerAssetFillAmount', takerAssetFillAmount);
assert.isETHAddressHex('takerAddress', takerAddress);
assert.doesConformToSchema('orderTransactionOpts', orderTransactionOpts, orderTxOptsSchema, [txOptsSchema]);
await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper);
const data = this._transactionEncoder.marketSellOrdersNoThrowTx(signedOrders, takerAssetFillAmount);
const txHash = await this._handleFillsAsync(data, takerAddress, signedOrders, orderTransactionOpts);
return txHash;
}
/**
* Soft cancel a given order.
* Soft cancels are recorded only on coordinator operator servers and do not involve an Ethereum transaction.
* See [soft cancels](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/coordinator-specification.md#soft-cancels).
* @param order An object that conforms to the Order or SignedOrder interface. The order you would like to cancel.
* @return CoordinatorServerCancellationResponse. See [Cancellation Response](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/coordinator-specification.md#response).
*/
public async softCancelOrderAsync(order: Order | SignedOrder): Promise<CoordinatorServerCancellationResponse> {
assert.doesConformToSchema('order', order, schemas.orderSchema);
assert.isETHAddressHex('feeRecipientAddress', order.feeRecipientAddress);
assert.isSenderAddressAsync('makerAddress', order.makerAddress, this._web3Wrapper);
const data = this._transactionEncoder.cancelOrderTx(order);
const transaction = await this._generateSignedZeroExTransactionAsync(data, order.makerAddress);
const endpoint = await this._getServerEndpointOrThrowAsync(order.feeRecipientAddress);
const response = await this._executeServerRequestAsync(transaction, order.makerAddress, endpoint);
if (response.isError) {
const approvedOrders = new Array();
const cancellations = new Array();
const errors = [
{
...response,
orders: [order],
},
];
throw new CoordinatorServerError(
CoordinatorServerErrorMsg.CancellationFailed,
approvedOrders,
cancellations,
errors,
);
} else {
return response.body as CoordinatorServerCancellationResponse;
}
}
/**
* Batch version of softCancelOrderAsync. Requests multiple soft cancels
* @param orders An array of orders to cancel.
* @return CoordinatorServerCancellationResponse. See [Cancellation Response](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/coordinator-specification.md#response).
*/
public async batchSoftCancelOrdersAsync(orders: SignedOrder[]): Promise<CoordinatorServerCancellationResponse[]> {
assert.doesConformToSchema('orders', orders, schemas.ordersSchema);
const makerAddress = getMakerAddressOrThrow(orders);
assert.isSenderAddressAsync('makerAddress', makerAddress, this._web3Wrapper);
const data = this._transactionEncoder.batchCancelOrdersTx(orders);
const serverEndpointsToOrders = await this._mapServerEndpointsToOrdersAsync(orders);
// make server requests
const errorResponses: CoordinatorServerResponse[] = [];
const successResponses: CoordinatorServerCancellationResponse[] = [];
const transaction = await this._generateSignedZeroExTransactionAsync(data, makerAddress);
for (const endpoint of Object.keys(serverEndpointsToOrders)) {
const response = await this._executeServerRequestAsync(transaction, makerAddress, endpoint);
if (response.isError) {
errorResponses.push(response);
} else {
successResponses.push(response.body as CoordinatorServerCancellationResponse);
}
}
// if no errors
if (errorResponses.length === 0) {
return successResponses;
} else {
// lookup orders with errors
const errorsWithOrders = errorResponses.map(resp => {
const endpoint = resp.coordinatorOperator;
const _orders = serverEndpointsToOrders[endpoint];
return {
...resp,
orders: _orders,
};
});
const approvedOrders = new Array();
const cancellations = successResponses;
// return errors and approvals
throw new CoordinatorServerError(
CoordinatorServerErrorMsg.CancellationFailed,
approvedOrders,
cancellations,
errorsWithOrders,
);
}
}
/**
* Cancels an order on-chain by submitting an Ethereum transaction.
* @param order An object that conforms to the Order or SignedOrder interface. The order you would like to cancel.
* @param orderTransactionOpts Optional arguments this method accepts.
* @return Transaction hash.
*/
@decorators.asyncZeroExErrorHandler
public async hardCancelOrderAsync(
order: Order | SignedOrder,
orderTransactionOpts: OrderTransactionOpts = { shouldValidate: true },
): Promise<string> {
assert.doesConformToSchema('order', order, schemas.orderSchema);
assert.doesConformToSchema('orderTransactionOpts', orderTransactionOpts, orderTxOptsSchema, [txOptsSchema]);
await assert.isSenderAddressAsync('makerAddress', order.makerAddress, this._web3Wrapper);
const data = this._transactionEncoder.cancelOrderTx(order);
const transaction = await this._generateSignedZeroExTransactionAsync(data, order.makerAddress);
const approvalSignatures = new Array();
const approvalExpirationTimeSeconds = new Array();
const txHash = await this._submitCoordinatorTransactionAsync(
transaction,
order.makerAddress,
transaction.signature,
approvalExpirationTimeSeconds,
approvalSignatures,
orderTransactionOpts,
);
return txHash;
}
/**
* Batch version of hardCancelOrderAsync. Cancels orders on-chain by submitting an Ethereum transaction.
* Executes multiple cancels atomically in a single transaction.
* @param orders An array of orders to cancel.
* @param orderTransactionOpts Optional arguments this method accepts.
* @return Transaction hash.
*/
@decorators.asyncZeroExErrorHandler
public async batchHardCancelOrdersAsync(
orders: SignedOrder[],
orderTransactionOpts: OrderTransactionOpts = { shouldValidate: true },
): Promise<string> {
assert.doesConformToSchema('orders', orders, schemas.ordersSchema);
const makerAddress = getMakerAddressOrThrow(orders);
assert.doesConformToSchema('orderTransactionOpts', orderTransactionOpts, orderTxOptsSchema, [txOptsSchema]);
await assert.isSenderAddressAsync('makerAddress', makerAddress, this._web3Wrapper);
const data = this._transactionEncoder.batchCancelOrdersTx(orders);
const transaction = await this._generateSignedZeroExTransactionAsync(data, makerAddress);
const approvalSignatures = new Array();
const approvalExpirationTimeSeconds = new Array();
const txHash = await this._submitCoordinatorTransactionAsync(
transaction,
makerAddress,
transaction.signature,
approvalExpirationTimeSeconds,
approvalSignatures,
orderTransactionOpts,
);
return txHash;
}
/**
* Cancels orders on-chain by submitting an Ethereum transaction.
* Cancels all orders created by makerAddress with a salt less than or equal to the targetOrderEpoch
* and senderAddress equal to coordinator extension contract address.
* @param targetOrderEpoch Target order epoch.
* @param senderAddress Address that should send the transaction.
* @param orderTransactionOpts Optional arguments this method accepts.
* @return Transaction hash.
*/
@decorators.asyncZeroExErrorHandler
public async hardCancelOrdersUpToAsync(
targetOrderEpoch: BigNumber,
senderAddress: string,
orderTransactionOpts: OrderTransactionOpts = { shouldValidate: true },
): Promise<string> {
assert.isBigNumber('targetOrderEpoch', targetOrderEpoch);
assert.doesConformToSchema('orderTransactionOpts', orderTransactionOpts, orderTxOptsSchema, [txOptsSchema]);
await assert.isSenderAddressAsync('senderAddress', senderAddress, this._web3Wrapper);
const data = this._transactionEncoder.cancelOrdersUpToTx(targetOrderEpoch);
const transaction = await this._generateSignedZeroExTransactionAsync(data, senderAddress);
const approvalSignatures = new Array();
const approvalExpirationTimeSeconds = new Array();
const txHash = await this._submitCoordinatorTransactionAsync(
transaction,
senderAddress,
transaction.signature,
approvalExpirationTimeSeconds,
approvalSignatures,
orderTransactionOpts,
);
return txHash;
}
/**
* Validates that the 0x transaction has been approved by all of the feeRecipients that correspond to each order in the transaction's Exchange calldata.
* Throws an error if the transaction approvals are not valid. Will not detect failures that would occur when the transaction is executed on the Exchange contract.
* @param transaction 0x transaction containing salt, signerAddress, and data.
* @param txOrigin Required signer of Ethereum transaction calling this function.
* @param transactionSignature Proof that the transaction has been signed by the signer.
* @param approvalExpirationTimeSeconds Array of expiration times in seconds for which each corresponding approval signature expires.
* @param approvalSignatures Array of signatures that correspond to the feeRecipients of each order in the transaction's Exchange calldata.
*/
public async assertValidCoordinatorApprovalsOrThrowAsync(
transaction: ZeroExTransaction,
txOrigin: string,
transactionSignature: string,
approvalExpirationTimeSeconds: BigNumber[],
approvalSignatures: string[],
): Promise<void> {
assert.doesConformToSchema('transaction', transaction, schemas.zeroExTransactionSchema);
assert.isETHAddressHex('txOrigin', txOrigin);
assert.isHexString('transactionSignature', transactionSignature);
for (const expirationTime of approvalExpirationTimeSeconds) {
assert.isBigNumber('expirationTime', expirationTime);
}
for (const approvalSignature of approvalSignatures) {
assert.isHexString('approvalSignature', approvalSignature);
}
await this._contractInstance.assertValidCoordinatorApprovals.callAsync(
transaction,
txOrigin,
transactionSignature,
approvalExpirationTimeSeconds,
approvalSignatures,
);
}
/**
* Recovers the address of a signer given a hash and signature.
* @param hash Any 32 byte hash.
* @param signature Proof that the hash has been signed by signer.
* @returns Signer address.
*/
public async getSignerAddressAsync(hash: string, signature: string): Promise<string> {
assert.isHexString('hash', hash);
assert.isHexString('signature', signature);
const signerAddress = await this._contractInstance.getSignerAddress.callAsync(hash, signature);
return signerAddress;
}
private async _handleFillsAsync(
data: string,
takerAddress: string,
signedOrders: SignedOrder[],
orderTransactionOpts: OrderTransactionOpts,
): Promise<string> {
const coordinatorOrders = signedOrders.filter(o => o.senderAddress === this.address);
const serverEndpointsToOrders = await this._mapServerEndpointsToOrdersAsync(coordinatorOrders);
// make server requests
const errorResponses: CoordinatorServerResponse[] = [];
const approvalResponses: CoordinatorServerResponse[] = [];
const transaction = await this._generateSignedZeroExTransactionAsync(data, takerAddress);
for (const endpoint of Object.keys(serverEndpointsToOrders)) {
const response = await this._executeServerRequestAsync(transaction, takerAddress, endpoint);
if (response.isError) {
errorResponses.push(response);
} else {
approvalResponses.push(response);
}
}
// if no errors
if (errorResponses.length === 0) {
// concatenate all approval responses
const allApprovals = approvalResponses.map(resp =>
formatRawResponse(resp.body as CoordinatorServerApprovalRawResponse),
);
const allSignatures = flatten(allApprovals.map(a => a.signatures));
const allExpirationTimes = flatten(allApprovals.map(a => a.expirationTimeSeconds));
// submit transaction with approvals
const txHash = await this._submitCoordinatorTransactionAsync(
transaction,
takerAddress,
transaction.signature,
allExpirationTimes,
allSignatures,
orderTransactionOpts,
);
return txHash;
} else {
// format errors and approvals
// concatenate approvals
const notCoordinatorOrders = signedOrders.filter(o => o.senderAddress !== this.address);
const approvedOrdersNested = approvalResponses.map(resp => {
const endpoint = resp.coordinatorOperator;
const orders = serverEndpointsToOrders[endpoint];
return orders;
});
const approvedOrders = flatten(approvedOrdersNested.concat(notCoordinatorOrders));
// lookup orders with errors
const errorsWithOrders = errorResponses.map(resp => {
const endpoint = resp.coordinatorOperator;
const orders = serverEndpointsToOrders[endpoint];
return {
...resp,
orders,
};
});
// throw informative error
const cancellations = new Array();
throw new CoordinatorServerError(
CoordinatorServerErrorMsg.FillFailed,
approvedOrders,
cancellations,
errorsWithOrders,
);
}
function formatRawResponse(
rawResponse: CoordinatorServerApprovalRawResponse,
): CoordinatorServerApprovalResponse {
return {
signatures: ([] as string[]).concat(rawResponse.signatures),
expirationTimeSeconds: ([] as BigNumber[]).concat(
Array(rawResponse.signatures.length).fill(rawResponse.expirationTimeSeconds),
),
};
}
}
private async _getServerEndpointOrThrowAsync(feeRecipientAddress: string): Promise<string> {
const cached = this._feeRecipientToEndpoint[feeRecipientAddress];
const endpoint =
cached !== undefined
? cached
: await _fetchServerEndpointOrThrowAsync(feeRecipientAddress, this._registryInstance);
return endpoint;
async function _fetchServerEndpointOrThrowAsync(
feeRecipient: string,
registryInstance: CoordinatorRegistryContract,
): Promise<string> {
const coordinatorOperatorEndpoint = await registryInstance.getCoordinatorEndpoint.callAsync(feeRecipient);
if (coordinatorOperatorEndpoint === '' || coordinatorOperatorEndpoint === undefined) {
throw new Error(
`No Coordinator server endpoint found in Coordinator Registry for feeRecipientAddress: ${feeRecipient}. Registry contract address: ${
registryInstance.address
}`,
);
}
return coordinatorOperatorEndpoint;
}
}
private async _generateSignedZeroExTransactionAsync(
data: string,
signerAddress: string,
): Promise<SignedZeroExTransaction> {
const transaction: ZeroExTransaction = {
salt: generatePseudoRandomSalt(),
signerAddress,
data,
verifyingContractAddress: this.exchangeAddress,
};
const signedTransaction = await signatureUtils.ecSignTransactionAsync(
this._web3Wrapper.getProvider(),
transaction,
transaction.signerAddress,
);
return signedTransaction;
}
private async _executeServerRequestAsync(
signedTransaction: SignedZeroExTransaction,
txOrigin: string,
endpoint: string,
): Promise<CoordinatorServerResponse> {
const requestPayload = {
signedTransaction,
txOrigin,
};
const response = await fetchAsync(`${endpoint}/v1/request_transaction?networkId=${this.networkId}`, {
body: JSON.stringify(requestPayload),
method: 'POST',
headers: {
'Content-Type': 'application/json; charset=utf-8',
},
});
const isError = response.status !== HttpStatus.OK;
const isValidationError = response.status === HttpStatus.BAD_REQUEST;
const json = isError && !isValidationError ? undefined : await response.json();
const result = {
isError,
status: response.status,
body: isError ? undefined : json,
error: isError ? json : undefined,
request: requestPayload,
coordinatorOperator: endpoint,
};
return result;
}
private async _submitCoordinatorTransactionAsync(
transaction: CoordinatorTransaction,
txOrigin: string,
transactionSignature: string,
approvalExpirationTimeSeconds: BigNumber[],
approvalSignatures: string[],
orderTransactionOpts: OrderTransactionOpts,
): Promise<string> {
if (orderTransactionOpts.shouldValidate) {
await this._contractInstance.executeTransaction.callAsync(
transaction,
txOrigin,
transactionSignature,
approvalExpirationTimeSeconds,
approvalSignatures,
{
from: txOrigin,
gas: orderTransactionOpts.gasLimit,
gasPrice: orderTransactionOpts.gasPrice,
nonce: orderTransactionOpts.nonce,
},
);
}
const txHash = await this._contractInstance.executeTransaction.sendTransactionAsync(
transaction,
txOrigin,
transactionSignature,
approvalExpirationTimeSeconds,
approvalSignatures,
{
from: txOrigin,
gas: orderTransactionOpts.gasLimit,
gasPrice: orderTransactionOpts.gasPrice,
nonce: orderTransactionOpts.nonce,
},
);
return txHash;
}
private async _mapServerEndpointsToOrdersAsync(
coordinatorOrders: SignedOrder[],
): Promise<{ [endpoint: string]: SignedOrder[] }> {
const feeRecipientsToOrders: { [feeRecipient: string]: SignedOrder[] } = {};
for (const order of coordinatorOrders) {
const feeRecipient = order.feeRecipientAddress;
if (feeRecipientsToOrders[feeRecipient] === undefined) {
feeRecipientsToOrders[feeRecipient] = [] as SignedOrder[];
}
feeRecipientsToOrders[feeRecipient].push(order);
}
const serverEndpointsToOrders: { [endpoint: string]: SignedOrder[] } = {};
for (const feeRecipient of Object.keys(feeRecipientsToOrders)) {
const endpoint = await this._getServerEndpointOrThrowAsync(feeRecipient);
const orders = feeRecipientsToOrders[feeRecipient];
if (serverEndpointsToOrders[endpoint] === undefined) {
serverEndpointsToOrders[endpoint] = [];
}
serverEndpointsToOrders[endpoint] = serverEndpointsToOrders[endpoint].concat(orders);
}
return serverEndpointsToOrders;
}
}
function getMakerAddressOrThrow(orders: Array<Order | SignedOrder>): string {
const uniqueMakerAddresses = new Set(orders.map(o => o.makerAddress));
if (uniqueMakerAddresses.size > 1) {
throw new Error(`All orders in a batch must have the same makerAddress`);
}
return orders[0].makerAddress;
}
// tslint:disable:max-file-line-count

View File

@ -71,8 +71,8 @@ export class DutchAuctionWrapper extends ContractWrapper {
['uint256', 'uint256'],
dutchAuctionDetailsBuffer,
);
const beginTimeSeconds = new BigNumber(`0x${beginTimeSecondsAsBN.toString()}`);
const beginAmount = new BigNumber(`0x${beginAmountAsBN.toString()}`);
const beginTimeSeconds = new BigNumber(beginTimeSecondsAsBN.toString());
const beginAmount = new BigNumber(beginAmountAsBN.toString());
return {
assetData,
beginTimeSeconds,

View File

@ -26,6 +26,7 @@ export {
} from '@0x/abi-gen-wrappers';
export { ContractWrappers } from './contract_wrappers';
export { CoordinatorWrapper } from './contract_wrappers/coordinator_wrapper';
export { ERC20TokenWrapper } from './contract_wrappers/erc20_token_wrapper';
export { ERC721TokenWrapper } from './contract_wrappers/erc721_token_wrapper';
export { EtherTokenWrapper } from './contract_wrappers/ether_token_wrapper';
@ -58,6 +59,8 @@ export {
TraderInfo,
ValidateOrderFillableOpts,
DutchAuctionData,
CoordinatorServerCancellationResponse,
CoordinatorServerError,
} from './types';
export {
@ -72,6 +75,8 @@ export {
Order,
SignedOrder,
AssetProxyId,
SignedZeroExTransaction,
ZeroExTransaction,
} from '@0x/types';
export {

View File

@ -225,3 +225,11 @@ export interface DutchAuctionData {
beginTimeSeconds: BigNumber;
beginAmount: BigNumber;
}
export { CoordinatorServerCancellationResponse, CoordinatorServerError } from './utils/coordinator_server_types';
export interface CoordinatorTransaction {
salt: BigNumber;
signerAddress: string;
data: string;
}

View File

@ -0,0 +1,61 @@
import { Order, SignedOrder, SignedZeroExTransaction } from '@0x/types';
import { BigNumber } from '@0x/utils';
export interface CoordinatorServerApprovalResponse {
signatures: string[];
expirationTimeSeconds: BigNumber[];
}
export interface CoordinatorServerApprovalRawResponse {
signatures: string[];
expirationTimeSeconds: BigNumber;
}
export interface CoordinatorServerCancellationResponse {
outstandingFillSignatures: CoordinatorOutstandingFillSignatures[];
cancellationSignatures: string[];
}
export interface CoordinatorOutstandingFillSignatures {
orderHash: string;
approvalSignatures: string[];
expirationTimeSeconds: BigNumber;
takerAssetFillAmount: BigNumber;
}
export interface CoordinatorServerResponse {
isError: boolean;
status: number;
body?: CoordinatorServerCancellationResponse | CoordinatorServerApprovalRawResponse;
error?: any;
request: CoordinatorServerRequest;
coordinatorOperator: string;
orders?: Array<SignedOrder | Order>;
}
export interface CoordinatorServerRequest {
signedTransaction: SignedZeroExTransaction;
txOrigin: string;
}
export class CoordinatorServerError extends Error {
public message: CoordinatorServerErrorMsg;
public approvedOrders?: SignedOrder[] = [];
public cancellations?: CoordinatorServerCancellationResponse[] = [];
public errors: CoordinatorServerResponse[];
constructor(
message: CoordinatorServerErrorMsg,
approvedOrders: SignedOrder[],
cancellations: CoordinatorServerCancellationResponse[],
errors: CoordinatorServerResponse[],
) {
super();
this.message = message;
this.approvedOrders = approvedOrders;
this.cancellations = cancellations;
this.errors = errors;
}
}
export enum CoordinatorServerErrorMsg {
CancellationFailed = 'Failed to cancel with some coordinator server(s). See errors for more info. See cancellations for successful cancellations.',
FillFailed = 'Failed to obtain approval signatures from some coordinator server(s). See errors for more info. Current transaction has been abandoned but you may resubmit with only approvedOrders (a new ZeroEx transaction will have to be signed).',
}

View File

@ -0,0 +1,715 @@
import { CoordinatorRegistryContract } from '@0x/abi-gen-wrappers';
import { CoordinatorRegistry } from '@0x/contract-artifacts';
import { constants } from '@0x/contracts-test-utils';
import { defaultOrmConfig, getAppAsync } from '@0x/coordinator-server';
import { BlockchainLifecycle } from '@0x/dev-utils';
import { FillScenarios } from '@0x/fill-scenarios';
import { assetDataUtils } from '@0x/order-utils';
import { SignedOrder } from '@0x/types';
import { BigNumber, fetchAsync, logUtils } from '@0x/utils';
import * as chai from 'chai';
import * as http from 'http';
import 'mocha';
import * as nock from 'nock';
import { ContractWrappers } from '../src';
import { CoordinatorServerErrorMsg } from '../src/utils/coordinator_server_types';
import { chaiSetup } from './utils/chai_setup';
import { migrateOnceAsync } from './utils/migrate';
import { tokenUtils } from './utils/token_utils';
import { provider, web3Wrapper } from './utils/web3_wrapper';
chaiSetup.configure();
const expect = chai.expect;
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
const coordinatorPort = '3000';
const anotherCoordinatorPort = '4000';
const coordinatorEndpoint = 'http://localhost:';
// tslint:disable:custom-no-magic-numbers
describe('CoordinatorWrapper', () => {
const fillableAmount = new BigNumber(5);
const takerTokenFillAmount = new BigNumber(5);
let coordinatorServerApp: http.Server;
let anotherCoordinatorServerApp: http.Server;
let contractWrappers: ContractWrappers;
let fillScenarios: FillScenarios;
let exchangeContractAddress: string;
let zrxTokenAddress: string;
let userAddresses: string[];
let makerAddress: string;
let takerAddress: string;
let feeRecipientAddressOne: string;
let feeRecipientAddressTwo: string;
let feeRecipientAddressThree: string;
let feeRecipientAddressFour: string;
let makerTokenAddress: string;
let takerTokenAddress: string;
let makerAssetData: string;
let takerAssetData: string;
let txHash: string;
let signedOrder: SignedOrder;
let anotherSignedOrder: SignedOrder;
let signedOrderWithDifferentFeeRecipient: SignedOrder;
let signedOrderWithDifferentCoordinatorOperator: SignedOrder;
let coordinatorRegistryInstance: CoordinatorRegistryContract;
// for testing server error responses
let serverValidationError: any;
let serverCancellationSuccess: any;
let serverApprovalSuccess: any;
before(async () => {
const contractAddresses = await migrateOnceAsync();
await blockchainLifecycle.startAsync();
const config = {
networkId: constants.TESTRPC_NETWORK_ID,
contractAddresses,
blockPollingIntervalMs: 10,
};
contractWrappers = new ContractWrappers(provider, config);
exchangeContractAddress = contractWrappers.exchange.address;
userAddresses = await web3Wrapper.getAvailableAddressesAsync();
zrxTokenAddress = contractWrappers.exchange.zrxTokenAddress;
fillScenarios = new FillScenarios(
provider,
userAddresses,
zrxTokenAddress,
exchangeContractAddress,
contractWrappers.erc20Proxy.address,
contractWrappers.erc721Proxy.address,
);
[
,
makerAddress,
takerAddress,
feeRecipientAddressOne,
feeRecipientAddressTwo,
feeRecipientAddressThree,
feeRecipientAddressFour,
] = userAddresses.slice(0, 7);
[makerTokenAddress, takerTokenAddress] = tokenUtils.getDummyERC20TokenAddresses();
[makerAssetData, takerAssetData] = [
assetDataUtils.encodeERC20AssetData(makerTokenAddress),
assetDataUtils.encodeERC20AssetData(takerTokenAddress),
];
// set up mock coordinator server
const coordinatorServerConfigs = {
HTTP_PORT: 3000, // Only used in default instantiation in 0x-coordinator-server/server.js; not used here
NETWORK_ID_TO_SETTINGS: {
50: {
FEE_RECIPIENTS: [
{
ADDRESS: feeRecipientAddressOne,
PRIVATE_KEY: constants.TESTRPC_PRIVATE_KEYS[
userAddresses.indexOf(feeRecipientAddressOne)
].toString('hex'),
},
{
ADDRESS: feeRecipientAddressTwo,
PRIVATE_KEY: constants.TESTRPC_PRIVATE_KEYS[
userAddresses.indexOf(feeRecipientAddressTwo)
].toString('hex'),
},
{
ADDRESS: feeRecipientAddressThree,
PRIVATE_KEY: constants.TESTRPC_PRIVATE_KEYS[
userAddresses.indexOf(feeRecipientAddressThree)
].toString('hex'),
},
],
// Ethereum RPC url, only used in the default instantiation in 0x-coordinator-server/server.js
// Not used here when instantiating with the imported app
RPC_URL: 'http://ignore',
},
},
// Optional selective delay on fill requests
SELECTIVE_DELAY_MS: 0,
EXPIRATION_DURATION_SECONDS: 60, // 1 minute
};
coordinatorServerApp = await getAppAsync(
{
[config.networkId]: provider,
},
coordinatorServerConfigs,
defaultOrmConfig,
);
coordinatorServerApp.listen(coordinatorPort, () => {
logUtils.log(`Coordinator SERVER API (HTTP) listening on port ${coordinatorPort}!`);
});
anotherCoordinatorServerApp = await getAppAsync(
{
[config.networkId]: provider,
},
coordinatorServerConfigs,
{
type: 'sqlite',
database: 'database.sqlite_2',
entities: defaultOrmConfig.entities,
cli: defaultOrmConfig.cli,
logging: defaultOrmConfig.logging,
synchronize: defaultOrmConfig.synchronize,
},
);
anotherCoordinatorServerApp.listen(anotherCoordinatorPort, () => {
logUtils.log(`Coordinator SERVER API (HTTP) listening on port ${anotherCoordinatorPort}!`);
});
// setup coordinator registry
coordinatorRegistryInstance = new CoordinatorRegistryContract(
CoordinatorRegistry.compilerOutput.abi,
contractAddresses.coordinatorRegistry,
provider,
);
// register coordinator server
await web3Wrapper.awaitTransactionSuccessAsync(
await coordinatorRegistryInstance.setCoordinatorEndpoint.sendTransactionAsync(
`${coordinatorEndpoint}${coordinatorPort}`,
{
from: feeRecipientAddressOne,
},
),
constants.AWAIT_TRANSACTION_MINED_MS,
);
await web3Wrapper.awaitTransactionSuccessAsync(
await coordinatorRegistryInstance.setCoordinatorEndpoint.sendTransactionAsync(
`${coordinatorEndpoint}${coordinatorPort}`,
{
from: feeRecipientAddressTwo,
},
),
constants.AWAIT_TRANSACTION_MINED_MS,
);
// register another coordinator server
await web3Wrapper.awaitTransactionSuccessAsync(
await coordinatorRegistryInstance.setCoordinatorEndpoint.sendTransactionAsync(
`${coordinatorEndpoint}${anotherCoordinatorPort}`,
{
from: feeRecipientAddressThree,
},
),
constants.AWAIT_TRANSACTION_MINED_MS,
);
});
after(async () => {
await blockchainLifecycle.revertAsync();
});
beforeEach(async () => {
await blockchainLifecycle.startAsync();
signedOrder = await fillScenarios.createFillableSignedOrderWithFeesAsync(
makerAssetData,
takerAssetData,
new BigNumber(1),
new BigNumber(1),
makerAddress,
takerAddress,
fillableAmount,
feeRecipientAddressOne,
undefined,
contractWrappers.coordinator.address,
);
anotherSignedOrder = await fillScenarios.createFillableSignedOrderWithFeesAsync(
makerAssetData,
takerAssetData,
new BigNumber(1),
new BigNumber(1),
makerAddress,
takerAddress,
fillableAmount,
feeRecipientAddressOne,
undefined,
contractWrappers.coordinator.address,
);
signedOrderWithDifferentFeeRecipient = await fillScenarios.createFillableSignedOrderWithFeesAsync(
makerAssetData,
takerAssetData,
new BigNumber(1),
new BigNumber(1),
makerAddress,
takerAddress,
fillableAmount,
feeRecipientAddressTwo,
undefined,
contractWrappers.coordinator.address,
);
signedOrderWithDifferentCoordinatorOperator = await fillScenarios.createFillableSignedOrderWithFeesAsync(
makerAssetData,
takerAssetData,
new BigNumber(1),
new BigNumber(1),
makerAddress,
takerAddress,
fillableAmount,
feeRecipientAddressThree,
undefined,
contractWrappers.coordinator.address,
);
});
afterEach(async () => {
await blockchainLifecycle.revertAsync();
});
describe('test setup', () => {
it('should have coordinator registry which returns an endpoint', async () => {
const setCoordinatorEndpoint = await coordinatorRegistryInstance.getCoordinatorEndpoint.callAsync(
feeRecipientAddressOne,
);
const anotherSetCoordinatorEndpoint = await coordinatorRegistryInstance.getCoordinatorEndpoint.callAsync(
feeRecipientAddressThree,
);
expect(setCoordinatorEndpoint).to.be.equal(`${coordinatorEndpoint}${coordinatorPort}`);
expect(anotherSetCoordinatorEndpoint).to.be.equal(`${coordinatorEndpoint}${anotherCoordinatorPort}`);
});
it('should have coordinator server endpoints which respond to pings', async () => {
let result = await fetchAsync(`${coordinatorEndpoint}${coordinatorPort}/v1/ping`);
expect(result.status).to.be.equal(200);
expect(await result.text()).to.be.equal('pong');
result = await fetchAsync(`${coordinatorEndpoint}${anotherCoordinatorPort}/v1/ping`);
expect(result.status).to.be.equal(200);
expect(await result.text()).to.be.equal('pong');
});
});
// fill handling is the same for all fill methods so we can test them all through the fillOrder and batchFillOrders interfaces
describe('fill order(s)', () => {
describe('#fillOrderAsync', () => {
it('should fill a valid order', async () => {
txHash = await contractWrappers.coordinator.fillOrderAsync(
signedOrder,
takerTokenFillAmount,
takerAddress,
);
await web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
});
});
describe('#batchFillOrdersAsync', () => {
it('should fill a batch of valid orders', async () => {
const signedOrders = [signedOrder, anotherSignedOrder];
const takerAssetFillAmounts = Array(2).fill(takerTokenFillAmount);
txHash = await contractWrappers.coordinator.batchFillOrdersAsync(
signedOrders,
takerAssetFillAmounts,
takerAddress,
);
await web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
});
it('should fill a batch of orders with different feeRecipientAddresses with the same coordinator server', async () => {
const signedOrders = [signedOrder, anotherSignedOrder, signedOrderWithDifferentFeeRecipient];
const takerAssetFillAmounts = Array(3).fill(takerTokenFillAmount);
txHash = await contractWrappers.coordinator.batchFillOrdersAsync(
signedOrders,
takerAssetFillAmounts,
takerAddress,
);
await web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
});
// coordinator-server, as currently implemented, shares a singleton database connection across
// all instantiations. Making the request to two different mocked server endpoints still hits the
// same database and fails because of the uniqueness constraint on transactions in the database.
it.skip('should fill a batch of orders with different feeRecipientAddresses with different coordinator servers', async () => {
const signedOrders = [
signedOrder,
anotherSignedOrder,
signedOrderWithDifferentFeeRecipient,
signedOrderWithDifferentCoordinatorOperator,
];
const takerAssetFillAmounts = Array(4).fill(takerTokenFillAmount);
txHash = await contractWrappers.coordinator.batchFillOrdersAsync(
signedOrders,
takerAssetFillAmounts,
takerAddress,
);
await web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
});
it('should fill a batch of mixed coordinator and non-coordinator orders', async () => {
const nonCoordinatorOrder = await fillScenarios.createFillableSignedOrderWithFeesAsync(
makerAssetData,
takerAssetData,
new BigNumber(1),
new BigNumber(1),
makerAddress,
takerAddress,
fillableAmount,
feeRecipientAddressOne,
undefined,
);
const signedOrders = [signedOrder, nonCoordinatorOrder];
const takerAssetFillAmounts = Array(2).fill(takerTokenFillAmount);
txHash = await contractWrappers.coordinator.batchFillOrdersAsync(
signedOrders,
takerAssetFillAmounts,
takerAddress,
);
await web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
});
});
});
describe('soft cancel order(s)', () => {
describe('#softCancelOrderAsync', () => {
it('should soft cancel a valid order', async () => {
const response = await contractWrappers.coordinator.softCancelOrderAsync(signedOrder);
expect(response.outstandingFillSignatures).to.have.lengthOf(0);
expect(response.cancellationSignatures).to.have.lengthOf(1);
});
});
describe('#batchSoftCancelOrdersAsync', () => {
it('should soft cancel a batch of valid orders', async () => {
const orders = [signedOrder, anotherSignedOrder];
const response = await contractWrappers.coordinator.batchSoftCancelOrdersAsync(orders);
expect(response).to.have.lengthOf(1);
expect(response[0].outstandingFillSignatures).to.have.lengthOf(0);
expect(response[0].cancellationSignatures).to.have.lengthOf(1);
});
it('should soft cancel a batch of orders with different feeRecipientAddresses', async () => {
const orders = [signedOrder, anotherSignedOrder, signedOrderWithDifferentFeeRecipient];
const response = await contractWrappers.coordinator.batchSoftCancelOrdersAsync(orders);
expect(response).to.have.lengthOf(1);
expect(response[0].outstandingFillSignatures).to.have.lengthOf(0);
expect(response[0].cancellationSignatures).to.have.lengthOf(2);
});
it('should soft cancel a batch of orders with different coordinatorOperator and concatenate responses', async () => {
const orders = [
signedOrder,
anotherSignedOrder,
signedOrderWithDifferentFeeRecipient,
signedOrderWithDifferentCoordinatorOperator,
];
const response = await contractWrappers.coordinator.batchSoftCancelOrdersAsync(orders);
expect(response).to.have.lengthOf(2);
expect(response[0].outstandingFillSignatures).to.have.lengthOf(0);
expect(response[0].cancellationSignatures).to.have.lengthOf(3);
expect(response[1].cancellationSignatures).to.have.lengthOf(3); // both coordinator servers support the same feeRecipients
});
});
});
describe('hard cancel order(s)', () => {
describe('#hardCancelOrderAsync', () => {
it('should hard cancel a valid order', async () => {
txHash = await contractWrappers.coordinator.hardCancelOrderAsync(signedOrder);
await web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
});
});
describe('#batchHardCancelOrdersAsync', () => {
it('should hard cancel a batch of valid orders', async () => {
const orders = [signedOrder, anotherSignedOrder];
txHash = await contractWrappers.coordinator.batchHardCancelOrdersAsync(orders);
await web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
});
});
describe('#cancelOrdersUpTo/getOrderEpochAsync', () => {
it('should hard cancel orders up to target order epoch', async () => {
const targetOrderEpoch = new BigNumber(42);
txHash = await contractWrappers.coordinator.hardCancelOrdersUpToAsync(targetOrderEpoch, makerAddress);
await web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
const orderEpoch = await contractWrappers.exchange.getOrderEpochAsync(
makerAddress,
contractWrappers.coordinator.address,
);
expect(orderEpoch).to.be.bignumber.equal(targetOrderEpoch.plus(1));
});
});
});
describe('coordinator edge cases', () => {
it('should throw error when feeRecipientAddress is not in registry', async () => {
const badOrder = await fillScenarios.createFillableSignedOrderWithFeesAsync(
makerAssetData,
takerAssetData,
new BigNumber(1),
new BigNumber(1),
makerAddress,
takerAddress,
fillableAmount,
feeRecipientAddressFour,
);
expect(
contractWrappers.coordinator.fillOrderAsync(badOrder, takerTokenFillAmount, takerAddress),
).to.be.rejected();
});
it('should throw error when coordinator endpoint is malformed', async () => {
await web3Wrapper.awaitTransactionSuccessAsync(
await coordinatorRegistryInstance.setCoordinatorEndpoint.sendTransactionAsync('localhost', {
from: feeRecipientAddressFour,
}),
constants.AWAIT_TRANSACTION_MINED_MS,
);
expect(
contractWrappers.coordinator.fillOrderAsync(signedOrder, takerTokenFillAmount, takerAddress),
).to.be.rejected();
});
});
describe('coordinator server errors', () => {
beforeEach('setup', () => {
serverValidationError = {
code: 100,
reason: 'Validation Failed',
validationErrors: [
{
field: 'signedTransaction',
code: 1011,
reason:
'A transaction can only be approved once. To request approval to perform the same actions, generate and sign an identical transaction with a different salt value.',
},
],
};
serverCancellationSuccess = {
outstandingFillSignatures: [
{
orderHash: '0xd1dc61f3e7e5f41d72beae7863487beea108971de678ca00d903756f842ef3ce',
approvalSignatures: [
'0x1c7383ca8ebd6de8b5b20b1c2d49bea166df7dfe4af1932c9c52ec07334e859cf2176901da35f4480ceb3ab63d8d0339d851c31929c40d88752689b9a8a535671303',
],
expirationTimeSeconds: 1552390380,
takerAssetFillAmount: 100000000000000000000,
},
],
cancellationSignatures: [
'0x2ea3117a8ebd6de8b5b20b1c2d49bea166df7dfe4af1932c9c52ec07334e859cf2176901da35f4480ceb3ab63d8d0339d851c31929c40d88752689b9a855b5a7b401',
],
};
serverApprovalSuccess = {
signatures: [
'0x1cc07d7ae39679690a91418d46491520f058e4fb14debdf2e98f2376b3970de8512ace44af0be6d1c65617f7aae8c2364ff63f241515ee1559c3eeecb0f671d9e903',
],
expirationTimeSeconds: 1552390014,
};
nock(`${coordinatorEndpoint}${coordinatorPort}`)
.post('/v1/request_transaction', () => true)
.query({
networkId: 50,
})
.reply(400, serverValidationError);
});
it('should throw error when softCancel fails', done => {
contractWrappers.coordinator
.softCancelOrderAsync(signedOrder)
.then(res => {
expect(res).to.be.undefined();
})
.catch(err => {
expect(err.message).equal(CoordinatorServerErrorMsg.CancellationFailed);
expect(err.approvedOrders).to.be.empty('array');
expect(err.cancellations).to.be.empty('array');
const errorBody = err.errors[0];
expect(errorBody.isError).to.be.true();
expect(errorBody.status).to.equal(400);
expect(errorBody.error).to.deep.equal(serverValidationError);
expect(errorBody.orders).to.deep.equal([signedOrder]);
expect(errorBody.coordinatorOperator).to.equal(`${coordinatorEndpoint}${coordinatorPort}`);
done();
});
});
it('should throw error when batch soft cancel fails with single coordinator operator', done => {
const orders = [signedOrder, signedOrderWithDifferentFeeRecipient];
contractWrappers.coordinator
.batchSoftCancelOrdersAsync(orders)
.then(res => {
expect(res).to.be.undefined();
})
.catch(err => {
expect(err.message).equal(CoordinatorServerErrorMsg.CancellationFailed);
expect(err.approvedOrders).to.be.empty('array');
expect(err.cancellations).to.be.empty('array');
const errorBody = err.errors[0];
expect(errorBody.isError).to.be.true();
expect(errorBody.status).to.equal(400);
expect(errorBody.error).to.deep.equal(serverValidationError);
expect(errorBody.orders).to.deep.equal(orders);
expect(errorBody.coordinatorOperator).to.equal(`${coordinatorEndpoint}${coordinatorPort}`);
done();
});
});
it('should throw consolidated error when batch soft cancel partially fails with different coordinator operators', done => {
nock(`${coordinatorEndpoint}${anotherCoordinatorPort}`)
.post('/v1/request_transaction', () => true)
.query({
networkId: 50,
})
.reply(200, serverCancellationSuccess);
const signedOrders = [signedOrder, signedOrderWithDifferentCoordinatorOperator];
contractWrappers.coordinator
.batchSoftCancelOrdersAsync(signedOrders)
.then(res => {
expect(res).to.be.undefined();
})
.catch(err => {
expect(err.message).equal(CoordinatorServerErrorMsg.CancellationFailed);
expect(err.approvedOrders).to.be.empty('array');
expect(err.cancellations).to.deep.equal([serverCancellationSuccess]);
const errorBody = err.errors[0];
expect(errorBody.isError).to.be.true();
expect(errorBody.status).to.equal(400);
expect(errorBody.error).to.deep.equal(serverValidationError);
expect(errorBody.orders).to.deep.equal([signedOrder]);
expect(errorBody.coordinatorOperator).to.equal(`${coordinatorEndpoint}${coordinatorPort}`);
done();
});
});
it('should throw consolidated error when batch soft cancel totally fails with different coordinator operators', done => {
nock(`${coordinatorEndpoint}${anotherCoordinatorPort}`)
.post('/v1/request_transaction', () => true)
.query({
networkId: 50,
})
.reply(400, serverValidationError);
const signedOrders = [signedOrder, signedOrderWithDifferentCoordinatorOperator];
contractWrappers.coordinator
.batchSoftCancelOrdersAsync(signedOrders)
.then(res => {
expect(res).to.be.undefined();
})
.catch(err => {
expect(err.message).equal(CoordinatorServerErrorMsg.CancellationFailed);
expect(err.approvedOrders).to.be.empty('array');
expect(err.cancellations).to.be.empty('array');
const errorBody = err.errors[0];
expect(errorBody.isError).to.be.true();
expect(errorBody.status).to.equal(400);
expect(errorBody.error).to.deep.equal(serverValidationError);
expect(errorBody.orders).to.deep.equal([signedOrder]);
expect(errorBody.coordinatorOperator).to.equal(`${coordinatorEndpoint}${coordinatorPort}`);
const anotherErrorBody = err.errors[1];
expect(anotherErrorBody.isError).to.be.true();
expect(anotherErrorBody.status).to.equal(400);
expect(anotherErrorBody.error).to.deep.equal(serverValidationError);
expect(anotherErrorBody.orders).to.deep.equal([signedOrderWithDifferentCoordinatorOperator]);
expect(anotherErrorBody.coordinatorOperator).to.equal(
`${coordinatorEndpoint}${anotherCoordinatorPort}`,
);
done();
});
});
it('should throw error when a fill fails', done => {
contractWrappers.coordinator
.fillOrderAsync(signedOrder, takerTokenFillAmount, takerAddress)
.then(res => {
expect(res).to.be.undefined();
})
.catch(err => {
expect(err.message).equal(CoordinatorServerErrorMsg.FillFailed);
expect(err.approvedOrders).to.be.empty('array');
expect(err.cancellations).to.be.empty('array');
const errorBody = err.errors[0];
expect(errorBody.isError).to.be.true();
expect(errorBody.status).to.equal(400);
expect(errorBody.error).to.deep.equal(serverValidationError);
expect(errorBody.orders).to.deep.equal([signedOrder]);
expect(errorBody.coordinatorOperator).to.equal(`${coordinatorEndpoint}${coordinatorPort}`);
done();
});
});
it('should throw error when batch fill fails with single coordinator operator', done => {
const signedOrders = [signedOrder, signedOrderWithDifferentFeeRecipient];
const takerAssetFillAmounts = [takerTokenFillAmount, takerTokenFillAmount, takerTokenFillAmount];
contractWrappers.coordinator
.batchFillOrdersAsync(signedOrders, takerAssetFillAmounts, takerAddress)
.then(res => {
expect(res).to.be.undefined();
})
.catch(err => {
expect(err.message).equal(CoordinatorServerErrorMsg.FillFailed);
expect(err.approvedOrders).to.be.empty('array');
expect(err.cancellations).to.be.empty('array');
const errorBody = err.errors[0];
expect(errorBody.isError).to.be.true();
expect(errorBody.status).to.equal(400);
expect(errorBody.error).to.deep.equal(serverValidationError);
expect(errorBody.orders).to.deep.equal(signedOrders);
expect(errorBody.coordinatorOperator).to.equal(`${coordinatorEndpoint}${coordinatorPort}`);
done();
});
});
it('should throw consolidated error when batch fill partially fails with different coordinator operators', done => {
nock(`${coordinatorEndpoint}${anotherCoordinatorPort}`)
.post('/v1/request_transaction', () => true)
.query({
networkId: 50,
})
.reply(200, serverApprovalSuccess);
const signedOrders = [signedOrder, signedOrderWithDifferentCoordinatorOperator];
const takerAssetFillAmounts = [takerTokenFillAmount, takerTokenFillAmount, takerTokenFillAmount];
contractWrappers.coordinator
.batchFillOrdersAsync(signedOrders, takerAssetFillAmounts, takerAddress)
.then(res => {
expect(res).to.be.undefined();
})
.catch(err => {
expect(err.message).equal(CoordinatorServerErrorMsg.FillFailed);
expect(err.approvedOrders).to.deep.equal([signedOrderWithDifferentCoordinatorOperator]);
expect(err.cancellations).to.be.empty('array');
const errorBody = err.errors[0];
expect(errorBody.isError).to.be.true();
expect(errorBody.status).to.equal(400);
expect(errorBody.error).to.deep.equal(serverValidationError);
expect(errorBody.orders).to.deep.equal([signedOrder]);
expect(errorBody.coordinatorOperator).to.equal(`${coordinatorEndpoint}${coordinatorPort}`);
done();
});
});
it('should throw consolidated error when batch fill totally fails with different coordinator operators', done => {
nock(`${coordinatorEndpoint}${anotherCoordinatorPort}`)
.post('/v1/request_transaction', () => true)
.query({
networkId: 50,
})
.reply(400, serverValidationError);
const signedOrders = [signedOrder, signedOrderWithDifferentCoordinatorOperator];
const takerAssetFillAmounts = [takerTokenFillAmount, takerTokenFillAmount, takerTokenFillAmount];
contractWrappers.coordinator
.batchFillOrdersAsync(signedOrders, takerAssetFillAmounts, takerAddress)
.then(res => {
expect(res).to.be.undefined();
})
.catch(err => {
expect(err.message).equal(CoordinatorServerErrorMsg.FillFailed);
expect(err.approvedOrders).to.be.empty('array');
expect(err.cancellations).to.be.empty('array');
const errorBody = err.errors[0];
expect(errorBody.isError).to.be.true();
expect(errorBody.status).to.equal(400);
expect(errorBody.error).to.deep.equal(serverValidationError);
expect(errorBody.orders).to.deep.equal([signedOrder]);
expect(errorBody.coordinatorOperator).to.equal(`${coordinatorEndpoint}${coordinatorPort}`);
const anotherErrorBody = err.errors[1];
expect(anotherErrorBody.isError).to.be.true();
expect(anotherErrorBody.status).to.equal(400);
expect(anotherErrorBody.error).to.deep.equal(serverValidationError);
expect(anotherErrorBody.orders).to.deep.equal([signedOrderWithDifferentCoordinatorOperator]);
expect(anotherErrorBody.coordinatorOperator).to.equal(
`${coordinatorEndpoint}${anotherCoordinatorPort}`,
);
done();
});
});
});
});
// tslint:disable:max-file-line-count

View File

@ -1,12 +1,12 @@
import { expectTransactionFailedAsync, getLatestBlockTimestampAsync } from '@0x/contracts-test-utils';
import { BlockchainLifecycle } from '@0x/dev-utils';
import { assetDataUtils } from '@0x/order-utils';
import { RevertReason, SignedOrder } from '@0x/types';
import { ERC20AssetData, RevertReason, SignedOrder } from '@0x/types';
import { BigNumber } from '@0x/utils';
import * as chai from 'chai';
import 'mocha';
import { ContractWrappers } from '../src';
import { ContractWrappers, DutchAuctionWrapper } from '../src';
import { chaiSetup } from './utils/chai_setup';
import { constants } from './utils/constants';
@ -91,6 +91,21 @@ describe('DutchAuctionWrapper', () => {
afterEach(async () => {
await blockchainLifecycle.revertAsync();
});
describe('.decodeDutchAuctionAssetData', () => {
it('decodes to the encoded values', async () => {
const encodedAssetData = DutchAuctionWrapper.encodeDutchAuctionAssetData(
makerTokenAssetData,
auctionBeginTimeSeconds,
makerAssetAmount,
);
const decodedAssetData = DutchAuctionWrapper.decodeDutchAuctionData(encodedAssetData);
// tslint:disable-next-line:no-unnecessary-type-assertion
const erc20AssetData = decodedAssetData.assetData as ERC20AssetData;
expect(erc20AssetData.tokenAddress).to.eq(makerTokenAddress);
expect(decodedAssetData.beginAmount).to.be.bignumber.eq(makerAssetAmount);
expect(decodedAssetData.beginTimeSeconds).to.be.bignumber.eq(auctionBeginTimeSeconds);
});
});
describe('#matchOrdersAsync', () => {
it('should match two orders', async () => {
const txHash = await contractWrappers.dutchAuction.matchOrdersAsync(buyOrder, sellOrder, takerAddress);

View File

@ -1,4 +1,13 @@
[
{
"timestamp": 1557507213,
"version": "1.0.9",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "1.0.8",
"changes": [

View File

@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v1.0.9 - _May 10, 2019_
* Dependencies updated
## v1.0.8 - _April 11, 2019_
* Dependencies updated

View File

@ -1,6 +1,6 @@
{
"name": "@0x/contracts-gen",
"version": "1.0.8",
"version": "1.0.9",
"engines": {
"node": ">=6.12"
},
@ -30,7 +30,7 @@
"@0x/sol-resolver": "^2.0.7",
"@0x/types": "^2.2.2",
"@0x/typescript-typings": "^4.2.2",
"@0x/utils": "^4.3.1",
"@0x/utils": "^4.3.3",
"ethereum-types": "^2.1.2",
"lodash": "^4.17.11",
"prettier": "^1.16.3",

View File

@ -1,6 +1,6 @@
{
"name": "@0x/dev-tools-pages",
"version": "0.0.25",
"version": "0.0.27",
"engines": {
"node": ">=6.12"
},
@ -27,7 +27,7 @@
},
"license": "Apache-2.0",
"dependencies": {
"@0x/react-shared": "^2.0.10",
"@0x/react-shared": "^2.0.12",
"basscss": "^8.0.3",
"bowser": "^1.9.4",
"highlight.js": "^9.13.1",

View File

@ -1,4 +1,22 @@
[
{
"timestamp": 1558712885,
"version": "2.2.3",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1557507213,
"version": "2.2.2",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "2.2.1",
"changes": [

View File

@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v2.2.3 - _May 24, 2019_
* Dependencies updated
## v2.2.2 - _May 10, 2019_
* Dependencies updated
## v2.2.1 - _April 11, 2019_
* Dependencies updated

View File

@ -1,6 +1,6 @@
{
"name": "@0x/dev-utils",
"version": "2.2.1",
"version": "2.2.3",
"engines": {
"node": ">=6.12"
},
@ -42,11 +42,11 @@
"typescript": "3.0.1"
},
"dependencies": {
"@0x/subproviders": "^4.0.5",
"@0x/subproviders": "^4.1.0",
"@0x/types": "^2.2.2",
"@0x/typescript-typings": "^4.2.2",
"@0x/utils": "^4.3.1",
"@0x/web3-wrapper": "^6.0.5",
"@0x/utils": "^4.3.3",
"@0x/web3-wrapper": "^6.0.6",
"@types/web3-provider-engine": "^14.0.0",
"chai": "^4.0.1",
"ethereum-types": "^2.1.2",

View File

@ -1,4 +1,40 @@
[
{
"timestamp": 1558712885,
"version": "3.0.10",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1557961111,
"version": "3.0.9",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "3.0.8",
"changes": [
{
"note": "Dependencies updated"
}
],
"timestamp": 1557799313
},
{
"timestamp": 1557507213,
"version": "3.0.6",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "3.0.5",
"changes": [

View File

@ -5,6 +5,22 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v3.0.10 - _May 24, 2019_
* Dependencies updated
## v3.0.9 - _May 15, 2019_
* Dependencies updated
## v3.0.8 - _May 14, 2019_
* Dependencies updated
## v3.0.6 - _May 10, 2019_
* Dependencies updated
## v3.0.5 - _April 11, 2019_
* Dependencies updated

View File

@ -1,6 +1,6 @@
{
"name": "@0x/fill-scenarios",
"version": "3.0.5",
"version": "3.0.10",
"description": "0x order fill scenario generator",
"main": "lib/index.js",
"types": "lib/index.d.ts",
@ -29,14 +29,14 @@
"typescript": "3.0.1"
},
"dependencies": {
"@0x/abi-gen-wrappers": "^4.2.0",
"@0x/base-contract": "^5.0.5",
"@0x/contract-artifacts": "^1.5.0",
"@0x/order-utils": "^7.2.0",
"@0x/abi-gen-wrappers": "^4.3.0",
"@0x/base-contract": "^5.1.0",
"@0x/contract-artifacts": "^1.5.1",
"@0x/order-utils": "^8.1.1",
"@0x/types": "^2.2.2",
"@0x/typescript-typings": "^4.2.2",
"@0x/utils": "^4.3.1",
"@0x/web3-wrapper": "^6.0.5",
"@0x/utils": "^4.3.3",
"@0x/web3-wrapper": "^6.0.6",
"ethereum-types": "^2.1.2",
"ethers": "~4.0.4",
"lodash": "^4.17.11"

View File

@ -62,6 +62,7 @@ export class FillScenarios {
fillableAmount: BigNumber,
feeRecipientAddress: string,
expirationTimeSeconds?: BigNumber,
senderAddress?: string,
): Promise<SignedOrder> {
return this._createAsymmetricFillableSignedOrderWithFeesAsync(
makerAssetData,
@ -74,6 +75,7 @@ export class FillScenarios {
fillableAmount,
feeRecipientAddress,
expirationTimeSeconds,
senderAddress,
);
}
public async createAsymmetricFillableSignedOrderAsync(
@ -149,6 +151,7 @@ export class FillScenarios {
takerFillableAmount: BigNumber,
feeRecipientAddress: string,
expirationTimeSeconds?: BigNumber,
senderAddress?: string,
): Promise<SignedOrder> {
await this._increaseBalanceAndAllowanceWithAssetDataAsync(makerAssetData, makerAddress, makerFillableAmount);
await this._increaseBalanceAndAllowanceWithAssetDataAsync(takerAssetData, takerAddress, takerFillableAmount);
@ -157,7 +160,7 @@ export class FillScenarios {
this._increaseERC20BalanceAndAllowanceAsync(this._zrxTokenAddress, makerAddress, makerFee),
this._increaseERC20BalanceAndAllowanceAsync(this._zrxTokenAddress, takerAddress, takerFee),
]);
const senderAddress = constants.NULL_ADDRESS;
const _senderAddress = senderAddress ? senderAddress : constants.NULL_ADDRESS;
const signedOrder = await orderFactory.createSignedOrderAsync(
this._web3Wrapper.getProvider(),
@ -169,7 +172,7 @@ export class FillScenarios {
this._exchangeAddress,
{
takerAddress,
senderAddress,
senderAddress: _senderAddress,
makerFee,
takerFee,
feeRecipientAddress,

Some files were not shown because too many files have changed in this diff Show More