Compare commits

..

128 Commits

Author SHA1 Message Date
Leonid Logvinov
0369f5ebc4 @0xproject/abi-gen@1.0.0 2018-07-19 22:46:33 +02:00
Leonid Logvinov
1e6b11b27e Change all package to depend on the new @0xproject/assert@1.0.0 2018-07-19 22:45:22 +02:00
Leonid Logvinov
7a8231435b Add forgotten file to git 2018-07-19 22:43:56 +02:00
Leonid Logvinov
b1aa7725df @0xproject/assert@1.0.0 2018-07-19 22:41:35 +02:00
Leonid Logvinov
bfe0ba3e9a Change all package to depend on the new @0xproject/sol-resolver@1.0.0 2018-07-19 22:39:42 +02:00
Leonid Logvinov
2d39329ee7 Add monorepo-scripts to sol-resolver 2018-07-19 22:38:19 +02:00
Leonid Logvinov
761b0063a0 @0xproject/sol-resolver@1.0.0 2018-07-19 22:33:24 +02:00
Leonid Logvinov
0f27ce3424 Change all package to depend on the new @0xproject/json-schemas@1.0.0-rc.1 2018-07-19 22:30:09 +02:00
Leonid Logvinov
2b0c0a6ff7 @0xproject/json-schemas@1.0.0-rc.1 2018-07-19 22:26:35 +02:00
Leonid Logvinov
5bd96f6fe9 Change the next @0xproject/json-schemas version to be 1.0.0-rc.1 2018-07-19 22:26:13 +02:00
Leonid Logvinov
37ac6749ba Change all package to depend on the new @0xproject/utils@1.0.0 2018-07-19 22:22:51 +02:00
Leonid Logvinov
bf955bd87f @0xproject/utils@1.0.0 2018-07-19 22:20:35 +02:00
Leonid Logvinov
6bd921d0bc Add a missing CHANGELOG entry 2018-07-19 22:20:08 +02:00
Leonid Logvinov
534decea95 Change all package to depend on the new @0xproject/types@1.0.0-rc.1 2018-07-19 22:17:55 +02:00
Leonid Logvinov
267830d463 FIx a typo 2018-07-19 22:15:31 +02:00
Leonid Logvinov
e82d0c21ec @0xproject/types@1.0.0-rc.1 2018-07-19 22:06:05 +02:00
Leonid Logvinov
ece6417699 Change the next @0xproject/types version to be 1.0.0-rc.1 2018-07-19 22:05:22 +02:00
Leonid Logvinov
74d5449719 Change all package to depend on the new @0xproject/tslint-config@1.0.0 2018-07-19 22:03:23 +02:00
Leonid Logvinov
4af7ff9cc3 @0xproject/tslint-config@1.0.0 2018-07-19 22:01:18 +02:00
Leonid Logvinov
46dedfcb67 Change the next @0xproject/tslint-config version to be 1.0.0 2018-07-19 22:00:58 +02:00
Leonid Logvinov
a9fa1a0df6 Change all package to depend on the new @0xproject/typescript-typings@1.0.0 2018-07-19 21:54:44 +02:00
Leonid Logvinov
a8572b4944 @0xproject/typescript-typings@1.0.0 2018-07-19 21:51:38 +02:00
Leonid Logvinov
91c0d47ad4 Change the next @0xproject/typescript-typings version to be 1.0.0 2018-07-19 21:51:12 +02:00
Leonid Logvinov
fd2611794a Change all package to depend on the new @0xproject/monorepo-scripts@1.0.0 2018-07-19 21:49:03 +02:00
Leonid Logvinov
1fe1c5321b @0xproject/monorepo-scripts@1.0.0 2018-07-19 21:45:38 +02:00
Leonid Logvinov
f063a5db0f Change all package to depend on the new ethereum-types@1.0.0 2018-07-19 21:44:09 +02:00
Leonid Logvinov
3883315447 Make PR numbers links on Github releases 2018-07-19 21:40:50 +02:00
Leonid Logvinov
7679e07957 v1.0.0 2018-07-19 21:28:51 +02:00
Leonid Logvinov
c39ba37ad8 Change the next ethereum-types version to be 1.0.0 2018-07-19 21:28:06 +02:00
Fabio Berger
f1c3840c3b Merge pull request #897 from 0xProject/doc-changes
Doc Changes for RC publish
2018-07-19 21:10:06 +02:00
Fabio Berger
e5c5b36a73 Specify exact version 2018-07-19 21:05:37 +02:00
Fabio Berger
c51f7a8375 Add PR nr. 2018-07-19 20:51:33 +02:00
Fabio Berger
e53e2ac31b Fix version dropdown so it also renders RC versions properly 2018-07-19 20:45:20 +02:00
Fabio Berger
b72857cd8b Update doc md files for v2 packages 2018-07-19 20:45:00 +02:00
Fabio Berger
cc223b9eab Compare host rather then origin so that it comes without the http/https prefix 2018-07-19 19:01:25 +02:00
Fabio Berger
f2c49e8b37 Merge branch 'v2-prototype' into doc-changes
* v2-prototype:
  Add missing import
  Remove comment and add assertion
  Add ability to nest doc ref markdown under specific versions
2018-07-19 18:15:35 +02:00
Fabio Berger
9b6476a6b7 Merge pull request #844 from 0xProject/support-multiple-doc-md
Support version-specific doc ref markdown sections
2018-07-19 18:14:58 +02:00
Fabio Berger
d8898cf9a3 merge v2-prototype 2018-07-19 17:48:06 +02:00
Fabio Berger
34df5af295 Don't export object literal because the docs cannot yet render them, moved type to types file 2018-07-19 17:46:24 +02:00
Fabio Berger
3de88d5345 Merge pull request #896 from 0xProject/update-lerna
Update Lerna & other small changes
2018-07-19 17:37:04 +02:00
Fabio Berger
9ab6ab1bf9 Improve log 2018-07-19 17:22:26 +02:00
Fabio Berger
b6de0bdd43 Merge branch 'v2-prototype' into update-lerna
* v2-prototype: (48 commits)
  Update CHANGELOG
  Rename call data schema id to CallData. Check for TypedArray when hashing data in order-utils crypto
  Fix broken links in sol-cov documentation
  Fix 0x.js ts warnings
  Update yarn.lock
  Fix 0x.js ts warnings
  Fix 0x.js tests on CI
  Fix a bad merge
  Update package versions
  Merge
  Update changelogs
  Add a test for ERC721 Allowance
  Use allowance instead of approval for all in fill-scenarios
  Upgrade sha3 to 1.2.2 to work with node v10
  Check if the token doesn't exist before minting in fill scenarios
  Make downlevelIteration a global config
  Fix tests descriptions
  DRY up the code in order-watcher collision-resistant abi decoder
  Await transactions in fillScenarios
  Rename decodeAssetData to decodeAssetDataOrThrow
  ...
