Compare commits
209 Commits
@0xproject
...
@0xproject
Author | SHA1 | Date | |
---|---|---|---|
|
855b6b1dc5 | ||
|
2c1daf9c9a | ||
|
ffdaf88fd0 | ||
|
195d11f9d0 | ||
|
06f61949f9 | ||
|
0e72b67865 | ||
|
b987eebf21 | ||
|
c808d12b74 | ||
|
b466431ede | ||
|
bf69ca6e53 | ||
|
e54501522d | ||
|
f2baeddc30 | ||
|
fd349b618a | ||
|
6ca2a02766 | ||
|
d9a282bd92 | ||
|
dc151f7290 | ||
|
cce2127f72 | ||
|
8e7c395f59 | ||
|
02d50a513a | ||
|
d61759f6dd | ||
|
5790ed7ba9 | ||
|
7fadba59e7 | ||
|
bcde0731db | ||
|
052afb67a4 | ||
|
6e15d7bb0f | ||
|
5bb68974ec | ||
|
0a3ba4d27d | ||
|
482a226dc5 | ||
|
9e69458ba8 | ||
|
71e386d5fa | ||
|
60b501b137 | ||
|
36f8e9f1d5 | ||
|
78707bd3ca | ||
|
56137d0605 | ||
|
681a582630 | ||
|
846a447c4d | ||
|
f76be4f016 | ||
|
ed19067096 | ||
|
eb9f7c2c9d | ||
|
52693f7d0a | ||
|
5e015872ef | ||
|
08c291bd3f | ||
|
48c5d69c9d | ||
|
0f9c262bb0 | ||
|
dff0fc65bf | ||
|
161f96c07d | ||
|
67ad21b368 | ||
|
d5e633c38f | ||
|
617ef5b6ce | ||
|
8bd4e38d02 | ||
|
f364b5c5ab | ||
|
6486fced34 | ||
|
bc9f2a51a2 | ||
|
9c03b54d75 | ||
|
eae08ea1e4 | ||
|
6f276223c6 | ||
|
21effcaa8b | ||
|
114b31a813 | ||
|
1a1b7a2bc4 | ||
|
c9b213839a | ||
|
4043fa76cc | ||
|
9c8e3bc4c9 | ||
|
18b1f01641 | ||
|
9085c674e4 | ||
|
b5d19d3fb1 | ||
|
cc0477153b | ||
|
76008b41c5 | ||
|
8193fdc304 | ||
|
9d06c81078 | ||
|
cdf85e5eee | ||
|
d774dbc432 | ||
|
0369f5ebc4 | ||
|
1e6b11b27e | ||
|
7a8231435b | ||
|
b1aa7725df | ||
|
bfe0ba3e9a | ||
|
2d39329ee7 | ||
|
761b0063a0 | ||
|
0f27ce3424 | ||
|
2b0c0a6ff7 | ||
|
5bd96f6fe9 | ||
|
37ac6749ba | ||
|
bf955bd87f | ||
|
6bd921d0bc | ||
|
534decea95 | ||
|
267830d463 | ||
|
e82d0c21ec | ||
|
ece6417699 | ||
|
74d5449719 | ||
|
4af7ff9cc3 | ||
|
46dedfcb67 | ||
|
a9fa1a0df6 | ||
|
a8572b4944 | ||
|
91c0d47ad4 | ||
|
fd2611794a | ||
|
1fe1c5321b | ||
|
f063a5db0f | ||
|
3883315447 | ||
|
7679e07957 | ||
|
c39ba37ad8 | ||
|
f1c3840c3b | ||
|
e5c5b36a73 | ||
|
c51f7a8375 | ||
|
e53e2ac31b | ||
|
b72857cd8b | ||
|
cc223b9eab | ||
|
f2c49e8b37 | ||
|
9b6476a6b7 | ||
|
d8898cf9a3 | ||
|
34df5af295 | ||
|
3de88d5345 | ||
|
9ab6ab1bf9 | ||
|
b6de0bdd43 | ||
|
a2b62fd808 | ||
|
f9c4d0925e | ||
|
1df9370bc2 | ||
|
7d840c7a18 | ||
|
ff12aafc0f | ||
|
c08b4aa6a1 | ||
|
52a6e6357b | ||
|
74c0fd419b | ||
|
6f540e3e58 | ||
|
dead04dce8 | ||
|
886a03fdcd | ||
|
81007c453c | ||
|
6529e06057 | ||
|
55336f96d7 | ||
|
3a18c249f5 | ||
|
7c0775aa1b | ||
|
ba92754669 | ||
|
30afd39129 | ||
|
41699406cf | ||
|
9aa49e59d0 | ||
|
29d5034260 | ||
|
00d1622b3f | ||
|
a1acf19ff3 | ||
|
86328af6b7 | ||
|
36c27bdbf8 | ||
|
c839965c05 | ||
|
e1a9f3435f | ||
|
9f74feb347 | ||
|
f99232095b | ||
|
5044fe4fe4 | ||
|
8e49169e6b | ||
|
c71781d9ab | ||
|
8a2a4052f3 | ||
|
dad557164e | ||
|
e2fb49a8f8 | ||
|
b9e7973a0f | ||
|
004b1f5288 | ||
|
857bd24c6d | ||
|
83747934ad | ||
|
7f90f5ecd4 | ||
|
12f02b9814 | ||
|
8931388309 | ||
|
25160d7344 | ||
|
ab6bf6edc7 | ||
|
f20b496dca | ||
|
cca17f70b8 | ||
|
b8e69718a1 | ||
|
50ed7d2af2 | ||
|
698de932ed | ||
|
a3d8858bb1 | ||
|
83f3ba21b8 | ||
|
2aa729b212 | ||
|
1de70e4474 | ||
|
f2393de59b | ||
|
94ea7cc451 | ||
|
f8dbf57582 | ||
|
c59cd36da6 | ||
|
96c648c4b4 | ||
|
01e617bb83 | ||
|
28a9a8c380 | ||
|
6c2796b433 | ||
|
82ad5f7897 | ||
|
bffffffc95 | ||
|
c3bd3437f5 | ||
|
90d72a3683 | ||
|
f9bcf936ed | ||
|
acff177c54 | ||
|
658214a2e2 | ||
|
55f6f02c9b | ||
|
c5ba52910a | ||
|
994ccd6694 | ||
|
4921a83813 | ||
|
a97ba41b86 | ||
|
67e2623d2c | ||
|
4111095da3 | ||
|
6c21ddcedb | ||
|
d86349658f | ||
|
ffeb3194a8 | ||
|
95e9f33f6a | ||
|
c599a20b34 | ||
|
ca59528a32 | ||
|
6f4fd06d38 | ||
|
4715c2d006 | ||
|
fcfa43b6f1 | ||
|
56b4c55654 | ||
|
830790eeac | ||
|
39de9c7879 | ||
|
7b6cc14b71 | ||
|
ec749a4033 | ||
|
fe32214613 | ||
|
f6fcb775b7 | ||
|
d209108a95 | ||
|
1aaf633df8 | ||
|
82771ec64a | ||
|
ada8a402da | ||
|
324b1079e7 |
@@ -64,7 +64,7 @@ jobs:
|
||||
- restore_cache:
|
||||
keys:
|
||||
- repo-{{ .Environment.CIRCLE_SHA1 }}
|
||||
- run: yarn wsrun test:circleci @0xproject/0x.js
|
||||
- run: yarn wsrun test:circleci 0x.js
|
||||
- run: yarn wsrun test:circleci @0xproject/abi-gen
|
||||
- run: yarn wsrun test:circleci @0xproject/assert
|
||||
- run: yarn wsrun test:circleci @0xproject/base-contract
|
||||
|
@@ -18,12 +18,10 @@
|
||||
|
||||
## Checklist:
|
||||
|
||||
<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
|
||||
<!--- The following points should be used to indicate the progress of your PR. Put an `x` in all the boxes that apply right now, and come back over time and check them off as you make progress. If you're unsure about any of these, don't hesitate to ask. We're here to help! -->
|
||||
|
||||
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->
|
||||
|
||||
* [ ] Change requires a change to the documentation.
|
||||
* [ ] Added tests to cover my changes.
|
||||
* [ ] Prefixed the title of this PR with `[WIP]` if it is a work in progress.
|
||||
* [ ] Prefixed the title of this PR with bracketed package name(s) corresponding to the changed package(s). For example: `[sol-cov] Fixed bug`.
|
||||
* [ ] Added tests to cover my changes, or decided that tests would be too impractical.
|
||||
* [ ] Updated documentation, or decided that no doc change is needed.
|
||||
* [ ] Added new entries to the relevant CHANGELOG.jsons.
|
||||
* [ ] Labeled this PR with the 'WIP' label if it is a work in progress.
|
||||
* [ ] Labeled this PR with the labels corresponding to the changed package.
|
||||
|
@@ -1,14 +1,10 @@
|
||||
{
|
||||
"lerna": "2.5.1",
|
||||
"lerna": "3.0.0-beta.14",
|
||||
"packages": ["packages/*"],
|
||||
"commands": {
|
||||
"publish": {
|
||||
"allowBranch": "development"
|
||||
}
|
||||
},
|
||||
"version": "independent",
|
||||
"commands": {
|
||||
"publish": {
|
||||
"registry": "http://localhost:4873/",
|
||||
"ignore": ["test/**/*", "*.md", "scripts", "lib", "tslint.json", "tsconfig.json"]
|
||||
}
|
||||
},
|
||||
|
@@ -30,8 +30,7 @@
|
||||
"test": "wsrun test $PKG --fast-exit --serial --exclude-missing",
|
||||
"stage_docs": "wsrun docs:stage $PKG --fast-exit --parallel --exclude-missing",
|
||||
"lint": "wsrun lint $PKG --fast-exit --parallel --exclude-missing",
|
||||
"comment:postinstall": "HACK: For some reason `yarn` is not setting up symlinks properly for order-utils. We temporarily set them manually. Remove this after V2 refactor is complete.",
|
||||
"postinstall": "rm -rf `pwd`/packages/0x.js/node_modules/@0xproject; mkdir `pwd`/packages/0x.js/node_modules/@0xproject; ln -s `pwd`/packages/contract-wrappers `pwd`/packages/0x.js/node_modules/@0xproject/contract-wrappers; ln -s `pwd`/packages/order-utils `pwd`/packages/0x.js/node_modules/@0xproject/order-utils; ln -s `pwd`/packages/types `pwd`/packages/0x.js/node_modules/@0xproject/types; rm -rf `pwd`/packages/order-utils/node_modules/@0xproject; mkdir `pwd`/packages/order-utils/node_modules/@0xproject; ln -s `pwd`/packages/json-schemas `pwd`/packages/order-utils/node_modules/@0xproject/json-schemas; ln -s `pwd`/packages/assert `pwd`/packages/order-utils/node_modules/@0xproject/assert; ln -s `pwd`/packages/types `pwd`/packages/order-utils/node_modules/@0xproject/types; rm -f `pwd`/packages/contracts/node_modules/@0xproject/types; ln -s `pwd`/packages/types `pwd`/packages/contracts/node_modules/@0xproject/types; rm -rf `pwd`/packages/fill-scenarios/node_modules/@0xproject; mkdir -p `pwd`/packages/fill-scenarios/node_modules/@0xproject; ln -s `pwd`/packages/types `pwd`/packages/fill-scenarios/node_modules/@0xproject/types; ln -s `pwd`/packages/json-schemas `pwd`/packages/fill-scenarios/node_modules/@0xproject/json-schemas; ln -s `pwd`/packages/order-utils `pwd`/packages/fill-scenarios/node_modules/@0xproject/order-utils; rm -rf `pwd`/packages/contract-wrappers/node_modules/@0xproject; mkdir -p `pwd`/packages/contract-wrappers/node_modules/@0xproject; ln -s `pwd`/packages/order-utils `pwd`/packages/contract-wrappers/node_modules/@0xproject/order-utils; ln -s `pwd`/packages/assert `pwd`/packages/contract-wrappers/node_modules/@0xproject/assert; ln -s `pwd`/packages/json-schemas `pwd`/packages/contract-wrappers/node_modules/@0xproject/json-schemas; ln -s `pwd`/packages/types `pwd`/packages/contract-wrappers/node_modules/@0xproject/types; ln -s `pwd`/packages/fill-scenarios `pwd`/packages/contract-wrappers/node_modules/@0xproject/fill-scenarios; rm -rf `pwd`/packages/assert/node_modules/@0xproject; mkdir -p `pwd`/packages/assert/node_modules/@0xproject; ln -s `pwd`/packages/json-schemas `pwd`/packages/assert/node_modules/@0xproject/json-schemas"
|
||||
"comment:postinstall": "HACK: For some reason `yarn` is not setting up symlinks properly for order-utils. We temporarily set them manually. Remove this after V2 refactor is complete."
|
||||
},
|
||||
"config": {
|
||||
"mnemonic": "concert load couple harbor equip island argue ramp clarify fence smart topic"
|
||||
@@ -41,7 +40,7 @@
|
||||
"coveralls": "^3.0.0",
|
||||
"ganache-cli": "6.1.3",
|
||||
"lcov-result-merger": "^3.0.0",
|
||||
"lerna": "^2.5.1",
|
||||
"lerna": "3.0.0-beta.14",
|
||||
"npm-run-all": "^4.1.2",
|
||||
"prettier": "^1.11.1",
|
||||
"wsrun": "^2.2.0",
|
||||
|
@@ -1,32 +1,51 @@
|
||||
[
|
||||
{
|
||||
"timestamp": 1532357734,
|
||||
"version": "1.0.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1532043100,
|
||||
"version": "1.0.0-rc.2",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Remove `zeroEx.assetData` and instead re-export it's static functions directly off `ZeroEx`"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1532043000,
|
||||
"version": "1.0.0-rc.1",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Remove tokenRegistry wrapper",
|
||||
"pr": 863
|
||||
},
|
||||
{
|
||||
"note": "Rename zeroEx.token to zeroEx.erc20Token, and add zeroEx.erc721Token",
|
||||
"note": "Rename `zeroEx.token` to `zeroEx.erc20Token`, and add `zeroEx.erc721Token`",
|
||||
"pr": 863
|
||||
},
|
||||
{
|
||||
"note": "Rename zeroEx.proxy to zeroEx.erc20Proxy and add zeroEx.erc721Proxy",
|
||||
"note": "Rename `zeroEx.proxy` to `zeroEx.erc20Proxy` and add `zeroEx.erc721Proxy`",
|
||||
"pr": 863
|
||||
},
|
||||
{
|
||||
"note":
|
||||
"Refactored ZeroEx.isValidSignature to zeroEx.isValidSignatureAsync. It is now async so that it can verify contract-dependent signature types",
|
||||
"Refactored `ZeroEx.isValidSignature` to `zeroEx.isValidSignatureAsync`. It is now async so that it can verify contract-dependent signature types",
|
||||
"pr": 863
|
||||
},
|
||||
{
|
||||
"note":
|
||||
"Refactored signOrderHashAsync to ecSignOrderHashAsync. There are now many non-ECSignature ways to sign orders too.",
|
||||
"Refactored `signOrderHashAsync` to `ecSignOrderHashAsync`. There are now many non-ECSignature ways to sign orders too.",
|
||||
"pr": 863
|
||||
},
|
||||
{
|
||||
"note":
|
||||
"Removed createOrderWatcherAsync method. Will be added back once OrderWatcher is refactored for V2",
|
||||
"Removed `createOrderWatcherAsync` method. Will be added back once OrderWatcher is refactored for V2",
|
||||
"pr": 863
|
||||
},
|
||||
{
|
||||
@@ -34,8 +53,17 @@
|
||||
"pr": 863
|
||||
},
|
||||
{
|
||||
"note": "Remove stateLayer config from OrderWatcher. It now always operates on the latest block",
|
||||
"pr": 875
|
||||
"note": "Export `ZeroEx.assetData` with methods to decode/encode assetData fields found in 0x orders",
|
||||
"pr": 884
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1531919263,
|
||||
"version": "0.38.6",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@@ -1,10 +1,33 @@
|
||||
<!--
|
||||
This file is auto-generated using the monorepo-scripts package. Don't edit directly.
|
||||
changelogUtils.file is auto-generated using the monorepo-scripts package. Don't edit directly.
|
||||
Edit the package's CHANGELOG.json file only.
|
||||
-->
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v1.0.0 - _July 23, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.0.0-rc.2 - _July 20, 2018_
|
||||
|
||||
* Remove `zeroEx.assetData` and instead re-export it's static functions directly off `ZeroEx`
|
||||
|
||||
## v1.0.0-rc.1 - _July 20, 2018_
|
||||
|
||||
* Remove tokenRegistry wrapper (#863)
|
||||
* Rename `zeroEx.token` to `zeroEx.erc20Token`, and add `zeroEx.erc721Token` (#863)
|
||||
* Rename `zeroEx.proxy` to `zeroEx.erc20Proxy` and add `zeroEx.erc721Proxy` (#863)
|
||||
* Refactored `ZeroEx.isValidSignature` to `zeroEx.isValidSignatureAsync`. It is now async so that it can verify contract-dependent signature types (#863)
|
||||
* Refactored `signOrderHashAsync` to `ecSignOrderHashAsync`. There are now many non-ECSignature ways to sign orders too. (#863)
|
||||
* Removed `createOrderWatcherAsync` method. Will be added back once OrderWatcher is refactored for V2 (#863)
|
||||
* 0x.js exports renamed contract events and event arg types (#863)
|
||||
* Export `ZeroEx.assetData` with methods to decode/encode assetData fields found in 0x orders (#884)
|
||||
|
||||
## v0.38.6 - _July 18, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.38.5 - _July 9, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "0x.js",
|
||||
"version": "0.38.5",
|
||||
"version": "1.0.0-rc.2",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
@@ -41,8 +41,8 @@
|
||||
"contracts": "ZRXToken",
|
||||
"postpublish": {
|
||||
"assets": [
|
||||
"packages/0x.js/_bundles/index.js",
|
||||
"packages/0x.js/_bundles/index.min.js"
|
||||
"_bundles/index.js",
|
||||
"_bundles/index.min.js"
|
||||
],
|
||||
"docPublishConfigs": {
|
||||
"extraFileIncludes": [
|
||||
@@ -51,13 +51,11 @@
|
||||
"../contract-wrappers/src/types.ts",
|
||||
"../contract-wrappers/src/contract_wrappers/ether_token_wrapper.ts",
|
||||
"../contract-wrappers/src/contract_wrappers/exchange_wrapper.ts",
|
||||
"../contract-wrappers/src/contract_wrappers/token_registry_wrapper.ts",
|
||||
"../contract-wrappers/src/contract_wrappers/token_transfer_proxy_wrapper.ts",
|
||||
"../contract-wrappers/src/contract_wrappers/token_wrapper.ts",
|
||||
"../order-watcher/src/order_watcher/order_watcher.ts",
|
||||
"./src/generated_contract_wrappers/ether_token.ts",
|
||||
"./src/generated_contract_wrappers/token.ts",
|
||||
"./src/generated_contract_wrappers/exchange.ts"
|
||||
"../contract-wrappers/src/contract_wrappers/erc20_proxy_wrapper.ts",
|
||||
"../contract-wrappers/src/contract_wrappers/erc721_proxy_wrapper.ts",
|
||||
"../contract-wrappers/src/contract_wrappers/erc20_token_wrapper.ts",
|
||||
"../contract-wrappers/src/contract_wrappers/erc721_token_wrapper.ts",
|
||||
"../order-watcher/src/order_watcher/order_watcher.ts"
|
||||
],
|
||||
"s3BucketPath": "s3://doc-jsons/0x.js/",
|
||||
"s3StagingBucketPath": "s3://staging-doc-jsons/0x.js/"
|
||||
@@ -70,11 +68,11 @@
|
||||
},
|
||||
"license": "Apache-2.0",
|
||||
"devDependencies": {
|
||||
"@0xproject/abi-gen": "^0.3.3",
|
||||
"@0xproject/dev-utils": "^0.4.5",
|
||||
"@0xproject/migrations": "^0.0.9",
|
||||
"@0xproject/monorepo-scripts": "^0.2.2",
|
||||
"@0xproject/tslint-config": "^0.4.21",
|
||||
"@0xproject/abi-gen": "^1.0.0",
|
||||
"@0xproject/dev-utils": "^1.0.0",
|
||||
"@0xproject/migrations": "^1.0.0",
|
||||
"@0xproject/monorepo-scripts": "^1.0.0",
|
||||
"@0xproject/tslint-config": "^1.0.0",
|
||||
"@types/lodash": "4.14.104",
|
||||
"@types/mocha": "^2.2.42",
|
||||
"@types/node": "^8.0.53",
|
||||
@@ -100,17 +98,17 @@
|
||||
"webpack": "^3.1.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0xproject/assert": "^0.2.13",
|
||||
"@0xproject/base-contract": "^0.3.5",
|
||||
"@0xproject/contract-wrappers": "^0.1.0",
|
||||
"@0xproject/order-utils": "^1.0.0",
|
||||
"@0xproject/sol-compiler": "^0.5.3",
|
||||
"@0xproject/subproviders": "^0.10.5",
|
||||
"@0xproject/types": "^1.0.0",
|
||||
"@0xproject/typescript-typings": "^0.4.2",
|
||||
"@0xproject/utils": "^0.7.2",
|
||||
"@0xproject/web3-wrapper": "^0.7.2",
|
||||
"ethereum-types": "^0.0.2",
|
||||
"@0xproject/assert": "^1.0.0",
|
||||
"@0xproject/base-contract": "^1.0.0",
|
||||
"@0xproject/contract-wrappers": "^1.0.0-rc.1",
|
||||
"@0xproject/order-utils": "^1.0.0-rc.1",
|
||||
"@0xproject/sol-compiler": "^1.0.0",
|
||||
"@0xproject/subproviders": "^1.0.0",
|
||||
"@0xproject/types": "^1.0.0-rc.1",
|
||||
"@0xproject/typescript-typings": "^1.0.0",
|
||||
"@0xproject/utils": "^1.0.0",
|
||||
"@0xproject/web3-wrapper": "^1.0.0",
|
||||
"ethereum-types": "^1.0.0",
|
||||
"ethers": "3.0.22",
|
||||
"lodash": "^4.17.4"
|
||||
},
|
||||
|
@@ -10,13 +10,17 @@ import {
|
||||
ExchangeWrapper,
|
||||
} from '@0xproject/contract-wrappers';
|
||||
import {
|
||||
assetDataUtils,
|
||||
ecSignOrderHashAsync,
|
||||
generatePseudoRandomSalt,
|
||||
isValidSignatureAsync,
|
||||
MessagePrefixOpts,
|
||||
orderHashUtils,
|
||||
} from '@0xproject/order-utils';
|
||||
import { ECSignature, Order, SignedOrder } from '@0xproject/types';
|
||||
// HACK: Since we export assetDataUtils from ZeroEx and it has AssetProxyId, ERC20AssetData and ERC721AssetData
|
||||
// in it's public interface, we need to import these types here.
|
||||
// tslint:disable-next-line:no-unused-variable
|
||||
import { AssetProxyId, ECSignature, ERC20AssetData, ERC721AssetData, Order, SignedOrder } from '@0xproject/types';
|
||||
import { BigNumber } from '@0xproject/utils';
|
||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||
import { Provider, TransactionReceiptWithDecodedLogs } from 'ethereum-types';
|
||||
@@ -117,6 +121,57 @@ export class ZeroEx {
|
||||
const baseUnitAmount = Web3Wrapper.toBaseUnitAmount(amount, decimals);
|
||||
return baseUnitAmount;
|
||||
}
|
||||
/**
|
||||
* Encodes an ERC20 token address into a hex encoded assetData string, usable in the makerAssetData or
|
||||
* takerAssetData fields in a 0x order.
|
||||
* @param tokenAddress The ERC20 token address to encode
|
||||
* @return The hex encoded assetData string
|
||||
*/
|
||||
public static encodeERC20AssetData(tokenAddress: string): string {
|
||||
return assetDataUtils.encodeERC20AssetData(tokenAddress);
|
||||
}
|
||||
/**
|
||||
* Decodes an ERC20 assetData hex string into it's corresponding ERC20 tokenAddress & assetProxyId
|
||||
* @param assetData Hex encoded assetData string to decode
|
||||
* @return An object containing the decoded tokenAddress & assetProxyId
|
||||
*/
|
||||
public static decodeERC20AssetData(assetData: string): ERC20AssetData {
|
||||
return assetDataUtils.decodeERC20AssetData(assetData);
|
||||
}
|
||||
/**
|
||||
* Encodes an ERC721 token address into a hex encoded assetData string, usable in the makerAssetData or
|
||||
* takerAssetData fields in a 0x order.
|
||||
* @param tokenAddress The ERC721 token address to encode
|
||||
* @param tokenId The ERC721 tokenId to encode
|
||||
* @return The hex encoded assetData string
|
||||
*/
|
||||
public static encodeERC721AssetData(tokenAddress: string, tokenId: BigNumber): string {
|
||||
return assetDataUtils.encodeERC721AssetData(tokenAddress, tokenId);
|
||||
}
|
||||
/**
|
||||
* Decodes an ERC721 assetData hex string into it's corresponding ERC721 tokenAddress, tokenId & assetProxyId
|
||||
* @param assetData Hex encoded assetData string to decode
|
||||
* @return An object containing the decoded tokenAddress, tokenId & assetProxyId
|
||||
*/
|
||||
public static decodeERC721AssetData(assetData: string): ERC721AssetData {
|
||||
return assetDataUtils.decodeERC721AssetData(assetData);
|
||||
}
|
||||
/**
|
||||
* Decode and return the assetProxyId from the assetData
|
||||
* @param assetData Hex encoded assetData string to decode
|
||||
* @return The assetProxyId
|
||||
*/
|
||||
public static decodeAssetProxyId(assetData: string): AssetProxyId {
|
||||
return assetDataUtils.decodeAssetProxyId(assetData);
|
||||
}
|
||||
/**
|
||||
* Decode any assetData into it's corresponding assetData object
|
||||
* @param assetData Hex encoded assetData string to decode
|
||||
* @return Either a ERC20 or ERC721 assetData object
|
||||
*/
|
||||
public static decodeAssetDataOrThrow(assetData: string): ERC20AssetData | ERC721AssetData {
|
||||
return assetDataUtils.decodeAssetDataOrThrow(assetData);
|
||||
}
|
||||
/**
|
||||
* Instantiates a new ZeroEx instance that provides the public interface to the 0x.js library.
|
||||
* @param provider The Provider instance you would like the 0x.js library to use for interacting with
|
||||
|
@@ -12,6 +12,9 @@ export {
|
||||
OrderStateInvalid,
|
||||
OrderState,
|
||||
Token,
|
||||
ERC20AssetData,
|
||||
ERC721AssetData,
|
||||
AssetProxyId,
|
||||
} from '@0xproject/types';
|
||||
|
||||
export {
|
||||
@@ -59,4 +62,5 @@ export {
|
||||
ExchangeCancelEventArgs,
|
||||
ExchangeEventArgs,
|
||||
ContractWrappersConfig,
|
||||
OrderInfo,
|
||||
} from '@0xproject/contract-wrappers';
|
||||
|
@@ -1,6 +1,17 @@
|
||||
[
|
||||
{
|
||||
"version": "0.4.0",
|
||||
"version": "1.0.1",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Fix the abi-gen entry point in package.json",
|
||||
"pr": 901
|
||||
}
|
||||
],
|
||||
"timestamp": 1532357734
|
||||
},
|
||||
{
|
||||
"timestamp": 1532043000,
|
||||
"version": "1.0.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Convert e_r_c to erc in generated file names",
|
||||
@@ -16,6 +27,15 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1531919263,
|
||||
"version": "0.3.4",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1531149657,
|
||||
"version": "0.3.3",
|
||||
|
@@ -1,10 +1,24 @@
|
||||
<!--
|
||||
This file is auto-generated using the monorepo-scripts package. Don't edit directly.
|
||||
changelogUtils.file is auto-generated using the monorepo-scripts package. Don't edit directly.
|
||||
Edit the package's CHANGELOG.json file only.
|
||||
-->
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v1.0.1 - _July 23, 2018_
|
||||
|
||||
* Fix the abi-gen entry point in package.json (#901)
|
||||
|
||||
## v1.0.0 - _July 20, 2018_
|
||||
|
||||
* Convert e_r_c to erc in generated file names (#822)
|
||||
* Remove the output directory before writing to it (#822)
|
||||
* skip generation of wrappers that are already up to date (#788)
|
||||
|
||||
## v0.3.4 - _July 18, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.3.3 - _July 9, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
@@ -1,2 +1,2 @@
|
||||
#!/usr/bin/env node
|
||||
require('../lib/src/index.js')
|
||||
require('../lib/src/index.js');
|
||||
|
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@0xproject/abi-gen",
|
||||
"version": "0.3.3",
|
||||
"version": "1.0.0",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
"description": "Generate contract wrappers from ABI and handlebars templates",
|
||||
"main": "lib/index.js",
|
||||
"types": "lib/index.d.ts",
|
||||
"main": "lib/src/index.js",
|
||||
"types": "lib/src/index.d.ts",
|
||||
"scripts": {
|
||||
"watch_without_deps": "tsc -w",
|
||||
"lint": "tslint --project .",
|
||||
@@ -32,11 +32,10 @@
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/0x-monorepo/packages/abi-gen/README.md",
|
||||
"dependencies": {
|
||||
"@0xproject/typescript-typings": "^0.4.2",
|
||||
"@0xproject/utils": "^0.7.2",
|
||||
"ethereum-types": "^0.0.2",
|
||||
"@0xproject/typescript-typings": "^1.0.0",
|
||||
"@0xproject/utils": "^1.0.0",
|
||||
"chalk": "^2.3.0",
|
||||
"ethereum-types": "^0.0.2",
|
||||
"ethereum-types": "^1.0.0",
|
||||
"glob": "^7.1.2",
|
||||
"handlebars": "^4.0.11",
|
||||
"lodash": "^4.17.4",
|
||||
@@ -47,8 +46,8 @@
|
||||
"yargs": "^10.0.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@0xproject/monorepo-scripts": "^0.2.2",
|
||||
"@0xproject/tslint-config": "^0.4.21",
|
||||
"@0xproject/monorepo-scripts": "^1.0.0",
|
||||
"@0xproject/tslint-config": "^1.0.0",
|
||||
"@types/glob": "5.0.35",
|
||||
"@types/handlebars": "^4.0.36",
|
||||
"@types/mkdirp": "^0.5.1",
|
||||
|
@@ -1,6 +1,16 @@
|
||||
[
|
||||
{
|
||||
"version": "0.2.14",
|
||||
"timestamp": 1532357734,
|
||||
"version": "1.0.1",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1532043000,
|
||||
"version": "1.0.0",
|
||||
"changes": [
|
||||
{
|
||||
"note":
|
||||
@@ -9,6 +19,15 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1531919263,
|
||||
"version": "0.2.14",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1531149657,
|
||||
"version": "0.2.13",
|
||||
|
@@ -1,10 +1,22 @@
|
||||
<!--
|
||||
This file is auto-generated using the monorepo-scripts package. Don't edit directly.
|
||||
changelogUtils.file is auto-generated using the monorepo-scripts package. Don't edit directly.
|
||||
Edit the package's CHANGELOG.json file only.
|
||||
-->
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v1.0.1 - _July 23, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.0.0 - _July 20, 2018_
|
||||
|
||||
* Fix bug in string enum assertion. We erroneously were checking against the enum keys, not values (#821)
|
||||
|
||||
## v0.2.14 - _July 18, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.2.13 - _July 9, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0xproject/assert",
|
||||
"version": "0.3.0",
|
||||
"version": "1.0.0",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
@@ -31,8 +31,8 @@
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/0x-monorepo/packages/assert/README.md",
|
||||
"devDependencies": {
|
||||
"@0xproject/monorepo-scripts": "^0.2.2",
|
||||
"@0xproject/tslint-config": "^0.4.21",
|
||||
"@0xproject/monorepo-scripts": "^1.0.0",
|
||||
"@0xproject/tslint-config": "^1.0.0",
|
||||
"@types/lodash": "4.14.104",
|
||||
"@types/mocha": "^2.2.42",
|
||||
"@types/valid-url": "^1.0.2",
|
||||
@@ -48,9 +48,9 @@
|
||||
"typescript": "2.7.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0xproject/json-schemas": "^1.0.0",
|
||||
"@0xproject/typescript-typings": "^0.4.2",
|
||||
"@0xproject/utils": "^0.7.2",
|
||||
"@0xproject/json-schemas": "^1.0.0-rc.1",
|
||||
"@0xproject/typescript-typings": "^1.0.0",
|
||||
"@0xproject/utils": "^1.0.0",
|
||||
"lodash": "^4.17.4",
|
||||
"valid-url": "^1.0.9"
|
||||
},
|
||||
|
@@ -1,4 +1,31 @@
|
||||
[
|
||||
{
|
||||
"timestamp": 1532357734,
|
||||
"version": "1.0.1",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1532043000,
|
||||
"version": "1.0.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1531919263,
|
||||
"version": "0.3.6",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1531149657,
|
||||
"version": "0.3.5",
|
||||
|
@@ -1,10 +1,22 @@
|
||||
<!--
|
||||
This file is auto-generated using the monorepo-scripts package. Don't edit directly.
|
||||
changelogUtils.file is auto-generated using the monorepo-scripts package. Don't edit directly.
|
||||
Edit the package's CHANGELOG.json file only.
|
||||
-->
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v1.0.1 - _July 23, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.0.0 - _July 20, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.3.6 - _July 18, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.3.5 - _July 9, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0xproject/base-contract",
|
||||
"version": "0.3.5",
|
||||
"version": "1.0.0",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
@@ -9,7 +9,7 @@
|
||||
"types": "lib/src/index.d.ts",
|
||||
"scripts": {
|
||||
"watch_without_deps": "tsc -w",
|
||||
"build": "tsc && copyfiles -u 2 './lib/monorepo_scripts/**/*' ./scripts",
|
||||
"build": "tsc && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts",
|
||||
"clean": "shx rm -rf lib scripts",
|
||||
"test": "yarn run_mocha",
|
||||
"rebuild_and_test": "run-s clean build test",
|
||||
@@ -30,8 +30,8 @@
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/0x-monorepo/packages/base-contract/README.md",
|
||||
"devDependencies": {
|
||||
"@0xproject/monorepo-scripts": "^0.2.2",
|
||||
"@0xproject/tslint-config": "^0.4.21",
|
||||
"@0xproject/monorepo-scripts": "^1.0.0",
|
||||
"@0xproject/tslint-config": "^1.0.0",
|
||||
"@types/lodash": "4.14.104",
|
||||
"chai": "^4.0.1",
|
||||
"copyfiles": "^1.2.0",
|
||||
@@ -43,10 +43,10 @@
|
||||
"typescript": "2.7.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"ethereum-types": "^0.0.2",
|
||||
"@0xproject/typescript-typings": "^0.4.2",
|
||||
"@0xproject/utils": "^0.7.2",
|
||||
"@0xproject/web3-wrapper": "^0.7.2",
|
||||
"ethereum-types": "^1.0.0",
|
||||
"@0xproject/typescript-typings": "^1.0.0",
|
||||
"@0xproject/utils": "^1.0.0",
|
||||
"@0xproject/web3-wrapper": "^1.0.0",
|
||||
"ethers": "3.0.22",
|
||||
"lodash": "^4.17.4"
|
||||
},
|
||||
|
@@ -1,10 +1,29 @@
|
||||
[
|
||||
{
|
||||
"timestamp": 1532357734,
|
||||
"version": "1.0.1",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1532043000,
|
||||
"version": "1.0.0",
|
||||
"changes": [
|
||||
{
|
||||
"note":
|
||||
"Remove WebSocketOrderbookChannel from the public interface and replace with orderbookChannelFactory"
|
||||
"Remove `WebSocketOrderbookChannel` from the public interface and replace with `orderbookChannelFactory`"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1531919263,
|
||||
"version": "0.6.17",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@@ -1,10 +1,22 @@
|
||||
<!--
|
||||
This file is auto-generated using the monorepo-scripts package. Don't edit directly.
|
||||
changelogUtils.file is auto-generated using the monorepo-scripts package. Don't edit directly.
|
||||
Edit the package's CHANGELOG.json file only.
|
||||
-->
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v1.0.1 - _July 23, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.0.0 - _July 20, 2018_
|
||||
|
||||
* Remove `WebSocketOrderbookChannel` from the public interface and replace with `orderbookChannelFactory`
|
||||
|
||||
## v0.6.17 - _July 18, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.6.16 - _July 9, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0xproject/connect",
|
||||
"version": "0.6.16",
|
||||
"version": "1.0.0",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
@@ -51,19 +51,19 @@
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/0x-monorepo/packages/connect/README.md",
|
||||
"dependencies": {
|
||||
"@0xproject/assert": "^0.2.13",
|
||||
"@0xproject/json-schemas": "0.8.2",
|
||||
"@0xproject/assert": "^0.2.14",
|
||||
"@0xproject/json-schemas": "^0.8.3",
|
||||
"@0xproject/types": "^0.8.2",
|
||||
"@0xproject/typescript-typings": "^0.4.2",
|
||||
"@0xproject/utils": "^0.7.2",
|
||||
"@0xproject/typescript-typings": "^1.0.0",
|
||||
"@0xproject/utils": "^1.0.0",
|
||||
"lodash": "^4.17.4",
|
||||
"query-string": "^5.0.1",
|
||||
"sinon": "^4.0.0",
|
||||
"websocket": "^1.0.25"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@0xproject/monorepo-scripts": "^0.2.2",
|
||||
"@0xproject/tslint-config": "^0.4.21",
|
||||
"@0xproject/monorepo-scripts": "^1.0.0",
|
||||
"@0xproject/tslint-config": "^1.0.0",
|
||||
"@types/fetch-mock": "^5.12.2",
|
||||
"@types/lodash": "4.14.104",
|
||||
"@types/mocha": "^2.2.42",
|
||||
|
@@ -1,16 +1,35 @@
|
||||
[
|
||||
{
|
||||
"timestamp": 1532357734,
|
||||
"version": "1.0.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Update blockstream to v5.0 and propogate up caught errors to active subscriptions"
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1532043000,
|
||||
"version": "1.0.0-rc.1",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Update blockstream to v5.0 and propogate up caught errors to active subscriptions",
|
||||
"pr": 815
|
||||
},
|
||||
{
|
||||
"note": "Update to v2 of 0x rpotocol",
|
||||
"pr": 822
|
||||
}
|
||||
],
|
||||
"timestamp": 1531149657
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1531919263,
|
||||
"version": "0.1.1",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1529397769,
|
||||
|
@@ -1,13 +1,22 @@
|
||||
<!--
|
||||
This file is auto-generated using the monorepo-scripts package. Don't edit directly.
|
||||
changelogUtils.file is auto-generated using the monorepo-scripts package. Don't edit directly.
|
||||
Edit the package's CHANGELOG.json file only.
|
||||
-->
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v0.1.0 - _July 9, 2018_
|
||||
## v1.0.0 - _July 23, 2018_
|
||||
|
||||
* Update Blockstream dep. to V5.0 and no longer force unsubscribe on blockstream error (which are not recoverable)
|
||||
* Dependencies updated
|
||||
|
||||
## v1.0.0-rc.1 - _July 20, 2018_
|
||||
|
||||
* Update blockstream to v5.0 and propogate up caught errors to active subscriptions (#815)
|
||||
* Update to v2 of 0x rpotocol (#822)
|
||||
|
||||
## v0.1.1 - _July 18, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.0.5 - _June 19, 2018_
|
||||
|
||||
@@ -15,11 +24,7 @@ CHANGELOG
|
||||
|
||||
## v0.0.4 - _May 29, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.0.3 - _May 29, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
* Expose 'abi' ContractAbi property on all contract wrappers
|
||||
|
||||
## v0.0.2 - _May 22, 2018_
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0xproject/contract-wrappers",
|
||||
"version": "0.1.0",
|
||||
"version": "1.0.0-rc.1",
|
||||
"description": "Smart TS wrappers for 0x smart contracts",
|
||||
"keywords": [
|
||||
"0xproject",
|
||||
@@ -26,14 +26,6 @@
|
||||
"run_mocha": "mocha --require source-map-support/register --require make-promises-safe lib/test/**/*_test.js lib/test/global_hooks.js --timeout 10000 --bail --exit",
|
||||
"manual:postpublish": "yarn build; node ./scripts/postpublish.js"
|
||||
},
|
||||
"config": {
|
||||
"postpublish": {
|
||||
"assets": [
|
||||
"packages/contract-wrappers/_bundles/index.js",
|
||||
"packages/contract-wrappers/_bundles/index.min.js"
|
||||
]
|
||||
}
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/0xProject/0x-monorepo"
|
||||
@@ -43,13 +35,13 @@
|
||||
"node": ">=6.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@0xproject/abi-gen": "^0.3.3",
|
||||
"@0xproject/dev-utils": "^0.4.5",
|
||||
"@0xproject/migrations": "^0.0.9",
|
||||
"@0xproject/monorepo-scripts": "^0.2.2",
|
||||
"@0xproject/sol-compiler": "^0.5.3",
|
||||
"@0xproject/subproviders": "^0.10.5",
|
||||
"@0xproject/tslint-config": "^0.4.21",
|
||||
"@0xproject/abi-gen": "^1.0.0",
|
||||
"@0xproject/dev-utils": "^1.0.0",
|
||||
"@0xproject/migrations": "^1.0.0",
|
||||
"@0xproject/monorepo-scripts": "^1.0.0",
|
||||
"@0xproject/sol-compiler": "^1.0.0",
|
||||
"@0xproject/subproviders": "^1.0.0",
|
||||
"@0xproject/tslint-config": "^1.0.0",
|
||||
"@types/lodash": "4.14.104",
|
||||
"@types/mocha": "^2.2.42",
|
||||
"@types/node": "^8.0.53",
|
||||
@@ -69,20 +61,21 @@
|
||||
"shx": "^0.2.2",
|
||||
"sinon": "^4.0.0",
|
||||
"source-map-support": "^0.5.0",
|
||||
"web3-provider-engine": "14.0.6",
|
||||
"tslint": "5.11.0",
|
||||
"typescript": "2.7.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0xproject/assert": "^0.3.0",
|
||||
"@0xproject/base-contract": "^0.3.5",
|
||||
"@0xproject/order-utils": "^1.0.0",
|
||||
"@0xproject/typescript-typings": "^0.4.2",
|
||||
"@0xproject/utils": "^0.7.2",
|
||||
"@0xproject/web3-wrapper": "^0.7.2",
|
||||
"@0xproject/fill-scenarios": "^1.0.0",
|
||||
"@0xproject/json-schemas": "^1.0.0",
|
||||
"@0xproject/types": "^1.0.0",
|
||||
"ethereum-types": "^0.0.2",
|
||||
"@0xproject/assert": "^1.0.0",
|
||||
"@0xproject/base-contract": "^1.0.0",
|
||||
"@0xproject/order-utils": "^1.0.0-rc.1",
|
||||
"@0xproject/typescript-typings": "^1.0.0",
|
||||
"@0xproject/utils": "^1.0.0",
|
||||
"@0xproject/web3-wrapper": "^1.0.0",
|
||||
"@0xproject/fill-scenarios": "^1.0.0-rc.1",
|
||||
"@0xproject/json-schemas": "^1.0.0-rc.1",
|
||||
"@0xproject/types": "^1.0.0-rc.1",
|
||||
"ethereum-types": "^1.0.0",
|
||||
"ethereumjs-blockstream": "5.0.0",
|
||||
"ethereumjs-util": "^5.1.1",
|
||||
"ethers": "3.0.22",
|
||||
|
@@ -342,15 +342,17 @@ export class ERC721TokenWrapper extends ContractWrapper {
|
||||
const normalizedSenderAddress = senderAddress.toLowerCase();
|
||||
const tokenContract = await this._getTokenContractAsync(normalizedTokenAddress);
|
||||
const ownerAddress = await this.getOwnerOfAsync(tokenAddress, tokenId);
|
||||
const isApprovedForAll = await this.isApprovedForAllAsync(
|
||||
normalizedTokenAddress,
|
||||
ownerAddress,
|
||||
normalizedSenderAddress,
|
||||
);
|
||||
if (!isApprovedForAll) {
|
||||
const approvedAddress = await this.getApprovedIfExistsAsync(normalizedTokenAddress, tokenId);
|
||||
if (approvedAddress !== senderAddress) {
|
||||
throw new Error(ContractWrappersError.ERC721NoApproval);
|
||||
if (normalizedSenderAddress !== ownerAddress) {
|
||||
const isApprovedForAll = await this.isApprovedForAllAsync(
|
||||
normalizedTokenAddress,
|
||||
ownerAddress,
|
||||
normalizedSenderAddress,
|
||||
);
|
||||
if (!isApprovedForAll) {
|
||||
const approvedAddress = await this.getApprovedIfExistsAsync(normalizedTokenAddress, tokenId);
|
||||
if (approvedAddress !== normalizedSenderAddress) {
|
||||
throw new Error(ContractWrappersError.ERC721NoApproval);
|
||||
}
|
||||
}
|
||||
}
|
||||
const txHash = await tokenContract.transferFrom.sendTransactionAsync(
|
||||
|
@@ -1,4 +1,5 @@
|
||||
import { schemas } from '@0xproject/json-schemas';
|
||||
import { assetDataUtils } from '@0xproject/order-utils';
|
||||
import { AssetProxyId, Order, SignedOrder } from '@0xproject/types';
|
||||
import { BigNumber } from '@0xproject/utils';
|
||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||
@@ -1071,9 +1072,9 @@ export class ExchangeWrapper extends ContractWrapper {
|
||||
* Returns the ZRX asset data used by the exchange contract.
|
||||
* @return ZRX asset data
|
||||
*/
|
||||
public async getZRXAssetDataAsync(): Promise<string> {
|
||||
const exchangeInstance = await this._getExchangeContractAsync();
|
||||
const zrxAssetData = exchangeInstance.ZRX_ASSET_DATA.callAsync();
|
||||
public getZRXAssetData(): string {
|
||||
const zrxTokenAddress = this.getZRXTokenAddress();
|
||||
const zrxAssetData = assetDataUtils.encodeERC20AssetData(zrxTokenAddress);
|
||||
return zrxAssetData;
|
||||
}
|
||||
// tslint:disable:no-unused-variable
|
||||
|
@@ -1,9 +1,9 @@
|
||||
export { ContractWrappers } from './contract_wrappers';
|
||||
export { ERC20TokenWrapper } from './contract_wrappers/erc20_token_wrapper';
|
||||
export { EtherTokenWrapper } from './contract_wrappers/ether_token_wrapper';
|
||||
export { ERC20ProxyWrapper } from './contract_wrappers/erc20_proxy_wrapper';
|
||||
export { ExchangeWrapper } from './contract_wrappers/exchange_wrapper';
|
||||
export { ERC721TokenWrapper } from './contract_wrappers/erc721_token_wrapper';
|
||||
export { EtherTokenWrapper } from './contract_wrappers/ether_token_wrapper';
|
||||
export { ExchangeWrapper } from './contract_wrappers/exchange_wrapper';
|
||||
export { ERC20ProxyWrapper } from './contract_wrappers/erc20_proxy_wrapper';
|
||||
export { ERC721ProxyWrapper } from './contract_wrappers/erc721_proxy_wrapper';
|
||||
|
||||
export {
|
||||
@@ -26,7 +26,15 @@ export {
|
||||
OrderInfo,
|
||||
} from './types';
|
||||
|
||||
export { Order, SignedOrder, ECSignature, OrderStateValid, OrderStateInvalid, OrderState } from '@0xproject/types';
|
||||
export {
|
||||
Order,
|
||||
SignedOrder,
|
||||
ECSignature,
|
||||
OrderStateValid,
|
||||
OrderStateInvalid,
|
||||
OrderState,
|
||||
AssetProxyId,
|
||||
} from '@0xproject/types';
|
||||
|
||||
export {
|
||||
BlockParamLiteral,
|
||||
@@ -60,6 +68,7 @@ export {
|
||||
ERC721TokenApprovalForAllEventArgs,
|
||||
ERC721TokenTransferEventArgs,
|
||||
ERC721TokenEvents,
|
||||
ERC721TokenEventArgs,
|
||||
} from './contract_wrappers/generated/erc721_token';
|
||||
|
||||
export {
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import { BlockchainLifecycle, callbackErrorReporter } from '@0xproject/dev-utils';
|
||||
import { FillScenarios } from '@0xproject/fill-scenarios';
|
||||
import { assetProxyUtils, orderHashUtils } from '@0xproject/order-utils';
|
||||
import { assetDataUtils, orderHashUtils } from '@0xproject/order-utils';
|
||||
import { DoneCallback, SignedOrder } from '@0xproject/types';
|
||||
import { BigNumber } from '@0xproject/utils';
|
||||
import * as chai from 'chai';
|
||||
@@ -53,7 +53,6 @@ describe('ExchangeWrapper', () => {
|
||||
await blockchainLifecycle.startAsync();
|
||||
contractWrappers = new ContractWrappers(provider, config);
|
||||
exchangeContractAddress = contractWrappers.exchange.getContractAddress();
|
||||
const erc20ProxyAddress = contractWrappers.erc20Proxy.getContractAddress();
|
||||
userAddresses = await web3Wrapper.getAvailableAddressesAsync();
|
||||
zrxTokenAddress = tokenUtils.getProtocolTokenAddress();
|
||||
fillScenarios = new FillScenarios(
|
||||
@@ -61,13 +60,14 @@ describe('ExchangeWrapper', () => {
|
||||
userAddresses,
|
||||
zrxTokenAddress,
|
||||
exchangeContractAddress,
|
||||
erc20ProxyAddress,
|
||||
contractWrappers.erc20Proxy.getContractAddress(),
|
||||
contractWrappers.erc721Proxy.getContractAddress(),
|
||||
);
|
||||
[coinbase, makerAddress, takerAddress, feeRecipient, anotherMakerAddress] = userAddresses;
|
||||
[makerTokenAddress, takerTokenAddress] = tokenUtils.getDummyERC20TokenAddresses();
|
||||
[makerAssetData, takerAssetData] = [
|
||||
assetProxyUtils.encodeERC20AssetData(makerTokenAddress),
|
||||
assetProxyUtils.encodeERC20AssetData(takerTokenAddress),
|
||||
assetDataUtils.encodeERC20AssetData(makerTokenAddress),
|
||||
assetDataUtils.encodeERC20AssetData(takerTokenAddress),
|
||||
];
|
||||
signedOrder = await fillScenarios.createFillableSignedOrderAsync(
|
||||
makerAssetData,
|
||||
@@ -264,8 +264,8 @@ describe('ExchangeWrapper', () => {
|
||||
});
|
||||
});
|
||||
describe('#getZRXAssetData', () => {
|
||||
it('should get the asset data', async () => {
|
||||
const ZRX_ASSET_DATA = await contractWrappers.exchange.getZRXAssetDataAsync();
|
||||
it('should get the asset data', () => {
|
||||
const ZRX_ASSET_DATA = contractWrappers.exchange.getZRXAssetData();
|
||||
const ASSET_DATA_HEX_LENGTH = 74;
|
||||
expect(ZRX_ASSET_DATA).to.have.length(ASSET_DATA_HEX_LENGTH);
|
||||
});
|
||||
|
@@ -25,6 +25,7 @@
|
||||
"DummyERC721Token",
|
||||
"ERC20Proxy",
|
||||
"ERC20Token",
|
||||
"ERC721Token",
|
||||
"ERC721Proxy",
|
||||
"Exchange",
|
||||
"ExchangeWrapper",
|
||||
|
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"private": true,
|
||||
"name": "contracts",
|
||||
"version": "2.1.34",
|
||||
"version": "2.1.35",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
@@ -46,11 +46,11 @@
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/0x-monorepo/packages/contracts/README.md",
|
||||
"devDependencies": {
|
||||
"@0xproject/abi-gen": "^0.3.3",
|
||||
"@0xproject/dev-utils": "^0.4.5",
|
||||
"@0xproject/tslint-config": "^0.4.21",
|
||||
"@0xproject/subproviders": "^0.10.5",
|
||||
"@0xproject/sol-cov": "^0.1.2",
|
||||
"@0xproject/abi-gen": "^1.0.0",
|
||||
"@0xproject/dev-utils": "^1.0.0",
|
||||
"@0xproject/tslint-config": "^1.0.0",
|
||||
"@0xproject/subproviders": "^1.0.0",
|
||||
"@0xproject/sol-cov": "^1.0.0",
|
||||
"@types/lodash": "4.14.104",
|
||||
"@types/bn.js": "^4.11.0",
|
||||
"@types/node": "^8.0.53",
|
||||
@@ -72,18 +72,18 @@
|
||||
"yargs": "^10.0.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0xproject/base-contract": "^0.3.5",
|
||||
"@0xproject/order-utils": "^1.0.0",
|
||||
"@0xproject/sol-compiler": "^0.5.3",
|
||||
"@0xproject/types": "^1.0.0",
|
||||
"@0xproject/typescript-typings": "^0.4.2",
|
||||
"@0xproject/utils": "^0.7.2",
|
||||
"@0xproject/web3-wrapper": "^0.7.2",
|
||||
"ethereum-types": "^0.0.2",
|
||||
"@0xproject/base-contract": "^1.0.0",
|
||||
"@0xproject/order-utils": "^1.0.0-rc.1",
|
||||
"@0xproject/sol-compiler": "^1.0.0",
|
||||
"@0xproject/types": "^1.0.0-rc.1",
|
||||
"@0xproject/typescript-typings": "^1.0.0",
|
||||
"@0xproject/utils": "^1.0.0",
|
||||
"@0xproject/web3-wrapper": "^1.0.0",
|
||||
"ethereum-types": "^1.0.0",
|
||||
"bn.js": "^4.11.8",
|
||||
"ethereumjs-abi": "^0.6.4",
|
||||
"ethereumjs-abi": "0.6.5",
|
||||
"ethereumjs-util": "^5.1.1",
|
||||
"ethers": "3.0.22",
|
||||
"lodash": "^4.17.4"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -40,7 +40,7 @@ contract MixinForwarderCore is
|
||||
MForwarderCore
|
||||
{
|
||||
bytes4 constant internal ERC20_DATA_ID = bytes4(keccak256("ERC20Token(address)"));
|
||||
bytes4 constant internal ERC721_DATA_ID = bytes4(keccak256("ERC721Token(address,uint256,bytes)"));
|
||||
bytes4 constant internal ERC721_DATA_ID = bytes4(keccak256("ERC721Token(address,uint256)"));
|
||||
uint256 constant internal MAX_UINT = 2**256 - 1;
|
||||
|
||||
constructor ()
|
||||
|
@@ -109,12 +109,10 @@ contract MixinTransfer is
|
||||
// Decode asset data.
|
||||
address token = assetData.readAddress(16);
|
||||
uint256 tokenId = assetData.readUint256(36);
|
||||
bytes memory receiverData = assetData.readBytesWithLength(100);
|
||||
IERC721Token(token).safeTransferFrom(
|
||||
IERC721Token(token).transferFrom(
|
||||
address(this),
|
||||
to,
|
||||
tokenId,
|
||||
receiverData
|
||||
tokenId
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -26,7 +26,7 @@ contract ERC721Proxy is
|
||||
MixinAuthorizable
|
||||
{
|
||||
// Id of this proxy.
|
||||
bytes4 constant internal PROXY_ID = bytes4(keccak256("ERC721Token(address,uint256,bytes)"));
|
||||
bytes4 constant internal PROXY_ID = bytes4(keccak256("ERC721Token(address,uint256)"));
|
||||
|
||||
// solhint-disable-next-line payable-fallback
|
||||
function ()
|
||||
@@ -83,19 +83,15 @@ contract ERC721Proxy is
|
||||
// WARNING: The ABIv2 specification allows additional padding between
|
||||
// the Params and Data section. This will result in a larger
|
||||
// offset to assetData.
|
||||
|
||||
|
||||
// Asset data itself is encoded as follows:
|
||||
//
|
||||
// | Area | Offset | Length | Contents |
|
||||
// |----------|--------|---------|-------------------------------------|
|
||||
// | Header | 0 | 4 | function selector |
|
||||
// | Params | | 3 * 32 | function parameters: |
|
||||
// | Params | | 2 * 32 | function parameters: |
|
||||
// | | 4 | 12 + 20 | 1. token address |
|
||||
// | | 36 | | 2. tokenId |
|
||||
// | | 68 | | 3. offset to receiverData (*) |
|
||||
// | Data | | | receiverData: |
|
||||
// | | 100 | 32 | receiverData Length |
|
||||
// | | 132 | ** | receiverData Contents |
|
||||
|
||||
// We construct calldata for the `token.safeTransferFrom` ABI.
|
||||
// The layout of this calldata is in the table below.
|
||||
@@ -103,14 +99,10 @@ contract ERC721Proxy is
|
||||
// | Area | Offset | Length | Contents |
|
||||
// |----------|--------|---------|-------------------------------------|
|
||||
// | Header | 0 | 4 | function selector |
|
||||
// | Params | | 4 * 32 | function parameters: |
|
||||
// | Params | | 3 * 32 | function parameters: |
|
||||
// | | 4 | | 1. from |
|
||||
// | | 36 | | 2. to |
|
||||
// | | 68 | | 3. tokenId |
|
||||
// | | 100 | | 4. offset to receiverData (*) |
|
||||
// | Data | | | receiverData: |
|
||||
// | | 132 | 32 | receiverData Length |
|
||||
// | | 164 | ** | receiverData Contents |
|
||||
|
||||
// There exists only 1 of each token.
|
||||
// require(amount == 1, "INVALID_AMOUNT")
|
||||
@@ -122,76 +114,32 @@ contract ERC721Proxy is
|
||||
mstore(96, 0)
|
||||
revert(0, 100)
|
||||
}
|
||||
|
||||
// Require assetData to be at least 132 bytes
|
||||
let offset := calldataload(4)
|
||||
if lt(calldataload(add(offset, 4)), 132) {
|
||||
// Revert with `Error("LENGTH_GREATER_THAN_131_REQUIRED")`
|
||||
mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000)
|
||||
mstore(32, 0x0000002000000000000000000000000000000000000000000000000000000000)
|
||||
mstore(64, 0x000000204c454e4754485f475245415445525f5448414e5f3133315f52455155)
|
||||
mstore(96, 0x4952454400000000000000000000000000000000000000000000000000000000)
|
||||
revert(0, 100)
|
||||
}
|
||||
|
||||
/////// Setup State ///////
|
||||
// `cdStart` is the start of the calldata for
|
||||
// `token.safeTransferFrom` (equal to free memory ptr).
|
||||
let cdStart := mload(64)
|
||||
// `dataAreaLength` is the total number of words
|
||||
// needed to store `receiverData`
|
||||
// As-per the ABI spec, this value is padded up to
|
||||
// the nearest multiple of 32,
|
||||
// and includes 32-bytes for length.
|
||||
// It's calculated as folows:
|
||||
// - Unpadded length in bytes = `mload(receiverData) + 32`
|
||||
// - Add 31 to convert rounding down to rounding up.
|
||||
// Combined with the previous and this is `63`.
|
||||
// - Round down to nearest multiple of 32 by clearing
|
||||
// bits 0x1F. This is done with `and` and a mask.
|
||||
|
||||
/////// Setup Header Area ///////
|
||||
// This area holds the 4-byte `transferFromSelector`.
|
||||
// Any trailing data in transferFromSelector will be
|
||||
// overwritten in the next `mstore` call.
|
||||
mstore(cdStart, 0xb88d4fde00000000000000000000000000000000000000000000000000000000)
|
||||
mstore(0, 0x23b872dd00000000000000000000000000000000000000000000000000000000)
|
||||
|
||||
/////// Setup Params Area ///////
|
||||
// Each parameter is padded to 32-bytes.
|
||||
// The entire Params Area is 128 bytes.
|
||||
// Notes:
|
||||
// 1. A 20-byte mask is applied to addresses
|
||||
// to zero-out the unused bytes.
|
||||
// 2. The offset to `receiverData` is the length
|
||||
// of the Params Area (128 bytes).
|
||||
|
||||
let length := calldataload(add(offset, 136))
|
||||
let token := calldataload(add(offset, 40))
|
||||
|
||||
// Round length up to multiple of 32
|
||||
length := and(add(length, 31), 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE0)
|
||||
|
||||
// Copy `from` and `to`
|
||||
calldatacopy(add(cdStart, 4), 36, 64)
|
||||
|
||||
// TokenId
|
||||
mstore(add(cdStart, 68), calldataload(add(offset, 72)))
|
||||
|
||||
// Offset to receiverData
|
||||
mstore(add(cdStart, 100), 128)
|
||||
|
||||
// receiverData (including length)
|
||||
calldatacopy(add(cdStart, 132), add(offset, 136), add(length, 32))
|
||||
|
||||
/////// Call `token.safeTransferFrom` using the calldata ///////
|
||||
// We copy the fields `from` and `to` in bulk
|
||||
// from our own calldata to the new calldata.
|
||||
calldatacopy(4, 36, 64)
|
||||
|
||||
// Copy `tokenId` field from our own calldata to the new calldata.
|
||||
let assetDataOffset := calldataload(4)
|
||||
calldatacopy(68, add(assetDataOffset, 72), 32)
|
||||
|
||||
/////// Call `token.transferFrom` using the calldata ///////
|
||||
let token := calldataload(add(assetDataOffset, 40))
|
||||
let success := call(
|
||||
gas, // forward all gas
|
||||
token, // call address of token contract
|
||||
0, // don't send any ETH
|
||||
cdStart, // pointer to start of input
|
||||
add(length, 164), // length of input
|
||||
0, // write output to null
|
||||
0 // output size is 0 bytes
|
||||
gas, // forward all gas
|
||||
token, // call address of token contract
|
||||
0, // don't send any ETH
|
||||
0, // pointer to start of input
|
||||
100, // length of input
|
||||
0, // write output to null
|
||||
0 // output size is 0 bytes
|
||||
)
|
||||
if success {
|
||||
return(0, 0)
|
||||
|
@@ -22,12 +22,14 @@ pragma experimental ABIEncoderV2;
|
||||
import "./libs/LibMath.sol";
|
||||
import "./libs/LibOrder.sol";
|
||||
import "./libs/LibFillResults.sol";
|
||||
import "./libs/LibAbiEncoder.sol";
|
||||
import "./mixins/MExchangeCore.sol";
|
||||
|
||||
|
||||
contract MixinWrapperFunctions is
|
||||
LibMath,
|
||||
LibFillResults,
|
||||
LibAbiEncoder,
|
||||
MExchangeCore
|
||||
{
|
||||
/// @dev Fills the input order. Reverts if exact takerAssetFillAmount not filled.
|
||||
@@ -68,177 +70,21 @@ contract MixinWrapperFunctions is
|
||||
public
|
||||
returns (FillResults memory fillResults)
|
||||
{
|
||||
// We need to call MExchangeCore.fillOrder using a delegatecall in
|
||||
// assembly so that we can intercept a call that throws. For this, we
|
||||
// need the input encoded in memory in the Ethereum ABIv2 format [1].
|
||||
|
||||
// | Area | Offset | Length | Contents |
|
||||
// | -------- |--------|---------|-------------------------------------------- |
|
||||
// | Header | 0x00 | 4 | function selector |
|
||||
// | Params | | 3 * 32 | function parameters: |
|
||||
// | | 0x00 | | 1. offset to order (*) |
|
||||
// | | 0x20 | | 2. takerAssetFillAmount |
|
||||
// | | 0x40 | | 3. offset to signature (*) |
|
||||
// | Data | | 12 * 32 | order: |
|
||||
// | | 0x000 | | 1. senderAddress |
|
||||
// | | 0x020 | | 2. makerAddress |
|
||||
// | | 0x040 | | 3. takerAddress |
|
||||
// | | 0x060 | | 4. feeRecipientAddress |
|
||||
// | | 0x080 | | 5. makerAssetAmount |
|
||||
// | | 0x0A0 | | 6. takerAssetAmount |
|
||||
// | | 0x0C0 | | 7. makerFeeAmount |
|
||||
// | | 0x0E0 | | 8. takerFeeAmount |
|
||||
// | | 0x100 | | 9. expirationTimeSeconds |
|
||||
// | | 0x120 | | 10. salt |
|
||||
// | | 0x140 | | 11. Offset to makerAssetData (*) |
|
||||
// | | 0x160 | | 12. Offset to takerAssetData (*) |
|
||||
// | | 0x180 | 32 | makerAssetData Length |
|
||||
// | | 0x1A0 | ** | makerAssetData Contents |
|
||||
// | | 0x1C0 | 32 | takerAssetData Length |
|
||||
// | | 0x1E0 | ** | takerAssetData Contents |
|
||||
// | | 0x200 | 32 | signature Length |
|
||||
// | | 0x220 | ** | signature Contents |
|
||||
|
||||
// * Offsets are calculated from the beginning of the current area: Header, Params, Data:
|
||||
// An offset stored in the Params area is calculated from the beginning of the Params section.
|
||||
// An offset stored in the Data area is calculated from the beginning of the Data section.
|
||||
|
||||
// ** The length of dynamic array contents are stored in the field immediately preceeding the contents.
|
||||
|
||||
// [1]: https://solidity.readthedocs.io/en/develop/abi-spec.html
|
||||
|
||||
bytes4 fillOrderSelector = this.fillOrder.selector;
|
||||
// ABI encode calldata for `fillOrder`
|
||||
bytes memory fillOrderCalldata = abiEncodeFillOrder(
|
||||
order,
|
||||
takerAssetFillAmount,
|
||||
signature
|
||||
);
|
||||
|
||||
// Delegate to `fillOrder` and handle any exceptions gracefully
|
||||
assembly {
|
||||
|
||||
// Areas below may use the following variables:
|
||||
// 1. <area>Start -- Start of this area in memory
|
||||
// 2. <area>End -- End of this area in memory. This value may
|
||||
// be precomputed (before writing contents),
|
||||
// or it may be computed as contents are written.
|
||||
// 3. <area>Offset -- Current offset into area. If an area's End
|
||||
// is precomputed, this variable tracks the
|
||||
// offsets of contents as they are written.
|
||||
|
||||
/////// Setup Header Area ///////
|
||||
// Load free memory pointer
|
||||
let headerAreaStart := mload(0x40)
|
||||
mstore(headerAreaStart, fillOrderSelector)
|
||||
let headerAreaEnd := add(headerAreaStart, 0x4)
|
||||
|
||||
/////// Setup Params Area ///////
|
||||
// This area is preallocated and written to later.
|
||||
// This is because we need to fill in offsets that have not yet been calculated.
|
||||
let paramsAreaStart := headerAreaEnd
|
||||
let paramsAreaEnd := add(paramsAreaStart, 0x60)
|
||||
let paramsAreaOffset := paramsAreaStart
|
||||
|
||||
/////// Setup Data Area ///////
|
||||
let dataAreaStart := paramsAreaEnd
|
||||
let dataAreaEnd := dataAreaStart
|
||||
|
||||
// Offset from the source data we're reading from
|
||||
let sourceOffset := order
|
||||
// arrayLenBytes and arrayLenWords track the length of a dynamically-allocated bytes array.
|
||||
let arrayLenBytes := 0
|
||||
let arrayLenWords := 0
|
||||
|
||||
/////// Write order Struct ///////
|
||||
// Write memory location of Order, relative to the start of the
|
||||
// parameter list, then increment the paramsAreaOffset respectively.
|
||||
mstore(paramsAreaOffset, sub(dataAreaEnd, paramsAreaStart))
|
||||
paramsAreaOffset := add(paramsAreaOffset, 0x20)
|
||||
|
||||
// Write values for each field in the order
|
||||
// It would be nice to use a loop, but we save on gas by writing
|
||||
// the stores sequentially.
|
||||
mstore(dataAreaEnd, mload(sourceOffset)) // makerAddress
|
||||
mstore(add(dataAreaEnd, 0x20), mload(add(sourceOffset, 0x20))) // takerAddress
|
||||
mstore(add(dataAreaEnd, 0x40), mload(add(sourceOffset, 0x40))) // feeRecipientAddress
|
||||
mstore(add(dataAreaEnd, 0x60), mload(add(sourceOffset, 0x60))) // senderAddress
|
||||
mstore(add(dataAreaEnd, 0x80), mload(add(sourceOffset, 0x80))) // makerAssetAmount
|
||||
mstore(add(dataAreaEnd, 0xA0), mload(add(sourceOffset, 0xA0))) // takerAssetAmount
|
||||
mstore(add(dataAreaEnd, 0xC0), mload(add(sourceOffset, 0xC0))) // makerFeeAmount
|
||||
mstore(add(dataAreaEnd, 0xE0), mload(add(sourceOffset, 0xE0))) // takerFeeAmount
|
||||
mstore(add(dataAreaEnd, 0x100), mload(add(sourceOffset, 0x100))) // expirationTimeSeconds
|
||||
mstore(add(dataAreaEnd, 0x120), mload(add(sourceOffset, 0x120))) // salt
|
||||
mstore(add(dataAreaEnd, 0x140), mload(add(sourceOffset, 0x140))) // Offset to makerAssetData
|
||||
mstore(add(dataAreaEnd, 0x160), mload(add(sourceOffset, 0x160))) // Offset to takerAssetData
|
||||
dataAreaEnd := add(dataAreaEnd, 0x180)
|
||||
sourceOffset := add(sourceOffset, 0x180)
|
||||
|
||||
// Write offset to <order.makerAssetData>
|
||||
mstore(add(dataAreaStart, mul(10, 0x20)), sub(dataAreaEnd, dataAreaStart))
|
||||
|
||||
// Calculate length of <order.makerAssetData>
|
||||
sourceOffset := mload(add(order, 0x140)) // makerAssetData
|
||||
arrayLenBytes := mload(sourceOffset)
|
||||
sourceOffset := add(sourceOffset, 0x20)
|
||||
arrayLenWords := div(add(arrayLenBytes, 0x1F), 0x20)
|
||||
|
||||
// Write length of <order.makerAssetData>
|
||||
mstore(dataAreaEnd, arrayLenBytes)
|
||||
dataAreaEnd := add(dataAreaEnd, 0x20)
|
||||
|
||||
// Write contents of <order.makerAssetData>
|
||||
for {let i := 0} lt(i, arrayLenWords) {i := add(i, 1)} {
|
||||
mstore(dataAreaEnd, mload(sourceOffset))
|
||||
dataAreaEnd := add(dataAreaEnd, 0x20)
|
||||
sourceOffset := add(sourceOffset, 0x20)
|
||||
}
|
||||
|
||||
// Write offset to <order.takerAssetData>
|
||||
mstore(add(dataAreaStart, mul(11, 0x20)), sub(dataAreaEnd, dataAreaStart))
|
||||
|
||||
// Calculate length of <order.takerAssetData>
|
||||
sourceOffset := mload(add(order, 0x160)) // takerAssetData
|
||||
arrayLenBytes := mload(sourceOffset)
|
||||
sourceOffset := add(sourceOffset, 0x20)
|
||||
arrayLenWords := div(add(arrayLenBytes, 0x1F), 0x20)
|
||||
|
||||
// Write length of <order.takerAssetData>
|
||||
mstore(dataAreaEnd, arrayLenBytes)
|
||||
dataAreaEnd := add(dataAreaEnd, 0x20)
|
||||
|
||||
// Write contents of <order.takerAssetData>
|
||||
for {let i := 0} lt(i, arrayLenWords) {i := add(i, 1)} {
|
||||
mstore(dataAreaEnd, mload(sourceOffset))
|
||||
dataAreaEnd := add(dataAreaEnd, 0x20)
|
||||
sourceOffset := add(sourceOffset, 0x20)
|
||||
}
|
||||
|
||||
/////// Write takerAssetFillAmount ///////
|
||||
mstore(paramsAreaOffset, takerAssetFillAmount)
|
||||
paramsAreaOffset := add(paramsAreaOffset, 0x20)
|
||||
|
||||
/////// Write signature ///////
|
||||
// Write offset to paramsArea
|
||||
mstore(paramsAreaOffset, sub(dataAreaEnd, paramsAreaStart))
|
||||
|
||||
// Calculate length of signature
|
||||
sourceOffset := signature
|
||||
arrayLenBytes := mload(sourceOffset)
|
||||
sourceOffset := add(sourceOffset, 0x20)
|
||||
arrayLenWords := div(add(arrayLenBytes, 0x1F), 0x20)
|
||||
|
||||
// Write length of signature
|
||||
mstore(dataAreaEnd, arrayLenBytes)
|
||||
dataAreaEnd := add(dataAreaEnd, 0x20)
|
||||
|
||||
// Write contents of signature
|
||||
for {let i := 0} lt(i, arrayLenWords) {i := add(i, 1)} {
|
||||
mstore(dataAreaEnd, mload(sourceOffset))
|
||||
dataAreaEnd := add(dataAreaEnd, 0x20)
|
||||
sourceOffset := add(sourceOffset, 0x20)
|
||||
}
|
||||
|
||||
// Execute delegatecall
|
||||
let success := delegatecall(
|
||||
gas, // forward all gas, TODO: look into gas consumption of assert/throw
|
||||
address, // call address of this contract
|
||||
headerAreaStart, // pointer to start of input
|
||||
sub(dataAreaEnd, headerAreaStart), // length of input
|
||||
headerAreaStart, // write output over input
|
||||
add(fillOrderCalldata, 32), // pointer to start of input (skip array length in first 32 bytes)
|
||||
mload(fillOrderCalldata), // length of input
|
||||
fillOrderCalldata, // write output over input
|
||||
128 // output size is 128 bytes
|
||||
)
|
||||
switch success
|
||||
@@ -249,10 +95,10 @@ contract MixinWrapperFunctions is
|
||||
mstore(add(fillResults, 96), 0)
|
||||
}
|
||||
case 1 {
|
||||
mstore(fillResults, mload(headerAreaStart))
|
||||
mstore(add(fillResults, 32), mload(add(headerAreaStart, 32)))
|
||||
mstore(add(fillResults, 64), mload(add(headerAreaStart, 64)))
|
||||
mstore(add(fillResults, 96), mload(add(headerAreaStart, 96)))
|
||||
mstore(fillResults, mload(fillOrderCalldata))
|
||||
mstore(add(fillResults, 32), mload(add(fillOrderCalldata, 32)))
|
||||
mstore(add(fillResults, 64), mload(add(fillOrderCalldata, 64)))
|
||||
mstore(add(fillResults, 96), mload(add(fillOrderCalldata, 96)))
|
||||
}
|
||||
}
|
||||
return fillResults;
|
||||
|
218
packages/contracts/src/2.0.0/protocol/Exchange/libs/LibAbiEncoder.sol
vendored
Normal file
218
packages/contracts/src/2.0.0/protocol/Exchange/libs/LibAbiEncoder.sol
vendored
Normal file
@@ -0,0 +1,218 @@
|
||||
/*
|
||||
|
||||
Copyright 2018 ZeroEx Intl.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity 0.4.24;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "./LibOrder.sol";
|
||||
|
||||
|
||||
contract LibAbiEncoder {
|
||||
|
||||
/// @dev ABI encodes calldata for `fillOrder` in memory and returns the address range.
|
||||
/// This range can be passed into `call` or `delegatecall` to invoke an external
|
||||
/// call to `fillOrder`.
|
||||
/// @param order Order struct containing order specifications.
|
||||
/// @param takerAssetFillAmount Desired amount of takerAsset to sell.
|
||||
/// @param signature Proof that order has been created by maker.
|
||||
/// @return calldataBegin Memory address of ABI encoded calldata.
|
||||
/// @return calldataLength Lenfgth of ABI encoded calldata.
|
||||
function abiEncodeFillOrder(
|
||||
LibOrder.Order memory order,
|
||||
uint256 takerAssetFillAmount,
|
||||
bytes memory signature
|
||||
)
|
||||
public
|
||||
pure
|
||||
returns (bytes memory fillOrderCalldata)
|
||||
{
|
||||
// We need to call MExchangeCore.fillOrder using a delegatecall in
|
||||
// assembly so that we can intercept a call that throws. For this, we
|
||||
// need the input encoded in memory in the Ethereum ABIv2 format [1].
|
||||
|
||||
// | Area | Offset | Length | Contents |
|
||||
// | -------- |--------|---------|-------------------------------------------- |
|
||||
// | Header | 0x00 | 4 | function selector |
|
||||
// | Params | | 3 * 32 | function parameters: |
|
||||
// | | 0x00 | | 1. offset to order (*) |
|
||||
// | | 0x20 | | 2. takerAssetFillAmount |
|
||||
// | | 0x40 | | 3. offset to signature (*) |
|
||||
// | Data | | 12 * 32 | order: |
|
||||
// | | 0x000 | | 1. senderAddress |
|
||||
// | | 0x020 | | 2. makerAddress |
|
||||
// | | 0x040 | | 3. takerAddress |
|
||||
// | | 0x060 | | 4. feeRecipientAddress |
|
||||
// | | 0x080 | | 5. makerAssetAmount |
|
||||
// | | 0x0A0 | | 6. takerAssetAmount |
|
||||
// | | 0x0C0 | | 7. makerFeeAmount |
|
||||
// | | 0x0E0 | | 8. takerFeeAmount |
|
||||
// | | 0x100 | | 9. expirationTimeSeconds |
|
||||
// | | 0x120 | | 10. salt |
|
||||
// | | 0x140 | | 11. Offset to makerAssetData (*) |
|
||||
// | | 0x160 | | 12. Offset to takerAssetData (*) |
|
||||
// | | 0x180 | 32 | makerAssetData Length |
|
||||
// | | 0x1A0 | ** | makerAssetData Contents |
|
||||
// | | 0x1C0 | 32 | takerAssetData Length |
|
||||
// | | 0x1E0 | ** | takerAssetData Contents |
|
||||
// | | 0x200 | 32 | signature Length |
|
||||
// | | 0x220 | ** | signature Contents |
|
||||
|
||||
// * Offsets are calculated from the beginning of the current area: Header, Params, Data:
|
||||
// An offset stored in the Params area is calculated from the beginning of the Params section.
|
||||
// An offset stored in the Data area is calculated from the beginning of the Data section.
|
||||
|
||||
// ** The length of dynamic array contents are stored in the field immediately preceeding the contents.
|
||||
|
||||
// [1]: https://solidity.readthedocs.io/en/develop/abi-spec.html
|
||||
|
||||
assembly {
|
||||
|
||||
// Areas below may use the following variables:
|
||||
// 1. <area>Start -- Start of this area in memory
|
||||
// 2. <area>End -- End of this area in memory. This value may
|
||||
// be precomputed (before writing contents),
|
||||
// or it may be computed as contents are written.
|
||||
// 3. <area>Offset -- Current offset into area. If an area's End
|
||||
// is precomputed, this variable tracks the
|
||||
// offsets of contents as they are written.
|
||||
|
||||
/////// Setup Header Area ///////
|
||||
// Load free memory pointer
|
||||
fillOrderCalldata := mload(0x40)
|
||||
// bytes4(keccak256("fillOrder((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),uint256,bytes)"))
|
||||
// = 0xb4be83d5
|
||||
// Leave 0x20 bytes to store the length
|
||||
mstore(add(fillOrderCalldata, 0x20), 0xb4be83d500000000000000000000000000000000000000000000000000000000)
|
||||
let headerAreaEnd := add(fillOrderCalldata, 0x24)
|
||||
|
||||
/////// Setup Params Area ///////
|
||||
// This area is preallocated and written to later.
|
||||
// This is because we need to fill in offsets that have not yet been calculated.
|
||||
let paramsAreaStart := headerAreaEnd
|
||||
let paramsAreaEnd := add(paramsAreaStart, 0x60)
|
||||
let paramsAreaOffset := paramsAreaStart
|
||||
|
||||
/////// Setup Data Area ///////
|
||||
let dataAreaStart := paramsAreaEnd
|
||||
let dataAreaEnd := dataAreaStart
|
||||
|
||||
// Offset from the source data we're reading from
|
||||
let sourceOffset := order
|
||||
// arrayLenBytes and arrayLenWords track the length of a dynamically-allocated bytes array.
|
||||
let arrayLenBytes := 0
|
||||
let arrayLenWords := 0
|
||||
|
||||
/////// Write order Struct ///////
|
||||
// Write memory location of Order, relative to the start of the
|
||||
// parameter list, then increment the paramsAreaOffset respectively.
|
||||
mstore(paramsAreaOffset, sub(dataAreaEnd, paramsAreaStart))
|
||||
paramsAreaOffset := add(paramsAreaOffset, 0x20)
|
||||
|
||||
// Write values for each field in the order
|
||||
// It would be nice to use a loop, but we save on gas by writing
|
||||
// the stores sequentially.
|
||||
mstore(dataAreaEnd, mload(sourceOffset)) // makerAddress
|
||||
mstore(add(dataAreaEnd, 0x20), mload(add(sourceOffset, 0x20))) // takerAddress
|
||||
mstore(add(dataAreaEnd, 0x40), mload(add(sourceOffset, 0x40))) // feeRecipientAddress
|
||||
mstore(add(dataAreaEnd, 0x60), mload(add(sourceOffset, 0x60))) // senderAddress
|
||||
mstore(add(dataAreaEnd, 0x80), mload(add(sourceOffset, 0x80))) // makerAssetAmount
|
||||
mstore(add(dataAreaEnd, 0xA0), mload(add(sourceOffset, 0xA0))) // takerAssetAmount
|
||||
mstore(add(dataAreaEnd, 0xC0), mload(add(sourceOffset, 0xC0))) // makerFeeAmount
|
||||
mstore(add(dataAreaEnd, 0xE0), mload(add(sourceOffset, 0xE0))) // takerFeeAmount
|
||||
mstore(add(dataAreaEnd, 0x100), mload(add(sourceOffset, 0x100))) // expirationTimeSeconds
|
||||
mstore(add(dataAreaEnd, 0x120), mload(add(sourceOffset, 0x120))) // salt
|
||||
mstore(add(dataAreaEnd, 0x140), mload(add(sourceOffset, 0x140))) // Offset to makerAssetData
|
||||
mstore(add(dataAreaEnd, 0x160), mload(add(sourceOffset, 0x160))) // Offset to takerAssetData
|
||||
dataAreaEnd := add(dataAreaEnd, 0x180)
|
||||
sourceOffset := add(sourceOffset, 0x180)
|
||||
|
||||
// Write offset to <order.makerAssetData>
|
||||
mstore(add(dataAreaStart, mul(10, 0x20)), sub(dataAreaEnd, dataAreaStart))
|
||||
|
||||
// Calculate length of <order.makerAssetData>
|
||||
sourceOffset := mload(add(order, 0x140)) // makerAssetData
|
||||
arrayLenBytes := mload(sourceOffset)
|
||||
sourceOffset := add(sourceOffset, 0x20)
|
||||
arrayLenWords := div(add(arrayLenBytes, 0x1F), 0x20)
|
||||
|
||||
// Write length of <order.makerAssetData>
|
||||
mstore(dataAreaEnd, arrayLenBytes)
|
||||
dataAreaEnd := add(dataAreaEnd, 0x20)
|
||||
|
||||
// Write contents of <order.makerAssetData>
|
||||
for {let i := 0} lt(i, arrayLenWords) {i := add(i, 1)} {
|
||||
mstore(dataAreaEnd, mload(sourceOffset))
|
||||
dataAreaEnd := add(dataAreaEnd, 0x20)
|
||||
sourceOffset := add(sourceOffset, 0x20)
|
||||
}
|
||||
|
||||
// Write offset to <order.takerAssetData>
|
||||
mstore(add(dataAreaStart, mul(11, 0x20)), sub(dataAreaEnd, dataAreaStart))
|
||||
|
||||
// Calculate length of <order.takerAssetData>
|
||||
sourceOffset := mload(add(order, 0x160)) // takerAssetData
|
||||
arrayLenBytes := mload(sourceOffset)
|
||||
sourceOffset := add(sourceOffset, 0x20)
|
||||
arrayLenWords := div(add(arrayLenBytes, 0x1F), 0x20)
|
||||
|
||||
// Write length of <order.takerAssetData>
|
||||
mstore(dataAreaEnd, arrayLenBytes)
|
||||
dataAreaEnd := add(dataAreaEnd, 0x20)
|
||||
|
||||
// Write contents of <order.takerAssetData>
|
||||
for {let i := 0} lt(i, arrayLenWords) {i := add(i, 1)} {
|
||||
mstore(dataAreaEnd, mload(sourceOffset))
|
||||
dataAreaEnd := add(dataAreaEnd, 0x20)
|
||||
sourceOffset := add(sourceOffset, 0x20)
|
||||
}
|
||||
|
||||
/////// Write takerAssetFillAmount ///////
|
||||
mstore(paramsAreaOffset, takerAssetFillAmount)
|
||||
paramsAreaOffset := add(paramsAreaOffset, 0x20)
|
||||
|
||||
/////// Write signature ///////
|
||||
// Write offset to paramsArea
|
||||
mstore(paramsAreaOffset, sub(dataAreaEnd, paramsAreaStart))
|
||||
|
||||
// Calculate length of signature
|
||||
sourceOffset := signature
|
||||
arrayLenBytes := mload(sourceOffset)
|
||||
sourceOffset := add(sourceOffset, 0x20)
|
||||
arrayLenWords := div(add(arrayLenBytes, 0x1F), 0x20)
|
||||
|
||||
// Write length of signature
|
||||
mstore(dataAreaEnd, arrayLenBytes)
|
||||
dataAreaEnd := add(dataAreaEnd, 0x20)
|
||||
|
||||
// Write contents of signature
|
||||
for {let i := 0} lt(i, arrayLenWords) {i := add(i, 1)} {
|
||||
mstore(dataAreaEnd, mload(sourceOffset))
|
||||
dataAreaEnd := add(dataAreaEnd, 0x20)
|
||||
sourceOffset := add(sourceOffset, 0x20)
|
||||
}
|
||||
|
||||
// Set length of calldata
|
||||
mstore(
|
||||
fillOrderCalldata,
|
||||
sub(dataAreaEnd, add(fillOrderCalldata, 0x20))
|
||||
)
|
||||
}
|
||||
|
||||
return fillOrderCalldata;
|
||||
}
|
||||
}
|
@@ -1,17 +1,12 @@
|
||||
import { BlockchainLifecycle } from '@0xproject/dev-utils';
|
||||
import { assetProxyUtils, generatePseudoRandomSalt } from '@0xproject/order-utils';
|
||||
import { assetDataUtils } from '@0xproject/order-utils';
|
||||
import { RevertReason } from '@0xproject/types';
|
||||
import { BigNumber } from '@0xproject/utils';
|
||||
import * as chai from 'chai';
|
||||
import { LogWithDecodedArgs } from 'ethereum-types';
|
||||
import ethUtil = require('ethereumjs-util');
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { DummyERC20TokenContract } from '../../generated_contract_wrappers/dummy_erc20_token';
|
||||
import {
|
||||
DummyERC721ReceiverContract,
|
||||
DummyERC721ReceiverTokenReceivedEventArgs,
|
||||
} from '../../generated_contract_wrappers/dummy_erc721_receiver';
|
||||
import { DummyERC721ReceiverContract } from '../../generated_contract_wrappers/dummy_erc721_receiver';
|
||||
import { DummyERC721TokenContract } from '../../generated_contract_wrappers/dummy_erc721_token';
|
||||
import { ERC20ProxyContract } from '../../generated_contract_wrappers/erc20_proxy';
|
||||
import { ERC721ProxyContract } from '../../generated_contract_wrappers/erc721_proxy';
|
||||
@@ -107,7 +102,7 @@ describe('Asset Transfer Proxies', () => {
|
||||
describe('transferFrom', () => {
|
||||
it('should successfully transfer tokens', async () => {
|
||||
// Construct ERC20 asset data
|
||||
const encodedAssetData = assetProxyUtils.encodeERC20AssetData(zrxToken.address);
|
||||
const encodedAssetData = assetDataUtils.encodeERC20AssetData(zrxToken.address);
|
||||
// Perform a transfer from makerAddress to takerAddress
|
||||
const erc20Balances = await erc20Wrapper.getBalancesAsync();
|
||||
const amount = new BigNumber(10);
|
||||
@@ -137,7 +132,7 @@ describe('Asset Transfer Proxies', () => {
|
||||
|
||||
it('should do nothing if transferring 0 amount of a token', async () => {
|
||||
// Construct ERC20 asset data
|
||||
const encodedAssetData = assetProxyUtils.encodeERC20AssetData(zrxToken.address);
|
||||
const encodedAssetData = assetDataUtils.encodeERC20AssetData(zrxToken.address);
|
||||
// Perform a transfer from makerAddress to takerAddress
|
||||
const erc20Balances = await erc20Wrapper.getBalancesAsync();
|
||||
const amount = new BigNumber(0);
|
||||
@@ -167,7 +162,7 @@ describe('Asset Transfer Proxies', () => {
|
||||
|
||||
it('should throw if allowances are too low', async () => {
|
||||
// Construct ERC20 asset data
|
||||
const encodedAssetData = assetProxyUtils.encodeERC20AssetData(zrxToken.address);
|
||||
const encodedAssetData = assetDataUtils.encodeERC20AssetData(zrxToken.address);
|
||||
// Create allowance less than transfer amount. Set allowance on proxy.
|
||||
const allowance = new BigNumber(0);
|
||||
const amount = new BigNumber(10);
|
||||
@@ -196,7 +191,7 @@ describe('Asset Transfer Proxies', () => {
|
||||
|
||||
it('should throw if requesting address is not authorized', async () => {
|
||||
// Construct ERC20 asset data
|
||||
const encodedAssetData = assetProxyUtils.encodeERC20AssetData(zrxToken.address);
|
||||
const encodedAssetData = assetDataUtils.encodeERC20AssetData(zrxToken.address);
|
||||
// Perform a transfer from makerAddress to takerAddress
|
||||
const amount = new BigNumber(10);
|
||||
const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData(
|
||||
@@ -227,7 +222,7 @@ describe('Asset Transfer Proxies', () => {
|
||||
describe('transferFrom', () => {
|
||||
it('should successfully transfer tokens', async () => {
|
||||
// Construct ERC721 asset data
|
||||
const encodedAssetData = assetProxyUtils.encodeERC721AssetData(erc721Token.address, erc721MakerTokenId);
|
||||
const encodedAssetData = assetDataUtils.encodeERC721AssetData(erc721Token.address, erc721MakerTokenId);
|
||||
// Verify pre-condition
|
||||
const ownerMakerAsset = await erc721Token.ownerOf.callAsync(erc721MakerTokenId);
|
||||
expect(ownerMakerAsset).to.be.bignumber.equal(makerAddress);
|
||||
@@ -252,9 +247,9 @@ describe('Asset Transfer Proxies', () => {
|
||||
expect(newOwnerMakerAsset).to.be.bignumber.equal(takerAddress);
|
||||
});
|
||||
|
||||
it('should call onERC721Received when transferring to a smart contract without receiver data', async () => {
|
||||
it('should not call onERC721Received when transferring to a smart contract', async () => {
|
||||
// Construct ERC721 asset data
|
||||
const encodedAssetData = assetProxyUtils.encodeERC721AssetData(erc721Token.address, erc721MakerTokenId);
|
||||
const encodedAssetData = assetDataUtils.encodeERC721AssetData(erc721Token.address, erc721MakerTokenId);
|
||||
// Verify pre-condition
|
||||
const ownerMakerAsset = await erc721Token.ownerOf.callAsync(erc721MakerTokenId);
|
||||
expect(ownerMakerAsset).to.be.bignumber.equal(makerAddress);
|
||||
@@ -276,88 +271,15 @@ describe('Asset Transfer Proxies', () => {
|
||||
}),
|
||||
);
|
||||
// Verify that no log was emitted by erc721 receiver
|
||||
expect(tx.logs.length).to.be.equal(1);
|
||||
const tokenReceivedLog = tx.logs[0] as LogWithDecodedArgs<DummyERC721ReceiverTokenReceivedEventArgs>;
|
||||
expect(tokenReceivedLog.args.from).to.be.equal(makerAddress);
|
||||
expect(tokenReceivedLog.args.tokenId).to.be.bignumber.equal(erc721MakerTokenId);
|
||||
expect(tokenReceivedLog.args.data).to.be.equal(constants.NULL_BYTES);
|
||||
expect(tx.logs.length).to.be.equal(0);
|
||||
// Verify transfer was successful
|
||||
const newOwnerMakerAsset = await erc721Token.ownerOf.callAsync(erc721MakerTokenId);
|
||||
expect(newOwnerMakerAsset).to.be.bignumber.equal(erc721Receiver.address);
|
||||
});
|
||||
|
||||
it('should call onERC721Received when transferring to a smart contract with receiver data', async () => {
|
||||
// Construct ERC721 asset data
|
||||
const receiverData = ethUtil.bufferToHex(assetProxyUtils.encodeUint256(generatePseudoRandomSalt()));
|
||||
const encodedAssetData = assetProxyUtils.encodeERC721AssetData(
|
||||
erc721Token.address,
|
||||
erc721MakerTokenId,
|
||||
receiverData,
|
||||
);
|
||||
// Verify pre-condition
|
||||
const ownerMakerAsset = await erc721Token.ownerOf.callAsync(erc721MakerTokenId);
|
||||
expect(ownerMakerAsset).to.be.bignumber.equal(makerAddress);
|
||||
// Perform a transfer from makerAddress to takerAddress
|
||||
const amount = new BigNumber(1);
|
||||
const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData(
|
||||
encodedAssetData,
|
||||
makerAddress,
|
||||
erc721Receiver.address,
|
||||
amount,
|
||||
);
|
||||
const logDecoder = new LogDecoder(web3Wrapper, erc721Receiver.address);
|
||||
const tx = await logDecoder.getTxWithDecodedLogsAsync(
|
||||
await web3Wrapper.sendTransactionAsync({
|
||||
to: erc721Proxy.address,
|
||||
data,
|
||||
from: exchangeAddress,
|
||||
gas: constants.MAX_TRANSFER_FROM_GAS,
|
||||
}),
|
||||
);
|
||||
// Validate log emitted by erc721 receiver
|
||||
expect(tx.logs.length).to.be.equal(1);
|
||||
const tokenReceivedLog = tx.logs[0] as LogWithDecodedArgs<DummyERC721ReceiverTokenReceivedEventArgs>;
|
||||
expect(tokenReceivedLog.args.from).to.be.equal(makerAddress);
|
||||
expect(tokenReceivedLog.args.tokenId).to.be.bignumber.equal(erc721MakerTokenId);
|
||||
expect(tokenReceivedLog.args.data).to.be.equal(receiverData);
|
||||
// Verify transfer was successful
|
||||
const newOwnerMakerAsset = await erc721Token.ownerOf.callAsync(erc721MakerTokenId);
|
||||
expect(newOwnerMakerAsset).to.be.bignumber.equal(erc721Receiver.address);
|
||||
});
|
||||
|
||||
it('should throw if there is receiver data but contract does not have onERC721Received', async () => {
|
||||
// Construct ERC721 asset data
|
||||
const receiverData = ethUtil.bufferToHex(assetProxyUtils.encodeUint256(generatePseudoRandomSalt()));
|
||||
const encodedAssetData = assetProxyUtils.encodeERC721AssetData(
|
||||
erc721Token.address,
|
||||
erc721MakerTokenId,
|
||||
receiverData,
|
||||
);
|
||||
// Verify pre-condition
|
||||
const ownerMakerAsset = await erc721Token.ownerOf.callAsync(erc721MakerTokenId);
|
||||
expect(ownerMakerAsset).to.be.bignumber.equal(makerAddress);
|
||||
// Perform a transfer from makerAddress to takerAddress
|
||||
const amount = new BigNumber(1);
|
||||
const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData(
|
||||
encodedAssetData,
|
||||
makerAddress,
|
||||
erc20Proxy.address, // the ERC20 proxy does not have an ERC721 receiver
|
||||
amount,
|
||||
);
|
||||
return expectTransactionFailedAsync(
|
||||
web3Wrapper.sendTransactionAsync({
|
||||
to: erc721Proxy.address,
|
||||
data,
|
||||
from: exchangeAddress,
|
||||
gas: constants.MAX_TRANSFER_FROM_GAS,
|
||||
}),
|
||||
RevertReason.TransferFailed,
|
||||
);
|
||||
});
|
||||
|
||||
it('should throw if transferring 0 amount of a token', async () => {
|
||||
// Construct ERC721 asset data
|
||||
const encodedAssetData = assetProxyUtils.encodeERC721AssetData(erc721Token.address, erc721MakerTokenId);
|
||||
const encodedAssetData = assetDataUtils.encodeERC721AssetData(erc721Token.address, erc721MakerTokenId);
|
||||
// Verify pre-condition
|
||||
const ownerMakerAsset = await erc721Token.ownerOf.callAsync(erc721MakerTokenId);
|
||||
expect(ownerMakerAsset).to.be.bignumber.equal(makerAddress);
|
||||
@@ -381,7 +303,7 @@ describe('Asset Transfer Proxies', () => {
|
||||
|
||||
it('should throw if transferring > 1 amount of a token', async () => {
|
||||
// Construct ERC721 asset data
|
||||
const encodedAssetData = assetProxyUtils.encodeERC721AssetData(erc721Token.address, erc721MakerTokenId);
|
||||
const encodedAssetData = assetDataUtils.encodeERC721AssetData(erc721Token.address, erc721MakerTokenId);
|
||||
// Verify pre-condition
|
||||
const ownerMakerAsset = await erc721Token.ownerOf.callAsync(erc721MakerTokenId);
|
||||
expect(ownerMakerAsset).to.be.bignumber.equal(makerAddress);
|
||||
@@ -405,7 +327,7 @@ describe('Asset Transfer Proxies', () => {
|
||||
|
||||
it('should throw if allowances are too low', async () => {
|
||||
// Construct ERC721 asset data
|
||||
const encodedAssetData = assetProxyUtils.encodeERC721AssetData(erc721Token.address, erc721MakerTokenId);
|
||||
const encodedAssetData = assetDataUtils.encodeERC721AssetData(erc721Token.address, erc721MakerTokenId);
|
||||
// Remove transfer approval for makerAddress.
|
||||
await web3Wrapper.awaitTransactionSuccessAsync(
|
||||
await erc721Token.approve.sendTransactionAsync(constants.NULL_ADDRESS, erc721MakerTokenId, {
|
||||
@@ -433,7 +355,7 @@ describe('Asset Transfer Proxies', () => {
|
||||
|
||||
it('should throw if requesting address is not authorized', async () => {
|
||||
// Construct ERC721 asset data
|
||||
const encodedAssetData = assetProxyUtils.encodeERC721AssetData(erc721Token.address, erc721MakerTokenId);
|
||||
const encodedAssetData = assetDataUtils.encodeERC721AssetData(erc721Token.address, erc721MakerTokenId);
|
||||
// Perform a transfer from makerAddress to takerAddress
|
||||
const amount = new BigNumber(1);
|
||||
const data = assetProxyInterface.transferFrom.getABIEncodedTransactionData(
|
||||
@@ -453,9 +375,9 @@ describe('Asset Transfer Proxies', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should have an id of 0x08e937fa', async () => {
|
||||
it('should have an id of 0x02571792', async () => {
|
||||
const proxyId = await erc721Proxy.getProxyId.callAsync();
|
||||
const expectedProxyId = '0x08e937fa';
|
||||
const expectedProxyId = '0x02571792';
|
||||
expect(proxyId).to.equal(expectedProxyId);
|
||||
});
|
||||
});
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import { BlockchainLifecycle } from '@0xproject/dev-utils';
|
||||
import { assetProxyUtils, orderHashUtils } from '@0xproject/order-utils';
|
||||
import { assetDataUtils, orderHashUtils } from '@0xproject/order-utils';
|
||||
import { RevertReason, SignedOrder } from '@0xproject/types';
|
||||
import { BigNumber } from '@0xproject/utils';
|
||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||
@@ -88,7 +88,7 @@ describe('Exchange core', () => {
|
||||
artifacts.Exchange,
|
||||
provider,
|
||||
txDefaults,
|
||||
assetProxyUtils.encodeERC20AssetData(zrxToken.address),
|
||||
assetDataUtils.encodeERC20AssetData(zrxToken.address),
|
||||
);
|
||||
exchangeWrapper = new ExchangeWrapper(exchange, provider);
|
||||
await exchangeWrapper.registerAssetProxyAsync(erc20Proxy.address, owner);
|
||||
@@ -115,8 +115,8 @@ describe('Exchange core', () => {
|
||||
exchangeAddress: exchange.address,
|
||||
makerAddress,
|
||||
feeRecipientAddress,
|
||||
makerAssetData: assetProxyUtils.encodeERC20AssetData(defaultMakerAssetAddress),
|
||||
takerAssetData: assetProxyUtils.encodeERC20AssetData(defaultTakerAssetAddress),
|
||||
makerAssetData: assetDataUtils.encodeERC20AssetData(defaultMakerAssetAddress),
|
||||
takerAssetData: assetDataUtils.encodeERC20AssetData(defaultTakerAssetAddress),
|
||||
};
|
||||
const privateKey = constants.TESTRPC_PRIVATE_KEYS[accounts.indexOf(makerAddress)];
|
||||
orderFactory = new OrderFactory(privateKey, defaultOrderParams);
|
||||
@@ -355,8 +355,8 @@ describe('Exchange core', () => {
|
||||
signedOrder = await orderFactory.newSignedOrderAsync({
|
||||
makerAssetAmount: new BigNumber(1),
|
||||
takerAssetAmount: new BigNumber(1),
|
||||
makerAssetData: assetProxyUtils.encodeERC721AssetData(erc721Token.address, makerAssetId),
|
||||
takerAssetData: assetProxyUtils.encodeERC721AssetData(erc721Token.address, takerAssetId),
|
||||
makerAssetData: assetDataUtils.encodeERC721AssetData(erc721Token.address, makerAssetId),
|
||||
takerAssetData: assetDataUtils.encodeERC721AssetData(erc721Token.address, takerAssetId),
|
||||
});
|
||||
// Verify pre-conditions
|
||||
const initialOwnerMakerAsset = await erc721Token.ownerOf.callAsync(makerAssetId);
|
||||
@@ -378,8 +378,8 @@ describe('Exchange core', () => {
|
||||
signedOrder = await orderFactory.newSignedOrderAsync({
|
||||
makerAssetAmount: new BigNumber(1),
|
||||
takerAssetAmount: new BigNumber(1),
|
||||
makerAssetData: assetProxyUtils.encodeERC721AssetData(erc721Token.address, makerAssetId),
|
||||
takerAssetData: assetProxyUtils.encodeERC721AssetData(erc721Token.address, takerAssetId),
|
||||
makerAssetData: assetDataUtils.encodeERC721AssetData(erc721Token.address, makerAssetId),
|
||||
takerAssetData: assetDataUtils.encodeERC721AssetData(erc721Token.address, takerAssetId),
|
||||
});
|
||||
// Verify pre-conditions
|
||||
const initialOwnerMakerAsset = await erc721Token.ownerOf.callAsync(makerAssetId);
|
||||
@@ -401,8 +401,8 @@ describe('Exchange core', () => {
|
||||
signedOrder = await orderFactory.newSignedOrderAsync({
|
||||
makerAssetAmount: new BigNumber(2),
|
||||
takerAssetAmount: new BigNumber(1),
|
||||
makerAssetData: assetProxyUtils.encodeERC721AssetData(erc721Token.address, makerAssetId),
|
||||
takerAssetData: assetProxyUtils.encodeERC721AssetData(erc721Token.address, takerAssetId),
|
||||
makerAssetData: assetDataUtils.encodeERC721AssetData(erc721Token.address, makerAssetId),
|
||||
takerAssetData: assetDataUtils.encodeERC721AssetData(erc721Token.address, takerAssetId),
|
||||
});
|
||||
// Verify pre-conditions
|
||||
const initialOwnerMakerAsset = await erc721Token.ownerOf.callAsync(makerAssetId);
|
||||
@@ -424,8 +424,8 @@ describe('Exchange core', () => {
|
||||
signedOrder = await orderFactory.newSignedOrderAsync({
|
||||
makerAssetAmount: new BigNumber(1),
|
||||
takerAssetAmount: new BigNumber(500),
|
||||
makerAssetData: assetProxyUtils.encodeERC721AssetData(erc721Token.address, makerAssetId),
|
||||
takerAssetData: assetProxyUtils.encodeERC721AssetData(erc721Token.address, takerAssetId),
|
||||
makerAssetData: assetDataUtils.encodeERC721AssetData(erc721Token.address, makerAssetId),
|
||||
takerAssetData: assetDataUtils.encodeERC721AssetData(erc721Token.address, takerAssetId),
|
||||
});
|
||||
// Verify pre-conditions
|
||||
const initialOwnerMakerAsset = await erc721Token.ownerOf.callAsync(makerAssetId);
|
||||
@@ -446,8 +446,8 @@ describe('Exchange core', () => {
|
||||
signedOrder = await orderFactory.newSignedOrderAsync({
|
||||
makerAssetAmount: new BigNumber(1),
|
||||
takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(100), 18),
|
||||
makerAssetData: assetProxyUtils.encodeERC721AssetData(erc721Token.address, makerAssetId),
|
||||
takerAssetData: assetProxyUtils.encodeERC20AssetData(defaultTakerAssetAddress),
|
||||
makerAssetData: assetDataUtils.encodeERC721AssetData(erc721Token.address, makerAssetId),
|
||||
takerAssetData: assetDataUtils.encodeERC20AssetData(defaultTakerAssetAddress),
|
||||
});
|
||||
// Call Exchange
|
||||
const takerAssetFillAmount = signedOrder.takerAssetAmount.div(2);
|
||||
@@ -456,32 +456,6 @@ describe('Exchange core', () => {
|
||||
RevertReason.RoundingError,
|
||||
);
|
||||
});
|
||||
|
||||
it('should throw if assetData has a length < 132', async () => {
|
||||
// Construct Exchange parameters
|
||||
const makerAssetId = erc721MakerAssetIds[0];
|
||||
const takerAssetId = erc721TakerAssetIds[0];
|
||||
const makerAssetData = assetProxyUtils
|
||||
.encodeERC721AssetData(erc721Token.address, makerAssetId)
|
||||
.slice(0, -2);
|
||||
signedOrder = await orderFactory.newSignedOrderAsync({
|
||||
makerAssetAmount: new BigNumber(1),
|
||||
takerAssetAmount: new BigNumber(1),
|
||||
makerAssetData,
|
||||
takerAssetData: assetProxyUtils.encodeERC721AssetData(erc721Token.address, takerAssetId),
|
||||
});
|
||||
// Verify pre-conditions
|
||||
const initialOwnerMakerAsset = await erc721Token.ownerOf.callAsync(makerAssetId);
|
||||
expect(initialOwnerMakerAsset).to.be.bignumber.equal(makerAddress);
|
||||
const initialOwnerTakerAsset = await erc721Token.ownerOf.callAsync(takerAssetId);
|
||||
expect(initialOwnerTakerAsset).to.be.bignumber.equal(takerAddress);
|
||||
// Call Exchange
|
||||
const takerAssetFillAmount = signedOrder.takerAssetAmount;
|
||||
return expectTransactionFailedAsync(
|
||||
exchangeWrapper.fillOrderAsync(signedOrder, takerAddress, { takerAssetFillAmount }),
|
||||
RevertReason.LengthGreaterThan131Required,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getOrderInfo', () => {
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import { BlockchainLifecycle } from '@0xproject/dev-utils';
|
||||
import { assetProxyUtils } from '@0xproject/order-utils';
|
||||
import { assetDataUtils } from '@0xproject/order-utils';
|
||||
import { AssetProxyId, RevertReason } from '@0xproject/types';
|
||||
import { BigNumber } from '@0xproject/utils';
|
||||
import * as chai from 'chai';
|
||||
@@ -180,7 +180,7 @@ describe('AssetProxyDispatcher', () => {
|
||||
constants.AWAIT_TRANSACTION_MINED_MS,
|
||||
);
|
||||
// Construct metadata for ERC20 proxy
|
||||
const encodedAssetData = assetProxyUtils.encodeERC20AssetData(zrxToken.address);
|
||||
const encodedAssetData = assetDataUtils.encodeERC20AssetData(zrxToken.address);
|
||||
|
||||
// Perform a transfer from makerAddress to takerAddress
|
||||
const erc20Balances = await erc20Wrapper.getBalancesAsync();
|
||||
@@ -207,7 +207,7 @@ describe('AssetProxyDispatcher', () => {
|
||||
|
||||
it('should throw if dispatching to unregistered proxy', async () => {
|
||||
// Construct metadata for ERC20 proxy
|
||||
const encodedAssetData = assetProxyUtils.encodeERC20AssetData(zrxToken.address);
|
||||
const encodedAssetData = assetDataUtils.encodeERC20AssetData(zrxToken.address);
|
||||
// Perform a transfer from makerAddress to takerAddress
|
||||
const amount = new BigNumber(10);
|
||||
return expectTransactionFailedAsync(
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import { BlockchainLifecycle } from '@0xproject/dev-utils';
|
||||
import { assetProxyUtils, EIP712Utils, orderHashUtils } from '@0xproject/order-utils';
|
||||
import { assetDataUtils, EIP712Utils, orderHashUtils } from '@0xproject/order-utils';
|
||||
import { SignedOrder } from '@0xproject/types';
|
||||
import { BigNumber } from '@0xproject/utils';
|
||||
import * as chai from 'chai';
|
||||
@@ -38,8 +38,8 @@ describe('Exchange libs', () => {
|
||||
exchangeAddress: libs.address,
|
||||
makerAddress,
|
||||
feeRecipientAddress: addressUtils.generatePseudoRandomAddress(),
|
||||
makerAssetData: assetProxyUtils.encodeERC20AssetData(addressUtils.generatePseudoRandomAddress()),
|
||||
takerAssetData: assetProxyUtils.encodeERC20AssetData(addressUtils.generatePseudoRandomAddress()),
|
||||
makerAssetData: assetDataUtils.encodeERC20AssetData(addressUtils.generatePseudoRandomAddress()),
|
||||
takerAssetData: assetDataUtils.encodeERC20AssetData(addressUtils.generatePseudoRandomAddress()),
|
||||
};
|
||||
const privateKey = constants.TESTRPC_PRIVATE_KEYS[accounts.indexOf(makerAddress)];
|
||||
orderFactory = new OrderFactory(privateKey, defaultOrderParams);
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import { BlockchainLifecycle } from '@0xproject/dev-utils';
|
||||
import { assetProxyUtils } from '@0xproject/order-utils';
|
||||
import { assetDataUtils } from '@0xproject/order-utils';
|
||||
import { RevertReason } from '@0xproject/types';
|
||||
import { BigNumber } from '@0xproject/utils';
|
||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||
@@ -100,7 +100,7 @@ describe('matchOrders', () => {
|
||||
artifacts.Exchange,
|
||||
provider,
|
||||
txDefaults,
|
||||
assetProxyUtils.encodeERC20AssetData(zrxToken.address),
|
||||
assetDataUtils.encodeERC20AssetData(zrxToken.address),
|
||||
);
|
||||
exchangeWrapper = new ExchangeWrapper(exchange, provider);
|
||||
await exchangeWrapper.registerAssetProxyAsync(erc20Proxy.address, owner);
|
||||
@@ -126,8 +126,8 @@ describe('matchOrders', () => {
|
||||
const defaultOrderParams = {
|
||||
...constants.STATIC_ORDER_PARAMS,
|
||||
exchangeAddress: exchange.address,
|
||||
makerAssetData: assetProxyUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress),
|
||||
takerAssetData: assetProxyUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress),
|
||||
makerAssetData: assetDataUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress),
|
||||
takerAssetData: assetDataUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress),
|
||||
};
|
||||
const privateKeyLeft = constants.TESTRPC_PRIVATE_KEYS[accounts.indexOf(makerAddressLeft)];
|
||||
orderFactoryLeft = new OrderFactory(privateKeyLeft, defaultOrderParams);
|
||||
@@ -158,8 +158,8 @@ describe('matchOrders', () => {
|
||||
});
|
||||
const signedOrderRight = await orderFactoryRight.newSignedOrderAsync({
|
||||
makerAddress: makerAddressRight,
|
||||
makerAssetData: assetProxyUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress),
|
||||
takerAssetData: assetProxyUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress),
|
||||
makerAssetData: assetDataUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress),
|
||||
takerAssetData: assetDataUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress),
|
||||
makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(10), 18),
|
||||
takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(2), 18),
|
||||
feeRecipientAddress: feeRecipientAddressRight,
|
||||
@@ -190,8 +190,8 @@ describe('matchOrders', () => {
|
||||
});
|
||||
const signedOrderRight = await orderFactoryRight.newSignedOrderAsync({
|
||||
makerAddress: makerAddressRight,
|
||||
makerAssetData: assetProxyUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress),
|
||||
takerAssetData: assetProxyUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress),
|
||||
makerAssetData: assetDataUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress),
|
||||
takerAssetData: assetDataUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress),
|
||||
makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(10), 18),
|
||||
takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(5), 18),
|
||||
feeRecipientAddress: feeRecipientAddressRight,
|
||||
@@ -233,8 +233,8 @@ describe('matchOrders', () => {
|
||||
});
|
||||
const signedOrderRight = await orderFactoryRight.newSignedOrderAsync({
|
||||
makerAddress: makerAddressRight,
|
||||
makerAssetData: assetProxyUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress),
|
||||
takerAssetData: assetProxyUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress),
|
||||
makerAssetData: assetDataUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress),
|
||||
takerAssetData: assetDataUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress),
|
||||
makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(20), 18),
|
||||
takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(4), 18),
|
||||
feeRecipientAddress: feeRecipientAddressRight,
|
||||
@@ -265,8 +265,8 @@ describe('matchOrders', () => {
|
||||
});
|
||||
const signedOrderRight = await orderFactoryRight.newSignedOrderAsync({
|
||||
makerAddress: makerAddressRight,
|
||||
makerAssetData: assetProxyUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress),
|
||||
takerAssetData: assetProxyUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress),
|
||||
makerAssetData: assetDataUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress),
|
||||
takerAssetData: assetDataUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress),
|
||||
makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(10), 18),
|
||||
takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(2), 18),
|
||||
feeRecipientAddress: feeRecipientAddressRight,
|
||||
@@ -297,8 +297,8 @@ describe('matchOrders', () => {
|
||||
});
|
||||
const signedOrderRight = await orderFactoryRight.newSignedOrderAsync({
|
||||
makerAddress: makerAddressRight,
|
||||
makerAssetData: assetProxyUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress),
|
||||
takerAssetData: assetProxyUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress),
|
||||
makerAssetData: assetDataUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress),
|
||||
takerAssetData: assetDataUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress),
|
||||
makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(10), 18),
|
||||
takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(2), 18),
|
||||
feeRecipientAddress: feeRecipientAddressRight,
|
||||
@@ -328,8 +328,8 @@ describe('matchOrders', () => {
|
||||
// branch in the contract twice for this test.
|
||||
const signedOrderRight2 = await orderFactoryRight.newSignedOrderAsync({
|
||||
makerAddress: makerAddressRight,
|
||||
makerAssetData: assetProxyUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress),
|
||||
takerAssetData: assetProxyUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress),
|
||||
makerAssetData: assetDataUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress),
|
||||
takerAssetData: assetDataUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress),
|
||||
makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(100), 18),
|
||||
takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(50), 18),
|
||||
feeRecipientAddress: feeRecipientAddressRight,
|
||||
@@ -365,8 +365,8 @@ describe('matchOrders', () => {
|
||||
|
||||
const signedOrderRight = await orderFactoryRight.newSignedOrderAsync({
|
||||
makerAddress: makerAddressRight,
|
||||
makerAssetData: assetProxyUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress),
|
||||
takerAssetData: assetProxyUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress),
|
||||
makerAssetData: assetDataUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress),
|
||||
takerAssetData: assetDataUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress),
|
||||
makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(50), 18),
|
||||
takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(100), 18),
|
||||
feeRecipientAddress: feeRecipientAddressRight,
|
||||
@@ -433,8 +433,8 @@ describe('matchOrders', () => {
|
||||
});
|
||||
const signedOrderRight = await orderFactoryRight.newSignedOrderAsync({
|
||||
makerAddress: makerAddressRight,
|
||||
makerAssetData: assetProxyUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress),
|
||||
takerAssetData: assetProxyUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress),
|
||||
makerAssetData: assetDataUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress),
|
||||
takerAssetData: assetDataUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress),
|
||||
makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(10), 18),
|
||||
takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(2), 18),
|
||||
feeRecipientAddress,
|
||||
@@ -459,8 +459,8 @@ describe('matchOrders', () => {
|
||||
});
|
||||
const signedOrderRight = await orderFactoryRight.newSignedOrderAsync({
|
||||
makerAddress: makerAddressRight,
|
||||
makerAssetData: assetProxyUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress),
|
||||
takerAssetData: assetProxyUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress),
|
||||
makerAssetData: assetDataUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress),
|
||||
takerAssetData: assetDataUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress),
|
||||
makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(10), 18),
|
||||
takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(2), 18),
|
||||
feeRecipientAddress: feeRecipientAddressRight,
|
||||
@@ -486,8 +486,8 @@ describe('matchOrders', () => {
|
||||
});
|
||||
const signedOrderRight = await orderFactoryRight.newSignedOrderAsync({
|
||||
makerAddress: makerAddressRight,
|
||||
makerAssetData: assetProxyUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress),
|
||||
takerAssetData: assetProxyUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress),
|
||||
makerAssetData: assetDataUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress),
|
||||
takerAssetData: assetDataUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress),
|
||||
makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(10), 18),
|
||||
takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(2), 18),
|
||||
feeRecipientAddress: feeRecipientAddressRight,
|
||||
@@ -513,8 +513,8 @@ describe('matchOrders', () => {
|
||||
});
|
||||
const signedOrderRight = await orderFactoryRight.newSignedOrderAsync({
|
||||
makerAddress: makerAddressRight,
|
||||
makerAssetData: assetProxyUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress),
|
||||
takerAssetData: assetProxyUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress),
|
||||
makerAssetData: assetDataUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress),
|
||||
takerAssetData: assetDataUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress),
|
||||
makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(10), 18),
|
||||
takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(2), 18),
|
||||
feeRecipientAddress: feeRecipientAddressRight,
|
||||
@@ -540,8 +540,8 @@ describe('matchOrders', () => {
|
||||
});
|
||||
const signedOrderRight = await orderFactoryRight.newSignedOrderAsync({
|
||||
makerAddress: makerAddressRight,
|
||||
makerAssetData: assetProxyUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress),
|
||||
takerAssetData: assetProxyUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress),
|
||||
makerAssetData: assetDataUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress),
|
||||
takerAssetData: assetDataUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress),
|
||||
makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(10), 18),
|
||||
takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(2), 18),
|
||||
feeRecipientAddress: feeRecipientAddressRight,
|
||||
@@ -567,8 +567,8 @@ describe('matchOrders', () => {
|
||||
});
|
||||
const signedOrderRight = await orderFactoryRight.newSignedOrderAsync({
|
||||
makerAddress: makerAddressRight,
|
||||
makerAssetData: assetProxyUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress),
|
||||
takerAssetData: assetProxyUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress),
|
||||
makerAssetData: assetDataUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress),
|
||||
takerAssetData: assetDataUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress),
|
||||
makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(10), 18),
|
||||
takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(2), 18),
|
||||
feeRecipientAddress: makerAddressRight,
|
||||
@@ -593,8 +593,8 @@ describe('matchOrders', () => {
|
||||
});
|
||||
const signedOrderRight = await orderFactoryRight.newSignedOrderAsync({
|
||||
makerAddress: makerAddressRight,
|
||||
makerAssetData: assetProxyUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress),
|
||||
takerAssetData: assetProxyUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress),
|
||||
makerAssetData: assetDataUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress),
|
||||
takerAssetData: assetDataUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress),
|
||||
makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(10), 18),
|
||||
takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(2), 18),
|
||||
feeRecipientAddress: feeRecipientAddressRight,
|
||||
@@ -618,8 +618,8 @@ describe('matchOrders', () => {
|
||||
});
|
||||
const signedOrderRight = await orderFactoryRight.newSignedOrderAsync({
|
||||
makerAddress: makerAddressRight,
|
||||
makerAssetData: assetProxyUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress),
|
||||
takerAssetData: assetProxyUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress),
|
||||
makerAssetData: assetDataUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress),
|
||||
takerAssetData: assetDataUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress),
|
||||
makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(10), 18),
|
||||
takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(2), 18),
|
||||
feeRecipientAddress: feeRecipientAddressRight,
|
||||
@@ -643,8 +643,8 @@ describe('matchOrders', () => {
|
||||
});
|
||||
const signedOrderRight = await orderFactoryRight.newSignedOrderAsync({
|
||||
makerAddress: makerAddressRight,
|
||||
makerAssetData: assetProxyUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress),
|
||||
takerAssetData: assetProxyUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress),
|
||||
makerAssetData: assetDataUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress),
|
||||
takerAssetData: assetDataUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress),
|
||||
makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(1), 18),
|
||||
takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(200), 18),
|
||||
feeRecipientAddress: feeRecipientAddressRight,
|
||||
@@ -666,8 +666,8 @@ describe('matchOrders', () => {
|
||||
});
|
||||
const signedOrderRight = await orderFactoryRight.newSignedOrderAsync({
|
||||
makerAddress: makerAddressRight,
|
||||
makerAssetData: assetProxyUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress),
|
||||
takerAssetData: assetProxyUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress),
|
||||
makerAssetData: assetDataUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress),
|
||||
takerAssetData: assetDataUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress),
|
||||
makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(10), 18),
|
||||
takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(2), 18),
|
||||
feeRecipientAddress: feeRecipientAddressRight,
|
||||
@@ -687,16 +687,16 @@ describe('matchOrders', () => {
|
||||
// Create orders to match
|
||||
const signedOrderLeft = await orderFactoryLeft.newSignedOrderAsync({
|
||||
makerAddress: makerAddressLeft,
|
||||
makerAssetData: assetProxyUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress),
|
||||
takerAssetData: assetProxyUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress),
|
||||
makerAssetData: assetDataUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress),
|
||||
takerAssetData: assetDataUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress),
|
||||
makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(5), 18),
|
||||
takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(10), 18),
|
||||
feeRecipientAddress: feeRecipientAddressLeft,
|
||||
});
|
||||
const signedOrderRight = await orderFactoryRight.newSignedOrderAsync({
|
||||
makerAddress: makerAddressRight,
|
||||
makerAssetData: assetProxyUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress),
|
||||
takerAssetData: assetProxyUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress),
|
||||
makerAssetData: assetDataUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress),
|
||||
takerAssetData: assetDataUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress),
|
||||
makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(10), 18),
|
||||
takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(2), 18),
|
||||
feeRecipientAddress: feeRecipientAddressRight,
|
||||
@@ -713,16 +713,16 @@ describe('matchOrders', () => {
|
||||
const erc721TokenToTransfer = erc721LeftMakerAssetIds[0];
|
||||
const signedOrderLeft = await orderFactoryLeft.newSignedOrderAsync({
|
||||
makerAddress: makerAddressLeft,
|
||||
makerAssetData: assetProxyUtils.encodeERC721AssetData(defaultERC721AssetAddress, erc721TokenToTransfer),
|
||||
takerAssetData: assetProxyUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress),
|
||||
makerAssetData: assetDataUtils.encodeERC721AssetData(defaultERC721AssetAddress, erc721TokenToTransfer),
|
||||
takerAssetData: assetDataUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress),
|
||||
makerAssetAmount: new BigNumber(1),
|
||||
takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(10), 18),
|
||||
feeRecipientAddress: feeRecipientAddressLeft,
|
||||
});
|
||||
const signedOrderRight = await orderFactoryRight.newSignedOrderAsync({
|
||||
makerAddress: makerAddressRight,
|
||||
makerAssetData: assetProxyUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress),
|
||||
takerAssetData: assetProxyUtils.encodeERC721AssetData(defaultERC721AssetAddress, erc721TokenToTransfer),
|
||||
makerAssetData: assetDataUtils.encodeERC20AssetData(defaultERC20TakerAssetAddress),
|
||||
takerAssetData: assetDataUtils.encodeERC721AssetData(defaultERC721AssetAddress, erc721TokenToTransfer),
|
||||
makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(10), 18),
|
||||
takerAssetAmount: new BigNumber(1),
|
||||
feeRecipientAddress: feeRecipientAddressRight,
|
||||
@@ -748,16 +748,16 @@ describe('matchOrders', () => {
|
||||
const erc721TokenToTransfer = erc721RightMakerAssetIds[0];
|
||||
const signedOrderLeft = await orderFactoryLeft.newSignedOrderAsync({
|
||||
makerAddress: makerAddressLeft,
|
||||
makerAssetData: assetProxyUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress),
|
||||
takerAssetData: assetProxyUtils.encodeERC721AssetData(defaultERC721AssetAddress, erc721TokenToTransfer),
|
||||
makerAssetData: assetDataUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress),
|
||||
takerAssetData: assetDataUtils.encodeERC721AssetData(defaultERC721AssetAddress, erc721TokenToTransfer),
|
||||
makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(10), 18),
|
||||
takerAssetAmount: new BigNumber(1),
|
||||
feeRecipientAddress: feeRecipientAddressLeft,
|
||||
});
|
||||
const signedOrderRight = await orderFactoryRight.newSignedOrderAsync({
|
||||
makerAddress: makerAddressRight,
|
||||
makerAssetData: assetProxyUtils.encodeERC721AssetData(defaultERC721AssetAddress, erc721TokenToTransfer),
|
||||
takerAssetData: assetProxyUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress),
|
||||
makerAssetData: assetDataUtils.encodeERC721AssetData(defaultERC721AssetAddress, erc721TokenToTransfer),
|
||||
takerAssetData: assetDataUtils.encodeERC20AssetData(defaultERC20MakerAssetAddress),
|
||||
makerAssetAmount: new BigNumber(1),
|
||||
takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(10), 18),
|
||||
feeRecipientAddress: feeRecipientAddressRight,
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import { BlockchainLifecycle } from '@0xproject/dev-utils';
|
||||
import { addSignedMessagePrefix, assetProxyUtils, MessagePrefixType, orderHashUtils } from '@0xproject/order-utils';
|
||||
import { addSignedMessagePrefix, assetDataUtils, MessagePrefixType, orderHashUtils } from '@0xproject/order-utils';
|
||||
import { RevertReason, SignatureType, SignedOrder } from '@0xproject/types';
|
||||
import * as chai from 'chai';
|
||||
import { LogWithDecodedArgs } from 'ethereum-types';
|
||||
@@ -78,8 +78,8 @@ describe('MixinSignatureValidator', () => {
|
||||
exchangeAddress: signatureValidator.address,
|
||||
makerAddress,
|
||||
feeRecipientAddress: addressUtils.generatePseudoRandomAddress(),
|
||||
makerAssetData: assetProxyUtils.encodeERC20AssetData(addressUtils.generatePseudoRandomAddress()),
|
||||
takerAssetData: assetProxyUtils.encodeERC20AssetData(addressUtils.generatePseudoRandomAddress()),
|
||||
makerAssetData: assetDataUtils.encodeERC20AssetData(addressUtils.generatePseudoRandomAddress()),
|
||||
takerAssetData: assetDataUtils.encodeERC20AssetData(addressUtils.generatePseudoRandomAddress()),
|
||||
};
|
||||
signerPrivateKey = constants.TESTRPC_PRIVATE_KEYS[accounts.indexOf(makerAddress)];
|
||||
notSignerPrivateKey = constants.TESTRPC_PRIVATE_KEYS[accounts.indexOf(notSignerAddress)];
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import { BlockchainLifecycle } from '@0xproject/dev-utils';
|
||||
import { assetProxyUtils, generatePseudoRandomSalt } from '@0xproject/order-utils';
|
||||
import { assetDataUtils, generatePseudoRandomSalt } from '@0xproject/order-utils';
|
||||
import { OrderWithoutExchangeAddress, RevertReason, SignedOrder } from '@0xproject/types';
|
||||
import { BigNumber } from '@0xproject/utils';
|
||||
import * as chai from 'chai';
|
||||
@@ -88,7 +88,7 @@ describe('Exchange transactions', () => {
|
||||
artifacts.Exchange,
|
||||
provider,
|
||||
txDefaults,
|
||||
assetProxyUtils.encodeERC20AssetData(zrxToken.address),
|
||||
assetDataUtils.encodeERC20AssetData(zrxToken.address),
|
||||
);
|
||||
exchangeWrapper = new ExchangeWrapper(exchange, provider);
|
||||
await exchangeWrapper.registerAssetProxyAsync(erc20Proxy.address, owner);
|
||||
@@ -107,8 +107,8 @@ describe('Exchange transactions', () => {
|
||||
exchangeAddress: exchange.address,
|
||||
makerAddress,
|
||||
feeRecipientAddress,
|
||||
makerAssetData: assetProxyUtils.encodeERC20AssetData(defaultMakerTokenAddress),
|
||||
takerAssetData: assetProxyUtils.encodeERC20AssetData(defaultTakerTokenAddress),
|
||||
makerAssetData: assetDataUtils.encodeERC20AssetData(defaultMakerTokenAddress),
|
||||
takerAssetData: assetDataUtils.encodeERC20AssetData(defaultTakerTokenAddress),
|
||||
};
|
||||
makerPrivateKey = constants.TESTRPC_PRIVATE_KEYS[accounts.indexOf(makerAddress)];
|
||||
takerPrivateKey = constants.TESTRPC_PRIVATE_KEYS[accounts.indexOf(takerAddress)];
|
||||
@@ -349,8 +349,8 @@ describe('Exchange transactions', () => {
|
||||
exchangeAddress: exchange.address,
|
||||
makerAddress,
|
||||
feeRecipientAddress,
|
||||
makerAssetData: assetProxyUtils.encodeERC20AssetData(defaultMakerTokenAddress),
|
||||
takerAssetData: assetProxyUtils.encodeERC20AssetData(defaultTakerTokenAddress),
|
||||
makerAssetData: assetDataUtils.encodeERC20AssetData(defaultMakerTokenAddress),
|
||||
takerAssetData: assetDataUtils.encodeERC20AssetData(defaultTakerTokenAddress),
|
||||
};
|
||||
whitelistOrderFactory = new OrderFactory(makerPrivateKey, defaultOrderParams);
|
||||
});
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import { BlockchainLifecycle } from '@0xproject/dev-utils';
|
||||
import { assetProxyUtils, orderHashUtils } from '@0xproject/order-utils';
|
||||
import { assetDataUtils, orderHashUtils } from '@0xproject/order-utils';
|
||||
import { RevertReason, SignedOrder } from '@0xproject/types';
|
||||
import { BigNumber } from '@0xproject/utils';
|
||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||
@@ -85,7 +85,7 @@ describe('Exchange wrappers', () => {
|
||||
artifacts.Exchange,
|
||||
provider,
|
||||
txDefaults,
|
||||
assetProxyUtils.encodeERC20AssetData(zrxToken.address),
|
||||
assetDataUtils.encodeERC20AssetData(zrxToken.address),
|
||||
);
|
||||
exchangeWrapper = new ExchangeWrapper(exchange, provider);
|
||||
await exchangeWrapper.registerAssetProxyAsync(erc20Proxy.address, owner);
|
||||
@@ -112,8 +112,8 @@ describe('Exchange wrappers', () => {
|
||||
exchangeAddress: exchange.address,
|
||||
makerAddress,
|
||||
feeRecipientAddress,
|
||||
makerAssetData: assetProxyUtils.encodeERC20AssetData(defaultMakerAssetAddress),
|
||||
takerAssetData: assetProxyUtils.encodeERC20AssetData(defaultTakerAssetAddress),
|
||||
makerAssetData: assetDataUtils.encodeERC20AssetData(defaultMakerAssetAddress),
|
||||
takerAssetData: assetDataUtils.encodeERC20AssetData(defaultTakerAssetAddress),
|
||||
};
|
||||
const privateKey = constants.TESTRPC_PRIVATE_KEYS[accounts.indexOf(makerAddress)];
|
||||
orderFactory = new OrderFactory(privateKey, defaultOrderParams);
|
||||
@@ -311,7 +311,7 @@ describe('Exchange wrappers', () => {
|
||||
const signedOrder = await orderFactory.newSignedOrderAsync({
|
||||
makerAssetAmount: makerZRXBalance,
|
||||
makerFee: new BigNumber(1),
|
||||
makerAssetData: assetProxyUtils.encodeERC20AssetData(zrxToken.address),
|
||||
makerAssetData: assetDataUtils.encodeERC20AssetData(zrxToken.address),
|
||||
});
|
||||
await exchangeWrapper.fillOrderNoThrowAsync(signedOrder, takerAddress);
|
||||
const newBalances = await erc20Wrapper.getBalancesAsync();
|
||||
@@ -323,7 +323,7 @@ describe('Exchange wrappers', () => {
|
||||
const signedOrder = await orderFactory.newSignedOrderAsync({
|
||||
makerAssetAmount: new BigNumber(makerZRXAllowance),
|
||||
makerFee: new BigNumber(1),
|
||||
makerAssetData: assetProxyUtils.encodeERC20AssetData(zrxToken.address),
|
||||
makerAssetData: assetDataUtils.encodeERC20AssetData(zrxToken.address),
|
||||
});
|
||||
await exchangeWrapper.fillOrderNoThrowAsync(signedOrder, takerAddress);
|
||||
const newBalances = await erc20Wrapper.getBalancesAsync();
|
||||
@@ -335,7 +335,7 @@ describe('Exchange wrappers', () => {
|
||||
const signedOrder = await orderFactory.newSignedOrderAsync({
|
||||
takerAssetAmount: takerZRXBalance,
|
||||
takerFee: new BigNumber(1),
|
||||
takerAssetData: assetProxyUtils.encodeERC20AssetData(zrxToken.address),
|
||||
takerAssetData: assetDataUtils.encodeERC20AssetData(zrxToken.address),
|
||||
});
|
||||
await exchangeWrapper.fillOrderNoThrowAsync(signedOrder, takerAddress);
|
||||
const newBalances = await erc20Wrapper.getBalancesAsync();
|
||||
@@ -347,7 +347,7 @@ describe('Exchange wrappers', () => {
|
||||
const signedOrder = await orderFactory.newSignedOrderAsync({
|
||||
takerAssetAmount: new BigNumber(takerZRXAllowance),
|
||||
takerFee: new BigNumber(1),
|
||||
takerAssetData: assetProxyUtils.encodeERC20AssetData(zrxToken.address),
|
||||
takerAssetData: assetDataUtils.encodeERC20AssetData(zrxToken.address),
|
||||
});
|
||||
await exchangeWrapper.fillOrderNoThrowAsync(signedOrder, takerAddress);
|
||||
const newBalances = await erc20Wrapper.getBalancesAsync();
|
||||
@@ -361,8 +361,8 @@ describe('Exchange wrappers', () => {
|
||||
const signedOrder = await orderFactory.newSignedOrderAsync({
|
||||
makerAssetAmount: new BigNumber(1),
|
||||
takerAssetAmount: new BigNumber(1),
|
||||
makerAssetData: assetProxyUtils.encodeERC721AssetData(erc721Token.address, makerAssetId),
|
||||
takerAssetData: assetProxyUtils.encodeERC721AssetData(erc721Token.address, takerAssetId),
|
||||
makerAssetData: assetDataUtils.encodeERC721AssetData(erc721Token.address, makerAssetId),
|
||||
takerAssetData: assetDataUtils.encodeERC721AssetData(erc721Token.address, takerAssetId),
|
||||
});
|
||||
// Verify pre-conditions
|
||||
const initialOwnerMakerAsset = await erc721Token.ownerOf.callAsync(makerAssetId);
|
||||
@@ -700,7 +700,7 @@ describe('Exchange wrappers', () => {
|
||||
signedOrders = [
|
||||
await orderFactory.newSignedOrderAsync(),
|
||||
await orderFactory.newSignedOrderAsync({
|
||||
takerAssetData: assetProxyUtils.encodeERC20AssetData(zrxToken.address),
|
||||
takerAssetData: assetDataUtils.encodeERC20AssetData(zrxToken.address),
|
||||
}),
|
||||
await orderFactory.newSignedOrderAsync(),
|
||||
];
|
||||
@@ -801,7 +801,7 @@ describe('Exchange wrappers', () => {
|
||||
await orderFactory.newSignedOrderAsync(),
|
||||
await orderFactory.newSignedOrderAsync(),
|
||||
await orderFactory.newSignedOrderAsync({
|
||||
takerAssetData: assetProxyUtils.encodeERC20AssetData(zrxToken.address),
|
||||
takerAssetData: assetDataUtils.encodeERC20AssetData(zrxToken.address),
|
||||
}),
|
||||
];
|
||||
const takerAssetFillAmount = Web3Wrapper.toBaseUnitAmount(new BigNumber(100000), 18);
|
||||
@@ -918,7 +918,7 @@ describe('Exchange wrappers', () => {
|
||||
signedOrders = [
|
||||
await orderFactory.newSignedOrderAsync(),
|
||||
await orderFactory.newSignedOrderAsync({
|
||||
makerAssetData: assetProxyUtils.encodeERC20AssetData(zrxToken.address),
|
||||
makerAssetData: assetDataUtils.encodeERC20AssetData(zrxToken.address),
|
||||
}),
|
||||
await orderFactory.newSignedOrderAsync(),
|
||||
];
|
||||
@@ -1017,7 +1017,7 @@ describe('Exchange wrappers', () => {
|
||||
await orderFactory.newSignedOrderAsync(),
|
||||
await orderFactory.newSignedOrderAsync(),
|
||||
await orderFactory.newSignedOrderAsync({
|
||||
makerAssetData: assetProxyUtils.encodeERC20AssetData(zrxToken.address),
|
||||
makerAssetData: assetDataUtils.encodeERC20AssetData(zrxToken.address),
|
||||
}),
|
||||
];
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import { BlockchainLifecycle } from '@0xproject/dev-utils';
|
||||
import { assetProxyUtils } from '@0xproject/order-utils';
|
||||
import { assetDataUtils } from '@0xproject/order-utils';
|
||||
import { RevertReason, SignedOrder } from '@0xproject/types';
|
||||
import { BigNumber } from '@0xproject/utils';
|
||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||
@@ -88,8 +88,8 @@ describe(ContractName.Forwarder, () => {
|
||||
weth = new DummyERC20TokenContract(wethContract.abi, wethContract.address, provider);
|
||||
erc20Wrapper.addDummyTokenContract(weth);
|
||||
|
||||
const wethAssetData = assetProxyUtils.encodeERC20AssetData(wethContract.address);
|
||||
const zrxAssetData = assetProxyUtils.encodeERC20AssetData(zrxToken.address);
|
||||
const wethAssetData = assetDataUtils.encodeERC20AssetData(wethContract.address);
|
||||
const zrxAssetData = assetDataUtils.encodeERC20AssetData(zrxToken.address);
|
||||
const exchangeInstance = await ExchangeContract.deployFrom0xArtifactAsync(
|
||||
artifacts.Exchange,
|
||||
provider,
|
||||
@@ -114,8 +114,8 @@ describe(ContractName.Forwarder, () => {
|
||||
exchangeAddress: exchangeInstance.address,
|
||||
makerAddress,
|
||||
feeRecipientAddress,
|
||||
makerAssetData: assetProxyUtils.encodeERC20AssetData(defaultMakerAssetAddress),
|
||||
takerAssetData: assetProxyUtils.encodeERC20AssetData(defaultTakerAssetAddress),
|
||||
makerAssetData: assetDataUtils.encodeERC20AssetData(defaultMakerAssetAddress),
|
||||
takerAssetData: assetDataUtils.encodeERC20AssetData(defaultTakerAssetAddress),
|
||||
makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(200), DECIMALS_DEFAULT),
|
||||
takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(10), DECIMALS_DEFAULT),
|
||||
makerFee: Web3Wrapper.toBaseUnitAmount(new BigNumber(1), DECIMALS_DEFAULT),
|
||||
@@ -151,7 +151,7 @@ describe(ContractName.Forwarder, () => {
|
||||
signedOrder = await orderFactory.newSignedOrderAsync();
|
||||
signedOrders = [signedOrder];
|
||||
feeOrder = await orderFactory.newSignedOrderAsync({
|
||||
makerAssetData: assetProxyUtils.encodeERC20AssetData(zrxToken.address),
|
||||
makerAssetData: assetDataUtils.encodeERC20AssetData(zrxToken.address),
|
||||
takerFee: Web3Wrapper.toBaseUnitAmount(new BigNumber(1), DECIMALS_DEFAULT),
|
||||
});
|
||||
feeOrders = [feeOrder];
|
||||
@@ -239,7 +239,7 @@ describe(ContractName.Forwarder, () => {
|
||||
});
|
||||
it('should fill the order when token is ZRX with fees', async () => {
|
||||
orderWithFee = await orderFactory.newSignedOrderAsync({
|
||||
makerAssetData: assetProxyUtils.encodeERC20AssetData(zrxToken.address),
|
||||
makerAssetData: assetDataUtils.encodeERC20AssetData(zrxToken.address),
|
||||
takerFee: Web3Wrapper.toBaseUnitAmount(new BigNumber(1), DECIMALS_DEFAULT),
|
||||
});
|
||||
signedOrdersWithFee = [orderWithFee];
|
||||
@@ -261,7 +261,7 @@ describe(ContractName.Forwarder, () => {
|
||||
});
|
||||
it('should fail if sent an ETH amount too high', async () => {
|
||||
signedOrder = await orderFactory.newSignedOrderAsync({
|
||||
makerAssetData: assetProxyUtils.encodeERC20AssetData(zrxToken.address),
|
||||
makerAssetData: assetDataUtils.encodeERC20AssetData(zrxToken.address),
|
||||
takerFee: Web3Wrapper.toBaseUnitAmount(new BigNumber(1), DECIMALS_DEFAULT),
|
||||
});
|
||||
const fillAmount = signedOrder.takerAssetAmount.times(2);
|
||||
@@ -279,7 +279,7 @@ describe(ContractName.Forwarder, () => {
|
||||
});
|
||||
signedOrdersWithFee = [orderWithFee];
|
||||
feeOrder = await orderFactory.newSignedOrderAsync({
|
||||
makerAssetData: assetProxyUtils.encodeERC20AssetData(zrxToken.address),
|
||||
makerAssetData: assetDataUtils.encodeERC20AssetData(zrxToken.address),
|
||||
makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(1), DECIMALS_DEFAULT),
|
||||
});
|
||||
feeOrders = [feeOrder];
|
||||
@@ -296,7 +296,7 @@ describe(ContractName.Forwarder, () => {
|
||||
const makerAssetId = erc721MakerAssetIds[0];
|
||||
const erc721SignedOrder = await orderFactory.newSignedOrderAsync({
|
||||
makerAssetAmount: new BigNumber(1),
|
||||
makerAssetData: assetProxyUtils.encodeERC721AssetData(erc721Token.address, makerAssetId),
|
||||
makerAssetData: assetDataUtils.encodeERC721AssetData(erc721Token.address, makerAssetId),
|
||||
});
|
||||
const erc20SignedOrder = await orderFactory.newSignedOrderAsync();
|
||||
signedOrders = [erc20SignedOrder, erc721SignedOrder];
|
||||
@@ -419,7 +419,7 @@ describe(ContractName.Forwarder, () => {
|
||||
});
|
||||
it('should buy the exact amount of assets when buying zrx with fee abstraction', async () => {
|
||||
signedOrder = await orderFactory.newSignedOrderAsync({
|
||||
makerAssetData: assetProxyUtils.encodeERC20AssetData(zrxToken.address),
|
||||
makerAssetData: assetDataUtils.encodeERC20AssetData(zrxToken.address),
|
||||
takerFee: Web3Wrapper.toBaseUnitAmount(new BigNumber(1), DECIMALS_DEFAULT),
|
||||
});
|
||||
signedOrdersWithFee = [signedOrder];
|
||||
@@ -448,7 +448,7 @@ describe(ContractName.Forwarder, () => {
|
||||
});
|
||||
it('throws if fees are higher than 5% when buying zrx', async () => {
|
||||
const highFeeZRXOrder = await orderFactory.newSignedOrderAsync({
|
||||
makerAssetData: assetProxyUtils.encodeERC20AssetData(zrxToken.address),
|
||||
makerAssetData: assetDataUtils.encodeERC20AssetData(zrxToken.address),
|
||||
makerAssetAmount: signedOrder.makerAssetAmount,
|
||||
takerFee: signedOrder.makerAssetAmount.times(0.06),
|
||||
});
|
||||
@@ -546,7 +546,7 @@ describe(ContractName.Forwarder, () => {
|
||||
const makerAssetId = erc721MakerAssetIds[0];
|
||||
signedOrder = await orderFactory.newSignedOrderAsync({
|
||||
makerAssetAmount: new BigNumber(1),
|
||||
makerAssetData: assetProxyUtils.encodeERC721AssetData(erc721Token.address, makerAssetId),
|
||||
makerAssetData: assetDataUtils.encodeERC721AssetData(erc721Token.address, makerAssetId),
|
||||
});
|
||||
feeOrders = [];
|
||||
signedOrders = [signedOrder];
|
||||
@@ -569,7 +569,7 @@ describe(ContractName.Forwarder, () => {
|
||||
signedOrder = await orderFactory.newSignedOrderAsync({
|
||||
makerAssetAmount: new BigNumber(1),
|
||||
takerFee: Web3Wrapper.toBaseUnitAmount(new BigNumber(1), DECIMALS_DEFAULT),
|
||||
makerAssetData: assetProxyUtils.encodeERC721AssetData(erc721Token.address, makerAssetId),
|
||||
makerAssetData: assetDataUtils.encodeERC721AssetData(erc721Token.address, makerAssetId),
|
||||
});
|
||||
signedOrders = [signedOrder];
|
||||
const makerAssetAmount = new BigNumber(signedOrders.length);
|
||||
@@ -591,7 +591,7 @@ describe(ContractName.Forwarder, () => {
|
||||
signedOrder = await orderFactory.newSignedOrderAsync({
|
||||
makerAssetAmount: new BigNumber(1),
|
||||
takerFee: Web3Wrapper.toBaseUnitAmount(new BigNumber(1), DECIMALS_DEFAULT),
|
||||
makerAssetData: assetProxyUtils.encodeERC721AssetData(erc721Token.address, makerAssetId),
|
||||
makerAssetData: assetDataUtils.encodeERC721AssetData(erc721Token.address, makerAssetId),
|
||||
});
|
||||
signedOrders = [signedOrder];
|
||||
feeProportion = 100;
|
||||
@@ -633,12 +633,12 @@ describe(ContractName.Forwarder, () => {
|
||||
const signedOrder1 = await orderFactory.newSignedOrderAsync({
|
||||
makerAssetAmount: new BigNumber(1),
|
||||
takerFee: Web3Wrapper.toBaseUnitAmount(new BigNumber(3), DECIMALS_DEFAULT),
|
||||
makerAssetData: assetProxyUtils.encodeERC721AssetData(erc721Token.address, makerAssetId1),
|
||||
makerAssetData: assetDataUtils.encodeERC721AssetData(erc721Token.address, makerAssetId1),
|
||||
});
|
||||
const signedOrder2 = await orderFactory.newSignedOrderAsync({
|
||||
makerAssetAmount: new BigNumber(1),
|
||||
takerFee: Web3Wrapper.toBaseUnitAmount(new BigNumber(4), DECIMALS_DEFAULT),
|
||||
makerAssetData: assetProxyUtils.encodeERC721AssetData(erc721Token.address, makerAssetId2),
|
||||
makerAssetData: assetDataUtils.encodeERC721AssetData(erc721Token.address, makerAssetId2),
|
||||
});
|
||||
signedOrders = [signedOrder1, signedOrder2];
|
||||
feeProportion = 10;
|
||||
@@ -669,19 +669,19 @@ describe(ContractName.Forwarder, () => {
|
||||
makerAssetAmount: erc721MakerAssetAmount,
|
||||
takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(10), DECIMALS_DEFAULT),
|
||||
takerFee: Web3Wrapper.toBaseUnitAmount(new BigNumber(6), DECIMALS_DEFAULT),
|
||||
makerAssetData: assetProxyUtils.encodeERC721AssetData(erc721Token.address, makerAssetId),
|
||||
makerAssetData: assetDataUtils.encodeERC721AssetData(erc721Token.address, makerAssetId),
|
||||
});
|
||||
signedOrders = [signedOrder];
|
||||
const firstFeeOrder = await orderFactory.newSignedOrderAsync({
|
||||
makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(8), DECIMALS_DEFAULT),
|
||||
takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(0.1), DECIMALS_DEFAULT),
|
||||
makerAssetData: assetProxyUtils.encodeERC20AssetData(zrxToken.address),
|
||||
makerAssetData: assetDataUtils.encodeERC20AssetData(zrxToken.address),
|
||||
takerFee: Web3Wrapper.toBaseUnitAmount(new BigNumber(0), DECIMALS_DEFAULT),
|
||||
});
|
||||
const secondFeeOrder = await orderFactory.newSignedOrderAsync({
|
||||
makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(8), DECIMALS_DEFAULT),
|
||||
takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(0.12), DECIMALS_DEFAULT),
|
||||
makerAssetData: assetProxyUtils.encodeERC20AssetData(zrxToken.address),
|
||||
makerAssetData: assetDataUtils.encodeERC20AssetData(zrxToken.address),
|
||||
takerFee: Web3Wrapper.toBaseUnitAmount(new BigNumber(0), DECIMALS_DEFAULT),
|
||||
});
|
||||
feeOrders = [firstFeeOrder, secondFeeOrder];
|
||||
@@ -733,20 +733,20 @@ describe(ContractName.Forwarder, () => {
|
||||
makerAssetAmount: erc721MakerAssetAmount,
|
||||
takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(10), DECIMALS_DEFAULT),
|
||||
takerFee: Web3Wrapper.toBaseUnitAmount(new BigNumber(6), DECIMALS_DEFAULT),
|
||||
makerAssetData: assetProxyUtils.encodeERC721AssetData(erc721Token.address, makerAssetId),
|
||||
makerAssetData: assetDataUtils.encodeERC721AssetData(erc721Token.address, makerAssetId),
|
||||
});
|
||||
const zrxMakerAssetAmount = Web3Wrapper.toBaseUnitAmount(new BigNumber(8), DECIMALS_DEFAULT);
|
||||
signedOrders = [signedOrder];
|
||||
const firstFeeOrder = await orderFactory.newSignedOrderAsync({
|
||||
makerAssetAmount: zrxMakerAssetAmount,
|
||||
takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(0.1), DECIMALS_DEFAULT),
|
||||
makerAssetData: assetProxyUtils.encodeERC20AssetData(zrxToken.address),
|
||||
makerAssetData: assetDataUtils.encodeERC20AssetData(zrxToken.address),
|
||||
takerFee: Web3Wrapper.toBaseUnitAmount(new BigNumber(0), DECIMALS_DEFAULT),
|
||||
});
|
||||
const secondFeeOrder = await orderFactory.newSignedOrderAsync({
|
||||
makerAssetAmount: zrxMakerAssetAmount,
|
||||
takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(0.12), DECIMALS_DEFAULT),
|
||||
makerAssetData: assetProxyUtils.encodeERC20AssetData(zrxToken.address),
|
||||
makerAssetData: assetDataUtils.encodeERC20AssetData(zrxToken.address),
|
||||
takerFee: Web3Wrapper.toBaseUnitAmount(new BigNumber(0), DECIMALS_DEFAULT),
|
||||
});
|
||||
feeOrders = [firstFeeOrder, secondFeeOrder];
|
||||
@@ -780,7 +780,7 @@ describe(ContractName.Forwarder, () => {
|
||||
const makerAssetId = erc721MakerAssetIds[0];
|
||||
const erc721SignedOrder = await orderFactory.newSignedOrderAsync({
|
||||
makerAssetAmount: new BigNumber(1),
|
||||
makerAssetData: assetProxyUtils.encodeERC721AssetData(erc721Token.address, makerAssetId),
|
||||
makerAssetData: assetDataUtils.encodeERC721AssetData(erc721Token.address, makerAssetId),
|
||||
});
|
||||
const erc20SignedOrder = await orderFactory.newSignedOrderAsync();
|
||||
signedOrders = [erc721SignedOrder, erc20SignedOrder];
|
||||
@@ -798,7 +798,7 @@ describe(ContractName.Forwarder, () => {
|
||||
const makerAssetId = erc721MakerAssetIds[0];
|
||||
const erc721SignedOrder = await orderFactory.newSignedOrderAsync({
|
||||
makerAssetAmount: new BigNumber(1),
|
||||
makerAssetData: assetProxyUtils.encodeERC721AssetData(erc721Token.address, makerAssetId),
|
||||
makerAssetData: assetDataUtils.encodeERC721AssetData(erc721Token.address, makerAssetId),
|
||||
});
|
||||
const erc20SignedOrder = await orderFactory.newSignedOrderAsync();
|
||||
signedOrders = [erc20SignedOrder, erc721SignedOrder];
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import { BlockchainLifecycle } from '@0xproject/dev-utils';
|
||||
import { assetProxyUtils, generatePseudoRandomSalt } from '@0xproject/order-utils';
|
||||
import { generatePseudoRandomSalt } from '@0xproject/order-utils';
|
||||
import { RevertReason } from '@0xproject/types';
|
||||
import { BigNumber } from '@0xproject/utils';
|
||||
import BN = require('bn.js');
|
||||
@@ -12,6 +12,7 @@ import { artifacts } from '../utils/artifacts';
|
||||
import { expectContractCallFailed } from '../utils/assertions';
|
||||
import { chaiSetup } from '../utils/chai_setup';
|
||||
import { constants } from '../utils/constants';
|
||||
import { typeEncodingUtils } from '../utils/type_encoding_utils';
|
||||
import { provider, txDefaults, web3Wrapper } from '../utils/web3_wrapper';
|
||||
|
||||
chaiSetup.configure();
|
||||
@@ -74,20 +75,20 @@ describe('LibBytes', () => {
|
||||
shortData = '0xffffaa';
|
||||
const encodedShortData = ethUtil.toBuffer(shortData);
|
||||
const shortDataLength = new BigNumber(encodedShortData.byteLength);
|
||||
const encodedShortDataLength = assetProxyUtils.encodeUint256(shortDataLength);
|
||||
const encodedShortDataLength = typeEncodingUtils.encodeUint256(shortDataLength);
|
||||
shortTestBytesAsBuffer = Buffer.concat([encodedShortDataLength, encodedShortData]);
|
||||
shortTestBytes = ethUtil.bufferToHex(shortTestBytesAsBuffer);
|
||||
// Create test bytes one word in length
|
||||
wordOfData = ethUtil.bufferToHex(assetProxyUtils.encodeUint256(generatePseudoRandomSalt()));
|
||||
wordOfData = ethUtil.bufferToHex(typeEncodingUtils.encodeUint256(generatePseudoRandomSalt()));
|
||||
const encodedWordOfData = ethUtil.toBuffer(wordOfData);
|
||||
const wordOfDataLength = new BigNumber(encodedWordOfData.byteLength);
|
||||
const encodedWordOfDataLength = assetProxyUtils.encodeUint256(wordOfDataLength);
|
||||
const encodedWordOfDataLength = typeEncodingUtils.encodeUint256(wordOfDataLength);
|
||||
wordOfTestBytesAsBuffer = Buffer.concat([encodedWordOfDataLength, encodedWordOfData]);
|
||||
wordOfTestBytes = ethUtil.bufferToHex(wordOfTestBytesAsBuffer);
|
||||
// Create long test bytes (combines short test bytes with word of test bytes)
|
||||
longData = ethUtil.bufferToHex(Buffer.concat([encodedShortData, encodedWordOfData]));
|
||||
const longDataLength = new BigNumber(encodedShortData.byteLength + encodedWordOfData.byteLength);
|
||||
const encodedLongDataLength = assetProxyUtils.encodeUint256(longDataLength);
|
||||
const encodedLongDataLength = typeEncodingUtils.encodeUint256(longDataLength);
|
||||
longTestBytesAsBuffer = Buffer.concat([encodedLongDataLength, encodedShortData, encodedWordOfData]);
|
||||
longTestBytes = ethUtil.bufferToHex(longTestBytesAsBuffer);
|
||||
});
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { assetProxyUtils } from '@0xproject/order-utils';
|
||||
import { assetDataUtils } from '@0xproject/order-utils';
|
||||
import { AssetProxyId } from '@0xproject/types';
|
||||
import { BigNumber, errorUtils } from '@0xproject/utils';
|
||||
import * as _ from 'lodash';
|
||||
@@ -26,7 +26,7 @@ export class AssetWrapper {
|
||||
});
|
||||
}
|
||||
public async getBalanceAsync(userAddress: string, assetData: string): Promise<BigNumber> {
|
||||
const proxyId = assetProxyUtils.decodeAssetDataId(assetData);
|
||||
const proxyId = assetDataUtils.decodeAssetProxyId(assetData);
|
||||
switch (proxyId) {
|
||||
case AssetProxyId.ERC20: {
|
||||
const erc20Wrapper = this._proxyIdToAssetWrappers[proxyId] as ERC20Wrapper;
|
||||
@@ -35,7 +35,7 @@ export class AssetWrapper {
|
||||
}
|
||||
case AssetProxyId.ERC721: {
|
||||
const assetWrapper = this._proxyIdToAssetWrappers[proxyId] as ERC721Wrapper;
|
||||
const assetProxyData = assetProxyUtils.decodeERC721AssetData(assetData);
|
||||
const assetProxyData = assetDataUtils.decodeERC721AssetData(assetData);
|
||||
const isOwner = await assetWrapper.isOwnerAsync(
|
||||
userAddress,
|
||||
assetProxyData.tokenAddress,
|
||||
@@ -49,7 +49,7 @@ export class AssetWrapper {
|
||||
}
|
||||
}
|
||||
public async setBalanceAsync(userAddress: string, assetData: string, desiredBalance: BigNumber): Promise<void> {
|
||||
const proxyId = assetProxyUtils.decodeAssetDataId(assetData);
|
||||
const proxyId = assetDataUtils.decodeAssetProxyId(assetData);
|
||||
switch (proxyId) {
|
||||
case AssetProxyId.ERC20: {
|
||||
const erc20Wrapper = this._proxyIdToAssetWrappers[proxyId] as ERC20Wrapper;
|
||||
@@ -61,7 +61,7 @@ export class AssetWrapper {
|
||||
throw new Error(`Balance for ERC721 token can only be set to 0 or 1. Got: ${desiredBalance}`);
|
||||
}
|
||||
const erc721Wrapper = this._proxyIdToAssetWrappers[proxyId] as ERC721Wrapper;
|
||||
const assetProxyData = assetProxyUtils.decodeERC721AssetData(assetData);
|
||||
const assetProxyData = assetDataUtils.decodeERC721AssetData(assetData);
|
||||
const doesTokenExist = erc721Wrapper.doesTokenExistAsync(
|
||||
assetProxyData.tokenAddress,
|
||||
assetProxyData.tokenId,
|
||||
@@ -107,7 +107,7 @@ export class AssetWrapper {
|
||||
}
|
||||
}
|
||||
public async getProxyAllowanceAsync(userAddress: string, assetData: string): Promise<BigNumber> {
|
||||
const proxyId = assetProxyUtils.decodeAssetDataId(assetData);
|
||||
const proxyId = assetDataUtils.decodeAssetProxyId(assetData);
|
||||
switch (proxyId) {
|
||||
case AssetProxyId.ERC20: {
|
||||
const erc20Wrapper = this._proxyIdToAssetWrappers[proxyId] as ERC20Wrapper;
|
||||
@@ -116,7 +116,7 @@ export class AssetWrapper {
|
||||
}
|
||||
case AssetProxyId.ERC721: {
|
||||
const assetWrapper = this._proxyIdToAssetWrappers[proxyId] as ERC721Wrapper;
|
||||
const erc721ProxyData = assetProxyUtils.decodeERC721AssetData(assetData);
|
||||
const erc721ProxyData = assetDataUtils.decodeERC721AssetData(assetData);
|
||||
const isProxyApprovedForAll = await assetWrapper.isProxyApprovedForAllAsync(
|
||||
userAddress,
|
||||
erc721ProxyData.tokenAddress,
|
||||
@@ -141,7 +141,7 @@ export class AssetWrapper {
|
||||
assetData: string,
|
||||
desiredAllowance: BigNumber,
|
||||
): Promise<void> {
|
||||
const proxyId = assetProxyUtils.decodeAssetDataId(assetData);
|
||||
const proxyId = assetDataUtils.decodeAssetProxyId(assetData);
|
||||
switch (proxyId) {
|
||||
case AssetProxyId.ERC20: {
|
||||
const erc20Wrapper = this._proxyIdToAssetWrappers[proxyId] as ERC20Wrapper;
|
||||
@@ -159,7 +159,7 @@ export class AssetWrapper {
|
||||
);
|
||||
}
|
||||
const erc721Wrapper = this._proxyIdToAssetWrappers[proxyId] as ERC721Wrapper;
|
||||
const assetProxyData = assetProxyUtils.decodeERC721AssetData(assetData);
|
||||
const assetProxyData = assetDataUtils.decodeERC721AssetData(assetData);
|
||||
|
||||
const doesTokenExist = await erc721Wrapper.doesTokenExistAsync(
|
||||
assetProxyData.tokenAddress,
|
||||
|
@@ -17,6 +17,7 @@ const TESTRPC_PRIVATE_KEYS_STRINGS = [
|
||||
];
|
||||
|
||||
export const constants = {
|
||||
BASE_16: 16,
|
||||
INVALID_OPCODE: 'invalid opcode',
|
||||
TESTRPC_NETWORK_ID: 50,
|
||||
// Note(albrow): In practice V8 and most other engines limit the minimum
|
||||
@@ -47,4 +48,5 @@ export const constants = {
|
||||
makerFee: Web3Wrapper.toBaseUnitAmount(new BigNumber(1), 18),
|
||||
takerFee: Web3Wrapper.toBaseUnitAmount(new BigNumber(1), 18),
|
||||
},
|
||||
WORD_LENGTH: 32,
|
||||
};
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import {
|
||||
assetProxyUtils,
|
||||
assetDataUtils,
|
||||
BalanceAndProxyAllowanceLazyStore,
|
||||
ExchangeTransferSimulator,
|
||||
orderHashUtils,
|
||||
@@ -72,7 +72,7 @@ export async function coreCombinatorialUtilsFactoryAsync(
|
||||
erc20EighteenDecimalTokenB,
|
||||
zrxToken,
|
||||
] = await erc20Wrapper.deployDummyTokensAsync(erc20EighteenDecimalTokenCount, eighteenDecimals);
|
||||
const zrxAssetData = assetProxyUtils.encodeERC20AssetData(zrxToken.address);
|
||||
const zrxAssetData = assetDataUtils.encodeERC20AssetData(zrxToken.address);
|
||||
|
||||
const erc20FiveDecimalTokenCount = 2;
|
||||
const fiveDecimals = new BigNumber(5);
|
||||
@@ -598,8 +598,8 @@ export class CoreCombinatorialUtils {
|
||||
break;
|
||||
|
||||
case TakerAssetFillAmountScenario.LessThanRemainingFillableTakerAssetAmount:
|
||||
const takerAssetProxyId = assetProxyUtils.decodeAssetDataId(signedOrder.takerAssetData);
|
||||
const makerAssetProxyId = assetProxyUtils.decodeAssetDataId(signedOrder.makerAssetData);
|
||||
const takerAssetProxyId = assetDataUtils.decodeAssetProxyId(signedOrder.takerAssetData);
|
||||
const makerAssetProxyId = assetDataUtils.decodeAssetProxyId(signedOrder.makerAssetData);
|
||||
const isEitherAssetERC721 =
|
||||
takerAssetProxyId === AssetProxyId.ERC721 || makerAssetProxyId === AssetProxyId.ERC721;
|
||||
if (isEitherAssetERC721) {
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { assetProxyUtils } from '@0xproject/order-utils';
|
||||
import { assetDataUtils } from '@0xproject/order-utils';
|
||||
import { BigNumber } from '@0xproject/utils';
|
||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||
import { Provider } from 'ethereum-types';
|
||||
@@ -154,7 +154,7 @@ export class ERC20Wrapper {
|
||||
return tokenAddresses;
|
||||
}
|
||||
private _getTokenContractFromAssetData(assetData: string): DummyERC20TokenContract {
|
||||
const erc20ProxyData = assetProxyUtils.decodeERC20AssetData(assetData);
|
||||
const erc20ProxyData = assetDataUtils.decodeERC20AssetData(assetData);
|
||||
const tokenAddress = erc20ProxyData.tokenAddress;
|
||||
const tokenContractIfExists = _.find(this._dummyTokenContracts, c => c.address === tokenAddress);
|
||||
if (_.isUndefined(tokenContractIfExists)) {
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { assetProxyUtils } from '@0xproject/order-utils';
|
||||
import { assetDataUtils } from '@0xproject/order-utils';
|
||||
import { AssetProxyId, SignedOrder } from '@0xproject/types';
|
||||
import { BigNumber } from '@0xproject/utils';
|
||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||
@@ -24,7 +24,7 @@ export class ForwarderWrapper {
|
||||
private readonly _zrxAddress: string;
|
||||
private static _createOptimizedSellOrders(signedOrders: SignedOrder[]): MarketSellOrders {
|
||||
const marketSellOrders = formatters.createMarketSellOrders(signedOrders, ZERO_AMOUNT);
|
||||
const assetDataId = assetProxyUtils.decodeAssetDataId(signedOrders[0].makerAssetData);
|
||||
const assetDataId = assetDataUtils.decodeAssetProxyId(signedOrders[0].makerAssetData);
|
||||
// Contract will fill this in for us as all of the assetData is assumed to be the same
|
||||
for (let i = 0; i < signedOrders.length; i++) {
|
||||
if (i !== 0 && assetDataId === AssetProxyId.ERC20) {
|
||||
@@ -90,7 +90,7 @@ export class ForwarderWrapper {
|
||||
txData: TxDataPayable,
|
||||
opts: { feeProportion?: number; feeRecipient?: string } = {},
|
||||
): Promise<TransactionReceiptWithDecodedLogs> {
|
||||
const assetDataId = assetProxyUtils.decodeAssetDataId(orders[0].makerAssetData);
|
||||
const assetDataId = assetDataUtils.decodeAssetProxyId(orders[0].makerAssetData);
|
||||
if (assetDataId !== AssetProxyId.ERC20) {
|
||||
throw new Error('Asset type not supported by marketSellEthForERC20');
|
||||
}
|
||||
@@ -116,7 +116,7 @@ export class ForwarderWrapper {
|
||||
feeProportion: number,
|
||||
makerAssetFillAmount: BigNumber,
|
||||
): Promise<BigNumber> {
|
||||
const assetProxyId = assetProxyUtils.decodeAssetDataId(orders[0].makerAssetData);
|
||||
const assetProxyId = assetDataUtils.decodeAssetProxyId(orders[0].makerAssetData);
|
||||
switch (assetProxyId) {
|
||||
case AssetProxyId.ERC20: {
|
||||
const fillAmountWei = this._calculateMarketBuyERC20FillAmountAsync(
|
||||
@@ -145,7 +145,7 @@ export class ForwarderWrapper {
|
||||
feeProportion: number,
|
||||
makerAssetFillAmount: BigNumber,
|
||||
): Promise<BigNumber> {
|
||||
const makerAssetData = assetProxyUtils.decodeAssetData(orders[0].makerAssetData);
|
||||
const makerAssetData = assetDataUtils.decodeAssetDataOrThrow(orders[0].makerAssetData);
|
||||
const makerAssetToken = makerAssetData.tokenAddress;
|
||||
const params = formatters.createMarketBuyOrders(orders, makerAssetFillAmount);
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { assetProxyUtils, orderHashUtils } from '@0xproject/order-utils';
|
||||
import { assetDataUtils, orderHashUtils } from '@0xproject/order-utils';
|
||||
import { AssetProxyId, SignedOrder } from '@0xproject/types';
|
||||
import { BigNumber } from '@0xproject/utils';
|
||||
import * as chai from 'chai';
|
||||
@@ -233,10 +233,10 @@ export class MatchOrderTester {
|
||||
const expectedNewERC20BalancesByOwner = _.cloneDeep(erc20BalancesByOwner);
|
||||
const expectedNewERC721TokenIdsByOwner = _.cloneDeep(erc721TokenIdsByOwner);
|
||||
// Left Maker Asset (Right Taker Asset)
|
||||
const makerAssetProxyIdLeft = assetProxyUtils.decodeAssetDataId(signedOrderLeft.makerAssetData);
|
||||
const makerAssetProxyIdLeft = assetDataUtils.decodeAssetProxyId(signedOrderLeft.makerAssetData);
|
||||
if (makerAssetProxyIdLeft === AssetProxyId.ERC20) {
|
||||
// Decode asset data
|
||||
const erc20AssetData = assetProxyUtils.decodeERC20AssetData(signedOrderLeft.makerAssetData);
|
||||
const erc20AssetData = assetDataUtils.decodeERC20AssetData(signedOrderLeft.makerAssetData);
|
||||
const makerAssetAddressLeft = erc20AssetData.tokenAddress;
|
||||
const takerAssetAddressRight = makerAssetAddressLeft;
|
||||
// Left Maker
|
||||
@@ -255,7 +255,7 @@ export class MatchOrderTester {
|
||||
][makerAssetAddressLeft].add(expectedTransferAmounts.amountReceivedByTaker);
|
||||
} else if (makerAssetProxyIdLeft === AssetProxyId.ERC721) {
|
||||
// Decode asset data
|
||||
const erc721AssetData = assetProxyUtils.decodeERC721AssetData(signedOrderLeft.makerAssetData);
|
||||
const erc721AssetData = assetDataUtils.decodeERC721AssetData(signedOrderLeft.makerAssetData);
|
||||
const makerAssetAddressLeft = erc721AssetData.tokenAddress;
|
||||
const makerAssetIdLeft = erc721AssetData.tokenId;
|
||||
const takerAssetAddressRight = makerAssetAddressLeft;
|
||||
@@ -268,10 +268,10 @@ export class MatchOrderTester {
|
||||
}
|
||||
// Left Taker Asset (Right Maker Asset)
|
||||
// Note: This exchange is only between the order makers: the Taker does not receive any of the left taker asset.
|
||||
const takerAssetProxyIdLeft = assetProxyUtils.decodeAssetDataId(signedOrderLeft.takerAssetData);
|
||||
const takerAssetProxyIdLeft = assetDataUtils.decodeAssetProxyId(signedOrderLeft.takerAssetData);
|
||||
if (takerAssetProxyIdLeft === AssetProxyId.ERC20) {
|
||||
// Decode asset data
|
||||
const erc20AssetData = assetProxyUtils.decodeERC20AssetData(signedOrderLeft.takerAssetData);
|
||||
const erc20AssetData = assetDataUtils.decodeERC20AssetData(signedOrderLeft.takerAssetData);
|
||||
const takerAssetAddressLeft = erc20AssetData.tokenAddress;
|
||||
const makerAssetAddressRight = takerAssetAddressLeft;
|
||||
// Left Maker
|
||||
@@ -286,7 +286,7 @@ export class MatchOrderTester {
|
||||
);
|
||||
} else if (takerAssetProxyIdLeft === AssetProxyId.ERC721) {
|
||||
// Decode asset data
|
||||
const erc721AssetData = assetProxyUtils.decodeERC721AssetData(signedOrderRight.makerAssetData);
|
||||
const erc721AssetData = assetDataUtils.decodeERC721AssetData(signedOrderRight.makerAssetData);
|
||||
const makerAssetAddressRight = erc721AssetData.tokenAddress;
|
||||
const makerAssetIdRight = erc721AssetData.tokenId;
|
||||
const takerAssetAddressLeft = makerAssetAddressRight;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { assetProxyUtils, generatePseudoRandomSalt } from '@0xproject/order-utils';
|
||||
import { assetDataUtils, generatePseudoRandomSalt } from '@0xproject/order-utils';
|
||||
import { Order } from '@0xproject/types';
|
||||
import { BigNumber, errorUtils } from '@0xproject/utils';
|
||||
|
||||
@@ -75,18 +75,16 @@ export class OrderFactoryFromScenario {
|
||||
|
||||
switch (orderScenario.makerAssetDataScenario) {
|
||||
case AssetDataScenario.ZRXFeeToken:
|
||||
makerAssetData = assetProxyUtils.encodeERC20AssetData(this._zrxAddress);
|
||||
makerAssetData = assetDataUtils.encodeERC20AssetData(this._zrxAddress);
|
||||
break;
|
||||
case AssetDataScenario.ERC20NonZRXEighteenDecimals:
|
||||
makerAssetData = assetProxyUtils.encodeERC20AssetData(
|
||||
this._nonZrxERC20EighteenDecimalTokenAddresses[0],
|
||||
);
|
||||
makerAssetData = assetDataUtils.encodeERC20AssetData(this._nonZrxERC20EighteenDecimalTokenAddresses[0]);
|
||||
break;
|
||||
case AssetDataScenario.ERC20FiveDecimals:
|
||||
makerAssetData = assetProxyUtils.encodeERC20AssetData(this._erc20FiveDecimalTokenAddresses[0]);
|
||||
makerAssetData = assetDataUtils.encodeERC20AssetData(this._erc20FiveDecimalTokenAddresses[0]);
|
||||
break;
|
||||
case AssetDataScenario.ERC721:
|
||||
makerAssetData = assetProxyUtils.encodeERC721AssetData(
|
||||
makerAssetData = assetDataUtils.encodeERC721AssetData(
|
||||
this._erc721Token.address,
|
||||
erc721MakerAssetIds[0],
|
||||
);
|
||||
@@ -97,18 +95,16 @@ export class OrderFactoryFromScenario {
|
||||
|
||||
switch (orderScenario.takerAssetDataScenario) {
|
||||
case AssetDataScenario.ZRXFeeToken:
|
||||
takerAssetData = assetProxyUtils.encodeERC20AssetData(this._zrxAddress);
|
||||
takerAssetData = assetDataUtils.encodeERC20AssetData(this._zrxAddress);
|
||||
break;
|
||||
case AssetDataScenario.ERC20NonZRXEighteenDecimals:
|
||||
takerAssetData = assetProxyUtils.encodeERC20AssetData(
|
||||
this._nonZrxERC20EighteenDecimalTokenAddresses[1],
|
||||
);
|
||||
takerAssetData = assetDataUtils.encodeERC20AssetData(this._nonZrxERC20EighteenDecimalTokenAddresses[1]);
|
||||
break;
|
||||
case AssetDataScenario.ERC20FiveDecimals:
|
||||
takerAssetData = assetProxyUtils.encodeERC20AssetData(this._erc20FiveDecimalTokenAddresses[1]);
|
||||
takerAssetData = assetDataUtils.encodeERC20AssetData(this._erc20FiveDecimalTokenAddresses[1]);
|
||||
break;
|
||||
case AssetDataScenario.ERC721:
|
||||
takerAssetData = assetProxyUtils.encodeERC721AssetData(
|
||||
takerAssetData = assetDataUtils.encodeERC721AssetData(
|
||||
this._erc721Token.address,
|
||||
erc721TakerAssetIds[0],
|
||||
);
|
||||
|
21
packages/contracts/test/utils/type_encoding_utils.ts
Normal file
21
packages/contracts/test/utils/type_encoding_utils.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { BigNumber } from '@0xproject/utils';
|
||||
import BN = require('bn.js');
|
||||
import ethUtil = require('ethereumjs-util');
|
||||
|
||||
import { constants } from './constants';
|
||||
|
||||
export const typeEncodingUtils = {
|
||||
encodeUint256(value: BigNumber): Buffer {
|
||||
const base = 10;
|
||||
const formattedValue = new BN(value.toString(base));
|
||||
const encodedValue = ethUtil.toBuffer(formattedValue);
|
||||
// tslint:disable-next-line:custom-no-magic-numbers
|
||||
const paddedValue = ethUtil.setLengthLeft(encodedValue, constants.WORD_LENGTH);
|
||||
return paddedValue;
|
||||
},
|
||||
decodeUint256(encodedValue: Buffer): BigNumber {
|
||||
const formattedValue = ethUtil.bufferToHex(encodedValue);
|
||||
const value = new BigNumber(formattedValue, constants.BASE_16);
|
||||
return value;
|
||||
},
|
||||
};
|
@@ -1,4 +1,31 @@
|
||||
[
|
||||
{
|
||||
"timestamp": 1532357734,
|
||||
"version": "1.0.1",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1532043000,
|
||||
"version": "1.0.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1531919263,
|
||||
"version": "0.4.6",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1531149657,
|
||||
"version": "0.4.5",
|
||||
@@ -28,7 +55,8 @@
|
||||
"note": "Add SolidityProfiler to EnvVars",
|
||||
"pr": 675
|
||||
}
|
||||
]
|
||||
],
|
||||
"timestamp": 1527008544
|
||||
},
|
||||
{
|
||||
"version": "0.4.2",
|
||||
|
@@ -1,10 +1,22 @@
|
||||
<!--
|
||||
This file is auto-generated using the monorepo-scripts package. Don't edit directly.
|
||||
changelogUtils.file is auto-generated using the monorepo-scripts package. Don't edit directly.
|
||||
Edit the package's CHANGELOG.json file only.
|
||||
-->
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v1.0.1 - _July 23, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.0.0 - _July 20, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.4.6 - _July 18, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.4.5 - _July 9, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
@@ -13,12 +25,14 @@ CHANGELOG
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.4.3 - _June 1, 2018_
|
||||
## v0.4.3 - _May 22, 2018_
|
||||
|
||||
* Incorrect publish that was unpublished
|
||||
* Add optional parameter shouldUseFakeGasEstimate to Web3Config (#622)
|
||||
* Add SolidityProfiler to EnvVars (#675)
|
||||
|
||||
## v0.4.2 - _May 22, 2018_
|
||||
|
||||
* Pass SolCompilerArtifactAdapter to CoverageSubprovider (#589)
|
||||
* Move callbackErrorReporter over from 0x.js (#579)
|
||||
|
||||
## v0.4.1 - _May 5, 2018_
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0xproject/dev-utils",
|
||||
"version": "0.4.5",
|
||||
"version": "1.0.0",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
@@ -30,8 +30,8 @@
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/0x-monorepo/packages/dev-utils/README.md",
|
||||
"devDependencies": {
|
||||
"@0xproject/monorepo-scripts": "^0.2.2",
|
||||
"@0xproject/tslint-config": "^0.4.21",
|
||||
"@0xproject/monorepo-scripts": "^1.0.0",
|
||||
"@0xproject/tslint-config": "^1.0.0",
|
||||
"@types/lodash": "4.14.104",
|
||||
"@types/mocha": "^2.2.42",
|
||||
"chai": "^4.0.1",
|
||||
@@ -45,12 +45,12 @@
|
||||
"typescript": "2.7.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0xproject/subproviders": "^0.10.5",
|
||||
"@0xproject/types": "^0.8.2",
|
||||
"@0xproject/utils": "^0.7.2",
|
||||
"ethereum-types": "^0.0.2",
|
||||
"@0xproject/typescript-typings": "^0.4.2",
|
||||
"@0xproject/web3-wrapper": "^0.7.2",
|
||||
"@0xproject/subproviders": "^1.0.0",
|
||||
"@0xproject/types": "^1.0.0-rc.1",
|
||||
"@0xproject/utils": "^1.0.0",
|
||||
"ethereum-types": "^1.0.0",
|
||||
"@0xproject/typescript-typings": "^1.0.0",
|
||||
"@0xproject/web3-wrapper": "^1.0.0",
|
||||
"lodash": "^4.17.4"
|
||||
},
|
||||
"publishConfig": {
|
||||
|
@@ -1,6 +1,16 @@
|
||||
[
|
||||
{
|
||||
"version": "0.0.3",
|
||||
"timestamp": 1532357734,
|
||||
"version": "1.0.1",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1532043000,
|
||||
"version": "1.0.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Add `TraceParams` interface for `debug_traceTransaction` parameters",
|
||||
|
19
packages/ethereum-types/CHANGELOG.md
Normal file
19
packages/ethereum-types/CHANGELOG.md
Normal file
@@ -0,0 +1,19 @@
|
||||
<!--
|
||||
changelogUtils.file is auto-generated using the monorepo-scripts package. Don't edit directly.
|
||||
Edit the package's CHANGELOG.json file only.
|
||||
-->
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v1.0.1 - _July 23, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.0.0 - _July 20, 2018_
|
||||
|
||||
* Add `TraceParams` interface for `debug_traceTransaction` parameters (#675)
|
||||
* Add `TransactionReceiptStatus` type (#812)
|
||||
|
||||
## v0.0.2 - _June 1, 2018_
|
||||
|
||||
* Initial publish (#642)
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ethereum-types",
|
||||
"version": "0.0.2",
|
||||
"version": "1.0.0",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
@@ -35,8 +35,8 @@
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/0x-monorepo/packages/ethereum-types/README.md",
|
||||
"devDependencies": {
|
||||
"@0xproject/monorepo-scripts": "^0.2.1",
|
||||
"@0xproject/tslint-config": "^0.4.20",
|
||||
"@0xproject/monorepo-scripts": "^1.0.0",
|
||||
"@0xproject/tslint-config": "^1.0.0",
|
||||
"copyfiles": "^1.2.0",
|
||||
"make-promises-safe": "^1.1.0",
|
||||
"shx": "^0.2.2",
|
||||
|
@@ -1,6 +1,16 @@
|
||||
[
|
||||
{
|
||||
"timestamp": 1532357734,
|
||||
"version": "1.0.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1532043000,
|
||||
"version": "1.0.0-rc.1",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Make fill-scenarios compatible with V2 of 0x protocol",
|
||||
@@ -8,6 +18,15 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1531919263,
|
||||
"version": "0.0.6",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1531149657,
|
||||
"version": "0.0.5",
|
||||
|
@@ -1,10 +1,22 @@
|
||||
<!--
|
||||
This file is auto-generated using the monorepo-scripts package. Don't edit directly.
|
||||
changelogUtils.file is auto-generated using the monorepo-scripts package. Don't edit directly.
|
||||
Edit the package's CHANGELOG.json file only.
|
||||
-->
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v1.0.0 - _July 23, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.0.0-rc.1 - _July 20, 2018_
|
||||
|
||||
* Make fill-scenarios compatible with V2 of 0x protocol (#656)
|
||||
|
||||
## v0.0.6 - _July 18, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.0.5 - _July 9, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
@@ -1,22 +1,22 @@
|
||||
{
|
||||
"name": "@0xproject/fill-scenarios",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.0-rc.1",
|
||||
"description": "0x order fill scenario generator",
|
||||
"main": "lib/index.js",
|
||||
"types": "lib/index.d.ts",
|
||||
"scripts": {
|
||||
"watch_without_deps": "yarn pre_build && tsc -w",
|
||||
"build": "yarn pre_build && tsc",
|
||||
"build": "yarn pre_build && tsc && copyfiles -u 2 './lib/monorepo_scripts/**/*' ./scripts",
|
||||
"pre_build": "run-s update_artifacts generate_contract_wrappers",
|
||||
"update_artifacts": "for i in ${npm_package_config_contracts}; do copyfiles -u 4 ../migrations/artifacts/2.0.0/$i.json lib/artifacts; done;",
|
||||
"generate_contract_wrappers": "abi-gen --abis 'lib/artifacts/@(Exchange|ERC20Token).json' --template ../contract_templates/contract.handlebars --partials '../contract_templates/partials/**/*.handlebars' --output src/generated_contract_wrappers --backend ethers",
|
||||
"generate_contract_wrappers": "abi-gen --abis 'lib/artifacts/@(Exchange|DummyERC20Token|DummyERC721Token).json' --template ../contract_templates/contract.handlebars --partials '../contract_templates/partials/**/*.handlebars' --output src/generated_contract_wrappers --backend ethers",
|
||||
"copy_monorepo_scripts": "copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts",
|
||||
"clean": "shx rm -rf lib scripts src/generated_contract_wrappers",
|
||||
"lint": "tslint --project . --exclude **/src/generated_contract_wrappers/**/*",
|
||||
"manual:postpublish": "yarn build; node ./scripts/postpublish.js"
|
||||
},
|
||||
"config": {
|
||||
"contracts": "Exchange ERC20Token"
|
||||
"contracts": "Exchange DummyERC20Token DummyERC721Token"
|
||||
},
|
||||
"license": "Apache-2.0",
|
||||
"repository": {
|
||||
@@ -28,10 +28,10 @@
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/0x-monorepo/packages/fill-scenarios/README.md",
|
||||
"devDependencies": {
|
||||
"@0xproject/abi-gen": "^0.3.3",
|
||||
"@0xproject/monorepo-scripts": "^0.2.2",
|
||||
"@0xproject/sol-compiler": "^0.5.3",
|
||||
"@0xproject/tslint-config": "^0.4.21",
|
||||
"@0xproject/abi-gen": "^1.0.0",
|
||||
"@0xproject/monorepo-scripts": "^1.0.0",
|
||||
"@0xproject/sol-compiler": "^1.0.0",
|
||||
"@0xproject/tslint-config": "^1.0.0",
|
||||
"@types/lodash": "4.14.104",
|
||||
"copyfiles": "^1.2.0",
|
||||
"make-promises-safe": "^1.1.0",
|
||||
@@ -41,13 +41,13 @@
|
||||
"typescript": "2.7.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0xproject/base-contract": "^0.3.5",
|
||||
"@0xproject/order-utils": "^1.0.0",
|
||||
"@0xproject/types": "1.0.0",
|
||||
"ethereum-types": "^0.0.2",
|
||||
"@0xproject/typescript-typings": "^0.4.2",
|
||||
"@0xproject/utils": "^0.7.2",
|
||||
"@0xproject/web3-wrapper": "^0.7.2",
|
||||
"@0xproject/base-contract": "^1.0.0",
|
||||
"@0xproject/order-utils": "^1.0.0-rc.1",
|
||||
"@0xproject/types": "^1.0.0-rc.1",
|
||||
"ethereum-types": "^1.0.0",
|
||||
"@0xproject/typescript-typings": "^1.0.0",
|
||||
"@0xproject/utils": "^1.0.0",
|
||||
"@0xproject/web3-wrapper": "^1.0.0",
|
||||
"ethers": "3.0.22",
|
||||
"lodash": "^4.17.4"
|
||||
},
|
||||
|
@@ -1,9 +1,11 @@
|
||||
import { ContractArtifact } from '@0xproject/sol-compiler';
|
||||
|
||||
import * as ERC20Token from './artifacts/ERC20Token.json';
|
||||
import * as DummyERC20Token from './artifacts/DummyERC20Token.json';
|
||||
import * as DummyERC721Token from './artifacts/DummyERC721Token.json';
|
||||
import * as Exchange from './artifacts/Exchange.json';
|
||||
|
||||
export const artifacts = {
|
||||
ERC20Token: (ERC20Token as any) as ContractArtifact,
|
||||
DummyERC20Token: (DummyERC20Token as any) as ContractArtifact,
|
||||
DummyERC721Token: (DummyERC721Token as any) as ContractArtifact,
|
||||
Exchange: (Exchange as any) as ContractArtifact,
|
||||
};
|
||||
|
@@ -1,3 +1,4 @@
|
||||
export const constants = {
|
||||
AWAIT_TRANSACTION_MINED_MS: 0,
|
||||
NULL_ADDRESS: '0x0000000000000000000000000000000000000000',
|
||||
};
|
||||
|
300
packages/fill-scenarios/src/fill_scenarios.ts
Normal file
300
packages/fill-scenarios/src/fill_scenarios.ts
Normal file
@@ -0,0 +1,300 @@
|
||||
import { assetDataUtils, orderFactory } from '@0xproject/order-utils';
|
||||
import { AssetProxyId, ERC721AssetData, OrderWithoutExchangeAddress, SignedOrder } from '@0xproject/types';
|
||||
import { BigNumber } from '@0xproject/utils';
|
||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||
import { Provider } from 'ethereum-types';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { artifacts } from './artifacts';
|
||||
import { constants } from './constants';
|
||||
import { DummyERC20TokenContract } from './generated_contract_wrappers/dummy_erc20_token';
|
||||
import { DummyERC721TokenContract } from './generated_contract_wrappers/dummy_erc721_token';
|
||||
import { ExchangeContract } from './generated_contract_wrappers/exchange';
|
||||
|
||||
export class FillScenarios {
|
||||
private readonly _web3Wrapper: Web3Wrapper;
|
||||
private readonly _userAddresses: string[];
|
||||
private readonly _coinbase: string;
|
||||
private readonly _zrxTokenAddress: string;
|
||||
private readonly _exchangeAddress: string;
|
||||
private readonly _erc20ProxyAddress: string;
|
||||
private readonly _erc721ProxyAddress: string;
|
||||
constructor(
|
||||
provider: Provider,
|
||||
userAddresses: string[],
|
||||
zrxTokenAddress: string,
|
||||
exchangeAddress: string,
|
||||
erc20ProxyAddress: string,
|
||||
erc721ProxyAddress: string,
|
||||
) {
|
||||
this._web3Wrapper = new Web3Wrapper(provider);
|
||||
this._userAddresses = userAddresses;
|
||||
this._coinbase = userAddresses[0];
|
||||
this._zrxTokenAddress = zrxTokenAddress;
|
||||
this._exchangeAddress = exchangeAddress;
|
||||
this._erc20ProxyAddress = erc20ProxyAddress;
|
||||
this._erc721ProxyAddress = erc721ProxyAddress;
|
||||
}
|
||||
public async createFillableSignedOrderAsync(
|
||||
makerAssetData: string,
|
||||
takerAssetData: string,
|
||||
makerAddress: string,
|
||||
takerAddress: string,
|
||||
fillableAmount: BigNumber,
|
||||
expirationTimeSeconds?: BigNumber,
|
||||
): Promise<SignedOrder> {
|
||||
return this.createAsymmetricFillableSignedOrderAsync(
|
||||
makerAssetData,
|
||||
takerAssetData,
|
||||
makerAddress,
|
||||
takerAddress,
|
||||
fillableAmount,
|
||||
fillableAmount,
|
||||
expirationTimeSeconds,
|
||||
);
|
||||
}
|
||||
public async createFillableSignedOrderWithFeesAsync(
|
||||
makerAssetData: string,
|
||||
takerAssetData: string,
|
||||
makerFee: BigNumber,
|
||||
takerFee: BigNumber,
|
||||
makerAddress: string,
|
||||
takerAddress: string,
|
||||
fillableAmount: BigNumber,
|
||||
feeRecepientAddress: string,
|
||||
expirationTimeSeconds?: BigNumber,
|
||||
): Promise<SignedOrder> {
|
||||
return this._createAsymmetricFillableSignedOrderWithFeesAsync(
|
||||
makerAssetData,
|
||||
takerAssetData,
|
||||
makerFee,
|
||||
takerFee,
|
||||
makerAddress,
|
||||
takerAddress,
|
||||
fillableAmount,
|
||||
fillableAmount,
|
||||
feeRecepientAddress,
|
||||
expirationTimeSeconds,
|
||||
);
|
||||
}
|
||||
public async createAsymmetricFillableSignedOrderAsync(
|
||||
makerAssetData: string,
|
||||
takerAssetData: string,
|
||||
makerAddress: string,
|
||||
takerAddress: string,
|
||||
makerFillableAmount: BigNumber,
|
||||
takerFillableAmount: BigNumber,
|
||||
expirationTimeSeconds?: BigNumber,
|
||||
): Promise<SignedOrder> {
|
||||
const makerFee = new BigNumber(0);
|
||||
const takerFee = new BigNumber(0);
|
||||
const feeRecepientAddress = constants.NULL_ADDRESS;
|
||||
return this._createAsymmetricFillableSignedOrderWithFeesAsync(
|
||||
makerAssetData,
|
||||
takerAssetData,
|
||||
makerFee,
|
||||
takerFee,
|
||||
makerAddress,
|
||||
takerAddress,
|
||||
makerFillableAmount,
|
||||
takerFillableAmount,
|
||||
feeRecepientAddress,
|
||||
expirationTimeSeconds,
|
||||
);
|
||||
}
|
||||
public async createPartiallyFilledSignedOrderAsync(
|
||||
makerAssetData: string,
|
||||
takerAssetData: string,
|
||||
takerAddress: string,
|
||||
fillableAmount: BigNumber,
|
||||
partialFillAmount: BigNumber,
|
||||
): Promise<SignedOrder> {
|
||||
const [makerAddress] = this._userAddresses;
|
||||
const signedOrder = await this.createAsymmetricFillableSignedOrderAsync(
|
||||
makerAssetData,
|
||||
takerAssetData,
|
||||
makerAddress,
|
||||
takerAddress,
|
||||
fillableAmount,
|
||||
fillableAmount,
|
||||
);
|
||||
const exchangeInstance = new ExchangeContract(
|
||||
artifacts.Exchange.compilerOutput.abi,
|
||||
signedOrder.exchangeAddress,
|
||||
this._web3Wrapper.getProvider(),
|
||||
this._web3Wrapper.getContractDefaults(),
|
||||
);
|
||||
|
||||
const orderWithoutExchangeAddress = _.omit(signedOrder, [
|
||||
'signature',
|
||||
'exchangeAddress',
|
||||
]) as OrderWithoutExchangeAddress;
|
||||
|
||||
const txHash = await exchangeInstance.fillOrder.sendTransactionAsync(
|
||||
orderWithoutExchangeAddress,
|
||||
partialFillAmount,
|
||||
signedOrder.signature,
|
||||
{ from: takerAddress },
|
||||
);
|
||||
await this._web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
|
||||
return signedOrder;
|
||||
}
|
||||
private async _createAsymmetricFillableSignedOrderWithFeesAsync(
|
||||
makerAssetData: string,
|
||||
takerAssetData: string,
|
||||
makerFee: BigNumber,
|
||||
takerFee: BigNumber,
|
||||
makerAddress: string,
|
||||
takerAddress: string,
|
||||
makerFillableAmount: BigNumber,
|
||||
takerFillableAmount: BigNumber,
|
||||
feeRecepientAddress: 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,
|
||||
);
|
||||
}
|
||||
// Fees
|
||||
await Promise.all([
|
||||
this._increaseERC20BalanceAndAllowanceAsync(this._zrxTokenAddress, makerAddress, makerFee),
|
||||
this._increaseERC20BalanceAndAllowanceAsync(this._zrxTokenAddress, takerAddress, takerFee),
|
||||
]);
|
||||
const senderAddress = constants.NULL_ADDRESS;
|
||||
|
||||
const signedOrder = await orderFactory.createSignedOrderAsync(
|
||||
this._web3Wrapper.getProvider(),
|
||||
makerAddress,
|
||||
takerAddress,
|
||||
senderAddress,
|
||||
makerFee,
|
||||
takerFee,
|
||||
makerFillableAmount,
|
||||
makerAssetData,
|
||||
takerFillableAmount,
|
||||
takerAssetData,
|
||||
this._exchangeAddress,
|
||||
feeRecepientAddress,
|
||||
expirationTimeSeconds,
|
||||
);
|
||||
return signedOrder;
|
||||
}
|
||||
private async _increaseERC721BalanceAndAllowanceAsync(
|
||||
tokenAddress: string,
|
||||
address: string,
|
||||
tokenId: BigNumber,
|
||||
): Promise<void> {
|
||||
await this._increaseERC721BalanceAsync(tokenAddress, address, tokenId);
|
||||
await this._increaseERC721AllowanceAsync(tokenAddress, address, tokenId);
|
||||
}
|
||||
private async _increaseERC721AllowanceAsync(
|
||||
tokenAddress: string,
|
||||
address: string,
|
||||
tokenId: BigNumber,
|
||||
): Promise<void> {
|
||||
const erc721Token = new DummyERC721TokenContract(
|
||||
artifacts.DummyERC721Token.compilerOutput.abi,
|
||||
tokenAddress,
|
||||
this._web3Wrapper.getProvider(),
|
||||
this._web3Wrapper.getContractDefaults(),
|
||||
);
|
||||
const txHash = await erc721Token.approve.sendTransactionAsync(this._erc721ProxyAddress, tokenId, {
|
||||
from: address,
|
||||
});
|
||||
await this._web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
|
||||
}
|
||||
private async _increaseERC721BalanceAsync(
|
||||
tokenAddress: string,
|
||||
address: string,
|
||||
tokenId: BigNumber,
|
||||
): Promise<void> {
|
||||
const erc721Token = new DummyERC721TokenContract(
|
||||
artifacts.DummyERC721Token.compilerOutput.abi,
|
||||
tokenAddress,
|
||||
this._web3Wrapper.getProvider(),
|
||||
this._web3Wrapper.getContractDefaults(),
|
||||
);
|
||||
try {
|
||||
const currentOwner = await erc721Token.ownerOf.callAsync(tokenId);
|
||||
if (currentOwner !== address) {
|
||||
throw new Error(`Token ${tokenAddress}:${tokenId} is already owner by ${currentOwner}`);
|
||||
}
|
||||
} catch (err) {
|
||||
const txHash = await erc721Token.mint.sendTransactionAsync(address, tokenId, { from: this._coinbase });
|
||||
await this._web3Wrapper.awaitTransactionSuccessAsync(txHash, constants.AWAIT_TRANSACTION_MINED_MS);
|
||||
}
|
||||
}
|
||||
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,222 +1 @@
|
||||
import { assetProxyUtils, orderFactory } from '@0xproject/order-utils';
|
||||
import { OrderWithoutExchangeAddress, SignedOrder } from '@0xproject/types';
|
||||
import { BigNumber } from '@0xproject/utils';
|
||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||
import { Provider } from 'ethereum-types';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { artifacts } from './artifacts';
|
||||
import { constants } from './constants';
|
||||
import { ERC20TokenContract } from './generated_contract_wrappers/erc20_token';
|
||||
import { ExchangeContract } from './generated_contract_wrappers/exchange';
|
||||
|
||||
export class FillScenarios {
|
||||
private readonly _web3Wrapper: Web3Wrapper;
|
||||
private readonly _userAddresses: string[];
|
||||
private readonly _coinbase: string;
|
||||
private readonly _zrxTokenAddress: string;
|
||||
private readonly _exchangeAddress: string;
|
||||
private readonly _erc20ProxyAddress: string;
|
||||
constructor(
|
||||
provider: Provider,
|
||||
userAddresses: string[],
|
||||
zrxTokenAddress: string,
|
||||
exchangeAddress: string,
|
||||
erc20ProxyAddress: string,
|
||||
) {
|
||||
this._web3Wrapper = new Web3Wrapper(provider);
|
||||
this._userAddresses = userAddresses;
|
||||
this._coinbase = userAddresses[0];
|
||||
this._zrxTokenAddress = zrxTokenAddress;
|
||||
this._exchangeAddress = exchangeAddress;
|
||||
this._erc20ProxyAddress = erc20ProxyAddress;
|
||||
}
|
||||
public async createFillableSignedOrderAsync(
|
||||
makerAssetData: string,
|
||||
takerAssetData: string,
|
||||
makerAddress: string,
|
||||
takerAddress: string,
|
||||
fillableAmount: BigNumber,
|
||||
expirationTimeSeconds?: BigNumber,
|
||||
): Promise<SignedOrder> {
|
||||
return this.createAsymmetricFillableSignedOrderAsync(
|
||||
makerAssetData,
|
||||
takerAssetData,
|
||||
makerAddress,
|
||||
takerAddress,
|
||||
fillableAmount,
|
||||
fillableAmount,
|
||||
expirationTimeSeconds,
|
||||
);
|
||||
}
|
||||
public async createFillableSignedOrderWithFeesAsync(
|
||||
makerAssetData: string,
|
||||
takerAssetData: string,
|
||||
makerFee: BigNumber,
|
||||
takerFee: BigNumber,
|
||||
makerAddress: string,
|
||||
takerAddress: string,
|
||||
fillableAmount: BigNumber,
|
||||
feeRecepientAddress: string,
|
||||
expirationTimeSeconds?: BigNumber,
|
||||
): Promise<SignedOrder> {
|
||||
return this._createAsymmetricFillableSignedOrderWithFeesAsync(
|
||||
makerAssetData,
|
||||
takerAssetData,
|
||||
makerFee,
|
||||
takerFee,
|
||||
makerAddress,
|
||||
takerAddress,
|
||||
fillableAmount,
|
||||
fillableAmount,
|
||||
feeRecepientAddress,
|
||||
expirationTimeSeconds,
|
||||
);
|
||||
}
|
||||
public async createAsymmetricFillableSignedOrderAsync(
|
||||
makerAssetData: string,
|
||||
takerAssetData: string,
|
||||
makerAddress: string,
|
||||
takerAddress: string,
|
||||
makerFillableAmount: BigNumber,
|
||||
takerFillableAmount: BigNumber,
|
||||
expirationTimeSeconds?: BigNumber,
|
||||
): Promise<SignedOrder> {
|
||||
const makerFee = new BigNumber(0);
|
||||
const takerFee = new BigNumber(0);
|
||||
const feeRecepientAddress = constants.NULL_ADDRESS;
|
||||
return this._createAsymmetricFillableSignedOrderWithFeesAsync(
|
||||
makerAssetData,
|
||||
takerAssetData,
|
||||
makerFee,
|
||||
takerFee,
|
||||
makerAddress,
|
||||
takerAddress,
|
||||
makerFillableAmount,
|
||||
takerFillableAmount,
|
||||
feeRecepientAddress,
|
||||
expirationTimeSeconds,
|
||||
);
|
||||
}
|
||||
public async createPartiallyFilledSignedOrderAsync(
|
||||
makerAssetData: string,
|
||||
takerAssetData: string,
|
||||
takerAddress: string,
|
||||
fillableAmount: BigNumber,
|
||||
partialFillAmount: BigNumber,
|
||||
): Promise<SignedOrder> {
|
||||
const [makerAddress] = this._userAddresses;
|
||||
const signedOrder = await this.createAsymmetricFillableSignedOrderAsync(
|
||||
makerAssetData,
|
||||
takerAssetData,
|
||||
makerAddress,
|
||||
takerAddress,
|
||||
fillableAmount,
|
||||
fillableAmount,
|
||||
);
|
||||
const exchangeInstance = new ExchangeContract(
|
||||
artifacts.Exchange.compilerOutput.abi,
|
||||
signedOrder.exchangeAddress,
|
||||
this._web3Wrapper.getProvider(),
|
||||
this._web3Wrapper.getContractDefaults(),
|
||||
);
|
||||
|
||||
const orderWithoutExchangeAddress = _.omit(signedOrder, [
|
||||
'signature',
|
||||
'exchangeAddress',
|
||||
]) as OrderWithoutExchangeAddress;
|
||||
|
||||
await exchangeInstance.fillOrder.sendTransactionAsync(
|
||||
orderWithoutExchangeAddress,
|
||||
partialFillAmount,
|
||||
signedOrder.signature,
|
||||
{ from: takerAddress },
|
||||
);
|
||||
return signedOrder;
|
||||
}
|
||||
private async _createAsymmetricFillableSignedOrderWithFeesAsync(
|
||||
makerAssetData: string,
|
||||
takerAssetData: string,
|
||||
makerFee: BigNumber,
|
||||
takerFee: BigNumber,
|
||||
makerAddress: string,
|
||||
takerAddress: string,
|
||||
makerFillableAmount: BigNumber,
|
||||
takerFillableAmount: BigNumber,
|
||||
feeRecepientAddress: string,
|
||||
expirationTimeSeconds?: BigNumber,
|
||||
): Promise<SignedOrder> {
|
||||
const makerERC20AssetData = assetProxyUtils.decodeERC20AssetData(makerAssetData);
|
||||
const makerTokenAddress = makerERC20AssetData.tokenAddress;
|
||||
const takerERC20AssetData = assetProxyUtils.decodeERC20AssetData(takerAssetData);
|
||||
const takerTokenAddress = takerERC20AssetData.tokenAddress;
|
||||
await Promise.all([
|
||||
this._increaseERC20BalanceAndAllowanceAsync(makerTokenAddress, makerAddress, makerFillableAmount),
|
||||
this._increaseERC20BalanceAndAllowanceAsync(takerTokenAddress, takerAddress, takerFillableAmount),
|
||||
]);
|
||||
await Promise.all([
|
||||
this._increaseERC20BalanceAndAllowanceAsync(this._zrxTokenAddress, makerAddress, makerFee),
|
||||
this._increaseERC20BalanceAndAllowanceAsync(this._zrxTokenAddress, takerAddress, takerFee),
|
||||
]);
|
||||
const senderAddress = constants.NULL_ADDRESS;
|
||||
|
||||
const signedOrder = await orderFactory.createSignedOrderAsync(
|
||||
this._web3Wrapper.getProvider(),
|
||||
makerAddress,
|
||||
takerAddress,
|
||||
senderAddress,
|
||||
makerFee,
|
||||
takerFee,
|
||||
makerFillableAmount,
|
||||
makerAssetData,
|
||||
takerFillableAmount,
|
||||
takerAssetData,
|
||||
this._exchangeAddress,
|
||||
feeRecepientAddress,
|
||||
expirationTimeSeconds,
|
||||
);
|
||||
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 token = new ERC20TokenContract(
|
||||
artifacts.ERC20Token.compilerOutput.abi,
|
||||
tokenAddress,
|
||||
this._web3Wrapper.getProvider(),
|
||||
this._web3Wrapper.getContractDefaults(),
|
||||
);
|
||||
await token.transfer.sendTransactionAsync(address, amount, {
|
||||
from: this._coinbase,
|
||||
});
|
||||
}
|
||||
private async _increaseERC20AllowanceAsync(
|
||||
tokenAddress: string,
|
||||
address: string,
|
||||
amount: BigNumber,
|
||||
): Promise<void> {
|
||||
const tokenInstance = new ERC20TokenContract(
|
||||
artifacts.ERC20Token.compilerOutput.abi,
|
||||
tokenAddress,
|
||||
this._web3Wrapper.getProvider(),
|
||||
this._web3Wrapper.getContractDefaults(),
|
||||
);
|
||||
const oldMakerAllowance = await tokenInstance.allowance.callAsync(address, this._erc20ProxyAddress);
|
||||
const newMakerAllowance = oldMakerAllowance.plus(amount);
|
||||
|
||||
await tokenInstance.approve.sendTransactionAsync(this._erc20ProxyAddress, newMakerAllowance, {
|
||||
from: address,
|
||||
});
|
||||
}
|
||||
}
|
||||
export { FillScenarios } from './fill_scenarios';
|
||||
|
@@ -1,14 +1,37 @@
|
||||
[
|
||||
{
|
||||
"timestamp": 1532357734,
|
||||
"version": "1.0.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Update schemas for V2",
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1532043000,
|
||||
"version": "1.0.0-rc.1",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Update schemas for V2 or 0x Protocol",
|
||||
"pr": 615
|
||||
},
|
||||
{
|
||||
"note": "Added CallData schema",
|
||||
"pr": 821
|
||||
},
|
||||
{
|
||||
"note": "Update CallData schema id to CallData",
|
||||
"pr": 894
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1531919263,
|
||||
"version": "0.8.3",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -38,7 +61,8 @@
|
||||
"Update Order & SignedOrder schemas, remove ECSignature schema and add Hex schema as part of V2 upgrades",
|
||||
"pr": 615
|
||||
}
|
||||
]
|
||||
],
|
||||
"timestamp": 1527008794
|
||||
},
|
||||
{
|
||||
"timestamp": 1527008794,
|
||||
|
@@ -1,10 +1,24 @@
|
||||
<!--
|
||||
This file is auto-generated using the monorepo-scripts package. Don't edit directly.
|
||||
changelogUtils.file is auto-generated using the monorepo-scripts package. Don't edit directly.
|
||||
Edit the package's CHANGELOG.json file only.
|
||||
-->
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v1.0.0 - _July 23, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.0.0-rc.1 - _July 20, 2018_
|
||||
|
||||
* Update schemas for V2 or 0x Protocol (#615)
|
||||
* Added CallData schema (#821)
|
||||
* Update CallData schema id to CallData (#894)
|
||||
|
||||
## v0.8.3 - _July 18, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.8.2 - _July 9, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
@@ -13,9 +27,9 @@ CHANGELOG
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.8.0 - _June 1, 2018_
|
||||
## v0.8.0 - _May 22, 2018_
|
||||
|
||||
* Incorrect publish that was unpublished
|
||||
* Update Order & SignedOrder schemas, remove ECSignature schema and add Hex schema as part of V2 upgrades (#615)
|
||||
|
||||
## v0.7.24 - _May 22, 2018_
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0xproject/json-schemas",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.0-rc.1",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
@@ -47,15 +47,15 @@
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/0x-monorepo/packages/json-schemas/README.md",
|
||||
"dependencies": {
|
||||
"@0xproject/typescript-typings": "^0.4.2",
|
||||
"@0xproject/typescript-typings": "^1.0.0",
|
||||
"@types/node": "^8.0.53",
|
||||
"jsonschema": "^1.2.0",
|
||||
"lodash.values": "^4.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@0xproject/monorepo-scripts": "^0.2.2",
|
||||
"@0xproject/tslint-config": "^0.4.21",
|
||||
"@0xproject/utils": "^0.7.2",
|
||||
"@0xproject/monorepo-scripts": "^1.0.0",
|
||||
"@0xproject/tslint-config": "^1.0.0",
|
||||
"@0xproject/utils": "^1.0.0",
|
||||
"@types/lodash.foreach": "^4.5.3",
|
||||
"@types/lodash.values": "^4.3.3",
|
||||
"@types/mocha": "^2.2.42",
|
||||
|
@@ -1,5 +1,5 @@
|
||||
export const callDataSchema = {
|
||||
id: '/TxData',
|
||||
id: '/CallData',
|
||||
properties: {
|
||||
from: { $ref: '/Address' },
|
||||
to: { $ref: '/Address' },
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0xproject/metacoin",
|
||||
"version": "0.0.9",
|
||||
"version": "0.0.10",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
@@ -29,25 +29,25 @@
|
||||
"author": "",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@0xproject/abi-gen": "^0.3.3",
|
||||
"@0xproject/base-contract": "^0.3.5",
|
||||
"@0xproject/sol-compiler": "^0.5.3",
|
||||
"@0xproject/sol-cov": "^0.1.2",
|
||||
"@0xproject/subproviders": "^0.10.5",
|
||||
"@0xproject/tslint-config": "^0.4.21",
|
||||
"@0xproject/types": "^0.8.2",
|
||||
"@0xproject/typescript-typings": "^0.4.2",
|
||||
"@0xproject/utils": "^0.7.2",
|
||||
"@0xproject/web3-wrapper": "^0.7.2",
|
||||
"@0xproject/abi-gen": "^1.0.0",
|
||||
"@0xproject/base-contract": "^1.0.0",
|
||||
"@0xproject/sol-compiler": "^1.0.0",
|
||||
"@0xproject/sol-cov": "^1.0.0",
|
||||
"@0xproject/subproviders": "^1.0.0",
|
||||
"@0xproject/tslint-config": "^1.0.0",
|
||||
"@0xproject/types": "^1.0.0-rc.1",
|
||||
"@0xproject/typescript-typings": "^1.0.0",
|
||||
"@0xproject/utils": "^1.0.0",
|
||||
"@0xproject/web3-wrapper": "^1.0.0",
|
||||
"@types/mocha": "^5.2.2",
|
||||
"copyfiles": "^2.0.0",
|
||||
"ethereum-types": "^0.0.2",
|
||||
"ethereum-types": "^1.0.0",
|
||||
"ethers": "3.0.22",
|
||||
"lodash": "^4.17.4",
|
||||
"run-s": "^0.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@0xproject/dev-utils": "^0.4.5",
|
||||
"@0xproject/dev-utils": "^1.0.0",
|
||||
"chai": "^4.0.1",
|
||||
"chai-as-promised": "^7.1.0",
|
||||
"chai-bignumber": "^2.0.1",
|
||||
|
@@ -1,4 +1,31 @@
|
||||
[
|
||||
{
|
||||
"timestamp": 1532357734,
|
||||
"version": "1.0.1",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1532043000,
|
||||
"version": "1.0.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Added migrations for 0x Protocol v2"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1531919263,
|
||||
"version": "0.0.10",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1531149657,
|
||||
"version": "0.0.9",
|
||||
@@ -18,6 +45,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1527008794,
|
||||
"version": "0.0.7",
|
||||
"changes": [
|
||||
{
|
||||
|
@@ -1,10 +1,22 @@
|
||||
<!--
|
||||
This file is auto-generated using the monorepo-scripts package. Don't edit directly.
|
||||
changelogUtils.file is auto-generated using the monorepo-scripts package. Don't edit directly.
|
||||
Edit the package's CHANGELOG.json file only.
|
||||
-->
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v1.0.1 - _July 23, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.0.0 - _July 20, 2018_
|
||||
|
||||
* Added migrations for 0x Protocol v2
|
||||
|
||||
## v0.0.10 - _July 18, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.0.9 - _July 9, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
@@ -13,9 +25,9 @@ CHANGELOG
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.0.7 - _June 1, 2018_
|
||||
## v0.0.7 - _May 22, 2018_
|
||||
|
||||
* Incorrect publish that was unpublished
|
||||
* Use AssetProxyOwner instead of MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress (#675)
|
||||
|
||||
## v0.0.6 - _May 22, 2018_
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
212
packages/migrations/artifacts/2.0.0/Exchange.json
vendored
212
packages/migrations/artifacts/2.0.0/Exchange.json
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0xproject/migrations",
|
||||
"version": "0.0.9",
|
||||
"version": "1.0.0",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
@@ -9,7 +9,8 @@
|
||||
"types": "lib/index.d.ts",
|
||||
"scripts": {
|
||||
"watch_without_deps": "yarn pre_build && tsc -w",
|
||||
"build": "yarn pre_build && tsc",
|
||||
"build": "yarn pre_build && tsc && copyfiles -u 2 './lib/monorepo_scripts/**/*' ./scripts",
|
||||
"manual:postpublish": "yarn build; node ./scripts/postpublish.js",
|
||||
"pre_build": "run-s copy_artifacts generate_contract_wrappers",
|
||||
"copy_artifacts": "copyfiles 'artifacts/**/*' ./lib",
|
||||
"clean": "shx rm -rf lib src/contract_wrappers",
|
||||
@@ -37,11 +38,13 @@
|
||||
},
|
||||
"license": "Apache-2.0",
|
||||
"devDependencies": {
|
||||
"@0xproject/abi-gen": "^0.3.3",
|
||||
"@0xproject/dev-utils": "^0.4.5",
|
||||
"@0xproject/tslint-config": "^0.4.21",
|
||||
"@0xproject/types": "^0.8.2",
|
||||
"@0xproject/abi-gen": "^1.0.0",
|
||||
"@0xproject/monorepo-scripts": "^1.0.0",
|
||||
"@0xproject/dev-utils": "^1.0.0",
|
||||
"@0xproject/tslint-config": "^1.0.0",
|
||||
"@0xproject/types": "^1.0.0-rc.1",
|
||||
"@types/yargs": "^10.0.0",
|
||||
"copyfiles": "^1.2.0",
|
||||
"yargs": "^10.0.3",
|
||||
"make-promises-safe": "^1.1.0",
|
||||
"npm-run-all": "^4.1.2",
|
||||
@@ -50,15 +53,15 @@
|
||||
"typescript": "2.7.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0xproject/base-contract": "^0.3.5",
|
||||
"@0xproject/order-utils": "^1.0.0",
|
||||
"@0xproject/sol-compiler": "^0.5.3",
|
||||
"@0xproject/subproviders": "^0.10.5",
|
||||
"@0xproject/typescript-typings": "^0.4.2",
|
||||
"@0xproject/utils": "^0.7.2",
|
||||
"@0xproject/web3-wrapper": "^0.7.2",
|
||||
"@0xproject/base-contract": "^1.0.0",
|
||||
"@0xproject/order-utils": "^1.0.0-rc.1",
|
||||
"@0xproject/sol-compiler": "^1.0.0",
|
||||
"@0xproject/subproviders": "^1.0.0",
|
||||
"@0xproject/typescript-typings": "^1.0.0",
|
||||
"@0xproject/utils": "^1.0.0",
|
||||
"@0xproject/web3-wrapper": "^1.0.0",
|
||||
"@ledgerhq/hw-app-eth": "^4.3.0",
|
||||
"ethereum-types": "^0.0.2",
|
||||
"ethereum-types": "^1.0.0",
|
||||
"ethers": "3.0.22",
|
||||
"lodash": "^4.17.4"
|
||||
},
|
||||
|
8
packages/migrations/src/2.0.0/migration.ts
vendored
8
packages/migrations/src/2.0.0/migration.ts
vendored
@@ -1,4 +1,4 @@
|
||||
import { assetProxyUtils } from '@0xproject/order-utils';
|
||||
import { assetDataUtils } from '@0xproject/order-utils';
|
||||
import { BigNumber } from '@0xproject/utils';
|
||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||
import { Provider, TxData } from 'ethereum-types';
|
||||
@@ -53,7 +53,7 @@ export const runV2MigrationsAsync = async (provider: Provider, artifactsDir: str
|
||||
artifacts.Exchange,
|
||||
provider,
|
||||
txDefaults,
|
||||
assetProxyUtils.encodeERC20AssetData(zrxToken.address),
|
||||
assetDataUtils.encodeERC20AssetData(zrxToken.address),
|
||||
);
|
||||
artifactsWriter.saveArtifact(exchange);
|
||||
|
||||
@@ -137,8 +137,8 @@ export const runV2MigrationsAsync = async (provider: Provider, artifactsDir: str
|
||||
exchange.address,
|
||||
etherToken.address,
|
||||
zrxToken.address,
|
||||
assetProxyUtils.encodeERC20AssetData(zrxToken.address),
|
||||
assetProxyUtils.encodeERC20AssetData(etherToken.address),
|
||||
assetDataUtils.encodeERC20AssetData(zrxToken.address),
|
||||
assetDataUtils.encodeERC20AssetData(etherToken.address),
|
||||
);
|
||||
artifactsWriter.saveArtifact(forwarder);
|
||||
};
|
||||
|
8
packages/migrations/src/monorepo_scripts/postpublish.ts
Normal file
8
packages/migrations/src/monorepo_scripts/postpublish.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { postpublishUtils } from '@0xproject/monorepo-scripts';
|
||||
|
||||
import * as packageJSON from '../package.json';
|
||||
import * as tsConfigJSON from '../tsconfig.json';
|
||||
|
||||
const cwd = `${__dirname}/..`;
|
||||
// tslint:disable-next-line:no-floating-promises
|
||||
postpublishUtils.runAsync(packageJSON, tsConfigJSON, cwd);
|
@@ -9,7 +9,7 @@ export const constants = {
|
||||
ASSET_PROXY_OWNER_TIMELOCK: new BigNumber(0),
|
||||
ASSET_PROXY_OWNER_CONFIRMATIONS: new BigNumber(1),
|
||||
ERC20_PROXY_ID: '0xf47261b0',
|
||||
ERC721_PROXY_ID: '0x08e937fa',
|
||||
ERC721_PROXY_ID: '0x02571792',
|
||||
NULL_ADDRESS: '0x0000000000000000000000000000000000000000',
|
||||
RPC_URL: 'http://localhost:8545',
|
||||
KOVAN_NETWORK_ID: 42,
|
||||
|
@@ -1,10 +1,23 @@
|
||||
[
|
||||
{
|
||||
"version": "0.2.3",
|
||||
"timestamp": 1532357734,
|
||||
"version": "1.0.1",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1532043000,
|
||||
"version": "1.0.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Fix git remote tag removal step & add an additional sanity assertion",
|
||||
"pr": 803
|
||||
},
|
||||
{
|
||||
"note": "Make PR numbers links on Github releases"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@@ -1,10 +1,19 @@
|
||||
<!--
|
||||
This file is auto-generated using the monorepo-scripts package. Don't edit directly.
|
||||
changelogUtils.file is auto-generated using the monorepo-scripts package. Don't edit directly.
|
||||
Edit the package's CHANGELOG.json file only.
|
||||
-->
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v1.0.1 - _July 23, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.0.0 - _July 20, 2018_
|
||||
|
||||
* Fix git remote tag removal step & add an additional sanity assertion (#803)
|
||||
* Make PR numbers links on Github releases
|
||||
|
||||
## v0.2.2 - _July 9, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0xproject/monorepo-scripts",
|
||||
"version": "0.2.2",
|
||||
"version": "1.0.0",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
@@ -33,12 +33,11 @@
|
||||
"@types/node": "^8.0.53",
|
||||
"@types/opn": "^5.1.0",
|
||||
"@types/rimraf": "^2.0.2",
|
||||
"@types/semver": "5.5.0",
|
||||
"depcheck": "^0.6.9",
|
||||
"lerna-get-packages": "^1.0.0",
|
||||
"make-promises-safe": "^1.1.0",
|
||||
"npm-run-all": "^4.1.2",
|
||||
"shx": "^0.2.2",
|
||||
"@types/semver": "5.5.0",
|
||||
"tslint": "5.11.0",
|
||||
"typescript": "2.7.1"
|
||||
},
|
||||
@@ -56,8 +55,8 @@
|
||||
"prompt": "^1.0.0",
|
||||
"publish-release": "0xproject/publish-release",
|
||||
"rimraf": "^2.6.2",
|
||||
"semver-diff": "^2.1.0",
|
||||
"semver": "5.5.0",
|
||||
"semver-diff": "^2.1.0",
|
||||
"semver-sort": "0.0.4"
|
||||
},
|
||||
"publishConfig": {
|
||||
|
@@ -3,6 +3,6 @@ import * as path from 'path';
|
||||
export const constants = {
|
||||
monorepoRootPath: path.join(__dirname, '../../..'),
|
||||
stagingWebsite: 'http://staging-0xproject.s3-website-us-east-1.amazonaws.com',
|
||||
lernaExecutable: path.join('node_modules', 'lerna', 'bin', 'lerna.js'),
|
||||
lernaExecutable: path.join('node_modules', 'lerna', 'cli.js'),
|
||||
githubPersonalAccessToken: process.env.GITHUB_PERSONAL_ACCESS_TOKEN_0X_JS,
|
||||
};
|
||||
|
@@ -1,7 +1,6 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import * as depcheckAsync from 'depcheck';
|
||||
import lernaGetPackages = require('lerna-get-packages');
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { constants } from './constants';
|
||||
@@ -13,15 +12,15 @@ const IGNORE_PACKAGES = ['@0xproject/sol-compiler'];
|
||||
(async () => {
|
||||
utils.log('*** NOTE: Not all deps listed here are actually not required. ***');
|
||||
utils.log("*** `depcheck` isn't perfect so double check before actually removing any. ***\n");
|
||||
const lernaPackages = lernaGetPackages(constants.monorepoRootPath);
|
||||
for (const lernaPackage of lernaPackages) {
|
||||
if (_.includes(IGNORE_PACKAGES, lernaPackage.package.name)) {
|
||||
const packages = utils.getPackages(constants.monorepoRootPath);
|
||||
for (const pkg of packages) {
|
||||
if (_.includes(IGNORE_PACKAGES, pkg.packageJson.name)) {
|
||||
continue; // skip
|
||||
}
|
||||
utils.log(`Checking ${lernaPackage.package.name} for unused deps. This might take a while...`);
|
||||
utils.log(`Checking ${pkg.packageJson.name} for unused deps. This might take a while...`);
|
||||
|
||||
const configs = {};
|
||||
const { dependencies } = await depcheckAsync(lernaPackage.location, configs);
|
||||
const { dependencies } = await depcheckAsync(pkg.location, configs);
|
||||
if (!_.isEmpty(dependencies)) {
|
||||
_.each(dependencies, dep => {
|
||||
utils.log(dep);
|
||||
|
19
packages/monorepo-scripts/src/globals.d.ts
vendored
19
packages/monorepo-scripts/src/globals.d.ts
vendored
@@ -13,23 +13,4 @@ declare module 'semver-sort' {
|
||||
const desc: (versions: string[]) => string[];
|
||||
}
|
||||
|
||||
declare interface LernaPackage {
|
||||
location: string;
|
||||
package: {
|
||||
private?: boolean;
|
||||
version: string;
|
||||
name: string;
|
||||
main?: string;
|
||||
scripts?: { [command: string]: string };
|
||||
config?: {
|
||||
additionalTsTypings?: string[];
|
||||
};
|
||||
};
|
||||
}
|
||||
declare function lernaGetPackages(path: string): LernaPackage[];
|
||||
// lerna-get-packages declarations
|
||||
declare module 'lerna-get-packages' {
|
||||
export = lernaGetPackages;
|
||||
}
|
||||
|
||||
declare module 'promisify-child-process';
|
||||
|
@@ -128,7 +128,7 @@ export const postpublishUtils = {
|
||||
_.each(latestLog.changes, change => {
|
||||
notes += `* ${change.note}`;
|
||||
if (change.pr) {
|
||||
notes += ` (${change.pr})`;
|
||||
notes += ` (#${change.pr})`;
|
||||
}
|
||||
notes += `\n`;
|
||||
});
|
||||
|
@@ -4,34 +4,33 @@ import semver = require('semver');
|
||||
import semverSort = require('semver-sort');
|
||||
|
||||
import { constants } from './constants';
|
||||
import { Package } from './types';
|
||||
import { changelogUtils } from './utils/changelog_utils';
|
||||
import { npmUtils } from './utils/npm_utils';
|
||||
import { utils } from './utils/utils';
|
||||
|
||||
async function prepublishChecksAsync(): Promise<void> {
|
||||
const shouldIncludePrivate = false;
|
||||
const updatedPublicLernaPackages = await utils.getUpdatedLernaPackagesAsync(shouldIncludePrivate);
|
||||
const updatedPublicPackages = await utils.getUpdatedPackagesAsync(shouldIncludePrivate);
|
||||
|
||||
await checkCurrentVersionMatchesLatestPublishedNPMPackageAsync(updatedPublicLernaPackages);
|
||||
await checkChangelogFormatAsync(updatedPublicLernaPackages);
|
||||
await checkGitTagsForNextVersionAndDeleteIfExistAsync(updatedPublicLernaPackages);
|
||||
await checkCurrentVersionMatchesLatestPublishedNPMPackageAsync(updatedPublicPackages);
|
||||
await checkChangelogFormatAsync(updatedPublicPackages);
|
||||
await checkGitTagsForNextVersionAndDeleteIfExistAsync(updatedPublicPackages);
|
||||
await checkPublishRequiredSetupAsync();
|
||||
}
|
||||
|
||||
async function checkGitTagsForNextVersionAndDeleteIfExistAsync(
|
||||
updatedPublicLernaPackages: LernaPackage[],
|
||||
): Promise<void> {
|
||||
const packageNames = _.map(updatedPublicLernaPackages, lernaPackage => lernaPackage.package.name);
|
||||
async function checkGitTagsForNextVersionAndDeleteIfExistAsync(updatedPublicPackages: Package[]): Promise<void> {
|
||||
const packageNames = _.map(updatedPublicPackages, pkg => pkg.packageJson.name);
|
||||
const localGitTags = await utils.getLocalGitTagsAsync();
|
||||
const localTagVersionsByPackageName = await utils.getGitTagsByPackageNameAsync(packageNames, localGitTags);
|
||||
|
||||
const remoteGitTags = await utils.getRemoteGitTagsAsync();
|
||||
const remoteTagVersionsByPackageName = await utils.getGitTagsByPackageNameAsync(packageNames, remoteGitTags);
|
||||
|
||||
for (const lernaPackage of updatedPublicLernaPackages) {
|
||||
const currentVersion = lernaPackage.package.version;
|
||||
const packageName = lernaPackage.package.name;
|
||||
const packageLocation = lernaPackage.location;
|
||||
for (const pkg of updatedPublicPackages) {
|
||||
const currentVersion = pkg.packageJson.version;
|
||||
const packageName = pkg.packageJson.name;
|
||||
const packageLocation = pkg.location;
|
||||
const nextVersion = await utils.getNextPackageVersionAsync(currentVersion, packageName, packageLocation);
|
||||
|
||||
const remoteTagVersions = remoteTagVersionsByPackageName[packageName];
|
||||
@@ -49,13 +48,13 @@ async function checkGitTagsForNextVersionAndDeleteIfExistAsync(
|
||||
}
|
||||
|
||||
async function checkCurrentVersionMatchesLatestPublishedNPMPackageAsync(
|
||||
updatedPublicLernaPackages: LernaPackage[],
|
||||
updatedPublicPackages: Package[],
|
||||
): Promise<void> {
|
||||
utils.log('Check package versions against npmjs.org...');
|
||||
const versionMismatches = [];
|
||||
for (const lernaPackage of updatedPublicLernaPackages) {
|
||||
const packageName = lernaPackage.package.name;
|
||||
const packageVersion = lernaPackage.package.version;
|
||||
for (const pkg of updatedPublicPackages) {
|
||||
const packageName = pkg.packageJson.name;
|
||||
const packageVersion = pkg.packageJson.version;
|
||||
const packageRegistryJsonIfExists = await npmUtils.getPackageRegistryJsonIfExistsAsync(packageName);
|
||||
if (_.isUndefined(packageRegistryJsonIfExists)) {
|
||||
continue; // noop for packages not yet published to NPM
|
||||
@@ -84,14 +83,14 @@ async function checkCurrentVersionMatchesLatestPublishedNPMPackageAsync(
|
||||
}
|
||||
}
|
||||
|
||||
async function checkChangelogFormatAsync(updatedPublicLernaPackages: LernaPackage[]): Promise<void> {
|
||||
async function checkChangelogFormatAsync(updatedPublicPackages: Package[]): Promise<void> {
|
||||
utils.log('Check CHANGELOGs for inconsistencies...');
|
||||
const changeLogInconsistencies = [];
|
||||
for (const lernaPackage of updatedPublicLernaPackages) {
|
||||
const packageName = lernaPackage.package.name;
|
||||
const changelog = changelogUtils.getChangelogOrCreateIfMissing(packageName, lernaPackage.location);
|
||||
for (const pkg of updatedPublicPackages) {
|
||||
const packageName = pkg.packageJson.name;
|
||||
const changelog = changelogUtils.getChangelogOrCreateIfMissing(packageName, pkg.location);
|
||||
|
||||
const currentVersion = lernaPackage.package.version;
|
||||
const currentVersion = pkg.packageJson.version;
|
||||
if (!_.isEmpty(changelog)) {
|
||||
const lastEntry = changelog[0];
|
||||
const doesLastEntryHaveTimestamp = !_.isUndefined(lastEntry.timestamp);
|
||||
@@ -105,7 +104,7 @@ async function checkChangelogFormatAsync(updatedPublicLernaPackages: LernaPackag
|
||||
// Remove incorrectly added timestamp
|
||||
delete changelog[0].timestamp;
|
||||
// Save updated CHANGELOG.json
|
||||
await changelogUtils.writeChangelogJsonFileAsync(lernaPackage.location, changelog);
|
||||
await changelogUtils.writeChangelogJsonFileAsync(pkg.location, changelog);
|
||||
utils.log(`${packageName}: Removed timestamp from latest CHANGELOG.json entry.`);
|
||||
}
|
||||
}
|
||||
|
@@ -11,7 +11,7 @@ import semverDiff = require('semver-diff');
|
||||
import semverSort = require('semver-sort');
|
||||
|
||||
import { constants } from './constants';
|
||||
import { PackageToVersionChange, SemVerIndex, VersionChangelog } from './types';
|
||||
import { Package, PackageToVersionChange, SemVerIndex, VersionChangelog } from './types';
|
||||
import { changelogUtils } from './utils/changelog_utils';
|
||||
import { utils } from './utils/utils';
|
||||
|
||||
@@ -34,19 +34,20 @@ const packageNameToWebsitePath: { [name: string]: string } = {
|
||||
'sol-cov': 'sol-cov',
|
||||
subproviders: 'subproviders',
|
||||
'order-utils': 'order-utils',
|
||||
'ethereum-types': 'ethereum-types',
|
||||
};
|
||||
|
||||
(async () => {
|
||||
// Fetch public, updated Lerna packages
|
||||
const shouldIncludePrivate = false;
|
||||
const updatedPublicLernaPackages = await utils.getUpdatedLernaPackagesAsync(shouldIncludePrivate);
|
||||
const updatedPublicPackages = await utils.getUpdatedPackagesAsync(shouldIncludePrivate);
|
||||
|
||||
await confirmDocPagesRenderAsync(updatedPublicLernaPackages);
|
||||
await confirmDocPagesRenderAsync(updatedPublicPackages);
|
||||
|
||||
// Update CHANGELOGs
|
||||
const updatedPublicLernaPackageNames = _.map(updatedPublicLernaPackages, pkg => pkg.package.name);
|
||||
utils.log(`Will update CHANGELOGs and publish: \n${updatedPublicLernaPackageNames.join('\n')}\n`);
|
||||
const packageToVersionChange = await updateChangeLogsAsync(updatedPublicLernaPackages);
|
||||
const updatedPublicPackageNames = _.map(updatedPublicPackages, pkg => pkg.packageJson.name);
|
||||
utils.log(`Will update CHANGELOGs and publish: \n${updatedPublicPackageNames.join('\n')}\n`);
|
||||
const packageToVersionChange = await updateChangeLogsAsync(updatedPublicPackages);
|
||||
|
||||
// Push changelog changes to Github
|
||||
if (!IS_DRY_RUN) {
|
||||
@@ -65,7 +66,7 @@ const packageNameToWebsitePath: { [name: string]: string } = {
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
async function confirmDocPagesRenderAsync(packages: LernaPackage[]): Promise<void> {
|
||||
async function confirmDocPagesRenderAsync(packages: Package[]): Promise<void> {
|
||||
// push docs to staging
|
||||
utils.log("Upload all docJson's to S3 staging...");
|
||||
await execAsync(`yarn stage_docs`, { cwd: constants.monorepoRootPath });
|
||||
@@ -76,14 +77,14 @@ async function confirmDocPagesRenderAsync(packages: LernaPackage[]): Promise<voi
|
||||
await execAsync(`yarn deploy_staging`, { cwd: pathToWebsite });
|
||||
|
||||
const packagesWithDocs = _.filter(packages, pkg => {
|
||||
const scriptsIfExists = pkg.package.scripts;
|
||||
const scriptsIfExists = pkg.packageJson.scripts;
|
||||
if (_.isUndefined(scriptsIfExists)) {
|
||||
throw new Error('Found a public package without any scripts in package.json');
|
||||
}
|
||||
return !_.isUndefined(scriptsIfExists[DOC_GEN_COMMAND]);
|
||||
});
|
||||
_.each(packagesWithDocs, pkg => {
|
||||
const name = pkg.package.name;
|
||||
const name = pkg.packageJson.name;
|
||||
const nameWithoutPrefix = _.startsWith(name, NPM_NAMESPACE) ? name.split('@0xproject/')[1] : name;
|
||||
const docSegmentIfExists = packageNameToWebsitePath[nameWithoutPrefix];
|
||||
if (_.isUndefined(docSegmentIfExists)) {
|
||||
@@ -114,15 +115,15 @@ async function pushChangelogsToGithubAsync(): Promise<void> {
|
||||
utils.log(`Pushed CHANGELOG updates to Github`);
|
||||
}
|
||||
|
||||
async function updateChangeLogsAsync(updatedPublicLernaPackages: LernaPackage[]): Promise<PackageToVersionChange> {
|
||||
async function updateChangeLogsAsync(updatedPublicPackages: Package[]): Promise<PackageToVersionChange> {
|
||||
const packageToVersionChange: PackageToVersionChange = {};
|
||||
for (const lernaPackage of updatedPublicLernaPackages) {
|
||||
const packageName = lernaPackage.package.name;
|
||||
let changelog = changelogUtils.getChangelogOrCreateIfMissing(packageName, lernaPackage.location);
|
||||
for (const pkg of updatedPublicPackages) {
|
||||
const packageName = pkg.packageJson.name;
|
||||
let changelog = changelogUtils.getChangelogOrCreateIfMissing(packageName, pkg.location);
|
||||
|
||||
const currentVersion = lernaPackage.package.version;
|
||||
const currentVersion = pkg.packageJson.version;
|
||||
const shouldAddNewEntry = changelogUtils.shouldAddNewChangelogEntry(
|
||||
lernaPackage.package.name,
|
||||
pkg.packageJson.name,
|
||||
currentVersion,
|
||||
changelog,
|
||||
);
|
||||
@@ -157,11 +158,11 @@ async function updateChangeLogsAsync(updatedPublicLernaPackages: LernaPackage[])
|
||||
}
|
||||
|
||||
// Save updated CHANGELOG.json
|
||||
await changelogUtils.writeChangelogJsonFileAsync(lernaPackage.location, changelog);
|
||||
await changelogUtils.writeChangelogJsonFileAsync(pkg.location, changelog);
|
||||
utils.log(`${packageName}: Updated CHANGELOG.json`);
|
||||
// Generate updated CHANGELOG.md
|
||||
const changelogMd = changelogUtils.generateChangelogMd(changelog);
|
||||
await changelogUtils.writeChangelogMdFileAsync(lernaPackage.location, changelogMd);
|
||||
await changelogUtils.writeChangelogMdFileAsync(pkg.location, changelogMd);
|
||||
utils.log(`${packageName}: Updated CHANGELOG.md`);
|
||||
}
|
||||
|
||||
|
@@ -1,7 +1,6 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import * as fs from 'fs';
|
||||
import lernaGetPackages = require('lerna-get-packages');
|
||||
import * as _ from 'lodash';
|
||||
import * as path from 'path';
|
||||
import { exec as execAsync } from 'promisify-child-process';
|
||||
@@ -11,17 +10,14 @@ import { utils } from './utils/utils';
|
||||
|
||||
(async () => {
|
||||
const monorepoRootPath = path.join(__dirname, '../../..');
|
||||
const lernaPackages = lernaGetPackages(monorepoRootPath);
|
||||
const packages = utils.getPackages(monorepoRootPath);
|
||||
const installablePackages = _.filter(
|
||||
lernaPackages,
|
||||
lernaPackage =>
|
||||
!lernaPackage.package.private &&
|
||||
!_.isUndefined(lernaPackage.package.main) &&
|
||||
lernaPackage.package.main.endsWith('.js'),
|
||||
packages,
|
||||
pkg => !pkg.packageJson.private && !_.isUndefined(pkg.packageJson.main) && pkg.packageJson.main.endsWith('.js'),
|
||||
);
|
||||
for (const installableLernaPackage of installablePackages) {
|
||||
const packagePath = installableLernaPackage.location;
|
||||
const packageName = installableLernaPackage.package.name;
|
||||
for (const installablePackage of installablePackages) {
|
||||
const packagePath = installablePackage.location;
|
||||
const packageName = installablePackage.packageJson.name;
|
||||
utils.log(`Testing ${packageName}`);
|
||||
let result = await execAsync('npm pack', { cwd: packagePath });
|
||||
const packedPackageFileName = result.stdout.trim();
|
||||
|
@@ -40,3 +40,17 @@ export interface PackageRegistryJson {
|
||||
export interface GitTagsByPackageName {
|
||||
[packageName: string]: string[];
|
||||
}
|
||||
|
||||
export interface Package {
|
||||
location: string;
|
||||
packageJson: {
|
||||
private?: boolean;
|
||||
version: string;
|
||||
name: string;
|
||||
main?: string;
|
||||
scripts?: { [command: string]: string };
|
||||
config?: {
|
||||
additionalTsTypings?: string[];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
@@ -1,10 +1,10 @@
|
||||
import lernaGetPackages = require('lerna-get-packages');
|
||||
import * as fs from 'fs';
|
||||
import * as _ from 'lodash';
|
||||
import { exec as execAsync } from 'promisify-child-process';
|
||||
import semver = require('semver');
|
||||
|
||||
import { constants } from '../constants';
|
||||
import { GitTagsByPackageName, UpdatedPackage } from '../types';
|
||||
import { GitTagsByPackageName, Package, UpdatedPackage } from '../types';
|
||||
|
||||
import { changelogUtils } from './changelog_utils';
|
||||
|
||||
@@ -12,15 +12,47 @@ export const utils = {
|
||||
log(...args: any[]): void {
|
||||
console.log(...args); // tslint:disable-line:no-console
|
||||
},
|
||||
async getUpdatedLernaPackagesAsync(shouldIncludePrivate: boolean): Promise<LernaPackage[]> {
|
||||
getPackages(rootDir: string): Package[] {
|
||||
const rootPackageJsonString = fs.readFileSync(`${rootDir}/package.json`, 'utf8');
|
||||
const rootPackageJson = JSON.parse(rootPackageJsonString);
|
||||
if (_.isUndefined(rootPackageJson.workspaces)) {
|
||||
throw new Error(`Did not find 'workspaces' key in root package.json`);
|
||||
}
|
||||
const packages = [];
|
||||
for (const workspace of rootPackageJson.workspaces) {
|
||||
// HACK: Remove allowed wildcards from workspace entries.
|
||||
// This might be entirely comprehensive.
|
||||
const workspacePath = workspace.replace('*', '').replace('**/*', '');
|
||||
const subpackageNames = fs.readdirSync(`${rootDir}/${workspacePath}`);
|
||||
for (const subpackageName of subpackageNames) {
|
||||
if (_.startsWith(subpackageName, '.')) {
|
||||
continue;
|
||||
}
|
||||
const pathToPackageJson = `${rootDir}/${workspacePath}${subpackageName}`;
|
||||
try {
|
||||
const packageJsonString = fs.readFileSync(`${pathToPackageJson}/package.json`, 'utf8');
|
||||
const packageJson = JSON.parse(packageJsonString);
|
||||
const pkg = {
|
||||
location: pathToPackageJson,
|
||||
packageJson,
|
||||
};
|
||||
packages.push(pkg);
|
||||
} catch (err) {
|
||||
utils.log(`Couldn't find a 'package.json' for ${subpackageName}. Skipping.`);
|
||||
}
|
||||
}
|
||||
}
|
||||
return packages;
|
||||
},
|
||||
async getUpdatedPackagesAsync(shouldIncludePrivate: boolean): Promise<Package[]> {
|
||||
const updatedPublicPackages = await utils.getLernaUpdatedPackagesAsync(shouldIncludePrivate);
|
||||
const updatedPackageNames = _.map(updatedPublicPackages, pkg => pkg.name);
|
||||
|
||||
const allLernaPackages = lernaGetPackages(constants.monorepoRootPath);
|
||||
const updatedPublicLernaPackages = _.filter(allLernaPackages, pkg => {
|
||||
return _.includes(updatedPackageNames, pkg.package.name);
|
||||
const allPackages = utils.getPackages(constants.monorepoRootPath);
|
||||
const updatedPackages = _.filter(allPackages, pkg => {
|
||||
return _.includes(updatedPackageNames, pkg.packageJson.name);
|
||||
});
|
||||
return updatedPublicLernaPackages;
|
||||
return updatedPackages;
|
||||
},
|
||||
async getLernaUpdatedPackagesAsync(shouldIncludePrivate: boolean): Promise<UpdatedPackage[]> {
|
||||
const result = await execAsync(`${constants.lernaExecutable} updated --json`, {
|
||||
|
@@ -1,6 +1,17 @@
|
||||
[
|
||||
{
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.0-rc.2",
|
||||
"changes": [
|
||||
{
|
||||
"note":
|
||||
"Upgrade ethereumjs-abi dep including a fix so that addresses starting with 0 are properly decoded by `decodeERC20AssetData`"
|
||||
}
|
||||
],
|
||||
"timestamp": 1532357734
|
||||
},
|
||||
{
|
||||
"timestamp": 1532043000,
|
||||
"version": "1.0.0-rc.1",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Refactor to work with V2 of 0x protocol",
|
||||
@@ -9,6 +20,19 @@
|
||||
{
|
||||
"note": "Export parseECSignature method",
|
||||
"pr": 684
|
||||
},
|
||||
{
|
||||
"note": "Handle Typed Arrays when hashing data",
|
||||
"pr": 894
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1531919263,
|
||||
"version": "0.0.9",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@@ -1,10 +1,24 @@
|
||||
<!--
|
||||
This file is auto-generated using the monorepo-scripts package. Don't edit directly.
|
||||
changelogUtils.file is auto-generated using the monorepo-scripts package. Don't edit directly.
|
||||
Edit the package's CHANGELOG.json file only.
|
||||
-->
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v1.0.0-rc.2 - _July 23, 2018_
|
||||
|
||||
* Upgrade ethereumjs-abi dep including a fix so that addresses starting with 0 are properly decoded by `decodeERC20AssetData`
|
||||
|
||||
## v1.0.0-rc.1 - _July 20, 2018_
|
||||
|
||||
* Refactor to work with V2 of 0x protocol (#636)
|
||||
* Export parseECSignature method (#684)
|
||||
* Handle Typed Arrays when hashing data (#894)
|
||||
|
||||
## v0.0.9 - _July 18, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.0.8 - _July 9, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user