Compare commits
124 Commits
monorepo@4
...
@0x/sol-co
Author | SHA1 | Date | |
---|---|---|---|
|
5b7eff217e | ||
|
0a6ead90d9 | ||
|
2fa4ed1fb7 | ||
|
3733a29ee2 | ||
|
62b5eef4a0 | ||
|
377d6367e0 | ||
|
a3b364dbdf | ||
|
5dd55491b8 | ||
|
28aa12691e | ||
|
c1bf2754a8 | ||
|
c388e6d2b8 | ||
|
622fa951ca | ||
|
27fc640a9e | ||
|
4689f20b86 | ||
|
de927d7207 | ||
|
93121892d6 | ||
|
c3a7cbc57d | ||
|
0cfeea7c8c | ||
|
e2df4b355b | ||
|
74ed0f4134 | ||
|
5e39eae84e | ||
|
0ea8669552 | ||
|
1631031fa7 | ||
|
0bcb81d3a9 | ||
|
0ac36cef28 | ||
|
04db7f0fae | ||
|
e39ae0350b | ||
|
d0a0673694 | ||
|
3c62815fe3 | ||
|
37b6858869 | ||
|
641685a41e | ||
|
7ad23ef6dc | ||
|
5f2a7cb78f | ||
|
edb989fbf3 | ||
|
ff0093460d | ||
|
a00e416a19 | ||
|
77a2ca1ddc | ||
|
61a3368826 | ||
|
55e3774480 | ||
|
c6ab380685 | ||
|
d6467d707f | ||
|
0893614859 | ||
|
dc940d692f | ||
|
e83a108c52 | ||
|
bbd4828340 | ||
|
6de3a33f36 | ||
|
06139cbfe5 | ||
|
cb1bfa0f97 | ||
|
b249a50d8f | ||
|
0432212a34 | ||
|
7203ca90cf | ||
|
5da748a062 | ||
|
09afee55ed | ||
|
43b648e7dc | ||
|
89fcbec43b | ||
|
c850046ea0 | ||
|
7dda953bc9 | ||
|
b8f3fa9c8c | ||
|
42e04012df | ||
|
17f0878707 | ||
|
e4bb6a4652 | ||
|
3cdb85606a | ||
|
fd37e88bdb | ||
|
24564b986d | ||
|
a91bc415ed | ||
|
ccdb81ac40 | ||
|
d7f9e3f0a0 | ||
|
5720589515 | ||
|
70508f52a1 | ||
|
b90c3196a3 | ||
|
1dda10b4f3 | ||
|
0fba0b1a1b | ||
|
df4f3d9eac | ||
|
de4916ccb8 | ||
|
b797a45d4a | ||
|
eeb07d76fc | ||
|
0abace337c | ||
|
c6ff77bdd8 | ||
|
492e0ae345 | ||
|
8549252a2c | ||
|
aae32037da | ||
|
46359c098b | ||
|
fc71d87d2b | ||
|
67dfe6030c | ||
|
19e93440b3 | ||
|
0cb5209266 | ||
|
1553b366da | ||
|
d957cd5344 | ||
|
354f7053dc | ||
|
4d5fcf8985 | ||
|
71c9b2f718 | ||
|
79863d830e | ||
|
59ec243c26 | ||
|
5e8da70eae | ||
|
99b6ca5b4f | ||
|
4e4de07e69 | ||
|
1b65efb38c | ||
|
ed0e6181bd | ||
|
4dded13259 | ||
|
c82393d763 | ||
|
2111ea159e | ||
|
c1150824dc | ||
|
c62d862967 | ||
|
1ceb3c9664 | ||
|
4252a760f0 | ||
|
5721b25c3a | ||
|
586a8ba8e7 | ||
|
72a56db5ab | ||
|
646e856b51 | ||
|
e62e61bf71 | ||
|
a3eab71908 | ||
|
9d5d0dbe14 | ||
|
2b7875571d | ||
|
0a1701eac9 | ||
|
bcd20081d3 | ||
|
7e12ae1bfc | ||
|
2a577e0475 | ||
|
c6815bddac | ||
|
6639201fdb | ||
|
57ac2f28a4 | ||
|
210840444d | ||
|
d92e143a7e | ||
|
087469f1f3 | ||
|
b6c8126589 |
@@ -188,9 +188,7 @@ jobs:
|
||||
working_directory: ~/repo
|
||||
docker:
|
||||
- image: circleci/python
|
||||
- image: 0xorg/ganache-cli
|
||||
command: |
|
||||
ganache-cli --gasLimit 10000000 --noVMErrorsOnRPCResponse --db /snapshot --noVMErrorsOnRPCResponse -p 8545 --networkId 50 -m "concert load couple harbor equip island argue ramp clarify fence smart topic"
|
||||
- image: 0xorg/ganache-cli:2.2.2
|
||||
- image: 0xorg/launch-kit-ci
|
||||
command: |
|
||||
yarn start:ts -p 3000:3000
|
||||
@@ -200,16 +198,27 @@ jobs:
|
||||
- run: sudo chown -R circleci:circleci /usr/local/lib/python3.7/site-packages
|
||||
- restore_cache:
|
||||
key: deps9-{{ .Branch }}-{{ .Environment.CIRCLE_SHA1 }}
|
||||
- run:
|
||||
command: |
|
||||
cd python-packages/json_schemas
|
||||
python -m ensurepip
|
||||
python -m pip install .[dev]
|
||||
# HACK! installing the package should do the following
|
||||
# copy for us, but it's not working in CircleCI for some
|
||||
# reason. Zendesk support ticket raised (#43979) with
|
||||
# CircleCI.
|
||||
mkdir /usr/local/lib/python3.7/site-packages/zero_ex/json_schemas/schemas
|
||||
cp -R src/zero_ex/json_schemas/schemas/* /usr/local/lib/python3.7/site-packages/zero_ex/json_schemas/schemas
|
||||
- run:
|
||||
command: |
|
||||
cd python-packages/order_utils
|
||||
python -m ensurepip
|
||||
python -m pip install -e .[dev]
|
||||
python -m pip install .[dev]
|
||||
- run:
|
||||
command: |
|
||||
cd python-packages/sra_client
|
||||
python -m ensurepip
|
||||
python -m pip install -e .
|
||||
python -m pip install .[dev]
|
||||
- save_cache:
|
||||
key: deps9-{{ .Branch }}-{{ .Environment.CIRCLE_SHA1 }}
|
||||
paths:
|
||||
@@ -219,6 +228,10 @@ jobs:
|
||||
- '.mypy_cache'
|
||||
- '.pytest_cache'
|
||||
- '.tox'
|
||||
- run:
|
||||
command: |
|
||||
cd python-packages/json_schemas
|
||||
coverage run setup.py test
|
||||
- run:
|
||||
command: |
|
||||
cd python-packages/order_utils
|
||||
@@ -227,6 +240,10 @@ jobs:
|
||||
command: |
|
||||
cd python-packages/sra_client
|
||||
coverage run setup.py test
|
||||
- save_cache:
|
||||
key: coverage-python-json-schemas-{{ .Environment.CIRCLE_SHA1 }}
|
||||
paths:
|
||||
- ~/repo/python-packages/json_schemas/.coverage
|
||||
- save_cache:
|
||||
key: coverage-python-order-utils-{{ .Environment.CIRCLE_SHA1 }}
|
||||
paths:
|
||||
@@ -249,7 +266,7 @@ jobs:
|
||||
command: |
|
||||
cd python-packages/order_utils
|
||||
python -m ensurepip
|
||||
python -m pip install -e .[dev]
|
||||
python -m pip install .
|
||||
- save_cache:
|
||||
key: deps9-{{ .Branch }}-{{ .Environment.CIRCLE_SHA1 }}
|
||||
paths:
|
||||
@@ -273,16 +290,25 @@ jobs:
|
||||
- run: sudo chown -R circleci:circleci /usr/local/lib/python3.7/site-packages
|
||||
- restore_cache:
|
||||
key: deps9-{{ .Branch }}-{{ .Environment.CIRCLE_SHA1 }}
|
||||
- run:
|
||||
command: |
|
||||
cd python-packages/json_schemas
|
||||
python -m ensurepip
|
||||
python -m pip install .[dev]
|
||||
- run:
|
||||
command: |
|
||||
cd python-packages/order_utils
|
||||
python -m ensurepip
|
||||
python -m pip install -e .[dev]
|
||||
python -m pip install .[dev]
|
||||
- save_cache:
|
||||
key: deps9-{{ .Branch }}-{{ .Environment.CIRCLE_SHA1 }}
|
||||
paths:
|
||||
- '/usr/local/bin'
|
||||
- '/usr/local/lib/python3.7/site-packages'
|
||||
- run:
|
||||
command: |
|
||||
cd python-packages/json_schemas
|
||||
python setup.py lint
|
||||
- run:
|
||||
command: |
|
||||
cd python-packages/order_utils
|
||||
@@ -355,6 +381,9 @@ jobs:
|
||||
- restore_cache:
|
||||
keys:
|
||||
- coverage-contracts-{{ .Environment.CIRCLE_SHA1 }}
|
||||
- restore_cache:
|
||||
keys:
|
||||
- coverage-python-json-schemas-{{ .Environment.CIRCLE_SHA1 }}
|
||||
- restore_cache:
|
||||
keys:
|
||||
- coverage-python-order-utils-{{ .Environment.CIRCLE_SHA1 }}
|
||||
|
@@ -20,10 +20,13 @@ lib
|
||||
/packages/contract-artifacts/artifacts
|
||||
/python-packages/order_utils/src/zero_ex/contract_artifacts/artifacts
|
||||
/packages/json-schemas/schemas
|
||||
/python-packages/order_utils/src/zero_ex/json_schemas/schemas
|
||||
/python-packages/json_schemas/src/zero_ex/json_schemas/schemas
|
||||
/packages/metacoin/src/contract_wrappers
|
||||
/packages/metacoin/artifacts
|
||||
/packages/sra-spec/public/
|
||||
package.json
|
||||
scripts/postpublish_utils.js
|
||||
packages/sol-cov/test/fixtures/artifacts
|
||||
.pytest_cache
|
||||
.mypy_cache
|
||||
.tox
|
||||
|
11
README.md
11
README.md
@@ -1,4 +1,4 @@
|
||||
<img src="https://github.com/0xProject/branding/blob/master/0x_Black_CMYK.png" width="200px" >
|
||||
<img src="https://github.com/0xProject/branding/blob/master/0x%20Logo/PNG/0x-Logo-Black.png" width="150px" >
|
||||
|
||||
---
|
||||
|
||||
@@ -24,10 +24,11 @@ Visit our [developer portal](https://0xproject.com/docs/order-utils) for a compr
|
||||
|
||||
### Python Packages
|
||||
|
||||
| Package | Version | Description |
|
||||
| ------------------------------------------------ | ----------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
|
||||
| [`0x-order-utils`](/python-packages/order_utils) | [](https://pypi.org/project/0x-order-utils/) | A set of utilities for generating, parsing, signing and validating 0x orders |
|
||||
| [`0x-sra-client`](/python-packages/sra_client) | [](https://pypi.org/project/0x-sra-client/) | A Python client for interacting with servers conforming to the Standard Relayer API specification |
|
||||
| Package | Version | Description |
|
||||
| -------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
|
||||
| [`0x-json-schemas`](/python-packages/json_schemas) | [](https://pypi.org/project/0x-json-schemas/) | 0x-related JSON schemas |
|
||||
| [`0x-order-utils`](/python-packages/order_utils) | [](https://pypi.org/project/0x-order-utils/) | A set of utilities for generating, parsing, signing and validating 0x orders |
|
||||
| [`0x-sra-client`](/python-packages/sra_client) | [](https://pypi.org/project/0x-sra-client/) | A Python client for interacting with servers conforming to the Standard Relayer API specification |
|
||||
|
||||
### Typescript/Javascript Packages
|
||||
|
||||
|
@@ -1,4 +1,13 @@
|
||||
[
|
||||
{
|
||||
"timestamp": 1547040760,
|
||||
"version": "1.0.3",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1544741676,
|
||||
"version": "1.0.2",
|
||||
|
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v1.0.3 - _January 9, 2019_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.0.2 - _December 13, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0x/contracts-examples",
|
||||
"version": "1.0.2",
|
||||
"version": "1.0.3",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
@@ -33,12 +33,12 @@
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/examples/README.md",
|
||||
"devDependencies": {
|
||||
"@0x/abi-gen": "^1.0.19",
|
||||
"@0x/contracts-test-utils": "^1.0.2",
|
||||
"@0x/dev-utils": "^1.0.21",
|
||||
"@0x/sol-compiler": "^1.1.16",
|
||||
"@0x/sol-cov": "^2.1.16",
|
||||
"@0x/subproviders": "^2.1.8",
|
||||
"@0x/abi-gen": "^1.0.20",
|
||||
"@0x/contracts-test-utils": "^1.0.3",
|
||||
"@0x/dev-utils": "^1.0.22",
|
||||
"@0x/sol-compiler": "^2.0.0",
|
||||
"@0x/sol-cov": "^2.1.17",
|
||||
"@0x/subproviders": "^2.1.9",
|
||||
"@0x/tslint-config": "^2.0.0",
|
||||
"@types/bn.js": "^4.11.0",
|
||||
"@types/lodash": "4.14.104",
|
||||
@@ -53,24 +53,23 @@
|
||||
"mocha": "^4.1.0",
|
||||
"npm-run-all": "^4.1.2",
|
||||
"shx": "^0.2.2",
|
||||
"solc": "^0.4.24",
|
||||
"solhint": "^1.4.1",
|
||||
"tslint": "5.11.0",
|
||||
"typescript": "3.0.1",
|
||||
"yargs": "^10.0.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0x/base-contract": "^3.0.10",
|
||||
"@0x/contracts-interfaces": "^1.0.2",
|
||||
"@0x/contracts-libs": "^1.0.2",
|
||||
"@0x/contracts-multisig": "^1.0.2",
|
||||
"@0x/contracts-tokens": "^1.0.2",
|
||||
"@0x/contracts-utils": "^1.0.2",
|
||||
"@0x/order-utils": "^3.0.7",
|
||||
"@0x/types": "^1.4.1",
|
||||
"@0x/base-contract": "^3.0.11",
|
||||
"@0x/contracts-interfaces": "^1.0.3",
|
||||
"@0x/contracts-libs": "^1.0.3",
|
||||
"@0x/contracts-multisig": "^1.0.3",
|
||||
"@0x/contracts-tokens": "^1.0.3",
|
||||
"@0x/contracts-utils": "^1.0.3",
|
||||
"@0x/order-utils": "^3.1.0",
|
||||
"@0x/types": "^1.5.0",
|
||||
"@0x/typescript-typings": "^3.0.6",
|
||||
"@0x/utils": "^2.0.8",
|
||||
"@0x/web3-wrapper": "^3.2.1",
|
||||
"@0x/utils": "^2.1.1",
|
||||
"@0x/web3-wrapper": "^3.2.2",
|
||||
"@types/js-combinatorics": "^0.5.29",
|
||||
"bn.js": "^4.11.8",
|
||||
"ethereum-types": "^1.1.4",
|
||||
|
@@ -1,4 +1,14 @@
|
||||
[
|
||||
{
|
||||
"version": "1.2.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Added Dutch Auction Wrapper",
|
||||
"pr": 1465
|
||||
}
|
||||
],
|
||||
"timestamp": 1547040760
|
||||
},
|
||||
{
|
||||
"version": "1.1.0",
|
||||
"changes": [
|
||||
|
@@ -5,6 +5,16 @@ Edit the package's CHANGELOG.json file only.
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v1.2.0 - _January 9, 2019_
|
||||
|
||||
* Added Dutch Auction Wrapper (#1465)
|
||||
|
||||
## v1.1.0 - _Invalid date_
|
||||
|
||||
* Added Balance Threshold Filter (#1383)
|
||||
* Add OrderMatcher (#1117)
|
||||
* Add OrderValidator (#1464)
|
||||
|
||||
## v1.0.2 - _December 13, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0x/contracts-extensions",
|
||||
"version": "1.0.2",
|
||||
"version": "1.2.0",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
@@ -44,12 +44,13 @@
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/extensions/README.md",
|
||||
"devDependencies": {
|
||||
"@0x/abi-gen": "^1.0.19",
|
||||
"@0x/contracts-test-utils": "^1.0.2",
|
||||
"@0x/dev-utils": "^1.0.21",
|
||||
"@0x/sol-compiler": "^1.1.16",
|
||||
"@0x/sol-cov": "^2.1.16",
|
||||
"@0x/subproviders": "^2.1.8",
|
||||
"@0x/abi-gen": "^1.0.20",
|
||||
"@0x/contract-wrappers": "^4.2.0",
|
||||
"@0x/contracts-test-utils": "^1.0.3",
|
||||
"@0x/dev-utils": "^1.0.22",
|
||||
"@0x/sol-compiler": "^2.0.0",
|
||||
"@0x/sol-cov": "^2.1.17",
|
||||
"@0x/subproviders": "^2.1.9",
|
||||
"@0x/tslint-config": "^2.0.0",
|
||||
"@types/bn.js": "^4.11.0",
|
||||
"@types/lodash": "4.14.104",
|
||||
@@ -64,24 +65,23 @@
|
||||
"mocha": "^4.1.0",
|
||||
"npm-run-all": "^4.1.2",
|
||||
"shx": "^0.2.2",
|
||||
"solc": "^0.4.24",
|
||||
"solhint": "^1.4.1",
|
||||
"tslint": "5.11.0",
|
||||
"typescript": "3.0.1",
|
||||
"yargs": "^10.0.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0x/base-contract": "^3.0.10",
|
||||
"@0x/contracts-interfaces": "^1.0.2",
|
||||
"@0x/contracts-libs": "^1.0.2",
|
||||
"@0x/contracts-protocol": "^2.1.59",
|
||||
"@0x/contracts-tokens": "^1.0.2",
|
||||
"@0x/contracts-utils": "^1.0.2",
|
||||
"@0x/order-utils": "^3.0.7",
|
||||
"@0x/types": "^1.4.1",
|
||||
"@0x/base-contract": "^3.0.11",
|
||||
"@0x/contracts-interfaces": "^1.0.3",
|
||||
"@0x/contracts-libs": "^1.0.3",
|
||||
"@0x/contracts-protocol": "^2.2.0",
|
||||
"@0x/contracts-tokens": "^1.0.3",
|
||||
"@0x/contracts-utils": "^1.0.3",
|
||||
"@0x/order-utils": "^3.1.0",
|
||||
"@0x/types": "^1.5.0",
|
||||
"@0x/typescript-typings": "^3.0.6",
|
||||
"@0x/utils": "^2.0.8",
|
||||
"@0x/web3-wrapper": "^3.2.1",
|
||||
"@0x/utils": "^2.1.1",
|
||||
"@0x/web3-wrapper": "^3.2.2",
|
||||
"@types/js-combinatorics": "^0.5.29",
|
||||
"bn.js": "^4.11.8",
|
||||
"ethereum-types": "^1.1.4",
|
||||
|
@@ -1,3 +1,4 @@
|
||||
import { DutchAuctionWrapper } from '@0x/contract-wrappers';
|
||||
import {
|
||||
artifacts as protocolArtifacts,
|
||||
ERC20Wrapper,
|
||||
@@ -29,12 +30,11 @@ import { RevertReason, SignedOrder } from '@0x/types';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import * as chai from 'chai';
|
||||
import ethAbi = require('ethereumjs-abi');
|
||||
import * as ethUtil from 'ethereumjs-util';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { DutchAuctionContract } from '../../generated-wrappers/dutch_auction';
|
||||
import { artifacts } from '../../src/artifacts';
|
||||
import { DutchAuctionTestWrapper } from '../utils/dutch_auction_test_wrapper';
|
||||
|
||||
chaiSetup.configure();
|
||||
const expect = chai.expect;
|
||||
@@ -68,19 +68,8 @@ describe(ContractName.DutchAuction, () => {
|
||||
let erc721MakerAssetIds: BigNumber[];
|
||||
const tenMinutesInSeconds = 10 * 60;
|
||||
|
||||
function extendMakerAssetData(makerAssetData: string, beginTimeSeconds: BigNumber, beginAmount: BigNumber): string {
|
||||
return ethUtil.bufferToHex(
|
||||
Buffer.concat([
|
||||
ethUtil.toBuffer(makerAssetData),
|
||||
ethUtil.toBuffer(
|
||||
(ethAbi as any).rawEncode(
|
||||
['uint256', 'uint256'],
|
||||
[beginTimeSeconds.toString(), beginAmount.toString()],
|
||||
),
|
||||
),
|
||||
]),
|
||||
);
|
||||
}
|
||||
let dutchAuctionTestWrapper: DutchAuctionTestWrapper;
|
||||
let defaultERC20MakerAssetData: string;
|
||||
|
||||
before(async () => {
|
||||
await blockchainLifecycle.startAsync();
|
||||
@@ -136,6 +125,7 @@ describe(ContractName.DutchAuction, () => {
|
||||
dutchAuctionInstance.address,
|
||||
provider,
|
||||
);
|
||||
dutchAuctionTestWrapper = new DutchAuctionTestWrapper(dutchAuctionInstance, provider);
|
||||
|
||||
defaultMakerAssetAddress = erc20TokenA.address;
|
||||
const defaultTakerAssetAddress = wethContract.address;
|
||||
@@ -174,7 +164,7 @@ describe(ContractName.DutchAuction, () => {
|
||||
feeRecipientAddress,
|
||||
// taker address or sender address should be set to the ducth auction contract
|
||||
takerAddress: dutchAuctionContract.address,
|
||||
makerAssetData: extendMakerAssetData(
|
||||
makerAssetData: DutchAuctionWrapper.encodeDutchAuctionAssetData(
|
||||
assetDataUtils.encodeERC20AssetData(defaultMakerAssetAddress),
|
||||
auctionBeginTimeSeconds,
|
||||
auctionBeginAmount,
|
||||
@@ -199,6 +189,7 @@ describe(ContractName.DutchAuction, () => {
|
||||
const takerPrivateKey = constants.TESTRPC_PRIVATE_KEYS[accounts.indexOf(takerAddress)];
|
||||
sellerOrderFactory = new OrderFactory(makerPrivateKey, sellerDefaultOrderParams);
|
||||
buyerOrderFactory = new OrderFactory(takerPrivateKey, buyerDefaultOrderParams);
|
||||
defaultERC20MakerAssetData = assetDataUtils.encodeERC20AssetData(defaultMakerAssetAddress);
|
||||
});
|
||||
after(async () => {
|
||||
await blockchainLifecycle.revertAsync();
|
||||
@@ -215,49 +206,41 @@ describe(ContractName.DutchAuction, () => {
|
||||
describe('matchOrders', () => {
|
||||
it('should be worth the begin price at the begining of the auction', async () => {
|
||||
auctionBeginTimeSeconds = new BigNumber(currentBlockTimestamp + 2);
|
||||
sellOrder = await sellerOrderFactory.newSignedOrderAsync({
|
||||
makerAssetData: extendMakerAssetData(
|
||||
assetDataUtils.encodeERC20AssetData(defaultMakerAssetAddress),
|
||||
auctionBeginTimeSeconds,
|
||||
auctionBeginAmount,
|
||||
),
|
||||
});
|
||||
const auctionDetails = await dutchAuctionContract.getAuctionDetails.callAsync(sellOrder);
|
||||
const makerAssetData = DutchAuctionWrapper.encodeDutchAuctionAssetData(
|
||||
defaultERC20MakerAssetData,
|
||||
auctionBeginTimeSeconds,
|
||||
auctionBeginAmount,
|
||||
);
|
||||
sellOrder = await sellerOrderFactory.newSignedOrderAsync({ makerAssetData });
|
||||
const auctionDetails = await dutchAuctionTestWrapper.getAuctionDetailsAsync(sellOrder);
|
||||
expect(auctionDetails.currentTimeSeconds).to.be.bignumber.lte(auctionBeginTimeSeconds);
|
||||
expect(auctionDetails.currentAmount).to.be.bignumber.equal(auctionBeginAmount);
|
||||
expect(auctionDetails.beginAmount).to.be.bignumber.equal(auctionBeginAmount);
|
||||
});
|
||||
it('should be be worth the end price at the end of the auction', async () => {
|
||||
auctionBeginTimeSeconds = new BigNumber(currentBlockTimestamp - tenMinutesInSeconds * 2);
|
||||
auctionEndTimeSeconds = new BigNumber(currentBlockTimestamp - tenMinutesInSeconds);
|
||||
const makerAssetData = DutchAuctionWrapper.encodeDutchAuctionAssetData(
|
||||
defaultERC20MakerAssetData,
|
||||
auctionBeginTimeSeconds,
|
||||
auctionBeginAmount,
|
||||
);
|
||||
sellOrder = await sellerOrderFactory.newSignedOrderAsync({
|
||||
makerAssetData: extendMakerAssetData(
|
||||
assetDataUtils.encodeERC20AssetData(defaultMakerAssetAddress),
|
||||
auctionBeginTimeSeconds,
|
||||
auctionBeginAmount,
|
||||
),
|
||||
makerAssetData,
|
||||
expirationTimeSeconds: auctionEndTimeSeconds,
|
||||
});
|
||||
const auctionDetails = await dutchAuctionContract.getAuctionDetails.callAsync(sellOrder);
|
||||
const auctionDetails = await dutchAuctionTestWrapper.getAuctionDetailsAsync(sellOrder);
|
||||
expect(auctionDetails.currentTimeSeconds).to.be.bignumber.gte(auctionEndTimeSeconds);
|
||||
expect(auctionDetails.currentAmount).to.be.bignumber.equal(auctionEndAmount);
|
||||
expect(auctionDetails.beginAmount).to.be.bignumber.equal(auctionBeginAmount);
|
||||
});
|
||||
it('should match orders at current amount and send excess to buyer', async () => {
|
||||
const beforeAuctionDetails = await dutchAuctionContract.getAuctionDetails.callAsync(sellOrder);
|
||||
const beforeAuctionDetails = await dutchAuctionTestWrapper.getAuctionDetailsAsync(sellOrder);
|
||||
buyOrder = await buyerOrderFactory.newSignedOrderAsync({
|
||||
makerAssetAmount: beforeAuctionDetails.currentAmount.times(2),
|
||||
});
|
||||
await web3Wrapper.awaitTransactionSuccessAsync(
|
||||
await dutchAuctionContract.matchOrders.sendTransactionAsync(
|
||||
buyOrder,
|
||||
sellOrder,
|
||||
buyOrder.signature,
|
||||
sellOrder.signature,
|
||||
{
|
||||
from: takerAddress,
|
||||
},
|
||||
),
|
||||
);
|
||||
const afterAuctionDetails = await dutchAuctionContract.getAuctionDetails.callAsync(sellOrder);
|
||||
await dutchAuctionTestWrapper.matchOrdersAsync(buyOrder, sellOrder, takerAddress);
|
||||
const afterAuctionDetails = await dutchAuctionTestWrapper.getAuctionDetailsAsync(sellOrder);
|
||||
const newBalances = await erc20Wrapper.getBalancesAsync();
|
||||
expect(newBalances[dutchAuctionContract.address][wethContract.address]).to.be.bignumber.equal(
|
||||
constants.ZERO_AMOUNT,
|
||||
@@ -276,17 +259,8 @@ describe(ContractName.DutchAuction, () => {
|
||||
sellOrder = await sellerOrderFactory.newSignedOrderAsync({
|
||||
makerFee: new BigNumber(1),
|
||||
});
|
||||
const txHash = await dutchAuctionContract.matchOrders.sendTransactionAsync(
|
||||
buyOrder,
|
||||
sellOrder,
|
||||
buyOrder.signature,
|
||||
sellOrder.signature,
|
||||
{
|
||||
from: takerAddress,
|
||||
},
|
||||
);
|
||||
await web3Wrapper.awaitTransactionSuccessAsync(txHash);
|
||||
const afterAuctionDetails = await dutchAuctionContract.getAuctionDetails.callAsync(sellOrder);
|
||||
await dutchAuctionTestWrapper.matchOrdersAsync(buyOrder, sellOrder, takerAddress);
|
||||
const afterAuctionDetails = await dutchAuctionTestWrapper.getAuctionDetailsAsync(sellOrder);
|
||||
const newBalances = await erc20Wrapper.getBalancesAsync();
|
||||
expect(newBalances[makerAddress][wethContract.address]).to.be.bignumber.gte(
|
||||
erc20Balances[makerAddress][wethContract.address].plus(afterAuctionDetails.currentAmount),
|
||||
@@ -299,18 +273,9 @@ describe(ContractName.DutchAuction, () => {
|
||||
buyOrder = await buyerOrderFactory.newSignedOrderAsync({
|
||||
makerFee: new BigNumber(1),
|
||||
});
|
||||
const txHash = await dutchAuctionContract.matchOrders.sendTransactionAsync(
|
||||
buyOrder,
|
||||
sellOrder,
|
||||
buyOrder.signature,
|
||||
sellOrder.signature,
|
||||
{
|
||||
from: takerAddress,
|
||||
},
|
||||
);
|
||||
await web3Wrapper.awaitTransactionSuccessAsync(txHash);
|
||||
await dutchAuctionTestWrapper.matchOrdersAsync(buyOrder, sellOrder, takerAddress);
|
||||
const newBalances = await erc20Wrapper.getBalancesAsync();
|
||||
const afterAuctionDetails = await dutchAuctionContract.getAuctionDetails.callAsync(sellOrder);
|
||||
const afterAuctionDetails = await dutchAuctionTestWrapper.getAuctionDetailsAsync(sellOrder);
|
||||
expect(newBalances[makerAddress][wethContract.address]).to.be.bignumber.gte(
|
||||
erc20Balances[makerAddress][wethContract.address].plus(afterAuctionDetails.currentAmount),
|
||||
);
|
||||
@@ -321,24 +286,17 @@ describe(ContractName.DutchAuction, () => {
|
||||
it('should revert when auction expires', async () => {
|
||||
auctionBeginTimeSeconds = new BigNumber(currentBlockTimestamp - tenMinutesInSeconds * 2);
|
||||
auctionEndTimeSeconds = new BigNumber(currentBlockTimestamp - tenMinutesInSeconds);
|
||||
const makerAssetData = DutchAuctionWrapper.encodeDutchAuctionAssetData(
|
||||
defaultERC20MakerAssetData,
|
||||
auctionBeginTimeSeconds,
|
||||
auctionBeginAmount,
|
||||
);
|
||||
sellOrder = await sellerOrderFactory.newSignedOrderAsync({
|
||||
expirationTimeSeconds: auctionEndTimeSeconds,
|
||||
makerAssetData: extendMakerAssetData(
|
||||
assetDataUtils.encodeERC20AssetData(defaultMakerAssetAddress),
|
||||
auctionBeginTimeSeconds,
|
||||
auctionBeginAmount,
|
||||
),
|
||||
makerAssetData,
|
||||
});
|
||||
return expectTransactionFailedAsync(
|
||||
dutchAuctionContract.matchOrders.sendTransactionAsync(
|
||||
buyOrder,
|
||||
sellOrder,
|
||||
buyOrder.signature,
|
||||
sellOrder.signature,
|
||||
{
|
||||
from: takerAddress,
|
||||
},
|
||||
),
|
||||
dutchAuctionTestWrapper.matchOrdersAsync(buyOrder, sellOrder, takerAddress),
|
||||
RevertReason.AuctionExpired,
|
||||
);
|
||||
});
|
||||
@@ -347,15 +305,7 @@ describe(ContractName.DutchAuction, () => {
|
||||
makerAssetAmount: sellOrder.takerAssetAmount,
|
||||
});
|
||||
return expectTransactionFailedAsync(
|
||||
dutchAuctionContract.matchOrders.sendTransactionAsync(
|
||||
buyOrder,
|
||||
sellOrder,
|
||||
buyOrder.signature,
|
||||
sellOrder.signature,
|
||||
{
|
||||
from: takerAddress,
|
||||
},
|
||||
),
|
||||
dutchAuctionTestWrapper.matchOrdersAsync(buyOrder, sellOrder, takerAddress),
|
||||
RevertReason.AuctionInvalidAmount,
|
||||
);
|
||||
});
|
||||
@@ -364,38 +314,23 @@ describe(ContractName.DutchAuction, () => {
|
||||
takerAssetAmount: auctionBeginAmount.plus(1),
|
||||
});
|
||||
return expectTransactionFailedAsync(
|
||||
dutchAuctionContract.matchOrders.sendTransactionAsync(
|
||||
buyOrder,
|
||||
sellOrder,
|
||||
buyOrder.signature,
|
||||
sellOrder.signature,
|
||||
{
|
||||
from: takerAddress,
|
||||
},
|
||||
),
|
||||
dutchAuctionTestWrapper.matchOrdersAsync(buyOrder, sellOrder, takerAddress),
|
||||
RevertReason.AuctionInvalidAmount,
|
||||
);
|
||||
});
|
||||
it('begin time is less than end time', async () => {
|
||||
auctionBeginTimeSeconds = new BigNumber(auctionEndTimeSeconds).plus(tenMinutesInSeconds);
|
||||
const makerAssetData = DutchAuctionWrapper.encodeDutchAuctionAssetData(
|
||||
defaultERC20MakerAssetData,
|
||||
auctionBeginTimeSeconds,
|
||||
auctionBeginAmount,
|
||||
);
|
||||
sellOrder = await sellerOrderFactory.newSignedOrderAsync({
|
||||
expirationTimeSeconds: auctionEndTimeSeconds,
|
||||
makerAssetData: extendMakerAssetData(
|
||||
assetDataUtils.encodeERC20AssetData(defaultMakerAssetAddress),
|
||||
auctionBeginTimeSeconds,
|
||||
auctionBeginAmount,
|
||||
),
|
||||
makerAssetData,
|
||||
});
|
||||
return expectTransactionFailedAsync(
|
||||
dutchAuctionContract.matchOrders.sendTransactionAsync(
|
||||
buyOrder,
|
||||
sellOrder,
|
||||
buyOrder.signature,
|
||||
sellOrder.signature,
|
||||
{
|
||||
from: takerAddress,
|
||||
},
|
||||
),
|
||||
dutchAuctionTestWrapper.matchOrdersAsync(buyOrder, sellOrder, takerAddress),
|
||||
RevertReason.AuctionInvalidBeginTime,
|
||||
);
|
||||
});
|
||||
@@ -404,45 +339,30 @@ describe(ContractName.DutchAuction, () => {
|
||||
makerAssetData: assetDataUtils.encodeERC20AssetData(defaultMakerAssetAddress),
|
||||
});
|
||||
return expectTransactionFailedAsync(
|
||||
dutchAuctionContract.matchOrders.sendTransactionAsync(
|
||||
buyOrder,
|
||||
sellOrder,
|
||||
buyOrder.signature,
|
||||
sellOrder.signature,
|
||||
{
|
||||
from: takerAddress,
|
||||
},
|
||||
),
|
||||
dutchAuctionTestWrapper.matchOrdersAsync(buyOrder, sellOrder, takerAddress),
|
||||
RevertReason.InvalidAssetData,
|
||||
);
|
||||
});
|
||||
|
||||
describe('ERC721', () => {
|
||||
it('should match orders when ERC721', async () => {
|
||||
const makerAssetId = erc721MakerAssetIds[0];
|
||||
const erc721MakerAssetData = assetDataUtils.encodeERC721AssetData(erc721Token.address, makerAssetId);
|
||||
const makerAssetData = DutchAuctionWrapper.encodeDutchAuctionAssetData(
|
||||
erc721MakerAssetData,
|
||||
auctionBeginTimeSeconds,
|
||||
auctionBeginAmount,
|
||||
);
|
||||
sellOrder = await sellerOrderFactory.newSignedOrderAsync({
|
||||
makerAssetAmount: new BigNumber(1),
|
||||
makerAssetData: extendMakerAssetData(
|
||||
assetDataUtils.encodeERC721AssetData(erc721Token.address, makerAssetId),
|
||||
auctionBeginTimeSeconds,
|
||||
auctionBeginAmount,
|
||||
),
|
||||
makerAssetData,
|
||||
});
|
||||
buyOrder = await buyerOrderFactory.newSignedOrderAsync({
|
||||
takerAssetAmount: new BigNumber(1),
|
||||
takerAssetData: sellOrder.makerAssetData,
|
||||
});
|
||||
await web3Wrapper.awaitTransactionSuccessAsync(
|
||||
await dutchAuctionContract.matchOrders.sendTransactionAsync(
|
||||
buyOrder,
|
||||
sellOrder,
|
||||
buyOrder.signature,
|
||||
sellOrder.signature,
|
||||
{
|
||||
from: takerAddress,
|
||||
},
|
||||
),
|
||||
);
|
||||
const afterAuctionDetails = await dutchAuctionContract.getAuctionDetails.callAsync(sellOrder);
|
||||
await dutchAuctionTestWrapper.matchOrdersAsync(buyOrder, sellOrder, takerAddress);
|
||||
const afterAuctionDetails = await dutchAuctionTestWrapper.getAuctionDetailsAsync(sellOrder);
|
||||
const newBalances = await erc20Wrapper.getBalancesAsync();
|
||||
// HACK gte used here due to a bug in ganache where the timestamp can change
|
||||
// between multiple calls to the same block. Which can move the amount in our case
|
||||
|
@@ -0,0 +1,62 @@
|
||||
import { artifacts as protocolArtifacts } from '@0x/contracts-protocol';
|
||||
import { LogDecoder } from '@0x/contracts-test-utils';
|
||||
import { artifacts as tokensArtifacts } from '@0x/contracts-tokens';
|
||||
import { DutchAuctionDetails, SignedOrder } from '@0x/types';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import { Provider, TransactionReceiptWithDecodedLogs } from 'ethereum-types';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { DutchAuctionContract } from '../../generated-wrappers/dutch_auction';
|
||||
import { artifacts } from '../../src/artifacts';
|
||||
|
||||
export class DutchAuctionTestWrapper {
|
||||
private readonly _dutchAuctionContract: DutchAuctionContract;
|
||||
private readonly _web3Wrapper: Web3Wrapper;
|
||||
private readonly _logDecoder: LogDecoder;
|
||||
|
||||
constructor(contractInstance: DutchAuctionContract, provider: Provider) {
|
||||
this._dutchAuctionContract = contractInstance;
|
||||
this._web3Wrapper = new Web3Wrapper(provider);
|
||||
this._logDecoder = new LogDecoder(this._web3Wrapper, {
|
||||
...artifacts,
|
||||
...tokensArtifacts,
|
||||
...protocolArtifacts,
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Matches the buy and sell orders at an amount given the following: the current block time, the auction
|
||||
* start time and the auction begin amount. The sell order is a an order at the lowest amount
|
||||
* at the end of the auction. Excess from the match is transferred to the seller.
|
||||
* Over time the price moves from beginAmount to endAmount given the current block.timestamp.
|
||||
* @param buyOrder The Buyer's order. This order is for the current expected price of the auction.
|
||||
* @param sellOrder The Seller's order. This order is for the lowest amount (at the end of the auction).
|
||||
* @param from Address the transaction is being sent from.
|
||||
* @return Transaction receipt with decoded logs.
|
||||
*/
|
||||
public async matchOrdersAsync(
|
||||
buyOrder: SignedOrder,
|
||||
sellOrder: SignedOrder,
|
||||
from: string,
|
||||
): Promise<TransactionReceiptWithDecodedLogs> {
|
||||
const txHash = await this._dutchAuctionContract.matchOrders.sendTransactionAsync(
|
||||
buyOrder,
|
||||
sellOrder,
|
||||
buyOrder.signature,
|
||||
sellOrder.signature,
|
||||
{
|
||||
from,
|
||||
},
|
||||
);
|
||||
const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash);
|
||||
return tx;
|
||||
}
|
||||
/**
|
||||
* Calculates the Auction Details for the given order
|
||||
* @param sellOrder The Seller's order. This order is for the lowest amount (at the end of the auction).
|
||||
* @return The dutch auction details.
|
||||
*/
|
||||
public async getAuctionDetailsAsync(sellOrder: SignedOrder): Promise<DutchAuctionDetails> {
|
||||
const auctionDetails = await this._dutchAuctionContract.getAuctionDetails.callAsync(sellOrder);
|
||||
return auctionDetails;
|
||||
}
|
||||
}
|
@@ -1,4 +1,13 @@
|
||||
[
|
||||
{
|
||||
"timestamp": 1547040760,
|
||||
"version": "1.0.3",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1544741676,
|
||||
"version": "1.0.2",
|
||||
|
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v1.0.3 - _January 9, 2019_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.0.2 - _December 13, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0x/contracts-interfaces",
|
||||
"version": "1.0.2",
|
||||
"version": "1.0.3",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
@@ -30,8 +30,8 @@
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/interfaces/README.md",
|
||||
"devDependencies": {
|
||||
"@0x/abi-gen": "^1.0.19",
|
||||
"@0x/sol-compiler": "^1.1.16",
|
||||
"@0x/abi-gen": "^1.0.20",
|
||||
"@0x/sol-compiler": "^2.0.0",
|
||||
"@0x/tslint-config": "^2.0.0",
|
||||
"npm-run-all": "^4.1.2",
|
||||
"shx": "^0.2.2",
|
||||
@@ -41,13 +41,13 @@
|
||||
"yargs": "^10.0.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0x/base-contract": "^3.0.10",
|
||||
"@0x/contracts-libs": "^1.0.2",
|
||||
"@0x/contracts-utils": "^1.0.2",
|
||||
"@0x/types": "^1.4.1",
|
||||
"@0x/base-contract": "^3.0.11",
|
||||
"@0x/contracts-libs": "^1.0.3",
|
||||
"@0x/contracts-utils": "^1.0.3",
|
||||
"@0x/types": "^1.5.0",
|
||||
"@0x/typescript-typings": "^3.0.6",
|
||||
"@0x/utils": "^2.0.8",
|
||||
"@0x/web3-wrapper": "^3.2.1",
|
||||
"@0x/utils": "^2.1.1",
|
||||
"@0x/web3-wrapper": "^3.2.2",
|
||||
"ethereum-types": "^1.1.4",
|
||||
"lodash": "^4.17.5"
|
||||
},
|
||||
|
@@ -1,4 +1,13 @@
|
||||
[
|
||||
{
|
||||
"timestamp": 1547040760,
|
||||
"version": "1.0.3",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1544741676,
|
||||
"version": "1.0.2",
|
||||
|
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v1.0.3 - _January 9, 2019_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.0.2 - _December 13, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0x/contracts-libs",
|
||||
"version": "1.0.2",
|
||||
"version": "1.0.3",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
@@ -44,12 +44,12 @@
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/libs/README.md",
|
||||
"devDependencies": {
|
||||
"@0x/abi-gen": "^1.0.19",
|
||||
"@0x/contracts-test-utils": "^1.0.2",
|
||||
"@0x/dev-utils": "^1.0.21",
|
||||
"@0x/sol-compiler": "^1.1.16",
|
||||
"@0x/sol-cov": "^2.1.16",
|
||||
"@0x/subproviders": "^2.1.8",
|
||||
"@0x/abi-gen": "^1.0.20",
|
||||
"@0x/contracts-test-utils": "^1.0.3",
|
||||
"@0x/dev-utils": "^1.0.22",
|
||||
"@0x/sol-compiler": "^2.0.0",
|
||||
"@0x/sol-cov": "^2.1.17",
|
||||
"@0x/subproviders": "^2.1.9",
|
||||
"@0x/tslint-config": "^2.0.0",
|
||||
"@types/bn.js": "^4.11.0",
|
||||
"@types/lodash": "4.14.104",
|
||||
@@ -64,21 +64,20 @@
|
||||
"mocha": "^4.1.0",
|
||||
"npm-run-all": "^4.1.2",
|
||||
"shx": "^0.2.2",
|
||||
"solc": "^0.4.24",
|
||||
"solhint": "^1.4.1",
|
||||
"tslint": "5.11.0",
|
||||
"typescript": "3.0.1",
|
||||
"yargs": "^10.0.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0x/base-contract": "^3.0.10",
|
||||
"@0x/contracts-multisig": "^1.0.2",
|
||||
"@0x/contracts-utils": "^1.0.2",
|
||||
"@0x/order-utils": "^3.0.7",
|
||||
"@0x/types": "^1.4.1",
|
||||
"@0x/base-contract": "^3.0.11",
|
||||
"@0x/contracts-multisig": "^1.0.3",
|
||||
"@0x/contracts-utils": "^1.0.3",
|
||||
"@0x/order-utils": "^3.1.0",
|
||||
"@0x/types": "^1.5.0",
|
||||
"@0x/typescript-typings": "^3.0.6",
|
||||
"@0x/utils": "^2.0.8",
|
||||
"@0x/web3-wrapper": "^3.2.1",
|
||||
"@0x/utils": "^2.1.1",
|
||||
"@0x/web3-wrapper": "^3.2.2",
|
||||
"@types/js-combinatorics": "^0.5.29",
|
||||
"bn.js": "^4.11.8",
|
||||
"ethereum-types": "^1.1.4",
|
||||
|
@@ -1,4 +1,13 @@
|
||||
[
|
||||
{
|
||||
"timestamp": 1547040760,
|
||||
"version": "1.0.3",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1544741676,
|
||||
"version": "1.0.2",
|
||||
|
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v1.0.3 - _January 9, 2019_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.0.2 - _December 13, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0x/contracts-multisig",
|
||||
"version": "1.0.2",
|
||||
"version": "1.0.3",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
@@ -44,12 +44,12 @@
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/multisig/README.md",
|
||||
"devDependencies": {
|
||||
"@0x/abi-gen": "^1.0.19",
|
||||
"@0x/contracts-test-utils": "^1.0.2",
|
||||
"@0x/dev-utils": "^1.0.21",
|
||||
"@0x/sol-compiler": "^1.1.16",
|
||||
"@0x/sol-cov": "^2.1.16",
|
||||
"@0x/subproviders": "^2.1.8",
|
||||
"@0x/abi-gen": "^1.0.20",
|
||||
"@0x/contracts-test-utils": "^1.0.3",
|
||||
"@0x/dev-utils": "^1.0.22",
|
||||
"@0x/sol-compiler": "^2.0.0",
|
||||
"@0x/sol-cov": "^2.1.17",
|
||||
"@0x/subproviders": "^2.1.9",
|
||||
"@0x/tslint-config": "^2.0.0",
|
||||
"@types/bn.js": "^4.11.0",
|
||||
"@types/ethereumjs-abi": "^0.6.0",
|
||||
@@ -64,19 +64,18 @@
|
||||
"mocha": "^4.1.0",
|
||||
"npm-run-all": "^4.1.2",
|
||||
"shx": "^0.2.2",
|
||||
"solc": "^0.4.24",
|
||||
"solhint": "^1.4.1",
|
||||
"tslint": "5.11.0",
|
||||
"typescript": "3.0.1",
|
||||
"yargs": "^10.0.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0x/base-contract": "^3.0.10",
|
||||
"@0x/order-utils": "^3.0.7",
|
||||
"@0x/types": "^1.4.1",
|
||||
"@0x/base-contract": "^3.0.11",
|
||||
"@0x/order-utils": "^3.1.0",
|
||||
"@0x/types": "^1.5.0",
|
||||
"@0x/typescript-typings": "^3.0.6",
|
||||
"@0x/utils": "^2.0.8",
|
||||
"@0x/web3-wrapper": "^3.2.1",
|
||||
"@0x/utils": "^2.1.1",
|
||||
"@0x/web3-wrapper": "^3.2.2",
|
||||
"ethereum-types": "^1.1.4",
|
||||
"lodash": "^4.17.5"
|
||||
},
|
||||
|
@@ -14,7 +14,8 @@
|
||||
"note": "Move OrderValidator to extensions",
|
||||
"pr": 1464
|
||||
}
|
||||
]
|
||||
],
|
||||
"timestamp": 1547040760
|
||||
},
|
||||
{
|
||||
"timestamp": 1544741676,
|
||||
|
@@ -5,6 +5,12 @@ Edit the package's CHANGELOG.json file only.
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v2.2.0 - _January 9, 2019_
|
||||
|
||||
* Added LibAddressArray (#1383)
|
||||
* Add validation and comments to MultiAssetProxy (#1455)
|
||||
* Move OrderValidator to extensions (#1464)
|
||||
|
||||
## v2.1.59 - _December 13, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0x/contracts-protocol",
|
||||
"version": "2.1.59",
|
||||
"version": "2.2.0",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
@@ -44,11 +44,11 @@
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/protocol/README.md",
|
||||
"devDependencies": {
|
||||
"@0x/abi-gen": "^1.0.19",
|
||||
"@0x/dev-utils": "^1.0.21",
|
||||
"@0x/sol-compiler": "^1.1.16",
|
||||
"@0x/sol-cov": "^2.1.16",
|
||||
"@0x/subproviders": "^2.1.8",
|
||||
"@0x/abi-gen": "^1.0.20",
|
||||
"@0x/dev-utils": "^1.0.22",
|
||||
"@0x/sol-compiler": "^2.0.0",
|
||||
"@0x/sol-cov": "^2.1.17",
|
||||
"@0x/subproviders": "^2.1.9",
|
||||
"@0x/tslint-config": "^2.0.0",
|
||||
"@types/bn.js": "^4.11.0",
|
||||
"@types/lodash": "4.14.104",
|
||||
@@ -63,26 +63,25 @@
|
||||
"mocha": "^4.1.0",
|
||||
"npm-run-all": "^4.1.2",
|
||||
"shx": "^0.2.2",
|
||||
"solc": "^0.4.24",
|
||||
"solhint": "^1.4.1",
|
||||
"tslint": "5.11.0",
|
||||
"typescript": "3.0.1",
|
||||
"yargs": "^10.0.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0x/base-contract": "^3.0.10",
|
||||
"@0x/contracts-examples": "^1.0.2",
|
||||
"@0x/contracts-interfaces": "^1.0.2",
|
||||
"@0x/contracts-libs": "^1.0.2",
|
||||
"@0x/contracts-multisig": "^1.0.2",
|
||||
"@0x/contracts-test-utils": "^1.0.2",
|
||||
"@0x/contracts-tokens": "^1.0.2",
|
||||
"@0x/contracts-utils": "^1.0.2",
|
||||
"@0x/order-utils": "^3.0.7",
|
||||
"@0x/types": "^1.4.1",
|
||||
"@0x/base-contract": "^3.0.11",
|
||||
"@0x/contracts-examples": "^1.0.3",
|
||||
"@0x/contracts-interfaces": "^1.0.3",
|
||||
"@0x/contracts-libs": "^1.0.3",
|
||||
"@0x/contracts-multisig": "^1.0.3",
|
||||
"@0x/contracts-test-utils": "^1.0.3",
|
||||
"@0x/contracts-tokens": "^1.0.3",
|
||||
"@0x/contracts-utils": "^1.0.3",
|
||||
"@0x/order-utils": "^3.1.0",
|
||||
"@0x/types": "^1.5.0",
|
||||
"@0x/typescript-typings": "^3.0.6",
|
||||
"@0x/utils": "^2.0.8",
|
||||
"@0x/web3-wrapper": "^3.2.1",
|
||||
"@0x/utils": "^2.1.1",
|
||||
"@0x/web3-wrapper": "^3.2.2",
|
||||
"@types/js-combinatorics": "^0.5.29",
|
||||
"bn.js": "^4.11.8",
|
||||
"ethereum-types": "^1.1.4",
|
||||
|
@@ -715,7 +715,7 @@ describe('Asset Transfer Proxies', () => {
|
||||
const erc20AssetData = assetDataUtils.encodeERC20AssetData(erc20TokenA.address);
|
||||
const amounts = [erc20Amount];
|
||||
const nestedAssetData = [erc20AssetData];
|
||||
const assetData = assetDataInterface.MultiAsset.getABIEncodedTransactionData(amounts, nestedAssetData);
|
||||
const assetData = assetDataUtils.encodeMultiAssetData(amounts, nestedAssetData);
|
||||
const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData(
|
||||
assetData,
|
||||
fromAddress,
|
||||
@@ -778,7 +778,7 @@ describe('Asset Transfer Proxies', () => {
|
||||
const erc20AssetData2 = assetDataUtils.encodeERC20AssetData(erc20TokenA.address);
|
||||
const amounts = [erc20Amount1, erc20Amount2];
|
||||
const nestedAssetData = [erc20AssetData1, erc20AssetData2];
|
||||
const assetData = assetDataInterface.MultiAsset.getABIEncodedTransactionData(amounts, nestedAssetData);
|
||||
const assetData = assetDataUtils.encodeMultiAssetData(amounts, nestedAssetData);
|
||||
const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData(
|
||||
assetData,
|
||||
fromAddress,
|
||||
@@ -811,7 +811,7 @@ describe('Asset Transfer Proxies', () => {
|
||||
const erc20AssetData2 = assetDataUtils.encodeERC20AssetData(erc20TokenB.address);
|
||||
const amounts = [erc20Amount1, erc20Amount2];
|
||||
const nestedAssetData = [erc20AssetData1, erc20AssetData2];
|
||||
const assetData = assetDataInterface.MultiAsset.getABIEncodedTransactionData(amounts, nestedAssetData);
|
||||
const assetData = assetDataUtils.encodeMultiAssetData(amounts, nestedAssetData);
|
||||
const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData(
|
||||
assetData,
|
||||
fromAddress,
|
||||
@@ -849,7 +849,7 @@ describe('Asset Transfer Proxies', () => {
|
||||
const erc721AssetData = assetDataUtils.encodeERC721AssetData(erc721TokenA.address, erc721AFromTokenId);
|
||||
const amounts = [erc721Amount];
|
||||
const nestedAssetData = [erc721AssetData];
|
||||
const assetData = assetDataInterface.MultiAsset.getABIEncodedTransactionData(amounts, nestedAssetData);
|
||||
const assetData = assetDataUtils.encodeMultiAssetData(amounts, nestedAssetData);
|
||||
const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData(
|
||||
assetData,
|
||||
fromAddress,
|
||||
@@ -881,7 +881,7 @@ describe('Asset Transfer Proxies', () => {
|
||||
const erc721Amount = new BigNumber(1);
|
||||
const amounts = [erc721Amount, erc721Amount];
|
||||
const nestedAssetData = [erc721AssetData1, erc721AssetData2];
|
||||
const assetData = assetDataInterface.MultiAsset.getABIEncodedTransactionData(amounts, nestedAssetData);
|
||||
const assetData = assetDataUtils.encodeMultiAssetData(amounts, nestedAssetData);
|
||||
const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData(
|
||||
assetData,
|
||||
fromAddress,
|
||||
@@ -913,7 +913,7 @@ describe('Asset Transfer Proxies', () => {
|
||||
const erc721Amount = new BigNumber(1);
|
||||
const amounts = [erc721Amount, erc721Amount];
|
||||
const nestedAssetData = [erc721AssetData1, erc721AssetData2];
|
||||
const assetData = assetDataInterface.MultiAsset.getABIEncodedTransactionData(amounts, nestedAssetData);
|
||||
const assetData = assetDataUtils.encodeMultiAssetData(amounts, nestedAssetData);
|
||||
const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData(
|
||||
assetData,
|
||||
fromAddress,
|
||||
@@ -946,7 +946,7 @@ describe('Asset Transfer Proxies', () => {
|
||||
const erc721AssetData = assetDataUtils.encodeERC721AssetData(erc721TokenA.address, erc721AFromTokenId);
|
||||
const amounts = [erc20Amount, erc721Amount];
|
||||
const nestedAssetData = [erc20AssetData, erc721AssetData];
|
||||
const assetData = assetDataInterface.MultiAsset.getABIEncodedTransactionData(amounts, nestedAssetData);
|
||||
const assetData = assetDataUtils.encodeMultiAssetData(amounts, nestedAssetData);
|
||||
const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData(
|
||||
assetData,
|
||||
fromAddress,
|
||||
@@ -984,10 +984,7 @@ describe('Asset Transfer Proxies', () => {
|
||||
const amounts = [erc20Amount, erc721Amount];
|
||||
const nestedAssetData = [erc20AssetData, erc721AssetData];
|
||||
const extraData = '0102030405060708';
|
||||
const assetData = `${assetDataInterface.MultiAsset.getABIEncodedTransactionData(
|
||||
amounts,
|
||||
nestedAssetData,
|
||||
)}${extraData}`;
|
||||
const assetData = `${assetDataUtils.encodeMultiAssetData(amounts, nestedAssetData)}${extraData}`;
|
||||
const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData(
|
||||
assetData,
|
||||
fromAddress,
|
||||
@@ -1024,7 +1021,7 @@ describe('Asset Transfer Proxies', () => {
|
||||
const erc20AssetData2 = assetDataUtils.encodeERC20AssetData(erc20TokenB.address);
|
||||
const amounts = [erc20Amount1, erc20Amount2];
|
||||
const nestedAssetData = [erc20AssetData1, erc20AssetData2];
|
||||
const assetData = assetDataInterface.MultiAsset.getABIEncodedTransactionData(amounts, nestedAssetData);
|
||||
const assetData = assetDataUtils.encodeMultiAssetData(amounts, nestedAssetData);
|
||||
const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData(
|
||||
assetData,
|
||||
fromAddress,
|
||||
@@ -1085,7 +1082,7 @@ describe('Asset Transfer Proxies', () => {
|
||||
erc721AssetData3,
|
||||
erc721AssetData4,
|
||||
];
|
||||
const assetData = assetDataInterface.MultiAsset.getABIEncodedTransactionData(amounts, nestedAssetData);
|
||||
const assetData = assetDataUtils.encodeMultiAssetData(amounts, nestedAssetData);
|
||||
const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData(
|
||||
assetData,
|
||||
fromAddress,
|
||||
@@ -1143,7 +1140,7 @@ describe('Asset Transfer Proxies', () => {
|
||||
const erc721AssetData = assetDataUtils.encodeERC721AssetData(erc721TokenA.address, erc721AFromTokenId);
|
||||
const amounts = [erc20Amount, erc721Amount];
|
||||
const nestedAssetData = [erc20AssetData, erc721AssetData];
|
||||
const assetData = assetDataInterface.MultiAsset.getABIEncodedTransactionData(amounts, nestedAssetData);
|
||||
const assetData = assetDataUtils.encodeMultiAssetData(amounts, nestedAssetData);
|
||||
const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData(
|
||||
assetData,
|
||||
fromAddress,
|
||||
@@ -1169,6 +1166,7 @@ describe('Asset Transfer Proxies', () => {
|
||||
const invalidErc721AssetData = `${invalidProxyId}${erc721AssetData.slice(10)}`;
|
||||
const amounts = [erc20Amount, erc721Amount];
|
||||
const nestedAssetData = [erc20AssetData, invalidErc721AssetData];
|
||||
// HACK: This is used to get around validation built into assetDataUtils
|
||||
const assetData = assetDataInterface.MultiAsset.getABIEncodedTransactionData(amounts, nestedAssetData);
|
||||
const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData(
|
||||
assetData,
|
||||
@@ -1192,6 +1190,7 @@ describe('Asset Transfer Proxies', () => {
|
||||
const erc721AssetData = assetDataUtils.encodeERC721AssetData(erc721TokenA.address, erc721AFromTokenId);
|
||||
const amounts = [erc20Amount];
|
||||
const nestedAssetData = [erc20AssetData, erc721AssetData];
|
||||
// HACK: This is used to get around validation built into assetDataUtils
|
||||
const assetData = assetDataInterface.MultiAsset.getABIEncodedTransactionData(amounts, nestedAssetData);
|
||||
const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData(
|
||||
assetData,
|
||||
@@ -1214,7 +1213,7 @@ describe('Asset Transfer Proxies', () => {
|
||||
const erc20AssetData = assetDataUtils.encodeERC20AssetData(erc20TokenA.address);
|
||||
const amounts = [erc20Amount];
|
||||
const nestedAssetData = [erc20AssetData];
|
||||
const assetData = assetDataInterface.MultiAsset.getABIEncodedTransactionData(amounts, nestedAssetData);
|
||||
const assetData = assetDataUtils.encodeMultiAssetData(amounts, nestedAssetData);
|
||||
const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData(
|
||||
assetData,
|
||||
fromAddress,
|
||||
@@ -1238,6 +1237,7 @@ describe('Asset Transfer Proxies', () => {
|
||||
const erc721AssetData = '0x123456';
|
||||
const amounts = [erc20Amount, erc721Amount];
|
||||
const nestedAssetData = [erc20AssetData, erc721AssetData];
|
||||
// HACK: This is used to get around validation built into assetDataUtils
|
||||
const assetData = assetDataInterface.MultiAsset.getABIEncodedTransactionData(amounts, nestedAssetData);
|
||||
const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData(
|
||||
assetData,
|
||||
@@ -1262,7 +1262,7 @@ describe('Asset Transfer Proxies', () => {
|
||||
const erc721AssetData = assetDataUtils.encodeERC721AssetData(erc721TokenA.address, erc721AFromTokenId);
|
||||
const amounts = [erc20Amount, erc721Amount];
|
||||
const nestedAssetData = [erc20AssetData, erc721AssetData];
|
||||
const assetData = assetDataInterface.MultiAsset.getABIEncodedTransactionData(amounts, nestedAssetData);
|
||||
const assetData = assetDataUtils.encodeMultiAssetData(amounts, nestedAssetData);
|
||||
const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData(
|
||||
assetData,
|
||||
fromAddress,
|
||||
|
@@ -1,4 +1,3 @@
|
||||
import { artifacts as interfacesArtifacts, IAssetDataContract } from '@0x/contracts-interfaces';
|
||||
import {
|
||||
chaiSetup,
|
||||
constants,
|
||||
@@ -43,11 +42,6 @@ import { ExchangeWrapper } from '../utils/exchange_wrapper';
|
||||
chaiSetup.configure();
|
||||
const expect = chai.expect;
|
||||
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
||||
const assetDataInterface = new IAssetDataContract(
|
||||
interfacesArtifacts.IAssetData.compilerOutput.abi,
|
||||
constants.NULL_ADDRESS,
|
||||
provider,
|
||||
);
|
||||
// tslint:disable:no-unnecessary-type-assertion
|
||||
describe('Exchange core', () => {
|
||||
let makerAddress: string;
|
||||
@@ -777,10 +771,7 @@ describe('Exchange core', () => {
|
||||
assetDataUtils.encodeERC20AssetData(erc20TokenA.address),
|
||||
assetDataUtils.encodeERC20AssetData(erc20TokenB.address),
|
||||
];
|
||||
const makerAssetData = assetDataInterface.MultiAsset.getABIEncodedTransactionData(
|
||||
makerAmounts,
|
||||
makerNestedAssetData,
|
||||
);
|
||||
const makerAssetData = assetDataUtils.encodeMultiAssetData(makerAmounts, makerNestedAssetData);
|
||||
const makerAssetAmount = new BigNumber(1);
|
||||
const takerAssetData = assetDataUtils.encodeERC20AssetData(zrxToken.address);
|
||||
const takerAssetAmount = new BigNumber(10);
|
||||
@@ -830,10 +821,7 @@ describe('Exchange core', () => {
|
||||
assetDataUtils.encodeERC20AssetData(erc20TokenA.address),
|
||||
assetDataUtils.encodeERC20AssetData(erc20TokenB.address),
|
||||
];
|
||||
const makerAssetData = assetDataInterface.MultiAsset.getABIEncodedTransactionData(
|
||||
makerAmounts,
|
||||
makerNestedAssetData,
|
||||
);
|
||||
const makerAssetData = assetDataUtils.encodeMultiAssetData(makerAmounts, makerNestedAssetData);
|
||||
const makerAssetAmount = new BigNumber(1);
|
||||
const takerAmounts = [new BigNumber(10), new BigNumber(1)];
|
||||
const takerAssetId = erc721TakerAssetIds[0];
|
||||
@@ -841,10 +829,7 @@ describe('Exchange core', () => {
|
||||
assetDataUtils.encodeERC20AssetData(zrxToken.address),
|
||||
assetDataUtils.encodeERC721AssetData(erc721Token.address, takerAssetId),
|
||||
];
|
||||
const takerAssetData = assetDataInterface.MultiAsset.getABIEncodedTransactionData(
|
||||
takerAmounts,
|
||||
takerNestedAssetData,
|
||||
);
|
||||
const takerAssetData = assetDataUtils.encodeMultiAssetData(takerAmounts, takerNestedAssetData);
|
||||
const takerAssetAmount = new BigNumber(1);
|
||||
signedOrder = await orderFactory.newSignedOrderAsync({
|
||||
makerAssetData,
|
||||
@@ -900,10 +885,7 @@ describe('Exchange core', () => {
|
||||
assetDataUtils.encodeERC20AssetData(erc20TokenA.address),
|
||||
assetDataUtils.encodeERC20AssetData(erc20TokenB.address),
|
||||
];
|
||||
const makerAssetData = assetDataInterface.MultiAsset.getABIEncodedTransactionData(
|
||||
makerAmounts,
|
||||
makerNestedAssetData,
|
||||
);
|
||||
const makerAssetData = assetDataUtils.encodeMultiAssetData(makerAmounts, makerNestedAssetData);
|
||||
const makerAssetAmount = new BigNumber(30);
|
||||
const takerAssetData = assetDataUtils.encodeERC20AssetData(zrxToken.address);
|
||||
const takerAssetAmount = new BigNumber(10);
|
||||
@@ -980,10 +962,7 @@ describe('Exchange core', () => {
|
||||
assetDataUtils.encodeERC20AssetData(erc20TokenA.address),
|
||||
assetDataUtils.encodeERC20AssetData(erc20TokenB.address),
|
||||
];
|
||||
const takerAssetData = assetDataInterface.MultiAsset.getABIEncodedTransactionData(
|
||||
takerAmounts,
|
||||
takerNestedAssetData,
|
||||
);
|
||||
const takerAssetData = assetDataUtils.encodeMultiAssetData(takerAmounts, takerNestedAssetData);
|
||||
const takerAssetAmount = new BigNumber(30);
|
||||
const makerAssetData = assetDataUtils.encodeERC20AssetData(zrxToken.address);
|
||||
const makerAssetAmount = new BigNumber(10);
|
||||
|
@@ -1,4 +1,13 @@
|
||||
[
|
||||
{
|
||||
"timestamp": 1547040760,
|
||||
"version": "1.0.3",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"version": "1.0.2",
|
||||
"changes": [
|
||||
|
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v1.0.3 - _January 9, 2019_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.0.2 - _December 13, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0x/contracts-test-utils",
|
||||
"version": "1.0.2",
|
||||
"version": "1.0.3",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
@@ -40,17 +40,17 @@
|
||||
"typescript": "3.0.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0x/abi-gen": "^1.0.19",
|
||||
"@0x/dev-utils": "^1.0.21",
|
||||
"@0x/order-utils": "^3.0.7",
|
||||
"@0x/sol-compiler": "^1.1.16",
|
||||
"@0x/sol-cov": "^2.1.16",
|
||||
"@0x/subproviders": "^2.1.8",
|
||||
"@0x/abi-gen": "^1.0.20",
|
||||
"@0x/dev-utils": "^1.0.22",
|
||||
"@0x/order-utils": "^3.1.0",
|
||||
"@0x/sol-compiler": "^2.0.0",
|
||||
"@0x/sol-cov": "^2.1.17",
|
||||
"@0x/subproviders": "^2.1.9",
|
||||
"@0x/tslint-config": "^2.0.0",
|
||||
"@0x/types": "^1.4.1",
|
||||
"@0x/types": "^1.5.0",
|
||||
"@0x/typescript-typings": "^3.0.6",
|
||||
"@0x/utils": "^2.0.8",
|
||||
"@0x/web3-wrapper": "^3.2.1",
|
||||
"@0x/utils": "^2.1.1",
|
||||
"@0x/web3-wrapper": "^3.2.2",
|
||||
"@types/bn.js": "^4.11.0",
|
||||
"@types/ethereumjs-abi": "^0.6.0",
|
||||
"@types/js-combinatorics": "^0.5.29",
|
||||
|
@@ -1,4 +1,13 @@
|
||||
[
|
||||
{
|
||||
"timestamp": 1547040760,
|
||||
"version": "1.0.3",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1544741676,
|
||||
"version": "1.0.2",
|
||||
|
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v1.0.3 - _January 9, 2019_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.0.2 - _December 13, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0x/contracts-tokens",
|
||||
"version": "1.0.2",
|
||||
"version": "1.0.3",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
@@ -44,12 +44,12 @@
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/tokens/README.md",
|
||||
"devDependencies": {
|
||||
"@0x/abi-gen": "^1.0.19",
|
||||
"@0x/contracts-test-utils": "^1.0.2",
|
||||
"@0x/dev-utils": "^1.0.21",
|
||||
"@0x/sol-compiler": "^1.1.16",
|
||||
"@0x/sol-cov": "^2.1.16",
|
||||
"@0x/subproviders": "^2.1.8",
|
||||
"@0x/abi-gen": "^1.0.20",
|
||||
"@0x/contracts-test-utils": "^1.0.3",
|
||||
"@0x/dev-utils": "^1.0.22",
|
||||
"@0x/sol-compiler": "^2.0.0",
|
||||
"@0x/sol-cov": "^2.1.17",
|
||||
"@0x/subproviders": "^2.1.9",
|
||||
"@0x/tslint-config": "^2.0.0",
|
||||
"@types/bn.js": "^4.11.0",
|
||||
"@types/lodash": "4.14.104",
|
||||
@@ -64,23 +64,22 @@
|
||||
"mocha": "^4.1.0",
|
||||
"npm-run-all": "^4.1.2",
|
||||
"shx": "^0.2.2",
|
||||
"solc": "^0.4.24",
|
||||
"solhint": "^1.4.1",
|
||||
"tslint": "5.11.0",
|
||||
"typescript": "3.0.1",
|
||||
"yargs": "^10.0.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0x/base-contract": "^3.0.10",
|
||||
"@0x/contracts-interfaces": "^1.0.2",
|
||||
"@0x/contracts-libs": "^1.0.2",
|
||||
"@0x/contracts-multisig": "^1.0.2",
|
||||
"@0x/contracts-utils": "^1.0.2",
|
||||
"@0x/order-utils": "^3.0.7",
|
||||
"@0x/types": "^1.4.1",
|
||||
"@0x/base-contract": "^3.0.11",
|
||||
"@0x/contracts-interfaces": "^1.0.3",
|
||||
"@0x/contracts-libs": "^1.0.3",
|
||||
"@0x/contracts-multisig": "^1.0.3",
|
||||
"@0x/contracts-utils": "^1.0.3",
|
||||
"@0x/order-utils": "^3.1.0",
|
||||
"@0x/types": "^1.5.0",
|
||||
"@0x/typescript-typings": "^3.0.6",
|
||||
"@0x/utils": "^2.0.8",
|
||||
"@0x/web3-wrapper": "^3.2.1",
|
||||
"@0x/utils": "^2.1.1",
|
||||
"@0x/web3-wrapper": "^3.2.2",
|
||||
"@types/js-combinatorics": "^0.5.29",
|
||||
"bn.js": "^4.11.8",
|
||||
"ethereum-types": "^1.1.4",
|
||||
|
@@ -22,6 +22,7 @@ import * as UnlimitedAllowanceToken_v1 from '../../generated-artifacts/Unlimited
|
||||
import * as WETH9 from '../../generated-artifacts/WETH9.json';
|
||||
import * as ZRXToken from '../../generated-artifacts/ZRXToken.json';
|
||||
|
||||
// tslint:disable:no-unnecessary-type-assertion
|
||||
export const artifacts = {
|
||||
DummyERC20Token: DummyERC20Token as ContractArtifact,
|
||||
DummyMultipleReturnERC20Token: DummyMultipleReturnERC20Token as ContractArtifact,
|
||||
|
@@ -1,4 +1,13 @@
|
||||
[
|
||||
{
|
||||
"timestamp": 1547040760,
|
||||
"version": "1.0.3",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1544741676,
|
||||
"version": "1.0.2",
|
||||
|
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v1.0.3 - _January 9, 2019_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.0.2 - _December 13, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0x/contracts-utils",
|
||||
"version": "1.0.2",
|
||||
"version": "1.0.3",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
@@ -44,12 +44,12 @@
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/0x-monorepo/contracts/utils/README.md",
|
||||
"devDependencies": {
|
||||
"@0x/abi-gen": "^1.0.19",
|
||||
"@0x/contracts-test-utils": "^1.0.2",
|
||||
"@0x/dev-utils": "^1.0.21",
|
||||
"@0x/sol-compiler": "^1.1.16",
|
||||
"@0x/sol-cov": "^2.1.16",
|
||||
"@0x/subproviders": "^2.1.8",
|
||||
"@0x/abi-gen": "^1.0.20",
|
||||
"@0x/contracts-test-utils": "^1.0.3",
|
||||
"@0x/dev-utils": "^1.0.22",
|
||||
"@0x/sol-compiler": "^2.0.0",
|
||||
"@0x/sol-cov": "^2.1.17",
|
||||
"@0x/subproviders": "^2.1.9",
|
||||
"@0x/tslint-config": "^2.0.0",
|
||||
"@types/bn.js": "^4.11.0",
|
||||
"@types/lodash": "4.14.104",
|
||||
@@ -65,20 +65,19 @@
|
||||
"mocha": "^4.1.0",
|
||||
"npm-run-all": "^4.1.2",
|
||||
"shx": "^0.2.2",
|
||||
"solc": "^0.4.24",
|
||||
"solhint": "^1.4.1",
|
||||
"tslint": "5.11.0",
|
||||
"typescript": "3.0.1",
|
||||
"yargs": "^10.0.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0x/base-contract": "^3.0.10",
|
||||
"@0x/contracts-multisig": "^1.0.2",
|
||||
"@0x/order-utils": "^3.0.7",
|
||||
"@0x/types": "^1.4.1",
|
||||
"@0x/base-contract": "^3.0.11",
|
||||
"@0x/contracts-multisig": "^1.0.3",
|
||||
"@0x/order-utils": "^3.1.0",
|
||||
"@0x/types": "^1.5.0",
|
||||
"@0x/typescript-typings": "^3.0.6",
|
||||
"@0x/utils": "^2.0.8",
|
||||
"@0x/web3-wrapper": "^3.2.1",
|
||||
"@0x/utils": "^2.1.1",
|
||||
"@0x/web3-wrapper": "^3.2.2",
|
||||
"ethereum-types": "^1.1.4",
|
||||
"ethereumjs-util": "^5.1.1",
|
||||
"lodash": "^4.17.5"
|
||||
|
@@ -1,4 +1,15 @@
|
||||
[
|
||||
{
|
||||
"version": "3.0.0",
|
||||
"changes": [
|
||||
{
|
||||
"note":
|
||||
"Export `MultiAssetData`, `MultiAssetDataWithRecursiveDecoding`, `ObjectMap`, and `SingleAssetData` from types. No longer export `AssetData`.",
|
||||
"pr": 1363
|
||||
}
|
||||
],
|
||||
"timestamp": 1547040760
|
||||
},
|
||||
{
|
||||
"version": "2.0.8",
|
||||
"changes": [
|
||||
|
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v3.0.0 - _January 9, 2019_
|
||||
|
||||
* Export `MultiAssetData`, `MultiAssetDataWithRecursiveDecoding`, `ObjectMap`, and `SingleAssetData` from types. No longer export `AssetData`. (#1363)
|
||||
|
||||
## v2.0.8 - _December 13, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "0x.js",
|
||||
"version": "2.0.8",
|
||||
"version": "3.0.0",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
@@ -42,10 +42,10 @@
|
||||
},
|
||||
"license": "Apache-2.0",
|
||||
"devDependencies": {
|
||||
"@0x/abi-gen-wrappers": "^2.0.2",
|
||||
"@0x/contract-addresses": "^2.0.0",
|
||||
"@0x/dev-utils": "^1.0.21",
|
||||
"@0x/migrations": "^2.2.2",
|
||||
"@0x/abi-gen-wrappers": "^2.1.0",
|
||||
"@0x/contract-addresses": "^2.1.0",
|
||||
"@0x/dev-utils": "^1.0.22",
|
||||
"@0x/migrations": "^2.3.0",
|
||||
"@0x/tslint-config": "^2.0.0",
|
||||
"@types/lodash": "4.14.104",
|
||||
"@types/mocha": "^2.2.42",
|
||||
@@ -72,16 +72,16 @@
|
||||
"webpack": "^4.20.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0x/assert": "^1.0.20",
|
||||
"@0x/base-contract": "^3.0.10",
|
||||
"@0x/contract-wrappers": "^4.1.3",
|
||||
"@0x/order-utils": "^3.0.7",
|
||||
"@0x/order-watcher": "^2.2.8",
|
||||
"@0x/subproviders": "^2.1.8",
|
||||
"@0x/types": "^1.4.1",
|
||||
"@0x/assert": "^1.0.21",
|
||||
"@0x/base-contract": "^3.0.11",
|
||||
"@0x/contract-wrappers": "^4.2.0",
|
||||
"@0x/order-utils": "^3.1.0",
|
||||
"@0x/order-watcher": "^2.4.0",
|
||||
"@0x/subproviders": "^2.1.9",
|
||||
"@0x/types": "^1.5.0",
|
||||
"@0x/typescript-typings": "^3.0.6",
|
||||
"@0x/utils": "^2.0.8",
|
||||
"@0x/web3-wrapper": "^3.2.1",
|
||||
"@0x/utils": "^2.1.1",
|
||||
"@0x/web3-wrapper": "^3.2.2",
|
||||
"@types/web3-provider-engine": "^14.0.0",
|
||||
"ethereum-types": "^1.1.4",
|
||||
"ethers": "~4.0.4",
|
||||
|
@@ -4,6 +4,7 @@ export { assetDataUtils, signatureUtils, generatePseudoRandomSalt, orderHashUtil
|
||||
|
||||
export {
|
||||
ContractWrappers,
|
||||
DutchAuctionWrapper,
|
||||
ERC20TokenWrapper,
|
||||
ERC721TokenWrapper,
|
||||
EtherTokenWrapper,
|
||||
@@ -27,6 +28,7 @@ export {
|
||||
OrderAndTraderInfo,
|
||||
TraderInfo,
|
||||
ValidateOrderFillableOpts,
|
||||
DutchAuctionData,
|
||||
} from '@0x/contract-wrappers';
|
||||
|
||||
export {
|
||||
@@ -80,11 +82,16 @@ export {
|
||||
OrderState,
|
||||
AssetProxyId,
|
||||
AssetData,
|
||||
SingleAssetData,
|
||||
ERC20AssetData,
|
||||
ERC721AssetData,
|
||||
MultiAssetData,
|
||||
MultiAssetDataWithRecursiveDecoding,
|
||||
SignatureType,
|
||||
ObjectMap,
|
||||
OrderRelevantState,
|
||||
Stats,
|
||||
DutchAuctionDetails,
|
||||
} from '@0x/types';
|
||||
|
||||
export {
|
||||
|
@@ -1,4 +1,14 @@
|
||||
[
|
||||
{
|
||||
"version": "2.1.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Added Dutch Auction Wrapper",
|
||||
"pr": 1465
|
||||
}
|
||||
],
|
||||
"timestamp": 1547040760
|
||||
},
|
||||
{
|
||||
"version": "2.0.2",
|
||||
"changes": [
|
||||
|
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v2.1.0 - _January 9, 2019_
|
||||
|
||||
* Added Dutch Auction Wrapper (#1465)
|
||||
|
||||
## v2.0.2 - _December 13, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0x/abi-gen-wrappers",
|
||||
"version": "2.0.2",
|
||||
"version": "2.1.0",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
@@ -18,7 +18,7 @@
|
||||
"generate_contract_wrappers": "abi-gen --abis ${npm_package_config_abis} --template ../../node_modules/@0x/abi-gen-templates/contract.handlebars --partials '../../node_modules/@0x/abi-gen-templates/partials/**/*.handlebars' --output src/generated-wrappers --backend ethers"
|
||||
},
|
||||
"config": {
|
||||
"abis": "../contract-artifacts/artifacts/@(AssetProxyOwner|DummyERC20Token|DummyERC721Token|ERC20Proxy|ERC20Token|ERC721Proxy|ERC721Token|Exchange|Forwarder|IValidator|IWallet|OrderValidator|WETH9|ZRXToken).json"
|
||||
"abis": "../contract-artifacts/artifacts/@(AssetProxyOwner|DutchAuction|DummyERC20Token|DummyERC721Token|ERC20Proxy|ERC20Token|ERC721Proxy|ERC721Token|Exchange|Forwarder|IValidator|IWallet|OrderValidator|WETH9|ZRXToken).json"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -30,19 +30,19 @@
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/0x-monorepo/packages/abi-gen-wrappers/README.md",
|
||||
"devDependencies": {
|
||||
"@0x/abi-gen": "^1.0.19",
|
||||
"@0x/abi-gen": "^1.0.20",
|
||||
"@0x/abi-gen-templates": "^1.0.1",
|
||||
"@0x/tslint-config": "^2.0.0",
|
||||
"@0x/types": "^1.4.1",
|
||||
"@0x/utils": "^2.0.8",
|
||||
"@0x/web3-wrapper": "^3.2.1",
|
||||
"@0x/types": "^1.5.0",
|
||||
"@0x/utils": "^2.1.1",
|
||||
"@0x/web3-wrapper": "^3.2.2",
|
||||
"ethereum-types": "^1.1.4",
|
||||
"ethers": "~4.0.4",
|
||||
"lodash": "^4.17.5",
|
||||
"shx": "^0.2.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0x/base-contract": "^3.0.10"
|
||||
"@0x/base-contract": "^3.0.11"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
|
@@ -0,0 +1,322 @@
|
||||
// tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma whitespace class-name
|
||||
// tslint:disable:no-unused-variable
|
||||
// tslint:disable:no-unbound-method
|
||||
import { BaseContract } from '@0x/base-contract';
|
||||
import { BlockParam, BlockParamLiteral, CallData, ContractAbi, ContractArtifact, DecodedLogArgs, MethodAbi, Provider, TxData, TxDataPayable } from 'ethereum-types';
|
||||
import { BigNumber, classUtils, logUtils } from '@0x/utils';
|
||||
import { SimpleContractArtifact } from '@0x/types';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import * as ethers from 'ethers';
|
||||
import * as _ from 'lodash';
|
||||
// tslint:enable:no-unused-variable
|
||||
|
||||
|
||||
/* istanbul ignore next */
|
||||
// tslint:disable:no-parameter-reassignment
|
||||
// tslint:disable-next-line:class-name
|
||||
export class DutchAuctionContract extends BaseContract {
|
||||
public getAuctionDetails = {
|
||||
async sendTransactionAsync(
|
||||
order: {makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string},
|
||||
txData: Partial<TxData> = {},
|
||||
): Promise<string> {
|
||||
const self = this as any as DutchAuctionContract;
|
||||
const inputAbi = self._lookupAbi('getAuctionDetails({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes})').inputs;
|
||||
[order
|
||||
] = BaseContract._formatABIDataItemList(inputAbi, [order
|
||||
], BaseContract._bigNumberToString.bind(self));
|
||||
BaseContract.strictArgumentEncodingCheck(inputAbi, [order
|
||||
]);
|
||||
const encodedData = self._lookupEthersInterface('getAuctionDetails({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes})').functions.getAuctionDetails.encode([order
|
||||
]);
|
||||
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||
{
|
||||
to: self.address,
|
||||
...txData,
|
||||
data: encodedData,
|
||||
},
|
||||
self._web3Wrapper.getContractDefaults(),
|
||||
self.getAuctionDetails.estimateGasAsync.bind(
|
||||
self,
|
||||
order
|
||||
),
|
||||
);
|
||||
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||
return txHash;
|
||||
},
|
||||
async estimateGasAsync(
|
||||
order: {makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string},
|
||||
txData: Partial<TxData> = {},
|
||||
): Promise<number> {
|
||||
const self = this as any as DutchAuctionContract;
|
||||
const inputAbi = self._lookupAbi('getAuctionDetails({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes})').inputs;
|
||||
[order
|
||||
] = BaseContract._formatABIDataItemList(inputAbi, [order
|
||||
], BaseContract._bigNumberToString);
|
||||
const encodedData = self._lookupEthersInterface('getAuctionDetails({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes})').functions.getAuctionDetails.encode([order
|
||||
]);
|
||||
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||
{
|
||||
to: self.address,
|
||||
...txData,
|
||||
data: encodedData,
|
||||
},
|
||||
self._web3Wrapper.getContractDefaults(),
|
||||
);
|
||||
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
||||
return gas;
|
||||
},
|
||||
getABIEncodedTransactionData(
|
||||
order: {makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string},
|
||||
): string {
|
||||
const self = this as any as DutchAuctionContract;
|
||||
const inputAbi = self._lookupAbi('getAuctionDetails({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes})').inputs;
|
||||
[order
|
||||
] = BaseContract._formatABIDataItemList(inputAbi, [order
|
||||
], BaseContract._bigNumberToString);
|
||||
const abiEncodedTransactionData = self._lookupEthersInterface('getAuctionDetails({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes})').functions.getAuctionDetails.encode([order
|
||||
]);
|
||||
return abiEncodedTransactionData;
|
||||
},
|
||||
async callAsync(
|
||||
order: {makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string},
|
||||
callData: Partial<CallData> = {},
|
||||
defaultBlock?: BlockParam,
|
||||
): Promise<{beginTimeSeconds: BigNumber;endTimeSeconds: BigNumber;beginAmount: BigNumber;endAmount: BigNumber;currentAmount: BigNumber;currentTimeSeconds: BigNumber}
|
||||
> {
|
||||
const self = this as any as DutchAuctionContract;
|
||||
const functionSignature = 'getAuctionDetails({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes})';
|
||||
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||
[order
|
||||
] = BaseContract._formatABIDataItemList(inputAbi, [order
|
||||
], BaseContract._bigNumberToString.bind(self));
|
||||
BaseContract.strictArgumentEncodingCheck(inputAbi, [order
|
||||
]);
|
||||
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.getAuctionDetails;
|
||||
const encodedData = ethersFunction.encode([order
|
||||
]);
|
||||
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||
{
|
||||
to: self.address,
|
||||
...callData,
|
||||
data: encodedData,
|
||||
},
|
||||
self._web3Wrapper.getContractDefaults(),
|
||||
);
|
||||
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||
let resultArray = ethersFunction.decode(rawCallResult);
|
||||
const outputAbi = (_.find(self.abi, {name: 'getAuctionDetails'}) as MethodAbi).outputs;
|
||||
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||
return resultArray[0];
|
||||
},
|
||||
};
|
||||
public matchOrders = {
|
||||
async sendTransactionAsync(
|
||||
buyOrder: {makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string},
|
||||
sellOrder: {makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string},
|
||||
buySignature: string,
|
||||
sellSignature: string,
|
||||
txData: Partial<TxData> = {},
|
||||
): Promise<string> {
|
||||
const self = this as any as DutchAuctionContract;
|
||||
const inputAbi = self._lookupAbi('matchOrders({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},{address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},bytes,bytes)').inputs;
|
||||
[buyOrder,
|
||||
sellOrder,
|
||||
buySignature,
|
||||
sellSignature
|
||||
] = BaseContract._formatABIDataItemList(inputAbi, [buyOrder,
|
||||
sellOrder,
|
||||
buySignature,
|
||||
sellSignature
|
||||
], BaseContract._bigNumberToString.bind(self));
|
||||
BaseContract.strictArgumentEncodingCheck(inputAbi, [buyOrder,
|
||||
sellOrder,
|
||||
buySignature,
|
||||
sellSignature
|
||||
]);
|
||||
const encodedData = self._lookupEthersInterface('matchOrders({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},{address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},bytes,bytes)').functions.matchOrders.encode([buyOrder,
|
||||
sellOrder,
|
||||
buySignature,
|
||||
sellSignature
|
||||
]);
|
||||
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||
{
|
||||
to: self.address,
|
||||
...txData,
|
||||
data: encodedData,
|
||||
},
|
||||
self._web3Wrapper.getContractDefaults(),
|
||||
self.matchOrders.estimateGasAsync.bind(
|
||||
self,
|
||||
buyOrder,
|
||||
sellOrder,
|
||||
buySignature,
|
||||
sellSignature
|
||||
),
|
||||
);
|
||||
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||
return txHash;
|
||||
},
|
||||
async estimateGasAsync(
|
||||
buyOrder: {makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string},
|
||||
sellOrder: {makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string},
|
||||
buySignature: string,
|
||||
sellSignature: string,
|
||||
txData: Partial<TxData> = {},
|
||||
): Promise<number> {
|
||||
const self = this as any as DutchAuctionContract;
|
||||
const inputAbi = self._lookupAbi('matchOrders({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},{address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},bytes,bytes)').inputs;
|
||||
[buyOrder,
|
||||
sellOrder,
|
||||
buySignature,
|
||||
sellSignature
|
||||
] = BaseContract._formatABIDataItemList(inputAbi, [buyOrder,
|
||||
sellOrder,
|
||||
buySignature,
|
||||
sellSignature
|
||||
], BaseContract._bigNumberToString);
|
||||
const encodedData = self._lookupEthersInterface('matchOrders({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},{address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},bytes,bytes)').functions.matchOrders.encode([buyOrder,
|
||||
sellOrder,
|
||||
buySignature,
|
||||
sellSignature
|
||||
]);
|
||||
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||
{
|
||||
to: self.address,
|
||||
...txData,
|
||||
data: encodedData,
|
||||
},
|
||||
self._web3Wrapper.getContractDefaults(),
|
||||
);
|
||||
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
||||
return gas;
|
||||
},
|
||||
getABIEncodedTransactionData(
|
||||
buyOrder: {makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string},
|
||||
sellOrder: {makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string},
|
||||
buySignature: string,
|
||||
sellSignature: string,
|
||||
): string {
|
||||
const self = this as any as DutchAuctionContract;
|
||||
const inputAbi = self._lookupAbi('matchOrders({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},{address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},bytes,bytes)').inputs;
|
||||
[buyOrder,
|
||||
sellOrder,
|
||||
buySignature,
|
||||
sellSignature
|
||||
] = BaseContract._formatABIDataItemList(inputAbi, [buyOrder,
|
||||
sellOrder,
|
||||
buySignature,
|
||||
sellSignature
|
||||
], BaseContract._bigNumberToString);
|
||||
const abiEncodedTransactionData = self._lookupEthersInterface('matchOrders({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},{address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},bytes,bytes)').functions.matchOrders.encode([buyOrder,
|
||||
sellOrder,
|
||||
buySignature,
|
||||
sellSignature
|
||||
]);
|
||||
return abiEncodedTransactionData;
|
||||
},
|
||||
async callAsync(
|
||||
buyOrder: {makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string},
|
||||
sellOrder: {makerAddress: string;takerAddress: string;feeRecipientAddress: string;senderAddress: string;makerAssetAmount: BigNumber;takerAssetAmount: BigNumber;makerFee: BigNumber;takerFee: BigNumber;expirationTimeSeconds: BigNumber;salt: BigNumber;makerAssetData: string;takerAssetData: string},
|
||||
buySignature: string,
|
||||
sellSignature: string,
|
||||
callData: Partial<CallData> = {},
|
||||
defaultBlock?: BlockParam,
|
||||
): Promise<{left: {makerAssetFilledAmount: BigNumber;takerAssetFilledAmount: BigNumber;makerFeePaid: BigNumber;takerFeePaid: BigNumber};right: {makerAssetFilledAmount: BigNumber;takerAssetFilledAmount: BigNumber;makerFeePaid: BigNumber;takerFeePaid: BigNumber};leftMakerAssetSpreadAmount: BigNumber}
|
||||
> {
|
||||
const self = this as any as DutchAuctionContract;
|
||||
const functionSignature = 'matchOrders({address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},{address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes},bytes,bytes)';
|
||||
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
||||
[buyOrder,
|
||||
sellOrder,
|
||||
buySignature,
|
||||
sellSignature
|
||||
] = BaseContract._formatABIDataItemList(inputAbi, [buyOrder,
|
||||
sellOrder,
|
||||
buySignature,
|
||||
sellSignature
|
||||
], BaseContract._bigNumberToString.bind(self));
|
||||
BaseContract.strictArgumentEncodingCheck(inputAbi, [buyOrder,
|
||||
sellOrder,
|
||||
buySignature,
|
||||
sellSignature
|
||||
]);
|
||||
const ethersFunction = self._lookupEthersInterface(functionSignature).functions.matchOrders;
|
||||
const encodedData = ethersFunction.encode([buyOrder,
|
||||
sellOrder,
|
||||
buySignature,
|
||||
sellSignature
|
||||
]);
|
||||
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||
{
|
||||
to: self.address,
|
||||
...callData,
|
||||
data: encodedData,
|
||||
},
|
||||
self._web3Wrapper.getContractDefaults(),
|
||||
);
|
||||
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||
let resultArray = ethersFunction.decode(rawCallResult);
|
||||
const outputAbi = (_.find(self.abi, {name: 'matchOrders'}) as MethodAbi).outputs;
|
||||
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._lowercaseAddress.bind(this));
|
||||
resultArray = BaseContract._formatABIDataItemList(outputAbi, resultArray, BaseContract._bnToBigNumber.bind(this));
|
||||
return resultArray[0];
|
||||
},
|
||||
};
|
||||
public static async deployFrom0xArtifactAsync(
|
||||
artifact: ContractArtifact | SimpleContractArtifact,
|
||||
provider: Provider,
|
||||
txDefaults: Partial<TxData>,
|
||||
_exchange: string,
|
||||
): Promise<DutchAuctionContract> {
|
||||
if (_.isUndefined(artifact.compilerOutput)) {
|
||||
throw new Error('Compiler output not found in the artifact file');
|
||||
}
|
||||
const bytecode = artifact.compilerOutput.evm.bytecode.object;
|
||||
const abi = artifact.compilerOutput.abi;
|
||||
return DutchAuctionContract.deployAsync(bytecode, abi, provider, txDefaults, _exchange
|
||||
);
|
||||
}
|
||||
public static async deployAsync(
|
||||
bytecode: string,
|
||||
abi: ContractAbi,
|
||||
provider: Provider,
|
||||
txDefaults: Partial<TxData>,
|
||||
_exchange: string,
|
||||
): Promise<DutchAuctionContract> {
|
||||
const constructorAbi = BaseContract._lookupConstructorAbi(abi);
|
||||
[_exchange
|
||||
] = BaseContract._formatABIDataItemList(
|
||||
constructorAbi.inputs,
|
||||
[_exchange
|
||||
],
|
||||
BaseContract._bigNumberToString,
|
||||
);
|
||||
const iface = new ethers.utils.Interface(abi);
|
||||
const deployInfo = iface.deployFunction;
|
||||
const txData = deployInfo.encode(bytecode, [_exchange
|
||||
]);
|
||||
const web3Wrapper = new Web3Wrapper(provider);
|
||||
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||
{data: txData},
|
||||
txDefaults,
|
||||
web3Wrapper.estimateGasAsync.bind(web3Wrapper),
|
||||
);
|
||||
const txHash = await web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||
logUtils.log(`transactionHash: ${txHash}`);
|
||||
const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
|
||||
logUtils.log(`DutchAuction successfully deployed at ${txReceipt.contractAddress}`);
|
||||
const contractInstance = new DutchAuctionContract(abi, txReceipt.contractAddress as string, provider, txDefaults);
|
||||
contractInstance.constructorArgs = [_exchange
|
||||
];
|
||||
return contractInstance;
|
||||
}
|
||||
constructor(abi: ContractAbi, address: string, provider: Provider, txDefaults?: Partial<TxData>) {
|
||||
super('DutchAuction', abi, address, provider, txDefaults);
|
||||
classUtils.bindAll(this, ['_ethersInterfacesByFunctionSignature', 'address', 'abi', '_web3Wrapper']);
|
||||
}
|
||||
} // tslint:disable:max-file-line-count
|
||||
// tslint:enable:no-unbound-method
|
@@ -1,6 +1,7 @@
|
||||
export * from './generated-wrappers/asset_proxy_owner';
|
||||
export * from './generated-wrappers/dummy_erc20_token';
|
||||
export * from './generated-wrappers/dummy_erc721_token';
|
||||
export * from './generated-wrappers/dutch_auction';
|
||||
export * from './generated-wrappers/erc20_proxy';
|
||||
export * from './generated-wrappers/erc20_token';
|
||||
export * from './generated-wrappers/erc721_proxy';
|
||||
|
@@ -1,4 +1,13 @@
|
||||
[
|
||||
{
|
||||
"timestamp": 1547040760,
|
||||
"version": "1.0.20",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"version": "1.0.19",
|
||||
"changes": [
|
||||
|
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v1.0.20 - _January 9, 2019_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.0.19 - _December 13, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0x/abi-gen",
|
||||
"version": "1.0.19",
|
||||
"version": "1.0.20",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
@@ -32,7 +32,7 @@
|
||||
"homepage": "https://github.com/0xProject/0x-monorepo/packages/abi-gen/README.md",
|
||||
"dependencies": {
|
||||
"@0x/typescript-typings": "^3.0.6",
|
||||
"@0x/utils": "^2.0.8",
|
||||
"@0x/utils": "^2.1.1",
|
||||
"chalk": "^2.3.0",
|
||||
"ethereum-types": "^1.1.4",
|
||||
"glob": "^7.1.2",
|
||||
|
@@ -1,4 +1,13 @@
|
||||
[
|
||||
{
|
||||
"timestamp": 1547040760,
|
||||
"version": "1.0.21",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"version": "1.0.20",
|
||||
"changes": [
|
||||
|
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v1.0.21 - _January 9, 2019_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.0.20 - _December 13, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0x/assert",
|
||||
"version": "1.0.20",
|
||||
"version": "1.0.21",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
@@ -44,9 +44,9 @@
|
||||
"typescript": "3.0.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0x/json-schemas": "^2.1.4",
|
||||
"@0x/json-schemas": "^2.1.5",
|
||||
"@0x/typescript-typings": "^3.0.6",
|
||||
"@0x/utils": "^2.0.8",
|
||||
"@0x/utils": "^2.1.1",
|
||||
"lodash": "^4.17.5",
|
||||
"valid-url": "^1.0.9"
|
||||
},
|
||||
|
@@ -1,4 +1,13 @@
|
||||
[
|
||||
{
|
||||
"timestamp": 1547040760,
|
||||
"version": "3.0.5",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"version": "3.0.4",
|
||||
"changes": [
|
||||
|
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v3.0.5 - _January 9, 2019_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v3.0.4 - _December 13, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
@@ -1,7 +1,5 @@
|
||||
## @0x/asset-buyer
|
||||
|
||||
**Warning: In Beta, has not been extensively tested.**
|
||||
|
||||
Convenience package for buying assets represented on the Ethereum blockchain using 0x. In its simplest form, the package helps in the usage of the [0x forwarder contract](https://github.com/0xProject/0x-protocol-specification/blob/master/v2/forwarder-specification.md), which allows users to execute [Wrapped Ether](https://weth.io/) based 0x orders without having to set allowances, wrap Ether or own ZRX, meaning they can buy tokens with Ether alone. Given some liquidity (0x signed orders), it helps estimate the Ether cost of buying a certain asset (giving a range) and then buying that asset.
|
||||
|
||||
In its more advanced and useful form, it integrates with the [Standard Relayer API](https://github.com/0xProject/standard-relayer-api) and takes care of sourcing liquidity for you given an SRA compliant endpoint. The final result is a library that tells you what assets are available, provides an Ether based quote for any asset desired, and allows you to buy that asset using Ether alone.
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0x/asset-buyer",
|
||||
"version": "3.0.4",
|
||||
"version": "3.0.5",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
@@ -36,16 +36,16 @@
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/0x-monorepo/packages/asset-buyer/README.md",
|
||||
"dependencies": {
|
||||
"@0x/assert": "^1.0.20",
|
||||
"@0x/connect": "^3.0.10",
|
||||
"@0x/contract-wrappers": "^4.1.3",
|
||||
"@0x/json-schemas": "^2.1.4",
|
||||
"@0x/order-utils": "^3.0.7",
|
||||
"@0x/subproviders": "^2.1.8",
|
||||
"@0x/types": "^1.4.1",
|
||||
"@0x/assert": "^1.0.21",
|
||||
"@0x/connect": "^3.0.11",
|
||||
"@0x/contract-wrappers": "^4.2.0",
|
||||
"@0x/json-schemas": "^2.1.5",
|
||||
"@0x/order-utils": "^3.1.0",
|
||||
"@0x/subproviders": "^2.1.9",
|
||||
"@0x/types": "^1.5.0",
|
||||
"@0x/typescript-typings": "^3.0.6",
|
||||
"@0x/utils": "^2.0.8",
|
||||
"@0x/web3-wrapper": "^3.2.1",
|
||||
"@0x/utils": "^2.1.1",
|
||||
"@0x/web3-wrapper": "^3.2.2",
|
||||
"ethereum-types": "^1.1.4",
|
||||
"lodash": "^4.17.5"
|
||||
},
|
||||
|
@@ -1,4 +1,13 @@
|
||||
[
|
||||
{
|
||||
"timestamp": 1547040760,
|
||||
"version": "3.0.11",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"version": "3.0.10",
|
||||
"changes": [
|
||||
|
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v3.0.11 - _January 9, 2019_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v3.0.10 - _December 13, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0x/base-contract",
|
||||
"version": "3.0.10",
|
||||
"version": "3.0.11",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
@@ -41,8 +41,8 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@0x/typescript-typings": "^3.0.6",
|
||||
"@0x/utils": "^2.0.8",
|
||||
"@0x/web3-wrapper": "^3.2.1",
|
||||
"@0x/utils": "^2.1.1",
|
||||
"@0x/web3-wrapper": "^3.2.2",
|
||||
"ethereum-types": "^1.1.4",
|
||||
"ethers": "~4.0.4",
|
||||
"lodash": "^4.17.5"
|
||||
|
@@ -1,4 +1,13 @@
|
||||
[
|
||||
{
|
||||
"timestamp": 1547040760,
|
||||
"version": "3.0.11",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"version": "3.0.10",
|
||||
"changes": [
|
||||
|
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v3.0.11 - _January 9, 2019_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v3.0.10 - _December 13, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0x/connect",
|
||||
"version": "3.0.10",
|
||||
"version": "3.0.11",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
@@ -44,12 +44,12 @@
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/0x-monorepo/packages/connect/README.md",
|
||||
"dependencies": {
|
||||
"@0x/assert": "^1.0.20",
|
||||
"@0x/json-schemas": "^2.1.4",
|
||||
"@0x/order-utils": "^3.0.7",
|
||||
"@0x/types": "^1.4.1",
|
||||
"@0x/assert": "^1.0.21",
|
||||
"@0x/json-schemas": "^2.1.5",
|
||||
"@0x/order-utils": "^3.1.0",
|
||||
"@0x/types": "^1.5.0",
|
||||
"@0x/typescript-typings": "^3.0.6",
|
||||
"@0x/utils": "^2.0.8",
|
||||
"@0x/utils": "^2.1.1",
|
||||
"lodash": "^4.17.5",
|
||||
"query-string": "^5.0.1",
|
||||
"sinon": "^4.0.0",
|
||||
|
@@ -1,4 +1,14 @@
|
||||
[
|
||||
{
|
||||
"version": "2.1.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Added testnet entries for Dutch Auction contract (kovan,rinkeby,ropsten)",
|
||||
"pr": 1465
|
||||
}
|
||||
],
|
||||
"timestamp": 1547040760
|
||||
},
|
||||
{
|
||||
"version": "2.0.0",
|
||||
"changes": [
|
||||
|
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v2.1.0 - _January 9, 2019_
|
||||
|
||||
* Added testnet entries for Dutch Auction contract (kovan,rinkeby,ropsten) (#1465)
|
||||
|
||||
## v2.0.0 - _November 28, 2018_
|
||||
|
||||
* Redeployed Rinkeby with testnet Exchange artifact (#1318)
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0x/contract-addresses",
|
||||
"version": "2.0.0",
|
||||
"version": "2.1.0",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
|
@@ -9,6 +9,7 @@ export interface ContractAddresses {
|
||||
assetProxyOwner: string;
|
||||
forwarder: string;
|
||||
orderValidator: string;
|
||||
dutchAuction: string;
|
||||
}
|
||||
|
||||
export enum NetworkId {
|
||||
@@ -19,6 +20,8 @@ export enum NetworkId {
|
||||
Ganache = 50,
|
||||
}
|
||||
|
||||
const NULL_ADDRESS = '0x0000000000000000000000000000000000000000';
|
||||
|
||||
const networkToAddresses: { [networkId: number]: ContractAddresses } = {
|
||||
1: {
|
||||
erc20Proxy: '0x2240dab907db71e64d3e0dba4800c83b5c502d4e',
|
||||
@@ -29,6 +32,8 @@ const networkToAddresses: { [networkId: number]: ContractAddresses } = {
|
||||
assetProxyOwner: '0x17992e4ffb22730138e4b62aaa6367fa9d3699a6',
|
||||
forwarder: '0x5468a1dc173652ee28d249c271fa9933144746b1',
|
||||
orderValidator: '0x9463e518dea6810309563c81d5266c1b1d149138',
|
||||
// @todo hysz/dekz: Add mainnet address once deployed.
|
||||
dutchAuction: NULL_ADDRESS,
|
||||
},
|
||||
3: {
|
||||
erc20Proxy: '0xb1408f4c245a23c31b98d2c626777d4c0d766caa',
|
||||
@@ -39,6 +44,7 @@ const networkToAddresses: { [networkId: number]: ContractAddresses } = {
|
||||
assetProxyOwner: '0xf5fa5b5fed2727a0e44ac67f6772e97977aa358b',
|
||||
forwarder: '0x2240dab907db71e64d3e0dba4800c83b5c502d4e',
|
||||
orderValidator: '0x90431a90516ab49af23a0530e04e8c7836e7122f',
|
||||
dutchAuction: '0x2df6b59309f35ada230ec7d61d7d97355017a1df',
|
||||
},
|
||||
4: {
|
||||
exchange: '0xbce0b5f6eb618c565c3e5f5cd69652bbc279f44e',
|
||||
@@ -49,6 +55,7 @@ const networkToAddresses: { [networkId: number]: ContractAddresses } = {
|
||||
assetProxyOwner: '0xe1703da878afcebff5b7624a826902af475b9c03',
|
||||
forwarder: '0x2d40589abbdee84961f3a7656b9af7adb0ee5ab4',
|
||||
orderValidator: '0x0c5173a51e26b29d6126c686756fb9fbef71f762',
|
||||
dutchAuction: '0xdd7bd6437e67c422879364740ab5855fe3dc41f7',
|
||||
},
|
||||
42: {
|
||||
erc20Proxy: '0xf1ec01d6236d3cd881a0bf0130ea25fe4234003e',
|
||||
@@ -59,6 +66,7 @@ const networkToAddresses: { [networkId: number]: ContractAddresses } = {
|
||||
assetProxyOwner: '0x2c824d2882baa668e0d5202b1e7f2922278703f8',
|
||||
forwarder: '0x17992e4ffb22730138e4b62aaa6367fa9d3699a6',
|
||||
orderValidator: '0xb389da3d204b412df2f75c6afb3d0a7ce0bc283d',
|
||||
dutchAuction: '0xe11667fb51f34c5367f40d7e379327ce32ee7150',
|
||||
},
|
||||
// NetworkId 50 represents our Ganache snapshot generated from migrations.
|
||||
50: {
|
||||
@@ -70,6 +78,7 @@ const networkToAddresses: { [networkId: number]: ContractAddresses } = {
|
||||
assetProxyOwner: '0x34d402f14d58e001d8efbe6585051bf9706aa064',
|
||||
forwarder: '0xb69e673309512a9d726f87304c6984054f87a93b',
|
||||
orderValidator: '0xe86bb98fcf9bff3512c74589b78fb168200cc546',
|
||||
dutchAuction: '0xdc688d29394a3f1e6f1e5100862776691afaf3d2',
|
||||
},
|
||||
};
|
||||
|
||||
|
@@ -1,4 +1,14 @@
|
||||
[
|
||||
{
|
||||
"version": "1.2.0",
|
||||
"changes": [
|
||||
{
|
||||
"pr": 1465,
|
||||
"note": "Added artifact for Dutch Auction contract"
|
||||
}
|
||||
],
|
||||
"timestamp": 1547040760
|
||||
},
|
||||
{
|
||||
"version": "1.1.2",
|
||||
"changes": [
|
||||
|
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v1.2.0 - _January 9, 2019_
|
||||
|
||||
* Added artifact for Dutch Auction contract (#1465)
|
||||
|
||||
## v1.1.2 - _November 28, 2018_
|
||||
|
||||
* Update Exchange artifact to receive ZRX asset data as a constructor argument (#1309)
|
||||
|
310
packages/contract-artifacts/artifacts/DutchAuction.json
generated
Normal file
310
packages/contract-artifacts/artifacts/DutchAuction.json
generated
Normal file
File diff suppressed because one or more lines are too long
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0x/contract-artifacts",
|
||||
"version": "1.1.2",
|
||||
"version": "1.2.0",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
|
@@ -1,4 +1,5 @@
|
||||
import * as AssetProxyOwner from '../artifacts/AssetProxyOwner.json';
|
||||
import * as DutchAuction from '../artifacts/DutchAuction.json';
|
||||
import * as DummyERC20Token from '../artifacts/DummyERC20Token.json';
|
||||
import * as DummyERC721Token from '../artifacts/DummyERC721Token.json';
|
||||
import * as ERC20Proxy from '../artifacts/ERC20Proxy.json';
|
||||
@@ -15,6 +16,7 @@ import * as ZRXToken from '../artifacts/ZRXToken.json';
|
||||
|
||||
export {
|
||||
AssetProxyOwner,
|
||||
DutchAuction,
|
||||
DummyERC20Token,
|
||||
DummyERC721Token,
|
||||
ERC20Proxy,
|
||||
|
@@ -8,6 +8,7 @@
|
||||
"include": ["./src/**/*"],
|
||||
"files": [
|
||||
"./artifacts/AssetProxyOwner.json",
|
||||
"./artifacts/DutchAuction.json",
|
||||
"./artifacts/DummyERC20Token.json",
|
||||
"./artifacts/DummyERC721Token.json",
|
||||
"./artifacts/ERC20Proxy.json",
|
||||
|
@@ -1,9 +1,23 @@
|
||||
[
|
||||
{
|
||||
"version": "4.2.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Added Dutch Auction wrapper",
|
||||
"pr": 1465
|
||||
}
|
||||
],
|
||||
"timestamp": 1547040760
|
||||
},
|
||||
{
|
||||
"version": "4.1.4",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Add support for Trust Wallet signature denial error"
|
||||
},
|
||||
{
|
||||
"note": "Add balance and allowance queries for `MultiAssetProxy`",
|
||||
"pr": 1363
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@@ -5,6 +5,15 @@ Edit the package's CHANGELOG.json file only.
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v4.2.0 - _January 9, 2019_
|
||||
|
||||
* Added Dutch Auction wrapper (#1465)
|
||||
|
||||
## v4.1.4 - _Invalid date_
|
||||
|
||||
* Add support for Trust Wallet signature denial error
|
||||
* Add balance and allowance queries for `MultiAssetProxy` (#1363)
|
||||
|
||||
## v4.1.3 - _December 13, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0x/contract-wrappers",
|
||||
"version": "4.1.3",
|
||||
"version": "4.2.0",
|
||||
"description": "Smart TS wrappers for 0x smart contracts",
|
||||
"keywords": [
|
||||
"0xproject",
|
||||
@@ -37,9 +37,9 @@
|
||||
"node": ">=6.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@0x/dev-utils": "^1.0.21",
|
||||
"@0x/migrations": "^2.2.2",
|
||||
"@0x/subproviders": "^2.1.8",
|
||||
"@0x/dev-utils": "^1.0.22",
|
||||
"@0x/migrations": "^2.3.0",
|
||||
"@0x/subproviders": "^2.1.9",
|
||||
"@0x/tslint-config": "^2.0.0",
|
||||
"@types/lodash": "4.14.104",
|
||||
"@types/mocha": "^2.2.42",
|
||||
@@ -65,18 +65,20 @@
|
||||
"web3-provider-engine": "14.0.6"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0x/abi-gen-wrappers": "^2.0.2",
|
||||
"@0x/assert": "^1.0.20",
|
||||
"@0x/contract-addresses": "^2.0.0",
|
||||
"@0x/contract-artifacts": "^1.1.2",
|
||||
"@0x/fill-scenarios": "^1.0.16",
|
||||
"@0x/json-schemas": "^2.1.4",
|
||||
"@0x/order-utils": "^3.0.7",
|
||||
"@0x/types": "^1.4.1",
|
||||
"@0x/abi-gen-wrappers": "^2.1.0",
|
||||
"@0x/assert": "^1.0.21",
|
||||
"@0x/contract-addresses": "^2.1.0",
|
||||
"@0x/contract-artifacts": "^1.2.0",
|
||||
"@0x/contracts-test-utils": "^1.0.3",
|
||||
"@0x/fill-scenarios": "^1.1.0",
|
||||
"@0x/json-schemas": "^2.1.5",
|
||||
"@0x/order-utils": "^3.1.0",
|
||||
"@0x/types": "^1.5.0",
|
||||
"@0x/typescript-typings": "^3.0.6",
|
||||
"@0x/utils": "^2.0.8",
|
||||
"@0x/web3-wrapper": "^3.2.1",
|
||||
"@0x/utils": "^2.1.1",
|
||||
"@0x/web3-wrapper": "^3.2.2",
|
||||
"ethereum-types": "^1.1.4",
|
||||
"ethereumjs-abi": "0.6.5",
|
||||
"ethereumjs-blockstream": "6.0.0",
|
||||
"ethereumjs-util": "^5.1.1",
|
||||
"ethers": "~4.0.4",
|
||||
|
@@ -12,6 +12,7 @@ import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import { Provider } from 'ethereum-types';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { DutchAuctionWrapper } from './contract_wrappers/dutch_auction_wrapper';
|
||||
import { ERC20ProxyWrapper } from './contract_wrappers/erc20_proxy_wrapper';
|
||||
import { ERC20TokenWrapper } from './contract_wrappers/erc20_token_wrapper';
|
||||
import { ERC721ProxyWrapper } from './contract_wrappers/erc721_proxy_wrapper';
|
||||
@@ -65,6 +66,10 @@ export class ContractWrappers {
|
||||
* An instance of the OrderValidatorWrapper class containing methods for interacting with any OrderValidator smart contract.
|
||||
*/
|
||||
public orderValidator: OrderValidatorWrapper;
|
||||
/**
|
||||
* An instance of the DutchAuctionWrapper class containing methods for interacting with any DutchAuction smart contract.
|
||||
*/
|
||||
public dutchAuction: DutchAuctionWrapper;
|
||||
|
||||
private readonly _web3Wrapper: Web3Wrapper;
|
||||
/**
|
||||
@@ -141,6 +146,11 @@ export class ContractWrappers {
|
||||
config.networkId,
|
||||
contractAddresses.orderValidator,
|
||||
);
|
||||
this.dutchAuction = new DutchAuctionWrapper(
|
||||
this._web3Wrapper,
|
||||
config.networkId,
|
||||
contractAddresses.dutchAuction,
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Unsubscribes from all subscriptions for all contracts.
|
||||
|
@@ -0,0 +1,182 @@
|
||||
import { DutchAuctionContract } from '@0x/abi-gen-wrappers';
|
||||
import { DutchAuction } from '@0x/contract-artifacts';
|
||||
import { schemas } from '@0x/json-schemas';
|
||||
import { assetDataUtils } from '@0x/order-utils';
|
||||
import { DutchAuctionDetails, SignedOrder } from '@0x/types';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import { ContractAbi } from 'ethereum-types';
|
||||
import * as ethAbi from 'ethereumjs-abi';
|
||||
import * as ethUtil from 'ethereumjs-util';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { orderTxOptsSchema } from '../schemas/order_tx_opts_schema';
|
||||
import { txOptsSchema } from '../schemas/tx_opts_schema';
|
||||
import { DutchAuctionData, DutchAuctionWrapperError, OrderTransactionOpts } from '../types';
|
||||
import { assert } from '../utils/assert';
|
||||
import { _getDefaultContractAddresses } from '../utils/contract_addresses';
|
||||
|
||||
import { ContractWrapper } from './contract_wrapper';
|
||||
|
||||
export class DutchAuctionWrapper extends ContractWrapper {
|
||||
public abi: ContractAbi = DutchAuction.compilerOutput.abi;
|
||||
public address: string;
|
||||
private _dutchAuctionContractIfExists?: DutchAuctionContract;
|
||||
/**
|
||||
* Dutch auction details are encoded with the asset data for a 0x order. This function produces a hex
|
||||
* encoded assetData string, containing information both about the asset being traded and the
|
||||
* dutch auction; which is usable in the makerAssetData or takerAssetData fields in a 0x order.
|
||||
* @param assetData Hex encoded assetData string for the asset being auctioned.
|
||||
* @param beginTimeSeconds Begin time of the dutch auction.
|
||||
* @param beginAmount Starting amount being sold in the dutch auction.
|
||||
* @return The hex encoded assetData string.
|
||||
*/
|
||||
public static encodeDutchAuctionAssetData(
|
||||
assetData: string,
|
||||
beginTimeSeconds: BigNumber,
|
||||
beginAmount: BigNumber,
|
||||
): string {
|
||||
const assetDataBuffer = ethUtil.toBuffer(assetData);
|
||||
const abiEncodedAuctionData = (ethAbi as any).rawEncode(
|
||||
['uint256', 'uint256'],
|
||||
[beginTimeSeconds.toString(), beginAmount.toString()],
|
||||
);
|
||||
const abiEncodedAuctionDataBuffer = ethUtil.toBuffer(abiEncodedAuctionData);
|
||||
const dutchAuctionDataBuffer = Buffer.concat([assetDataBuffer, abiEncodedAuctionDataBuffer]);
|
||||
const dutchAuctionData = ethUtil.bufferToHex(dutchAuctionDataBuffer);
|
||||
return dutchAuctionData;
|
||||
}
|
||||
/**
|
||||
* Dutch auction details are encoded with the asset data for a 0x order. This function decodes a hex
|
||||
* encoded assetData string, containing information both about the asset being traded and the
|
||||
* dutch auction.
|
||||
* @param dutchAuctionData Hex encoded assetData string for the asset being auctioned.
|
||||
* @return An object containing the auction asset, auction begin time and auction begin amount.
|
||||
*/
|
||||
public static decodeDutchAuctionData(dutchAuctionData: string): DutchAuctionData {
|
||||
const dutchAuctionDataBuffer = ethUtil.toBuffer(dutchAuctionData);
|
||||
// Decode asset data
|
||||
const dutchAuctionDataLengthInBytes = 64;
|
||||
const assetDataBuffer = dutchAuctionDataBuffer.slice(
|
||||
0,
|
||||
dutchAuctionDataBuffer.byteLength - dutchAuctionDataLengthInBytes,
|
||||
);
|
||||
const assetDataHex = ethUtil.bufferToHex(assetDataBuffer);
|
||||
const assetData = assetDataUtils.decodeAssetDataOrThrow(assetDataHex);
|
||||
// Decode auction details
|
||||
const dutchAuctionDetailsBuffer = dutchAuctionDataBuffer.slice(
|
||||
dutchAuctionDataBuffer.byteLength - dutchAuctionDataLengthInBytes,
|
||||
);
|
||||
const [beginTimeSecondsAsBN, beginAmountAsBN] = ethAbi.rawDecode(
|
||||
['uint256', 'uint256'],
|
||||
dutchAuctionDetailsBuffer,
|
||||
);
|
||||
const beginTimeSeconds = new BigNumber(`0x${beginTimeSecondsAsBN.toString()}`);
|
||||
const beginAmount = new BigNumber(`0x${beginAmountAsBN.toString()}`);
|
||||
return {
|
||||
assetData,
|
||||
beginTimeSeconds,
|
||||
beginAmount,
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Instantiate DutchAuctionWrapper
|
||||
* @param web3Wrapper Web3Wrapper instance to use.
|
||||
* @param networkId Desired networkId.
|
||||
* @param address The address of the Dutch Auction contract. If undefined, will
|
||||
* default to the known address corresponding to the networkId.
|
||||
*/
|
||||
public constructor(web3Wrapper: Web3Wrapper, networkId: number, address?: string) {
|
||||
super(web3Wrapper, networkId);
|
||||
this.address = _.isUndefined(address) ? _getDefaultContractAddresses(networkId).dutchAuction : address;
|
||||
}
|
||||
/**
|
||||
* Matches the buy and sell orders at an amount given the following: the current block time, the auction
|
||||
* start time and the auction begin amount. The sell order is a an order at the lowest amount
|
||||
* at the end of the auction. Excess from the match is transferred to the seller.
|
||||
* Over time the price moves from beginAmount to endAmount given the current block.timestamp.
|
||||
* @param buyOrder The Buyer's order. This order is for the current expected price of the auction.
|
||||
* @param sellOrder The Seller's order. This order is for the lowest amount (at the end of the auction).
|
||||
* @param takerAddress The user Ethereum address who would like to fill this order. Must be available via the supplied
|
||||
* Provider provided at instantiation.
|
||||
* @return Transaction hash.
|
||||
*/
|
||||
public async matchOrdersAsync(
|
||||
buyOrder: SignedOrder,
|
||||
sellOrder: SignedOrder,
|
||||
takerAddress: string,
|
||||
orderTransactionOpts: OrderTransactionOpts = { shouldValidate: true },
|
||||
): Promise<string> {
|
||||
// type assertions
|
||||
assert.doesConformToSchema('buyOrder', buyOrder, schemas.signedOrderSchema);
|
||||
assert.doesConformToSchema('sellOrder', sellOrder, schemas.signedOrderSchema);
|
||||
await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper);
|
||||
assert.doesConformToSchema('orderTransactionOpts', orderTransactionOpts, orderTxOptsSchema, [txOptsSchema]);
|
||||
const normalizedTakerAddress = takerAddress.toLowerCase();
|
||||
// other assertions
|
||||
if (
|
||||
sellOrder.makerAssetData !== buyOrder.takerAssetData ||
|
||||
sellOrder.takerAssetData !== buyOrder.makerAssetData
|
||||
) {
|
||||
throw new Error(DutchAuctionWrapperError.AssetDataMismatch);
|
||||
}
|
||||
// get contract
|
||||
const dutchAuctionInstance = await this._getDutchAuctionContractAsync();
|
||||
// validate transaction
|
||||
if (orderTransactionOpts.shouldValidate) {
|
||||
await dutchAuctionInstance.matchOrders.callAsync(
|
||||
buyOrder,
|
||||
sellOrder,
|
||||
buyOrder.signature,
|
||||
sellOrder.signature,
|
||||
{
|
||||
from: normalizedTakerAddress,
|
||||
gas: orderTransactionOpts.gasLimit,
|
||||
gasPrice: orderTransactionOpts.gasPrice,
|
||||
nonce: orderTransactionOpts.nonce,
|
||||
},
|
||||
);
|
||||
}
|
||||
// send transaction
|
||||
const txHash = await dutchAuctionInstance.matchOrders.sendTransactionAsync(
|
||||
buyOrder,
|
||||
sellOrder,
|
||||
buyOrder.signature,
|
||||
sellOrder.signature,
|
||||
{
|
||||
from: normalizedTakerAddress,
|
||||
gas: orderTransactionOpts.gasLimit,
|
||||
gasPrice: orderTransactionOpts.gasPrice,
|
||||
nonce: orderTransactionOpts.nonce,
|
||||
},
|
||||
);
|
||||
return txHash;
|
||||
}
|
||||
/**
|
||||
* Fetches the Auction Details for the given order
|
||||
* @param sellOrder The Seller's order. This order is for the lowest amount (at the end of the auction).
|
||||
* @return The dutch auction details.
|
||||
*/
|
||||
public async getAuctionDetailsAsync(sellOrder: SignedOrder): Promise<DutchAuctionDetails> {
|
||||
// type assertions
|
||||
assert.doesConformToSchema('sellOrder', sellOrder, schemas.signedOrderSchema);
|
||||
// get contract
|
||||
const dutchAuctionInstance = await this._getDutchAuctionContractAsync();
|
||||
// call contract
|
||||
const auctionDetails = await dutchAuctionInstance.getAuctionDetails.callAsync(sellOrder);
|
||||
return auctionDetails;
|
||||
}
|
||||
private async _getDutchAuctionContractAsync(): Promise<DutchAuctionContract> {
|
||||
if (!_.isUndefined(this._dutchAuctionContractIfExists)) {
|
||||
return this._dutchAuctionContractIfExists;
|
||||
}
|
||||
const contractInstance = new DutchAuctionContract(
|
||||
this.abi,
|
||||
this.address,
|
||||
this._web3Wrapper.getProvider(),
|
||||
this._web3Wrapper.getContractDefaults(),
|
||||
);
|
||||
this._dutchAuctionContractIfExists = contractInstance;
|
||||
return this._dutchAuctionContractIfExists;
|
||||
}
|
||||
}
|
@@ -1,8 +1,7 @@
|
||||
// tslint:disable:no-unnecessary-type-assertion
|
||||
import { AbstractBalanceAndProxyAllowanceFetcher, assetDataUtils } from '@0x/order-utils';
|
||||
import { AssetProxyId, ERC20AssetData, ERC721AssetData } from '@0x/types';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import { BlockParamLiteral } from 'ethereum-types';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { ERC20TokenWrapper } from '../contract_wrappers/erc20_token_wrapper';
|
||||
import { ERC721TokenWrapper } from '../contract_wrappers/erc721_token_wrapper';
|
||||
@@ -18,42 +17,45 @@ export class AssetBalanceAndProxyAllowanceFetcher implements AbstractBalanceAndP
|
||||
}
|
||||
public async getBalanceAsync(assetData: string, userAddress: string): Promise<BigNumber> {
|
||||
const decodedAssetData = assetDataUtils.decodeAssetDataOrThrow(assetData);
|
||||
if (decodedAssetData.assetProxyId === AssetProxyId.ERC20) {
|
||||
const decodedERC20AssetData = decodedAssetData as ERC20AssetData;
|
||||
const balance = await this._erc20Token.getBalanceAsync(decodedERC20AssetData.tokenAddress, userAddress, {
|
||||
let balance: BigNumber | undefined;
|
||||
if (assetDataUtils.isERC20AssetData(decodedAssetData)) {
|
||||
balance = await this._erc20Token.getBalanceAsync(decodedAssetData.tokenAddress, userAddress, {
|
||||
defaultBlock: this._stateLayer,
|
||||
});
|
||||
return balance;
|
||||
} else {
|
||||
const decodedERC721AssetData = decodedAssetData as ERC721AssetData;
|
||||
} else if (assetDataUtils.isERC721AssetData(decodedAssetData)) {
|
||||
const tokenOwner = await this._erc721Token.getOwnerOfAsync(
|
||||
decodedERC721AssetData.tokenAddress,
|
||||
decodedERC721AssetData.tokenId,
|
||||
decodedAssetData.tokenAddress,
|
||||
decodedAssetData.tokenId,
|
||||
{
|
||||
defaultBlock: this._stateLayer,
|
||||
},
|
||||
);
|
||||
const balance = tokenOwner === userAddress ? new BigNumber(1) : new BigNumber(0);
|
||||
return balance;
|
||||
balance = tokenOwner === userAddress ? new BigNumber(1) : new BigNumber(0);
|
||||
} else if (assetDataUtils.isMultiAssetData(decodedAssetData)) {
|
||||
// The `balance` for MultiAssetData is the total units of the entire `assetData` that are held by the `userAddress`.
|
||||
for (const [index, nestedAssetDataElement] of decodedAssetData.nestedAssetData.entries()) {
|
||||
const nestedAmountElement = decodedAssetData.amounts[index];
|
||||
const nestedAssetBalance = (await this.getBalanceAsync(
|
||||
nestedAssetDataElement,
|
||||
userAddress,
|
||||
)).dividedToIntegerBy(nestedAmountElement);
|
||||
if (_.isUndefined(balance) || nestedAssetBalance.lessThan(balance)) {
|
||||
balance = nestedAssetBalance;
|
||||
}
|
||||
}
|
||||
}
|
||||
return balance as BigNumber;
|
||||
}
|
||||
public async getProxyAllowanceAsync(assetData: string, userAddress: string): Promise<BigNumber> {
|
||||
const decodedAssetData = assetDataUtils.decodeAssetDataOrThrow(assetData);
|
||||
if (decodedAssetData.assetProxyId === AssetProxyId.ERC20) {
|
||||
const decodedERC20AssetData = decodedAssetData as ERC20AssetData;
|
||||
const proxyAllowance = await this._erc20Token.getProxyAllowanceAsync(
|
||||
decodedERC20AssetData.tokenAddress,
|
||||
userAddress,
|
||||
{
|
||||
defaultBlock: this._stateLayer,
|
||||
},
|
||||
);
|
||||
return proxyAllowance;
|
||||
} else {
|
||||
const decodedERC721AssetData = decodedAssetData as ERC721AssetData;
|
||||
|
||||
let proxyAllowance: BigNumber | undefined;
|
||||
if (assetDataUtils.isERC20AssetData(decodedAssetData)) {
|
||||
proxyAllowance = await this._erc20Token.getProxyAllowanceAsync(decodedAssetData.tokenAddress, userAddress, {
|
||||
defaultBlock: this._stateLayer,
|
||||
});
|
||||
} else if (assetDataUtils.isERC721AssetData(decodedAssetData)) {
|
||||
const isApprovedForAll = await this._erc721Token.isProxyApprovedForAllAsync(
|
||||
decodedERC721AssetData.tokenAddress,
|
||||
decodedAssetData.tokenAddress,
|
||||
userAddress,
|
||||
{
|
||||
defaultBlock: this._stateLayer,
|
||||
@@ -63,15 +65,27 @@ export class AssetBalanceAndProxyAllowanceFetcher implements AbstractBalanceAndP
|
||||
return new BigNumber(this._erc20Token.UNLIMITED_ALLOWANCE_IN_BASE_UNITS);
|
||||
} else {
|
||||
const isApproved = await this._erc721Token.isProxyApprovedAsync(
|
||||
decodedERC721AssetData.tokenAddress,
|
||||
decodedERC721AssetData.tokenId,
|
||||
decodedAssetData.tokenAddress,
|
||||
decodedAssetData.tokenId,
|
||||
{
|
||||
defaultBlock: this._stateLayer,
|
||||
},
|
||||
);
|
||||
const proxyAllowance = isApproved ? new BigNumber(1) : new BigNumber(0);
|
||||
return proxyAllowance;
|
||||
proxyAllowance = isApproved ? new BigNumber(1) : new BigNumber(0);
|
||||
}
|
||||
} else if (assetDataUtils.isMultiAssetData(decodedAssetData)) {
|
||||
// The `proxyAllowance` for MultiAssetData is the total units of the entire `assetData` that the proxies have been approved to spend by the `userAddress`.
|
||||
for (const [index, nestedAssetDataElement] of decodedAssetData.nestedAssetData.entries()) {
|
||||
const nestedAmountElement = decodedAssetData.amounts[index];
|
||||
const nestedAssetAllowance = (await this.getProxyAllowanceAsync(
|
||||
nestedAssetDataElement,
|
||||
userAddress,
|
||||
)).dividedToIntegerBy(nestedAmountElement);
|
||||
if (_.isUndefined(proxyAllowance) || nestedAssetAllowance.lessThan(proxyAllowance)) {
|
||||
proxyAllowance = nestedAssetAllowance;
|
||||
}
|
||||
}
|
||||
}
|
||||
return proxyAllowance as BigNumber;
|
||||
}
|
||||
}
|
||||
|
@@ -34,6 +34,7 @@ export { ERC20ProxyWrapper } from './contract_wrappers/erc20_proxy_wrapper';
|
||||
export { ERC721ProxyWrapper } from './contract_wrappers/erc721_proxy_wrapper';
|
||||
export { ForwarderWrapper } from './contract_wrappers/forwarder_wrapper';
|
||||
export { OrderValidatorWrapper } from './contract_wrappers/order_validator_wrapper';
|
||||
export { DutchAuctionWrapper } from './contract_wrappers/dutch_auction_wrapper';
|
||||
|
||||
export { TransactionEncoder } from './utils/transaction_encoder';
|
||||
|
||||
@@ -54,9 +55,21 @@ export {
|
||||
OrderAndTraderInfo,
|
||||
TraderInfo,
|
||||
ValidateOrderFillableOpts,
|
||||
DutchAuctionData,
|
||||
} from './types';
|
||||
|
||||
export { Order, SignedOrder, AssetProxyId } from '@0x/types';
|
||||
export {
|
||||
AssetData,
|
||||
ERC20AssetData,
|
||||
ERC721AssetData,
|
||||
SingleAssetData,
|
||||
MultiAssetData,
|
||||
MultiAssetDataWithRecursiveDecoding,
|
||||
DutchAuctionDetails,
|
||||
Order,
|
||||
SignedOrder,
|
||||
AssetProxyId,
|
||||
} from '@0x/types';
|
||||
|
||||
export {
|
||||
BlockParamLiteral,
|
||||
|
@@ -9,7 +9,7 @@ import {
|
||||
WETH9Events,
|
||||
} from '@0x/abi-gen-wrappers';
|
||||
import { ContractAddresses } from '@0x/contract-addresses';
|
||||
import { OrderState, SignedOrder } from '@0x/types';
|
||||
import { AssetData, OrderState, SignedOrder } from '@0x/types';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
|
||||
import { BlockParam, ContractEventArg, DecodedLogArgs, LogEntryEvent, LogWithDecodedArgs } from 'ethereum-types';
|
||||
@@ -206,3 +206,13 @@ export interface BalanceAndAllowance {
|
||||
balance: BigNumber;
|
||||
allowance: BigNumber;
|
||||
}
|
||||
|
||||
export enum DutchAuctionWrapperError {
|
||||
AssetDataMismatch = 'ASSET_DATA_MISMATCH',
|
||||
}
|
||||
|
||||
export interface DutchAuctionData {
|
||||
assetData: AssetData;
|
||||
beginTimeSeconds: BigNumber;
|
||||
beginAmount: BigNumber;
|
||||
}
|
||||
|
128
packages/contract-wrappers/test/dutch_auction_wrapper_test.ts
Normal file
128
packages/contract-wrappers/test/dutch_auction_wrapper_test.ts
Normal file
@@ -0,0 +1,128 @@
|
||||
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 { BigNumber } from '@0x/utils';
|
||||
import * as chai from 'chai';
|
||||
import 'mocha';
|
||||
|
||||
import { ContractWrappers } from '../src';
|
||||
|
||||
import { chaiSetup } from './utils/chai_setup';
|
||||
import { constants } from './utils/constants';
|
||||
import { DutchAuctionUtils } from './utils/dutch_auction_utils';
|
||||
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);
|
||||
|
||||
// tslint:disable:custom-no-magic-numbers
|
||||
describe('DutchAuctionWrapper', () => {
|
||||
const makerAssetAmount = new BigNumber(5);
|
||||
const auctionEndTakerAmount = new BigNumber(10);
|
||||
const auctionBeginTakerAmount = auctionEndTakerAmount.times(2);
|
||||
const tenMinutesInSeconds = 10 * 60;
|
||||
let contractWrappers: ContractWrappers;
|
||||
let exchangeContractAddress: string;
|
||||
let userAddresses: string[];
|
||||
let makerAddress: string;
|
||||
let takerAddress: string;
|
||||
let makerTokenAddress: string;
|
||||
let takerTokenAddress: string;
|
||||
let buyOrder: SignedOrder;
|
||||
let sellOrder: SignedOrder;
|
||||
let makerTokenAssetData: string;
|
||||
let takerTokenAssetData: string;
|
||||
let auctionBeginTimeSeconds: BigNumber;
|
||||
let auctionEndTimeSeconds: BigNumber;
|
||||
before(async () => {
|
||||
// setup contract wrappers & addresses
|
||||
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();
|
||||
[, makerAddress, takerAddress] = userAddresses;
|
||||
[makerTokenAddress, takerTokenAddress] = tokenUtils.getDummyERC20TokenAddresses();
|
||||
// construct asset data for tokens being swapped
|
||||
[makerTokenAssetData, takerTokenAssetData] = [
|
||||
assetDataUtils.encodeERC20AssetData(makerTokenAddress),
|
||||
assetDataUtils.encodeERC20AssetData(takerTokenAddress),
|
||||
];
|
||||
// setup auction details in maker asset data
|
||||
const currentBlockTimestamp: number = await getLatestBlockTimestampAsync();
|
||||
auctionBeginTimeSeconds = new BigNumber(currentBlockTimestamp - tenMinutesInSeconds);
|
||||
auctionEndTimeSeconds = new BigNumber(currentBlockTimestamp + tenMinutesInSeconds);
|
||||
// create auction orders
|
||||
const coinbase = userAddresses[0];
|
||||
const dutchAuctionUtils = new DutchAuctionUtils(
|
||||
web3Wrapper,
|
||||
coinbase,
|
||||
exchangeContractAddress,
|
||||
contractWrappers.erc20Proxy.address,
|
||||
);
|
||||
sellOrder = await dutchAuctionUtils.createSignedSellOrderAsync(
|
||||
auctionBeginTimeSeconds,
|
||||
auctionEndTimeSeconds,
|
||||
auctionBeginTakerAmount,
|
||||
auctionEndTakerAmount,
|
||||
makerAssetAmount,
|
||||
makerTokenAssetData,
|
||||
takerTokenAssetData,
|
||||
makerAddress,
|
||||
constants.NULL_ADDRESS,
|
||||
);
|
||||
buyOrder = await dutchAuctionUtils.createSignedBuyOrderAsync(sellOrder, takerAddress);
|
||||
});
|
||||
after(async () => {
|
||||
await blockchainLifecycle.revertAsync();
|
||||
});
|
||||
beforeEach(async () => {
|
||||
await blockchainLifecycle.startAsync();
|
||||
});
|
||||
afterEach(async () => {
|
||||
await blockchainLifecycle.revertAsync();
|
||||
});
|
||||
describe('#matchOrdersAsync', () => {
|
||||
it('should match two orders', async () => {
|
||||
const txHash = await contractWrappers.dutchAuction.matchOrdersAsync(buyOrder, sellOrder, takerAddress);
|
||||
await web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
|
||||
});
|
||||
it('should throw when invalid transaction and shouldValidate is true', async () => {
|
||||
// request match with bad buy/sell orders
|
||||
const badSellOrder = buyOrder;
|
||||
const badBuyOrder = sellOrder;
|
||||
return expectTransactionFailedAsync(
|
||||
contractWrappers.dutchAuction.matchOrdersAsync(badBuyOrder, badSellOrder, takerAddress, {
|
||||
shouldValidate: true,
|
||||
}),
|
||||
RevertReason.InvalidAssetData,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#getAuctionDetailsAsync', () => {
|
||||
it('should get auction details', async () => {
|
||||
// get auction details
|
||||
const auctionDetails = await contractWrappers.dutchAuction.getAuctionDetailsAsync(sellOrder);
|
||||
// run some basic sanity checks on the return value
|
||||
expect(auctionDetails.beginTimeSeconds, 'auctionDetails.beginTimeSeconds').to.be.bignumber.equal(
|
||||
auctionBeginTimeSeconds,
|
||||
);
|
||||
expect(auctionDetails.beginAmount, 'auctionDetails.beginAmount').to.be.bignumber.equal(
|
||||
auctionBeginTakerAmount,
|
||||
);
|
||||
expect(auctionDetails.endTimeSeconds, 'auctionDetails.endTimeSeconds').to.be.bignumber.equal(
|
||||
auctionEndTimeSeconds,
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
153
packages/contract-wrappers/test/utils/dutch_auction_utils.ts
Normal file
153
packages/contract-wrappers/test/utils/dutch_auction_utils.ts
Normal file
@@ -0,0 +1,153 @@
|
||||
import { DummyERC20TokenContract } from '@0x/abi-gen-wrappers';
|
||||
import * as artifacts from '@0x/contract-artifacts';
|
||||
import { assetDataUtils } from '@0x/order-utils';
|
||||
import { orderFactory } from '@0x/order-utils/lib/src/order_factory';
|
||||
import { SignedOrder } from '@0x/types';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
|
||||
import { DutchAuctionWrapper } from '../../src/contract_wrappers/dutch_auction_wrapper';
|
||||
|
||||
import { constants } from './constants';
|
||||
|
||||
export class DutchAuctionUtils {
|
||||
private readonly _web3Wrapper: Web3Wrapper;
|
||||
private readonly _coinbase: string;
|
||||
private readonly _exchangeAddress: string;
|
||||
private readonly _erc20ProxyAddress: string;
|
||||
|
||||
constructor(web3Wrapper: Web3Wrapper, coinbase: string, exchangeAddress: string, erc20ProxyAddress: string) {
|
||||
this._web3Wrapper = web3Wrapper;
|
||||
this._coinbase = coinbase;
|
||||
this._exchangeAddress = exchangeAddress;
|
||||
this._erc20ProxyAddress = erc20ProxyAddress;
|
||||
}
|
||||
public async createSignedSellOrderAsync(
|
||||
auctionBeginTimeSections: BigNumber,
|
||||
acutionEndTimeSeconds: BigNumber,
|
||||
auctionBeginTakerAssetAmount: BigNumber,
|
||||
auctionEndTakerAssetAmount: BigNumber,
|
||||
makerAssetAmount: BigNumber,
|
||||
makerAssetData: string,
|
||||
takerAssetData: string,
|
||||
makerAddress: string,
|
||||
takerAddress: string,
|
||||
senderAddress?: string,
|
||||
makerFee?: BigNumber,
|
||||
takerFee?: BigNumber,
|
||||
feeRecipientAddress?: string,
|
||||
): Promise<SignedOrder> {
|
||||
// Notes on sell order:
|
||||
// - The `takerAssetAmount` is set to the `auctionEndTakerAssetAmount`, which is the lowest amount the
|
||||
// the seller can expect to receive
|
||||
// - The `makerAssetData` is overloaded to include the auction begin time and begin taker asset amount
|
||||
const makerAssetDataWithAuctionDetails = DutchAuctionWrapper.encodeDutchAuctionAssetData(
|
||||
makerAssetData,
|
||||
auctionBeginTimeSections,
|
||||
auctionBeginTakerAssetAmount,
|
||||
);
|
||||
const signedOrder = await orderFactory.createSignedOrderAsync(
|
||||
this._web3Wrapper.getProvider(),
|
||||
makerAddress,
|
||||
makerAssetAmount,
|
||||
makerAssetDataWithAuctionDetails,
|
||||
auctionEndTakerAssetAmount,
|
||||
takerAssetData,
|
||||
this._exchangeAddress,
|
||||
{
|
||||
takerAddress,
|
||||
senderAddress,
|
||||
makerFee,
|
||||
takerFee,
|
||||
feeRecipientAddress,
|
||||
expirationTimeSeconds: acutionEndTimeSeconds,
|
||||
},
|
||||
);
|
||||
const erc20AssetData = assetDataUtils.decodeERC20AssetData(makerAssetData);
|
||||
await this._increaseERC20BalanceAndAllowanceAsync(erc20AssetData.tokenAddress, makerAddress, makerAssetAmount);
|
||||
return signedOrder;
|
||||
}
|
||||
public async createSignedBuyOrderAsync(
|
||||
sellOrder: SignedOrder,
|
||||
buyerAddress: string,
|
||||
senderAddress?: string,
|
||||
makerFee?: BigNumber,
|
||||
takerFee?: BigNumber,
|
||||
feeRecipientAddress?: string,
|
||||
expirationTimeSeconds?: BigNumber,
|
||||
): Promise<SignedOrder> {
|
||||
const dutchAuctionData = DutchAuctionWrapper.decodeDutchAuctionData(sellOrder.makerAssetData);
|
||||
// Notes on buy order:
|
||||
// - The `makerAssetAmount` is set to `dutchAuctionData.beginAmount`, which is
|
||||
// the highest amount the buyer would have to pay out at any point during the auction.
|
||||
// - The `takerAssetAmount` is set to the seller's `makerAssetAmount`, as the buyer
|
||||
// receives the entire amount being sold by the seller.
|
||||
// - The `makerAssetData`/`takerAssetData` are reversed from the sell order
|
||||
const signedOrder = await orderFactory.createSignedOrderAsync(
|
||||
this._web3Wrapper.getProvider(),
|
||||
buyerAddress,
|
||||
dutchAuctionData.beginAmount,
|
||||
sellOrder.takerAssetData,
|
||||
sellOrder.makerAssetAmount,
|
||||
sellOrder.makerAssetData,
|
||||
sellOrder.exchangeAddress,
|
||||
{
|
||||
senderAddress,
|
||||
makerFee,
|
||||
takerFee,
|
||||
feeRecipientAddress,
|
||||
expirationTimeSeconds,
|
||||
},
|
||||
);
|
||||
const buyerERC20AssetData = assetDataUtils.decodeERC20AssetData(sellOrder.takerAssetData);
|
||||
await this._increaseERC20BalanceAndAllowanceAsync(
|
||||
buyerERC20AssetData.tokenAddress,
|
||||
buyerAddress,
|
||||
dutchAuctionData.beginAmount,
|
||||
);
|
||||
return signedOrder;
|
||||
}
|
||||
private async _increaseERC20BalanceAndAllowanceAsync(
|
||||
tokenAddress: string,
|
||||
address: string,
|
||||
amount: BigNumber,
|
||||
): Promise<void> {
|
||||
if (amount.isZero() || address === constants.NULL_ADDRESS) {
|
||||
return; // noop
|
||||
}
|
||||
await Promise.all([
|
||||
this._increaseERC20BalanceAsync(tokenAddress, address, amount),
|
||||
this._increaseERC20AllowanceAsync(tokenAddress, address, amount),
|
||||
]);
|
||||
}
|
||||
private async _increaseERC20BalanceAsync(tokenAddress: string, address: string, amount: BigNumber): Promise<void> {
|
||||
const erc20Token = new DummyERC20TokenContract(
|
||||
artifacts.DummyERC20Token.compilerOutput.abi,
|
||||
tokenAddress,
|
||||
this._web3Wrapper.getProvider(),
|
||||
this._web3Wrapper.getContractDefaults(),
|
||||
);
|
||||
const txHash = await erc20Token.transfer.sendTransactionAsync(address, amount, {
|
||||
from: this._coinbase,
|
||||
});
|
||||
await this._web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
|
||||
}
|
||||
private async _increaseERC20AllowanceAsync(
|
||||
tokenAddress: string,
|
||||
address: string,
|
||||
amount: BigNumber,
|
||||
): Promise<void> {
|
||||
const erc20Token = new DummyERC20TokenContract(
|
||||
artifacts.DummyERC20Token.compilerOutput.abi,
|
||||
tokenAddress,
|
||||
this._web3Wrapper.getProvider(),
|
||||
this._web3Wrapper.getContractDefaults(),
|
||||
);
|
||||
const oldMakerAllowance = await erc20Token.allowance.callAsync(address, this._erc20ProxyAddress);
|
||||
const newMakerAllowance = oldMakerAllowance.plus(amount);
|
||||
const txHash = await erc20Token.approve.sendTransactionAsync(this._erc20ProxyAddress, newMakerAllowance, {
|
||||
from: address,
|
||||
});
|
||||
await this._web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
|
||||
}
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0x/dev-tools-pages",
|
||||
"version": "0.0.10",
|
||||
"version": "0.0.11",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
@@ -16,7 +16,7 @@
|
||||
},
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@0x/react-shared": "^1.0.25",
|
||||
"@0x/react-shared": "^1.1.0",
|
||||
"basscss": "^8.0.3",
|
||||
"bowser": "^1.9.3",
|
||||
"less": "^2.7.2",
|
||||
|
@@ -1,4 +1,13 @@
|
||||
[
|
||||
{
|
||||
"timestamp": 1547040760,
|
||||
"version": "1.0.22",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"version": "1.0.21",
|
||||
"changes": [
|
||||
|
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v1.0.22 - _January 9, 2019_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.0.21 - _December 13, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0x/dev-utils",
|
||||
"version": "1.0.21",
|
||||
"version": "1.0.22",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
@@ -41,11 +41,11 @@
|
||||
"typescript": "3.0.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0x/subproviders": "^2.1.8",
|
||||
"@0x/types": "^1.4.1",
|
||||
"@0x/subproviders": "^2.1.9",
|
||||
"@0x/types": "^1.5.0",
|
||||
"@0x/typescript-typings": "^3.0.6",
|
||||
"@0x/utils": "^2.0.8",
|
||||
"@0x/web3-wrapper": "^3.2.1",
|
||||
"@0x/utils": "^2.1.1",
|
||||
"@0x/web3-wrapper": "^3.2.2",
|
||||
"@types/web3-provider-engine": "^14.0.0",
|
||||
"chai": "^4.0.1",
|
||||
"ethereum-types": "^1.1.4",
|
||||
|
@@ -17,6 +17,7 @@ export interface Web3Config {
|
||||
shouldThrowErrorsOnGanacheRPCResponse?: boolean; // default: true
|
||||
rpcUrl?: string; // default: localhost:8545
|
||||
shouldUseFakeGasEstimate?: boolean; // default: true
|
||||
ganacheDatabasePath?: string; // default: undefined, creates a tmp dir
|
||||
}
|
||||
|
||||
export const web3Factory = {
|
||||
@@ -45,9 +46,14 @@ export const web3Factory = {
|
||||
const shouldThrowErrorsOnGanacheRPCResponse =
|
||||
_.isUndefined(config.shouldThrowErrorsOnGanacheRPCResponse) ||
|
||||
config.shouldThrowErrorsOnGanacheRPCResponse;
|
||||
if (!_.isUndefined(config.ganacheDatabasePath)) {
|
||||
// Saving the snapshot to a local db. Ganache requires this directory to exist
|
||||
fs.mkdirSync(config.ganacheDatabasePath);
|
||||
}
|
||||
provider.addProvider(
|
||||
new GanacheSubprovider({
|
||||
vmErrorsOnRPCResponse: shouldThrowErrorsOnGanacheRPCResponse,
|
||||
db_path: config.ganacheDatabasePath,
|
||||
gasLimit: constants.GAS_LIMIT,
|
||||
logger,
|
||||
verbose: env.parseBoolean(EnvVars.VerboseGanache),
|
||||
|
@@ -1,4 +1,14 @@
|
||||
[
|
||||
{
|
||||
"version": "1.1.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Add support for MultiAssetProxy",
|
||||
"pr": 1363
|
||||
}
|
||||
],
|
||||
"timestamp": 1547040760
|
||||
},
|
||||
{
|
||||
"version": "1.0.16",
|
||||
"changes": [
|
||||
|
@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v1.1.0 - _January 9, 2019_
|
||||
|
||||
* Add support for MultiAssetProxy (#1363)
|
||||
|
||||
## v1.0.16 - _December 13, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0x/fill-scenarios",
|
||||
"version": "1.0.16",
|
||||
"version": "1.1.0",
|
||||
"description": "0x order fill scenario generator",
|
||||
"main": "lib/index.js",
|
||||
"types": "lib/index.d.ts",
|
||||
@@ -28,14 +28,14 @@
|
||||
"typescript": "3.0.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0x/abi-gen-wrappers": "^2.0.2",
|
||||
"@0x/base-contract": "^3.0.10",
|
||||
"@0x/contract-artifacts": "^1.1.2",
|
||||
"@0x/order-utils": "^3.0.7",
|
||||
"@0x/types": "^1.4.1",
|
||||
"@0x/abi-gen-wrappers": "^2.1.0",
|
||||
"@0x/base-contract": "^3.0.11",
|
||||
"@0x/contract-artifacts": "^1.2.0",
|
||||
"@0x/order-utils": "^3.1.0",
|
||||
"@0x/types": "^1.5.0",
|
||||
"@0x/typescript-typings": "^3.0.6",
|
||||
"@0x/utils": "^2.0.8",
|
||||
"@0x/web3-wrapper": "^3.2.1",
|
||||
"@0x/utils": "^2.1.1",
|
||||
"@0x/web3-wrapper": "^3.2.2",
|
||||
"ethereum-types": "^1.1.4",
|
||||
"ethers": "~4.0.4",
|
||||
"lodash": "^4.17.5"
|
||||
|
@@ -2,7 +2,7 @@ import { DummyERC20TokenContract, DummyERC721TokenContract, ExchangeContract } f
|
||||
import * as artifacts from '@0x/contract-artifacts';
|
||||
import { assetDataUtils } from '@0x/order-utils';
|
||||
import { orderFactory } from '@0x/order-utils/lib/src/order_factory';
|
||||
import { AssetProxyId, ERC721AssetData, OrderWithoutExchangeAddress, SignedOrder } from '@0x/types';
|
||||
import { OrderWithoutExchangeAddress, SignedOrder } from '@0x/types';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import { Provider } from 'ethereum-types';
|
||||
@@ -150,39 +150,8 @@ export class FillScenarios {
|
||||
feeRecipientAddress: string,
|
||||
expirationTimeSeconds?: BigNumber,
|
||||
): Promise<SignedOrder> {
|
||||
const decodedMakerAssetData = assetDataUtils.decodeAssetDataOrThrow(makerAssetData);
|
||||
if (decodedMakerAssetData.assetProxyId === AssetProxyId.ERC20) {
|
||||
await this._increaseERC20BalanceAndAllowanceAsync(
|
||||
decodedMakerAssetData.tokenAddress,
|
||||
makerAddress,
|
||||
makerFillableAmount,
|
||||
);
|
||||
} else {
|
||||
if (!makerFillableAmount.equals(1)) {
|
||||
throw new Error(`ERC721 makerFillableAmount should be equal 1. Found: ${makerFillableAmount}`);
|
||||
}
|
||||
await this._increaseERC721BalanceAndAllowanceAsync(
|
||||
decodedMakerAssetData.tokenAddress,
|
||||
makerAddress,
|
||||
// tslint:disable-next-line:no-unnecessary-type-assertion
|
||||
(decodedMakerAssetData as ERC721AssetData).tokenId,
|
||||
);
|
||||
}
|
||||
const decodedTakerAssetData = assetDataUtils.decodeAssetDataOrThrow(takerAssetData);
|
||||
if (decodedTakerAssetData.assetProxyId === AssetProxyId.ERC20) {
|
||||
const takerTokenAddress = decodedTakerAssetData.tokenAddress;
|
||||
await this._increaseERC20BalanceAndAllowanceAsync(takerTokenAddress, takerAddress, takerFillableAmount);
|
||||
} else {
|
||||
if (!takerFillableAmount.equals(1)) {
|
||||
throw new Error(`ERC721 takerFillableAmount should be equal 1. Found: ${takerFillableAmount}`);
|
||||
}
|
||||
await this._increaseERC721BalanceAndAllowanceAsync(
|
||||
decodedTakerAssetData.tokenAddress,
|
||||
takerAddress,
|
||||
// tslint:disable-next-line:no-unnecessary-type-assertion
|
||||
(decodedMakerAssetData as ERC721AssetData).tokenId,
|
||||
);
|
||||
}
|
||||
await this._increaseBalanceAndAllowanceWithAssetDataAsync(makerAssetData, makerAddress, makerFillableAmount);
|
||||
await this._increaseBalanceAndAllowanceWithAssetDataAsync(takerAssetData, takerAddress, takerFillableAmount);
|
||||
// Fees
|
||||
await Promise.all([
|
||||
this._increaseERC20BalanceAndAllowanceAsync(this._zrxTokenAddress, makerAddress, makerFee),
|
||||
@@ -298,4 +267,30 @@ export class FillScenarios {
|
||||
});
|
||||
await this._web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
|
||||
}
|
||||
private async _increaseBalanceAndAllowanceWithAssetDataAsync(
|
||||
assetData: string,
|
||||
userAddress: string,
|
||||
amount: BigNumber,
|
||||
): Promise<void> {
|
||||
const decodedAssetData = assetDataUtils.decodeAssetDataOrThrow(assetData);
|
||||
if (assetDataUtils.isERC20AssetData(decodedAssetData)) {
|
||||
await this._increaseERC20BalanceAndAllowanceAsync(decodedAssetData.tokenAddress, userAddress, amount);
|
||||
} else if (assetDataUtils.isERC721AssetData(decodedAssetData)) {
|
||||
await this._increaseERC721BalanceAndAllowanceAsync(
|
||||
decodedAssetData.tokenAddress,
|
||||
userAddress,
|
||||
decodedAssetData.tokenId,
|
||||
);
|
||||
} else if (assetDataUtils.isMultiAssetData(decodedAssetData)) {
|
||||
for (const [index, nestedAssetDataElement] of decodedAssetData.nestedAssetData.entries()) {
|
||||
const amountsElement = decodedAssetData.amounts[index];
|
||||
const totalAmount = amount.times(amountsElement);
|
||||
await this._increaseBalanceAndAllowanceWithAssetDataAsync(
|
||||
nestedAssetDataElement,
|
||||
userAddress,
|
||||
totalAmount,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0x/instant",
|
||||
"version": "1.0.4",
|
||||
"version": "1.0.5",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
@@ -41,15 +41,15 @@
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/0x-monorepo/packages/instant/README.md",
|
||||
"dependencies": {
|
||||
"@0x/assert": "^1.0.20",
|
||||
"@0x/asset-buyer": "^3.0.4",
|
||||
"@0x/json-schemas": "^2.1.4",
|
||||
"@0x/order-utils": "^3.0.7",
|
||||
"@0x/subproviders": "^2.1.8",
|
||||
"@0x/types": "^1.4.1",
|
||||
"@0x/assert": "^1.0.21",
|
||||
"@0x/asset-buyer": "^3.0.5",
|
||||
"@0x/json-schemas": "^2.1.5",
|
||||
"@0x/order-utils": "^3.1.0",
|
||||
"@0x/subproviders": "^2.1.9",
|
||||
"@0x/types": "^1.5.0",
|
||||
"@0x/typescript-typings": "^3.0.6",
|
||||
"@0x/utils": "^2.0.8",
|
||||
"@0x/web3-wrapper": "^3.2.1",
|
||||
"@0x/utils": "^2.1.1",
|
||||
"@0x/web3-wrapper": "^3.2.2",
|
||||
"bowser": "^1.9.4",
|
||||
"copy-to-clipboard": "^3.0.8",
|
||||
"ethereum-types": "^1.1.4",
|
||||
|
@@ -30,3 +30,5 @@ export const AmountPlaceholder: React.StatelessComponent<AmountPlaceholderProps>
|
||||
return <PlainPlaceholder color={props.color} />;
|
||||
}
|
||||
};
|
||||
|
||||
AmountPlaceholder.displayName = 'AmountPlaceholder';
|
||||
|
@@ -11,6 +11,7 @@ export interface SlideAnimationProps {
|
||||
slideOutSettings: OptionallyScreenSpecific<PositionAnimationSettings>;
|
||||
zIndex?: OptionallyScreenSpecific<number>;
|
||||
height?: string;
|
||||
onAnimationEnd?: () => void;
|
||||
}
|
||||
|
||||
export const SlideAnimation: React.StatelessComponent<SlideAnimationProps> = props => {
|
||||
@@ -19,8 +20,15 @@ export const SlideAnimation: React.StatelessComponent<SlideAnimationProps> = pro
|
||||
}
|
||||
const positionSettings = props.animationState === 'slidIn' ? props.slideInSettings : props.slideOutSettings;
|
||||
return (
|
||||
<PositionAnimation height={props.height} positionSettings={positionSettings} zIndex={props.zIndex}>
|
||||
<PositionAnimation
|
||||
onAnimationEnd={props.onAnimationEnd}
|
||||
height={props.height}
|
||||
positionSettings={positionSettings}
|
||||
zIndex={props.zIndex}
|
||||
>
|
||||
{props.children}
|
||||
</PositionAnimation>
|
||||
);
|
||||
};
|
||||
|
||||
SlideAnimation.displayName = 'SlideAnimation';
|
||||
|
@@ -32,7 +32,7 @@ export interface BuyButtonProps {
|
||||
onBuyFailure: (buyQuote: BuyQuote, txHash: string) => void;
|
||||
}
|
||||
|
||||
export class BuyButton extends React.Component<BuyButtonProps> {
|
||||
export class BuyButton extends React.PureComponent<BuyButtonProps> {
|
||||
public static defaultProps = {
|
||||
onClick: util.boundNoop,
|
||||
onBuySuccess: util.boundNoop,
|
||||
|
@@ -31,3 +31,5 @@ export const BuyOrderProgress: React.StatelessComponent<BuyOrderProgressProps> =
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
BuyOrderProgress.displayName = 'BuyOrderProgress';
|
||||
|
@@ -71,3 +71,5 @@ export const BuyOrderStateButtons: React.StatelessComponent<BuyOrderStateButtonP
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
BuyOrderStateButtons.displayName = 'BuyOrderStateButtons';
|
||||
|
@@ -31,7 +31,7 @@ export interface ERC20AssetAmountInputState {
|
||||
currentFontSizePx: number;
|
||||
}
|
||||
|
||||
export class ERC20AssetAmountInput extends React.Component<ERC20AssetAmountInputProps, ERC20AssetAmountInputState> {
|
||||
export class ERC20AssetAmountInput extends React.PureComponent<ERC20AssetAmountInputProps, ERC20AssetAmountInputState> {
|
||||
public static defaultProps = {
|
||||
onChange: util.boundNoop,
|
||||
isDisabled: false,
|
||||
|
@@ -21,12 +21,12 @@ export interface ERC20TokenSelectorState {
|
||||
searchQuery: string;
|
||||
}
|
||||
|
||||
export class ERC20TokenSelector extends React.Component<ERC20TokenSelectorProps> {
|
||||
export class ERC20TokenSelector extends React.PureComponent<ERC20TokenSelectorProps> {
|
||||
public state: ERC20TokenSelectorState = {
|
||||
searchQuery: '',
|
||||
};
|
||||
public render(): React.ReactNode {
|
||||
const { tokens, onTokenSelect } = this.props;
|
||||
const { tokens } = this.props;
|
||||
return (
|
||||
<Container height="100%">
|
||||
<Container marginBottom="10px">
|
||||
@@ -42,12 +42,11 @@ export class ERC20TokenSelector extends React.Component<ERC20TokenSelectorProps>
|
||||
tabIndex={-1}
|
||||
/>
|
||||
<Container overflow="scroll" height="calc(100% - 90px)" marginTop="10px">
|
||||
{_.map(tokens, token => {
|
||||
if (!this._isTokenQueryMatch(token)) {
|
||||
return null;
|
||||
}
|
||||
return <TokenSelectorRow key={token.assetData} token={token} onClick={onTokenSelect} />;
|
||||
})}
|
||||
<TokenRowFilter
|
||||
tokens={tokens}
|
||||
onClick={this._handleTokenClick}
|
||||
searchQuery={this.state.searchQuery}
|
||||
/>
|
||||
</Container>
|
||||
</Container>
|
||||
);
|
||||
@@ -59,8 +58,32 @@ export class ERC20TokenSelector extends React.Component<ERC20TokenSelectorProps>
|
||||
});
|
||||
analytics.trackTokenSelectorSearched(searchQuery);
|
||||
};
|
||||
private readonly _handleTokenClick = (token: ERC20Asset): void => {
|
||||
this.props.onTokenSelect(token);
|
||||
};
|
||||
}
|
||||
|
||||
interface TokenRowFilterProps {
|
||||
tokens: ERC20Asset[];
|
||||
onClick: (token: ERC20Asset) => void;
|
||||
searchQuery: string;
|
||||
}
|
||||
|
||||
class TokenRowFilter extends React.Component<TokenRowFilterProps> {
|
||||
public render(): React.ReactNode {
|
||||
return _.map(this.props.tokens, token => {
|
||||
if (!this._isTokenQueryMatch(token)) {
|
||||
return null;
|
||||
}
|
||||
return <TokenSelectorRow key={token.assetData} token={token} onClick={this.props.onClick} />;
|
||||
});
|
||||
}
|
||||
public shouldComponentUpdate(nextProps: TokenRowFilterProps): boolean {
|
||||
const arePropsDeeplyEqual = _.isEqual(nextProps, this.props);
|
||||
return !arePropsDeeplyEqual;
|
||||
}
|
||||
private readonly _isTokenQueryMatch = (token: ERC20Asset): boolean => {
|
||||
const { searchQuery } = this.state;
|
||||
const { searchQuery } = this.props;
|
||||
const searchQueryLowerCase = searchQuery.toLowerCase().trim();
|
||||
if (searchQueryLowerCase === '') {
|
||||
return true;
|
||||
@@ -76,7 +99,7 @@ interface TokenSelectorRowProps {
|
||||
onClick: (token: ERC20Asset) => void;
|
||||
}
|
||||
|
||||
class TokenSelectorRow extends React.Component<TokenSelectorRowProps> {
|
||||
class TokenSelectorRow extends React.PureComponent<TokenSelectorRowProps> {
|
||||
public render(): React.ReactNode {
|
||||
const { token } = this.props;
|
||||
const circleColor = token.metaData.primaryColor || 'black';
|
||||
@@ -131,21 +154,23 @@ const getTokenIcon = (symbol: string): React.StatelessComponent | undefined => {
|
||||
}
|
||||
};
|
||||
|
||||
const TokenSelectorRowIcon: React.StatelessComponent<TokenSelectorRowIconProps> = props => {
|
||||
const { token } = props;
|
||||
const iconUrlIfExists = token.metaData.iconUrl;
|
||||
class TokenSelectorRowIcon extends React.PureComponent<TokenSelectorRowIconProps> {
|
||||
public render(): React.ReactNode {
|
||||
const { token } = this.props;
|
||||
const iconUrlIfExists = token.metaData.iconUrl;
|
||||
|
||||
const TokenIcon = getTokenIcon(token.metaData.symbol);
|
||||
const displaySymbol = assetUtils.bestNameForAsset(token);
|
||||
if (!_.isUndefined(iconUrlIfExists)) {
|
||||
return <img src={iconUrlIfExists} />;
|
||||
} else if (!_.isUndefined(TokenIcon)) {
|
||||
return <TokenIcon />;
|
||||
} else {
|
||||
return (
|
||||
<Text fontColor={ColorOption.white} fontSize="8px">
|
||||
{displaySymbol}
|
||||
</Text>
|
||||
);
|
||||
const TokenIcon = getTokenIcon(token.metaData.symbol);
|
||||
const displaySymbol = assetUtils.bestNameForAsset(token);
|
||||
if (!_.isUndefined(iconUrlIfExists)) {
|
||||
return <img src={iconUrlIfExists} />;
|
||||
} else if (!_.isUndefined(TokenIcon)) {
|
||||
return <TokenIcon />;
|
||||
} else {
|
||||
return (
|
||||
<Text fontColor={ColorOption.white} fontSize="8px">
|
||||
{displaySymbol}
|
||||
</Text>
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@@ -18,7 +18,7 @@ import { Button } from './ui/button';
|
||||
|
||||
export interface InstallWalletPanelContentProps {}
|
||||
|
||||
export class InstallWalletPanelContent extends React.Component<InstallWalletPanelContentProps> {
|
||||
export class InstallWalletPanelContent extends React.PureComponent<InstallWalletPanelContentProps> {
|
||||
public render(): React.ReactNode {
|
||||
const panelProps = this._getStandardPanelContentProps();
|
||||
return <StandardPanelContent {...panelProps} />;
|
||||
|
@@ -28,7 +28,7 @@ const ICON_WIDTH = 34;
|
||||
const ICON_HEIGHT = 34;
|
||||
const ICON_COLOR = ColorOption.white;
|
||||
|
||||
export class InstantHeading extends React.Component<InstantHeadingProps, {}> {
|
||||
export class InstantHeading extends React.PureComponent<InstantHeadingProps, {}> {
|
||||
public render(): React.ReactNode {
|
||||
const iconOrAmounts = this._renderIcon() || this._renderAmountsSection();
|
||||
return (
|
||||
|
@@ -26,7 +26,7 @@ export interface OrderDetailsProps {
|
||||
onBaseCurrencySwitchEth: () => void;
|
||||
onBaseCurrencySwitchUsd: () => void;
|
||||
}
|
||||
export class OrderDetails extends React.Component<OrderDetailsProps> {
|
||||
export class OrderDetails extends React.PureComponent<OrderDetailsProps> {
|
||||
public render(): React.ReactNode {
|
||||
const shouldShowUsdError = this.props.baseCurrency === BaseCurrency.USD && this._hadErrorFetchingUsdPrice();
|
||||
return (
|
||||
@@ -200,7 +200,7 @@ export interface OrderDetailsRowProps {
|
||||
primaryValue: React.ReactNode;
|
||||
secondaryValue?: React.ReactNode;
|
||||
}
|
||||
export class OrderDetailsRow extends React.Component<OrderDetailsRowProps, {}> {
|
||||
export class OrderDetailsRow extends React.PureComponent<OrderDetailsRowProps, {}> {
|
||||
public render(): React.ReactNode {
|
||||
return (
|
||||
<Container padding="10px 0px" borderTop="1px dashed" borderColor={ColorOption.feintGrey}>
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user