2018-07-19 16:38:33 +02:00
Fabio Berger
a2b62fd808 Update yarn.lock 2018-07-19 16:38:02 +02:00
Fabio Berger
f9c4d0925e Add additional pattern removal and added HACK comment 2018-07-19 16:32:03 +02:00
Fabio Berger
1df9370bc2 Renames to remove mention of Lerna 2018-07-19 16:26:45 +02:00
Fabio Berger
7d840c7a18 Remove unused declaration 2018-07-19 16:26:00 +02:00
Fabio Berger
74c0fd419b Upgrade Lerna to 3.0-Beta14 2018-07-19 15:51:38 +02:00
Fabio Berger
6f540e3e58 Replace lerna-get-packages with our own implementation 2018-07-19 15:50:21 +02:00
Jacob Evans
886a03fdcd Merge pull request #894 from 0xProject/bug/minor-fixes-json-schema-order-utils
Rename json schema call data id to CallData.
2018-07-19 20:06:37 +10:00
Jacob Evans
81007c453c Update CHANGELOG 2018-07-19 19:51:07 +10:00
Jacob Evans
6529e06057 Rename call data schema id to CallData.
Check for TypedArray when hashing data in order-utils crypto
2018-07-19 17:51:03 +10:00
Brandon Millman
55336f96d7 Fix broken links in sol-cov documentation 2018-07-18 15:53:33 -07:00
Fabio Berger
3a18c249f5 Merge pull request #889 from 0xProject/update_versions
Update Versions & Changelogs
2018-07-18 17:20:38 +02:00
Fabio Berger
7c0775aa1b Fix 0x.js ts warnings 2018-07-18 17:06:05 +02:00
Fabio Berger
ba92754669 Update yarn.lock 2018-07-18 17:00:14 +02:00
Fabio Berger
30afd39129 Fix 0x.js ts warnings 2018-07-18 17:00:07 +02:00
Leonid Logvinov
41699406cf Fix 0x.js tests on CI 2018-07-18 16:44:45 +02:00
Fabio Berger
29d5034260 merge v2-prototype 2018-07-18 16:43:25 +02:00
Leonid Logvinov
00d1622b3f Merge pull request #887 from 0xProject/feature/order-watcher-v2
Order watcher v2
2018-07-18 16:38:16 +02:00
Leonid Logvinov
a1acf19ff3 Fix a bad merge 2018-07-18 16:31:17 +02:00
Fabio Berger
c839965c05 Update to Lerna v3.0-beta 2018-07-18 16:06:39 +02:00
Fabio Berger
f99232095b Update package versions 2018-07-18 15:48:09 +02:00
Leonid Logvinov
5044fe4fe4 Merge branch 'v2-prototype' into feature/order-watcher-v2 2018-07-18 15:40:45 +02:00
Leonid Logvinov
8e49169e6b Merge branch 'feature/order-watcher-v2' of github.com:0xProject/0x-monorepo into feature/order-watcher-v2 2018-07-18 15:39:11 +02:00
Leonid Logvinov
c71781d9ab Merge 2018-07-18 15:38:10 +02:00
Fabio Berger
8a2a4052f3 Update changelogs 2018-07-18 15:30:38 +02:00
Leonid Logvinov
dad557164e Merge branch 'v2-prototype' into feature/order-watcher-v2 2018-07-18 15:27:38 +02:00
Fabio Berger
e2fb49a8f8 Merge pull request #884 from 0xProject/export-more-0x.js
Export missing V2 pieces from 0x.js
2018-07-18 15:18:54 +02:00
Fabio Berger
b9e7973a0f edit changelog message 2018-07-18 14:53:38 +02:00
Fabio Berger
004b1f5288 Fix prettier 2018-07-18 14:53:31 +02:00
Leonid Logvinov
857bd24c6d Merge branch 'v2-prototype' into feature/order-watcher-v2 2018-07-18 14:51:24 +02:00
Fabio Berger
83747934ad Fix linter 2018-07-18 12:11:11 +02:00
Fabio Berger
7f90f5ecd4 merge v2-prototype 2018-07-18 12:04:57 +02:00
Fabio Berger
12f02b9814 Rename decodeAssetDataId to decodeAssetProxyId for consistency 2018-07-18 11:49:30 +02:00
Fabio Berger
8931388309 Add java doc comments to assetDataUtils 2018-07-18 11:47:42 +02:00
Fabio Berger
25160d7344 Move encodeUint256 & decodeUint256 out of assetDataUtils since we don't want them exported 2018-07-18 11:32:01 +02:00
Leonid Logvinov
ab6bf6edc7 Merge pull request #879 from 0xProject/feature/order-watcher-erc721-tests
Add ERC721 tests for order watcher v2
2018-07-18 10:38:07 +02:00
Leonid Logvinov
f20b496dca Add a test for ERC721 Allowance 2018-07-17 18:46:58 +02:00
Leonid Logvinov
cca17f70b8 Use allowance instead of approval for all in fill-scenarios 2018-07-17 18:45:35 +02:00
Leonid Logvinov
b8e69718a1 Upgrade sha3 to 1.2.2 to work with node v10 2018-07-17 16:54:25 +02:00
Fabio Berger
50ed7d2af2 Export missing types and add to doc ref whitelist 2018-07-17 16:41:55 +02:00
Fabio Berger
698de932ed Remove unused dep 2018-07-17 16:27:59 +02:00
Fabio Berger
a3d8858bb1 Fix typing 2018-07-17 16:27:46 +02:00
Fabio Berger
83f3ba21b8 Move type decl. to typescript-typings 2018-07-17 16:01:01 +02:00
Leonid Logvinov
2aa729b212 Check if the token doesn't exist before minting in fill scenarios 2018-07-17 15:56:10 +02:00
Fabio Berger
1de70e4474 Add PR 2018-07-17 15:40:06 +02:00
Fabio Berger
f2393de59b Make assetData a static property and add to CHANGELOG 2018-07-17 15:33:49 +02:00
Fabio Berger
94ea7cc451 Export assetDataUtils from 0x.js 2018-07-17 15:31:25 +02:00
Fabio Berger
f8dbf57582 Rename assetProxyUtils to assetDataUtils 2018-07-17 15:26:55 +02:00
Leonid Logvinov
c59cd36da6 Make downlevelIteration a global config 2018-07-17 15:25:20 +02:00
Leonid Logvinov
96c648c4b4 Fix tests descriptions 2018-07-17 13:29:59 +02:00
Leonid Logvinov
01e617bb83 DRY up the code in order-watcher collision-resistant abi decoder 2018-07-17 13:28:27 +02:00
Leonid Logvinov
28a9a8c380 Await transactions in fillScenarios 2018-07-17 13:26:49 +02:00
Leonid Logvinov
6c2796b433 Rename decodeAssetData to decodeAssetDataOrThrow 2018-07-17 13:16:47 +02:00
Leonid Logvinov
82ad5f7897 Use normalizedAddress 2018-07-17 13:13:05 +02:00
Leonid Logvinov
c3bd3437f5 Make addOrder async 2018-07-16 15:50:06 +02:00
Leonid Logvinov
90d72a3683 Await the promise in order watcher assertion 2018-07-16 14:54:36 +02:00
Leonid Logvinov
f9bcf936ed Merge branch 'feature/order-watcher-v2' into feature/order-watcher-erc721-tests 2018-07-16 14:38:51 +02:00
Leonid Logvinov
acff177c54 Merge branch 'v2-prototype' into feature/order-watcher-v2 2018-07-16 14:38:27 +02:00
Leonid Logvinov
658214a2e2 Yarn lock changes 2018-07-16 14:31:46 +02:00
Leonid Logvinov
55f6f02c9b Import AssetproxyId 2018-07-16 14:31:33 +02:00
Leonid Logvinov
c5ba52910a Add ERC721 tests to order watcher 2018-07-16 14:30:48 +02:00
Leonid Logvinov
994ccd6694 Enable downlevelIteration 2018-07-16 14:29:59 +02:00
Leonid Logvinov
4921a83813 Register asset types within collisionResistantAbiDecoder 2018-07-16 14:29:23 +02:00
Leonid Logvinov
a97ba41b86 Add ERC721 support to fill-scenarios 2018-07-16 14:28:44 +02:00
Leonid Logvinov
67e2623d2c Remove no-unused-variable rule from tslint as it's buggy and has side-effects 2018-07-16 14:28:22 +02:00
Leonid Logvinov
4111095da3 Don't throw on transferFrom is the sender is an owner 2018-07-16 14:27:53 +02:00
Leonid Logvinov
6c21ddcedb Pass erc721ProxyAddress to fillScenarios 2018-07-16 14:27:34 +02:00
Leonid Logvinov
d86349658f Fix postinstall hook for contracts -> types 2018-07-16 14:26:23 +02:00
Leonid Logvinov
ffeb3194a8 Fix a dependency version 2018-07-13 17:46:53 +02:00
Leonid Logvinov
95e9f33f6a Migrate order-watcher to v2 2018-07-13 17:45:25 +02:00
Leonid Logvinov
c599a20b34 Enable prefer-readonly rule 2018-07-13 17:44:39 +02:00
Leonid Logvinov
ca59528a32 Add OrderWatcherPartialConfigSchema 2018-07-13 17:44:00 +02:00
Leonid Logvinov
6f4fd06d38 Use migrated package versions as order-watcher dependencies 2018-07-13 17:43:32 +02:00
Leonid Logvinov
4715c2d006 Update compact_artifacts in order-watcher 2018-07-13 17:42:50 +02:00
Leonid Logvinov
fcfa43b6f1 Export newly created store from order-utils 2018-07-13 17:42:27 +02:00
Leonid Logvinov
56b4c55654 Add OrderFilledCancelledLazyStore 2018-07-13 17:41:30 +02:00
Leonid Logvinov
830790eeac Add AbstractOrderFilledCancelledLazyStore 2018-07-13 17:39:41 +02:00
Leonid Logvinov
39de9c7879 Export forgotten stuff from contract-wrappers 2018-07-13 17:38:02 +02:00
Leonid Logvinov
7b6cc14b71 Make getZRXAssetData not async 2018-07-13 17:37:33 +02:00
Leonid Logvinov
ec749a4033 Add order-watcher to a postinstall HACK 2018-07-13 17:36:20 +02:00
Leonid Logvinov
fe32214613 Add no-return-await, no-duplicate-switch-case, no-implicit-dependencies rules 2018-07-13 17:30:44 +02:00
Leonid Logvinov
f6fcb775b7 Upgrade tslint to use prefer-readonly 2018-07-13 17:30:44 +02:00
Leonid Logvinov
d209108a95 Update contract artifacts 2018-07-13 17:30:00 +02:00
Fabio Berger
1aaf633df8 Add missing import 2018-07-09 19:59:26 +02:00
Fabio Berger
82771ec64a Remove comment and add assertion 2018-07-09 19:53:54 +02:00
Fabio Berger
ada8a402da merge v2-prototype 2018-07-09 19:46:28 +02:00
Fabio Berger
324b1079e7 Add ability to nest doc ref markdown under specific versions 2018-07-09 19:05:38 +02:00
207 changed files with 3773 additions and 4231 deletions

View File

@@ -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

View File

@@ -1,5 +1,5 @@
{
"lerna": "2.5.1",
"lerna": "3.0.0-beta.14",
"packages": ["packages/*"],
"commands": {
"publish": {

View File

@@ -31,7 +31,7 @@
"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"
"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 -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; rm -rf `pwd`/packages/order-watcher/node_modules/@0xproject; mkdir `pwd`/packages/order-watcher/node_modules/@0xproject; ln -s `pwd`/packages/assert `pwd`/packages/order-watcher/node_modules/@0xproject/assert; ln -s `pwd`/packages/json-schemas `pwd`/packages/order-watcher/node_modules/@0xproject/json-schemas; ln -s `pwd`/packages/order-utils `pwd`/packages/order-watcher/node_modules/@0xproject/order-utils; ln -s `pwd`/packages/types `pwd`/packages/order-watcher/node_modules/@0xproject/types; ln -s `pwd`/packages/contract-wrappers `pwd`/packages/order-watcher/node_modules/@0xproject/contract-wrappers; rm -rf `pwd`/packages/contracts/node_modules/@0xproject; mkdir `pwd`/packages/contracts/node_modules/@0xproject; ln -s `pwd`/packages/order-utils `pwd`/packages/contracts/node_modules/@0xproject/order-utils; ln -s `pwd`/packages/types `pwd`/packages/contracts/node_modules/@0xproject/types; rm -rf `pwd`/packages/migrations/node_modules/@0xproject; mkdir `pwd`/packages/migrations/node_modules/@0xproject; ln -s `pwd`/packages/order-utils `pwd`/packages/migrations/node_modules/@0xproject/order-utils"
},
"config": {
"mnemonic": "concert load couple harbor equip island argue ramp clarify fence smart topic"
@@ -41,7 +41,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",

View File

@@ -36,6 +36,19 @@
{
"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"
}
]
},

View File

@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v0.38.6 - _July 18, 2018_
* Dependencies updated
## v0.38.5 - _July 9, 2018_
* Dependencies updated

View File

@@ -1,6 +1,6 @@
{
"name": "0x.js",
"version": "0.38.5",
"version": "0.38.6",
"engines": {
"node": ">=6.12"
},
@@ -70,11 +70,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": "^0.3.4",
"@0xproject/dev-utils": "^0.4.6",
"@0xproject/migrations": "^0.0.10",
"@0xproject/monorepo-script": "^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 +100,17 @@
"webpack": "^3.1.0"
},
"dependencies": {
"@0xproject/assert": "^0.2.13",
"@0xproject/base-contract": "^0.3.5",
"@0xproject/contract-wrappers": "^0.1.0",
"@0xproject/assert": "^1.0.0",
"@0xproject/base-contract": "^0.3.6",
"@0xproject/contract-wrappers": "^0.1.1",
"@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/sol-compiler": "^0.5.4",
"@0xproject/subproviders": "^0.10.6",
"@0xproject/types": "^1.0.0-rc.1",
"@0xproject/typescript-typings": "^1.0.0",
"@0xproject/utils": "^1.0.0",
"@0xproject/web3-wrapper": "^0.7.3",
"ethereum-types": "^1.0.0",
"ethers": "3.0.22",
"lodash": "^4.17.4"
},

View File

@@ -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';
@@ -34,6 +38,10 @@ export class ZeroEx {
* this constant for your convenience.
*/
public static NULL_ADDRESS = constants.NULL_ADDRESS;
/**
* A set of methods to easily decode/encode assetData fields found in 0x orders.
*/
public static assetData = assetDataUtils;
/**
* An instance of the ExchangeWrapper class containing methods for interacting with the 0x Exchange smart contract.
*/

View File

@@ -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';

View File

@@ -1,6 +1,6 @@
[
{
"version": "0.4.0",
"version": "1.0.0",
"changes": [
{
"note": "Convert e_r_c to erc in generated file names",
@@ -16,6 +16,15 @@
}
]
},
{
"timestamp": 1531919263,
"version": "0.3.4",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1531149657,
"version": "0.3.3",

View File

@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v0.3.4 - _July 18, 2018_
* Dependencies updated
## v0.3.3 - _July 9, 2018_
* Dependencies updated

View File

@@ -1,6 +1,6 @@
{
"name": "@0xproject/abi-gen",
"version": "0.3.3",
"version": "1.0.0",
"engines": {
"node": ">=6.12"
},
@@ -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-script": "^1.0.0",
"@0xproject/tslint-config": "^1.0.0",
"@types/glob": "5.0.35",
"@types/handlebars": "^4.0.36",
"@types/mkdirp": "^0.5.1",

View File

@@ -1,6 +1,6 @@
[
{
"version": "0.2.14",
"version": "1.0.0",
"changes": [
{
"note":
@@ -9,6 +9,15 @@
}
]
},
{
"timestamp": 1531919263,
"version": "0.2.14",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1531149657,
"version": "0.2.13",

View File

@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v0.2.14 - _July 18, 2018_
* Dependencies updated
## v0.2.13 - _July 9, 2018_
* Dependencies updated

View File

@@ -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-script": "^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"
},

View File

@@ -1,4 +1,13 @@
[
{
"timestamp": 1531919263,
"version": "0.3.6",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1531149657,
"version": "0.3.5",

View File

@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v0.3.6 - _July 18, 2018_
* Dependencies updated
## v0.3.5 - _July 9, 2018_
* Dependencies updated

View File

@@ -1,6 +1,6 @@
{
"name": "@0xproject/base-contract",
"version": "0.3.5",
"version": "0.3.6",
"engines": {
"node": ">=6.12"
},
@@ -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-script": "^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": "^0.7.3",
"ethers": "3.0.22",
"lodash": "^4.17.4"
},

View File

@@ -8,6 +8,15 @@
}
]
},
{
"timestamp": 1531919263,
"version": "0.6.17",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1531149657,
"version": "0.6.16",

View File

@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v0.6.17 - _July 18, 2018_
* Dependencies updated
## v0.6.16 - _July 9, 2018_
* Dependencies updated

View File

@@ -1,6 +1,6 @@
{
"name": "@0xproject/connect",
"version": "0.6.16",
"version": "0.6.17",
"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/types": "^0.8.2",
"@0xproject/typescript-typings": "^0.4.2",
"@0xproject/utils": "^0.7.2",
"@0xproject/assert": "^1.0.0",
"@0xproject/json-schemas": "^1.0.0-rc.1",
"@0xproject/types": "^1.0.0-rc.1",
"@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-script": "^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",

View File

@@ -12,6 +12,15 @@
],
"timestamp": 1531149657
},
{
"timestamp": 1531919263,
"version": "0.1.1",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1529397769,
"version": "0.0.5",

View File

@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v0.1.1 - _July 18, 2018_
* Dependencies updated
## v0.1.0 - _July 9, 2018_
* Update Blockstream dep. to V5.0 and no longer force unsubscribe on blockstream error (which are not recoverable)

View File

@@ -1,6 +1,6 @@
{
"name": "@0xproject/contract-wrappers",
"version": "0.1.0",
"version": "0.1.1",
"description": "Smart TS wrappers for 0x smart contracts",
"keywords": [
"0xproject",
@@ -43,13 +43,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": "^0.3.4",
"@0xproject/dev-utils": "^0.4.6",
"@0xproject/migrations": "^0.0.10",
"@0xproject/monorepo-script": "^1.0.0",
"@0xproject/sol-compiler": "^0.5.4",
"@0xproject/subproviders": "^0.10.6",
"@0xproject/tslint-config": "^1.0.0",
"@types/lodash": "4.14.104",
"@types/mocha": "^2.2.42",
"@types/node": "^8.0.53",
@@ -69,20 +69,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/assert": "^1.0.0",
"@0xproject/base-contract": "^0.3.6",
"@0xproject/order-utils": "^1.0.0",
"@0xproject/typescript-typings": "^0.4.2",
"@0xproject/utils": "^0.7.2",
"@0xproject/web3-wrapper": "^0.7.2",
"@0xproject/typescript-typings": "^1.0.0",
"@0xproject/utils": "^1.0.0",
"@0xproject/web3-wrapper": "^0.7.3",
"@0xproject/fill-scenarios": "^1.0.0",
"@0xproject/json-schemas": "^1.0.0",
"@0xproject/types": "^1.0.0",
"ethereum-types": "^0.0.2",
"@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",

View File

@@ -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(

View File

@@ -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

View File

@@ -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 {

View File

@@ -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);
});

View File

@@ -25,6 +25,7 @@
"DummyERC721Token",
"ERC20Proxy",
"ERC20Token",
"ERC721Token",
"ERC721Proxy",
"Exchange",
"ExchangeWrapper",

View File

@@ -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": "^0.3.4",
"@0xproject/dev-utils": "^0.4.6",
"@0xproject/tslint-config": "^1.0.0",
"@0xproject/subproviders": "^0.10.6",
"@0xproject/sol-cov": "^0.1.3",
"@types/lodash": "4.14.104",
"@types/bn.js": "^4.11.0",
"@types/node": "^8.0.53",
@@ -72,14 +72,14 @@
"yargs": "^10.0.3"
},
"dependencies": {
"@0xproject/base-contract": "^0.3.5",
"@0xproject/base-contract": "^0.3.6",
"@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/sol-compiler": "^0.5.4",
"@0xproject/types": "^1.0.0-rc.1",
"@0xproject/typescript-typings": "^1.0.0",
"@0xproject/utils": "^1.0.0",
"@0xproject/web3-wrapper": "^0.7.3",
"ethereum-types": "^1.0.0",
"bn.js": "^4.11.8",
"ethereumjs-abi": "^0.6.4",
"ethereumjs-util": "^5.1.1",

View File

@@ -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 { RevertReason } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
import * as chai from 'chai';
@@ -23,6 +23,7 @@ import { constants } from '../utils/constants';
import { ERC20Wrapper } from '../utils/erc20_wrapper';
import { ERC721Wrapper } from '../utils/erc721_wrapper';
import { LogDecoder } from '../utils/log_decoder';
import { typeEncodingUtils } from '../utils/type_encoding_utils';
import { provider, txDefaults, web3Wrapper } from '../utils/web3_wrapper';
chaiSetup.configure();
@@ -107,7 +108,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 +138,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 +168,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 +197,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 +228,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);
@@ -254,7 +255,7 @@ describe('Asset Transfer Proxies', () => {
it('should call onERC721Received when transferring to a smart contract without receiver data', 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);
@@ -288,8 +289,8 @@ describe('Asset Transfer Proxies', () => {
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(
const receiverData = ethUtil.bufferToHex(typeEncodingUtils.encodeUint256(generatePseudoRandomSalt()));
const encodedAssetData = assetDataUtils.encodeERC721AssetData(
erc721Token.address,
erc721MakerTokenId,
receiverData,
@@ -327,8 +328,8 @@ describe('Asset Transfer Proxies', () => {
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(
const receiverData = ethUtil.bufferToHex(typeEncodingUtils.encodeUint256(generatePseudoRandomSalt()));
const encodedAssetData = assetDataUtils.encodeERC721AssetData(
erc721Token.address,
erc721MakerTokenId,
receiverData,
@@ -357,7 +358,7 @@ describe('Asset Transfer Proxies', () => {
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 +382,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 +406,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 +434,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(

View File

@@ -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);
@@ -461,14 +461,12 @@ describe('Exchange core', () => {
// Construct Exchange parameters
const makerAssetId = erc721MakerAssetIds[0];
const takerAssetId = erc721TakerAssetIds[0];
const makerAssetData = assetProxyUtils
.encodeERC721AssetData(erc721Token.address, makerAssetId)
.slice(0, -2);
const makerAssetData = assetDataUtils.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),
takerAssetData: assetDataUtils.encodeERC721AssetData(erc721Token.address, takerAssetId),
});
// Verify pre-conditions
const initialOwnerMakerAsset = await erc721Token.ownerOf.callAsync(makerAssetId);

View File

@@ -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(

View File

@@ -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);

View File

@@ -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,

View File

@@ -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)];

View File

@@ -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);
});

View File

@@ -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),
}),
];

View File

@@ -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];

View File

@@ -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);
});

View File

@@ -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,

View File

@@ -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,
};

View File

@@ -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) {

View File

@@ -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)) {

View File

@@ -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);

View File

@@ -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;

View File

@@ -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],
);

View 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;
},
};

View File

@@ -1,4 +1,13 @@
[
{
"timestamp": 1531919263,
"version": "0.4.6",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1531149657,
"version": "0.4.5",

View File

@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v0.4.6 - _July 18, 2018_
* Dependencies updated
## v0.4.5 - _July 9, 2018_
* Dependencies updated

View File

@@ -1,6 +1,6 @@
{
"name": "@0xproject/dev-utils",
"version": "0.4.5",
"version": "0.4.6",
"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-script": "^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": "^0.10.6",
"@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": "^0.7.3",
"lodash": "^4.17.4"
},
"publishConfig": {

View File

@@ -1,6 +1,6 @@
[
{
"version": "0.0.3",
"version": "1.0.0",
"changes": [
{
"note": "Add `TraceParams` interface for `debug_traceTransaction` parameters",

View File

@@ -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-script": "^1.0.0",
"@0xproject/tslint-config": "^1.0.0",
"copyfiles": "^1.2.0",
"make-promises-safe": "^1.1.0",
"shx": "^0.2.2",

View File

@@ -8,6 +8,15 @@
}
]
},
{
"timestamp": 1531919263,
"version": "0.0.6",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1531149657,
"version": "0.0.5",

View File

@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v0.0.6 - _July 18, 2018_
* Dependencies updated
## v0.0.5 - _July 9, 2018_
* Dependencies updated

View File

@@ -9,14 +9,14 @@
"build": "yarn pre_build && tsc",
"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": "^0.3.4",
"@0xproject/monorepo-script": "^1.0.0",
"@0xproject/sol-compiler": "^0.5.4",
"@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/base-contract": "^0.3.6",
"@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/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": "^0.7.3",
"ethers": "3.0.22",
"lodash": "^4.17.4"
},

View File

@@ -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,
};

View File

@@ -1,3 +1,4 @@
export const constants = {
AWAIT_TRANSACTION_MINED_MS: 0,
NULL_ADDRESS: '0x0000000000000000000000000000000000000000',
};

View 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);
}
}

View File

@@ -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';

View File

@@ -1,14 +1,27 @@
[
{
"version": "1.0.0",
"version": "1.0.0-rc.1",
"changes": [
{
"note": "Update schemas for V2",
"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"
}
]
},

View File

@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v0.8.3 - _July 18, 2018_
* Dependencies updated
## v0.8.2 - _July 9, 2018_
* Dependencies updated

View File

@@ -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-script": "^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",

View File

@@ -1,5 +1,5 @@
export const callDataSchema = {
id: '/TxData',
id: '/CallData',
properties: {
from: { $ref: '/Address' },
to: { $ref: '/Address' },

View File

@@ -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": "^0.3.4",
"@0xproject/base-contract": "^0.3.6",
"@0xproject/sol-compiler": "^0.5.4",
"@0xproject/sol-cov": "^0.1.3",
"@0xproject/subproviders": "^0.10.6",
"@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": "^0.7.3",
"@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": "^0.4.6",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
"chai-bignumber": "^2.0.1",

View File

@@ -1,4 +1,13 @@
[
{
"timestamp": 1531919263,
"version": "0.0.10",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"timestamp": 1531149657,
"version": "0.0.9",

View File

@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v0.0.10 - _July 18, 2018_
* Dependencies updated
## v0.0.9 - _July 9, 2018_
* Dependencies updated

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

File diff suppressed because one or more lines are too long

View File

@@ -1,6 +1,6 @@
{
"name": "@0xproject/migrations",
"version": "0.0.9",
"version": "0.0.10",
"engines": {
"node": ">=6.12"
},
@@ -37,10 +37,10 @@
},
"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": "^0.3.4",
"@0xproject/dev-utils": "^0.4.6",
"@0xproject/tslint-config": "^1.0.0",
"@0xproject/types": "^1.0.0-rc.1",
"@types/yargs": "^10.0.0",
"yargs": "^10.0.3",
"make-promises-safe": "^1.1.0",
@@ -50,15 +50,15 @@
"typescript": "2.7.1"
},
"dependencies": {
"@0xproject/base-contract": "^0.3.5",
"@0xproject/base-contract": "^0.3.6",
"@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/sol-compiler": "^0.5.4",
"@0xproject/subproviders": "^0.10.6",
"@0xproject/typescript-typings": "^1.0.0",
"@0xproject/utils": "^1.0.0",
"@0xproject/web3-wrapper": "^0.7.3",
"@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"
},

View File

@@ -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);
};

View File

@@ -1,10 +1,13 @@
[
{
"version": "0.2.3",
"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"
}
]
},

View File

@@ -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": {

View File

@@ -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,
};

View File

@@ -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);

View File

@@ -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';

View File

@@ -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`;
});

View File

@@ -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.`);
}
}

View File

@@ -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`);
}

View File

@@ -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();

View File

@@ -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[];
};
};
}

View File

@@ -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`, {

View File

@@ -9,6 +9,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"
}
]
},

View File

@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v0.0.9 - _July 18, 2018_
* Dependencies updated
## v0.0.8 - _July 9, 2018_
* Dependencies updated

View File

@@ -51,10 +51,9 @@
},
"homepage": "https://github.com/0xProject/0x-monorepo/packages/order-utils/README.md",
"devDependencies": {
"@0xproject/dev-utils": "^0.4.5",
"@0xproject/monorepo-scripts": "^0.2.2",
"@0xproject/tslint-config": "^0.4.21",
"@types/ethereumjs-abi": "^0.6.0",
"@0xproject/dev-utils": "^0.4.6",
"@0xproject/monorepo-script": "^1.0.0",
"@0xproject/tslint-config": "^1.0.0",
"@types/bn.js": "^4.11.0",
"@types/lodash": "4.14.104",
"chai": "^4.0.1",
@@ -72,17 +71,17 @@
"typescript": "2.7.1"
},
"dependencies": {
"@0xproject/assert": "^0.3.0",
"@0xproject/base-contract": "^0.3.5",
"@0xproject/json-schemas": "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",
"@0xproject/assert": "^1.0.0",
"@0xproject/base-contract": "^0.3.6",
"@0xproject/json-schemas": "^1.0.0-rc.1",
"@0xproject/sol-compiler": "^0.5.4",
"@0xproject/types": "^1.0.0-rc.1",
"@0xproject/typescript-typings": "^1.0.0",
"@0xproject/utils": "^1.0.0",
"@0xproject/web3-wrapper": "^0.7.3",
"@types/node": "^8.0.53",
"bn.js": "^4.11.8",
"ethereum-types": "^0.0.2",
"ethereum-types": "^1.0.0",
"ethereumjs-abi": "^0.6.4",
"ethereumjs-util": "^5.1.1",
"ethers": "3.0.22",

View File

@@ -0,0 +1,12 @@
import { BigNumber } from '@0xproject/utils';
export abstract class AbstractOrderFilledCancelledLazyStore {
public abstract async getFilledTakerAmountAsync(orderHash: string): Promise<BigNumber>;
public abstract async getIsCancelledAsync(orderHash: string): Promise<boolean>;
public abstract setFilledTakerAmount(orderHash: string, balance: BigNumber): void;
public abstract deleteFilledTakerAmount(orderHash: string): void;
public abstract setIsCancelled(orderHash: string, isCancelled: boolean): void;
public abstract deleteIsCancelled(orderHash: string): void;
public abstract deleteAll(): void;
public abstract getZRXAssetData(): string;
}

View File

@@ -1,64 +1,25 @@
import { AssetProxyId, ERC20AssetData, ERC721AssetData } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
import BN = require('bn.js');
import ethAbi = require('ethereumjs-abi');
import ethUtil = require('ethereumjs-util');
import { constants } from './constants';
// TODO: Push upstream to DefinitelyTyped
interface EthAbi {
simpleEncode(signature: string, ...args: any[]): Buffer;
rawDecode(signature: string[], data: Buffer): any[];
}
// tslint:disable:no-var-requires
const ethAbi = require('ethereumjs-abi') as EthAbi;
export const assetProxyUtils = {
encodeAssetProxyId(assetProxyId: AssetProxyId): Buffer {
return ethUtil.toBuffer(assetProxyId);
},
decodeAssetProxyId(encodedAssetProxyId: Buffer): AssetProxyId {
const hexString = ethUtil.bufferToHex(encodedAssetProxyId);
if (hexString === AssetProxyId.ERC20) {
return AssetProxyId.ERC20;
}
if (hexString === AssetProxyId.ERC721) {
return AssetProxyId.ERC721;
}
throw new Error(`Invalid ProxyId: ${hexString}`);
},
encodeAddress(address: string): Buffer {
if (!ethUtil.isValidAddress(address)) {
throw new Error(`Invalid Address: ${address}`);
}
const encodedAddress = ethUtil.toBuffer(address);
const padded = ethUtil.setLengthLeft(encodedAddress, constants.WORD_LENGTH);
return padded;
},
decodeAddress(encodedAddress: Buffer): string {
const unpadded = ethUtil.setLengthLeft(encodedAddress, constants.ADDRESS_LENGTH);
const address = ethUtil.bufferToHex(unpadded);
if (!ethUtil.isValidAddress(address)) {
throw new Error(`Invalid Address: ${address}`);
}
return address;
},
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;
},
export const assetDataUtils = {
/**
* 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
*/
encodeERC20AssetData(tokenAddress: string): string {
return ethUtil.bufferToHex(ethAbi.simpleEncode('ERC20Token(address)', 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
*/
decodeERC20AssetData(assetData: string): ERC20AssetData {
const data = ethUtil.toBuffer(assetData);
if (data.byteLength < constants.ERC20_ASSET_DATA_BYTE_LENGTH) {
@@ -82,6 +43,13 @@ export const assetProxyUtils = {
tokenAddress: ethUtil.addHexPrefix(tokenAddress),
};
},
/**
* 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
*/
encodeERC721AssetData(tokenAddress: string, tokenId: BigNumber, receiverData?: string): string {
// TODO: Pass `tokendId` as a BigNumber.
return ethUtil.bufferToHex(
@@ -93,6 +61,11 @@ export const assetProxyUtils = {
),
);
},
/**
* 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
*/
decodeERC721AssetData(assetData: string): ERC721AssetData {
const data = ethUtil.toBuffer(assetData);
if (data.byteLength < constants.ERC721_ASSET_DATA_MINIMUM_BYTE_LENGTH) {
@@ -121,30 +94,51 @@ export const assetProxyUtils = {
receiverData: ethUtil.bufferToHex(receiverData),
};
},
decodeAssetDataId(assetData: string): AssetProxyId {
/**
* Decode and return the assetProxyId from the assetData
* @param assetData Hex encoded assetData string to decode
* @return The assetProxyId
*/
decodeAssetProxyId(assetData: string): AssetProxyId {
const encodedAssetData = ethUtil.toBuffer(assetData);
if (encodedAssetData.byteLength < constants.SELECTOR_LENGTH) {
throw new Error(
`Could not decode Proxy Data. Expected length of encoded data to be at least 4. Got ${
`Could not decode assetData. Expected length of encoded data to be at least 4. Got ${
encodedAssetData.byteLength
}`,
);
}
const encodedAssetProxyId = encodedAssetData.slice(0, constants.SELECTOR_LENGTH);
const assetProxyId = assetProxyUtils.decodeAssetProxyId(encodedAssetProxyId);
const assetProxyId = decodeAssetProxyId(encodedAssetProxyId);
return assetProxyId;
},
decodeAssetData(assetData: string): ERC20AssetData | ERC721AssetData {
const assetProxyId = assetProxyUtils.decodeAssetDataId(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
*/
decodeAssetDataOrThrow(assetData: string): ERC20AssetData | ERC721AssetData {
const assetProxyId = assetDataUtils.decodeAssetProxyId(assetData);
switch (assetProxyId) {
case AssetProxyId.ERC20:
const erc20AssetData = assetProxyUtils.decodeERC20AssetData(assetData);
const erc20AssetData = assetDataUtils.decodeERC20AssetData(assetData);
return erc20AssetData;
case AssetProxyId.ERC721:
const erc721AssetData = assetProxyUtils.decodeERC721AssetData(assetData);
const erc721AssetData = assetDataUtils.decodeERC721AssetData(assetData);
return erc721AssetData;
default:
throw new Error(`Unrecognized asset proxy id: ${assetProxyId}`);
}
},
};
function decodeAssetProxyId(encodedAssetProxyId: Buffer): AssetProxyId {
const hexString = ethUtil.bufferToHex(encodedAssetProxyId);
if (hexString === AssetProxyId.ERC20) {
return AssetProxyId.ERC20;
}
if (hexString === AssetProxyId.ERC721) {
return AssetProxyId.ERC721;
}
throw new Error(`Invalid ProxyId: ${hexString}`);
}

View File

@@ -6,7 +6,6 @@ export const constants = {
UNLIMITED_ALLOWANCE_IN_BASE_UNITS: new BigNumber(2).pow(256).minus(1),
TESTRPC_NETWORK_ID: 50,
ADDRESS_LENGTH: 20,
WORD_LENGTH: 32,
ERC20_ASSET_DATA_BYTE_LENGTH: 36,
ERC721_ASSET_DATA_MINIMUM_BYTE_LENGTH: 53,
SELECTOR_LENGTH: 4,

View File

@@ -32,7 +32,7 @@ export const crypto = {
argTypes.push('address');
} else if (_.isString(arg)) {
argTypes.push('string');
} else if (_.isBuffer(arg)) {
} else if (_.isBuffer(arg) || _.isTypedArray(arg)) {
argTypes.push('bytes');
} else if (_.isBoolean(arg)) {
argTypes.push('bool');

View File

@@ -17,9 +17,10 @@ export { OrderError, MessagePrefixType, MessagePrefixOpts, EIP712Parameter, EIP7
export { AbstractBalanceAndProxyAllowanceFetcher } from './abstract/abstract_balance_and_proxy_allowance_fetcher';
export { AbstractOrderFilledCancelledFetcher } from './abstract/abstract_order_filled_cancelled_fetcher';
export { BalanceAndProxyAllowanceLazyStore } from './store/balance_and_proxy_allowance_lazy_store';
export { OrderFilledCancelledLazyStore } from './store/order_filled_cancelled_lazy_store';
export { RemainingFillableCalculator } from './remaining_fillable_calculator';
export { OrderStateUtils } from './order_state_utils';
export { assetProxyUtils } from './asset_proxy_utils';
export { assetDataUtils } from './asset_data_utils';
export { EIP712Utils } from './eip712_utils';
export { OrderValidationUtils } from './order_validation_utils';
export { ExchangeTransferSimulator } from './exchange_transfer_simulator';

View File

@@ -1,8 +1,10 @@
import { AssetProxyId } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
import * as _ from 'lodash';
import { AbstractBalanceAndProxyAllowanceFetcher } from '../abstract/abstract_balance_and_proxy_allowance_fetcher';
import { AbstractBalanceAndProxyAllowanceLazyStore } from '../abstract/abstract_balance_and_proxy_allowance_lazy_store';
import { assetDataUtils } from '../asset_data_utils';
/**
* Copy on read store for balances/proxyAllowances of tokens/accounts
@@ -74,6 +76,20 @@ export class BalanceAndProxyAllowanceLazyStore implements AbstractBalanceAndProx
}
}
}
public deleteAllERC721ProxyAllowance(tokenAddress: string, userAddress: string): void {
for (const assetData in this._proxyAllowance) {
if (this._proxyAllowance.hasOwnProperty(assetData)) {
const decodedAssetData = assetDataUtils.decodeAssetDataOrThrow(assetData);
if (
decodedAssetData.assetProxyId === AssetProxyId.ERC721 &&
decodedAssetData.tokenAddress === tokenAddress &&
!_.isUndefined(this._proxyAllowance[assetData][userAddress])
) {
delete this._proxyAllowance[assetData][userAddress];
}
}
}
}
public deleteAll(): void {
this._balance = {};
this._proxyAllowance = {};

View File

@@ -0,0 +1,65 @@
import { BigNumber } from '@0xproject/utils';
import * as _ from 'lodash';
import { AbstractOrderFilledCancelledFetcher } from '../abstract/abstract_order_filled_cancelled_fetcher';
import { AbstractOrderFilledCancelledLazyStore } from '../abstract/abstract_order_filled_cancelled_lazy_store';
/**
* Copy on read store for balances/proxyAllowances of tokens/accounts
*/
export class OrderFilledCancelledLazyStore implements AbstractOrderFilledCancelledLazyStore {
private readonly _orderFilledCancelledFetcher: AbstractOrderFilledCancelledFetcher;
private _filledTakerAmount: {
[orderHash: string]: BigNumber;
};
private _isCancelled: {
[orderHash: string]: boolean;
};
constructor(orderFilledCancelledFetcher: AbstractOrderFilledCancelledFetcher) {
this._orderFilledCancelledFetcher = orderFilledCancelledFetcher;
this._filledTakerAmount = {};
this._isCancelled = {};
}
public async getFilledTakerAmountAsync(orderHash: string): Promise<BigNumber> {
if (_.isUndefined(this._filledTakerAmount[orderHash])) {
const filledTakerAmount = await this._orderFilledCancelledFetcher.getFilledTakerAmountAsync(orderHash);
this.setFilledTakerAmount(orderHash, filledTakerAmount);
}
const cachedFilledTakerAmount = this._filledTakerAmount[orderHash];
return cachedFilledTakerAmount;
}
public setFilledTakerAmount(orderHash: string, filledTakerAmount: BigNumber): void {
this._filledTakerAmount[orderHash] = filledTakerAmount;
}
public deleteFilledTakerAmount(orderHash: string): void {
delete this._filledTakerAmount[orderHash];
}
public async getIsCancelledAsync(orderHash: string): Promise<boolean> {
if (_.isUndefined(this._isCancelled[orderHash])) {
const isCancelled = await this._orderFilledCancelledFetcher.isOrderCancelledAsync(orderHash);
this.setIsCancelled(orderHash, isCancelled);
}
const cachedIsCancelled = this._isCancelled[orderHash]; // tslint:disable-line:boolean-naming
return cachedIsCancelled;
}
public setIsCancelled(orderHash: string, isCancelled: boolean): void {
this._isCancelled[orderHash] = isCancelled;
}
public deleteIsCancelled(orderHash: string): void {
delete this._isCancelled[orderHash];
}
public deleteAll(): void {
this.deleteAllFilled();
this.deleteAllIsCancelled();
}
public deleteAllIsCancelled(): void {
this._isCancelled = {};
}
public deleteAllFilled(): void {
this._filledTakerAmount = {};
}
public getZRXAssetData(): string {
const zrxAssetData = this._orderFilledCancelledFetcher.getZRXAssetData();
return zrxAssetData;
}
}

View File

@@ -4,7 +4,7 @@ import { BigNumber } from '@0xproject/utils';
import * as chai from 'chai';
import { artifacts } from '../src/artifacts';
import { assetProxyUtils } from '../src/asset_proxy_utils';
import { assetDataUtils } from '../src/asset_data_utils';
import { constants } from '../src/constants';
import { ExchangeTransferSimulator } from '../src/exchange_transfer_simulator';
import { DummyERC20TokenContract } from '../src/generated_contract_wrappers/dummy_erc20_token';
@@ -66,7 +66,7 @@ describe('ExchangeTransferSimulator', async () => {
totalSupply,
);
exampleAssetData = assetProxyUtils.encodeERC20AssetData(dummyERC20Token.address);
exampleAssetData = assetDataUtils.encodeERC20AssetData(dummyERC20Token.address);
});
beforeEach(async () => {
await blockchainLifecycle.startAsync();

View File

@@ -1,4 +1,13 @@
[
{
"timestamp": 1531919263,
"version": "0.0.8",
"changes": [
{
"note": "Dependencies updated"
}
]
},
{
"version": "0.0.7",
"changes": [

View File

@@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only.
CHANGELOG
## v0.0.8 - _July 18, 2018_
* Dependencies updated
## v0.0.7 - _July 9, 2018_
* Switch out simple getLogs polling with ethereumjs-blockstream (#825)

View File

@@ -1,6 +1,6 @@
{
"name": "@0xproject/order-watcher",
"version": "0.0.7",
"version": "0.0.8",
"description": "An order watcher daemon that watches for order validity",
"keywords": [
"0x",
@@ -47,12 +47,12 @@
"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/tslint-config": "^0.4.21",
"@0xproject/abi-gen": "^0.3.4",
"@0xproject/dev-utils": "^0.4.6",
"@0xproject/migrations": "^0.0.10",
"@0xproject/monorepo-script": "^1.0.0",
"@0xproject/sol-compiler": "^0.5.4",
"@0xproject/tslint-config": "^1.0.0",
"@types/bintrees": "^1.0.2",
"@types/lodash": "4.14.104",
"@types/mocha": "^2.2.42",
@@ -77,18 +77,18 @@
"typescript": "2.7.1"
},
"dependencies": {
"@0xproject/assert": "0.2.13",
"@0xproject/base-contract": "^0.3.5",
"@0xproject/contract-wrappers": "0.0.5",
"@0xproject/fill-scenarios": "^0.0.5",
"@0xproject/json-schemas": "0.8.2",
"@0xproject/order-utils": "^0.0.8",
"@0xproject/types": "^0.8.2",
"@0xproject/typescript-typings": "^0.4.2",
"@0xproject/utils": "^0.7.2",
"@0xproject/web3-wrapper": "^0.7.2",
"@0xproject/assert": "^1.0.0",
"@0xproject/base-contract": "0.3.6",
"@0xproject/contract-wrappers": "0.1.1",
"@0xproject/fill-scenarios": "1.0.0",
"@0xproject/json-schemas": "^1.0.0-rc.1",
"@0xproject/order-utils": "1.0.0",
"@0xproject/types": "^1.0.0-rc.1",
"@0xproject/typescript-typings": "^1.0.0",
"@0xproject/utils": "^1.0.0",
"@0xproject/web3-wrapper": "^0.7.3",
"ethereumjs-blockstream": "5.0.0",
"ethereum-types": "^0.0.2",
"ethereum-types": "^1.0.0",
"bintrees": "^1.0.2",
"ethers": "3.0.22",
"lodash": "^4.17.4"

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