Compare commits
549 Commits
@0xproject
...
@0xproject
Author | SHA1 | Date | |
---|---|---|---|
|
95c627f581 | ||
|
512dbb448b | ||
|
b793c1cc73 | ||
|
aea048ecc7 | ||
|
d0e6413fcf | ||
|
3b7ad1688b | ||
|
e907b99314 | ||
|
973bcb0483 | ||
|
87fb9a76ce | ||
|
0187e0c47d | ||
|
8732d8ece8 | ||
|
2e7c130f62 | ||
|
a90f434df5 | ||
|
3b005ad47c | ||
|
735bc2f178 | ||
|
e3cfa6363d | ||
|
331b1cb9a0 | ||
|
55dbb0ece0 | ||
|
af4071e119 | ||
|
9947e643d0 | ||
|
d3be4f2852 | ||
|
e320f343f8 | ||
|
f6cc7d9c3c | ||
|
b756f76b0e | ||
|
034948065d | ||
|
0c2df7e589 | ||
|
2ae6a71ca3 | ||
|
206fd0f78e | ||
|
b84225ac70 | ||
|
5ebcea53d6 | ||
|
a491e01144 | ||
|
1236efc008 | ||
|
e63bbdeb87 | ||
|
084ccb62a6 | ||
|
015469885d | ||
|
061f223269 | ||
|
88ee35d5f9 | ||
|
6c5b33ec71 | ||
|
31b8dd1bfc | ||
|
35113487f1 | ||
|
9ce8e10115 | ||
|
d07d059eda | ||
|
d836b0f815 | ||
|
1b1733ce7c | ||
|
5fd64a969b | ||
|
9a762e584c | ||
|
7fc0fd9fb6 | ||
|
da4b70fcae | ||
|
a0db69ee05 | ||
|
2c62504b79 | ||
|
67303106dc | ||
|
600d574042 | ||
|
07d4f21807 | ||
|
4da12067b9 | ||
|
24ab24879c | ||
|
dc51741b83 | ||
|
dd979dbf6d | ||
|
0cfea5613a | ||
|
98dd3ecab7 | ||
|
fe05e0bac3 | ||
|
d3f9b72c84 | ||
|
05b35c0fdc | ||
|
36b61650b3 | ||
|
c37b6f0eeb | ||
|
28114c3b5a | ||
|
2617df4ec7 | ||
|
0d28c48eb9 | ||
|
c6a6a54cce | ||
|
e5aa03da64 | ||
|
47c0195b07 | ||
|
f13d43dbf5 | ||
|
f9e99a27d3 | ||
|
854b8fad22 | ||
|
91c7105d43 | ||
|
c1e3533287 | ||
|
bb7c308081 | ||
|
fcbaf2f4e3 | ||
|
109c5df973 | ||
|
b0fab3ea4a | ||
|
c40b3dea6c | ||
|
dbc798596b | ||
|
fac90c446c | ||
|
c5859b65a3 | ||
|
14bb697924 | ||
|
dbd815c1e0 | ||
|
9592a9a821 | ||
|
dd9f020c9b | ||
|
56f21f4bab | ||
|
91bc1b468b | ||
|
97268d2253 | ||
|
14b3c50b69 | ||
|
333bf9de05 | ||
|
16a38c687e | ||
|
24aa5cd1bf | ||
|
f699da90ba | ||
|
d1e33a3dff | ||
|
f50ac932d6 | ||
|
cab32d7593 | ||
|
2073aa9abc | ||
|
0386025395 | ||
|
0772403ea9 | ||
|
8acfc9a2f9 | ||
|
de087abc8d | ||
|
98b2875512 | ||
|
e9e73aa0a3 | ||
|
d280311734 | ||
|
789762617f | ||
|
6f38d1bee5 | ||
|
73d75bc405 | ||
|
91dcfd5ee8 | ||
|
5fe0e9f2e7 | ||
|
51fb6e6a23 | ||
|
9392d5c84f | ||
|
e49d136b99 | ||
|
d50174b89e | ||
|
1d9a77027e | ||
|
b4cd8897b2 | ||
|
df341717f7 | ||
|
68974313e1 | ||
|
39a06e1d3b | ||
|
bfe57b84d6 | ||
|
dae975b08c | ||
|
27d44e3021 | ||
|
df00d93b9c | ||
|
15bbbb3762 | ||
|
c9ee526d8b | ||
|
b110d95de1 | ||
|
76eab5d3ec | ||
|
4a2715e61f | ||
|
7fbcc3999f | ||
|
e873b8948f | ||
|
c8108a1db2 | ||
|
195c3af84e | ||
|
39724292e3 | ||
|
24b5aa0e82 | ||
|
3af2ef8439 | ||
|
e2d027e252 | ||
|
bddcebfbb1 | ||
|
a05b14e4d9 | ||
|
9a36e73f4e | ||
|
a66ccaa1da | ||
|
f05a563802 | ||
|
06396b8874 | ||
|
e5e68de2d7 | ||
|
dcc0908617 | ||
|
45d68285f1 | ||
|
e20f3a0f97 | ||
|
c5029e61e3 | ||
|
e90ed01105 | ||
|
d8099d53fe | ||
|
0a976a3fb8 | ||
|
4636d5fbc2 | ||
|
3506ec1caa | ||
|
1f0e819756 | ||
|
799ff2a5c3 | ||
|
ec5f768f9b | ||
|
66ab010055 | ||
|
6fb157488c | ||
|
814518dd80 | ||
|
554b18a466 | ||
|
855b6b1dc5 | ||
|
c2ae9f62a4 | ||
|
4159a8fe6e | ||
|
d8b44283a2 | ||
|
2c1daf9c9a | ||
|
c7962216e9 | ||
|
ffdaf88fd0 | ||
|
f84f879950 | ||
|
eb6027fba7 | ||
|
9a1f0ac8e2 | ||
|
51b6f8bc71 | ||
|
4f73b81b9c | ||
|
195d11f9d0 | ||
|
b325ad1735 | ||
|
74483631d0 | ||
|
89b24a21a0 | ||
|
f0f13aa1dd | ||
|
06f61949f9 | ||
|
0e72b67865 | ||
|
b987eebf21 | ||
|
c808d12b74 | ||
|
b466431ede | ||
|
bf69ca6e53 | ||
|
6ffa907f0e | ||
|
e54501522d | ||
|
f2baeddc30 | ||
|
fd349b618a | ||
|
6ca2a02766 | ||
|
d9a282bd92 | ||
|
dc151f7290 | ||
|
cce2127f72 | ||
|
ad4c2b95e4 | ||
|
8e7c395f59 | ||
|
02d50a513a | ||
|
d61759f6dd | ||
|
5790ed7ba9 | ||
|
067adbfb62 | ||
|
7fadba59e7 | ||
|
bcde0731db | ||
|
052afb67a4 | ||
|
6e15d7bb0f | ||
|
5bb68974ec | ||
|
0a3ba4d27d | ||
|
482a226dc5 | ||
|
9e69458ba8 | ||
|
71e386d5fa | ||
|
60b501b137 | ||
|
36f8e9f1d5 | ||
|
78707bd3ca | ||
|
56137d0605 | ||
|
681a582630 | ||
|
846a447c4d | ||
|
f76be4f016 | ||
|
ed19067096 | ||
|
eb9f7c2c9d | ||
|
52693f7d0a | ||
|
5e015872ef | ||
|
08c291bd3f | ||
|
48c5d69c9d | ||
|
0f9c262bb0 | ||
|
dff0fc65bf | ||
|
161f96c07d | ||
|
67ad21b368 | ||
|
d5e633c38f | ||
|
617ef5b6ce | ||
|
8bd4e38d02 | ||
|
f364b5c5ab | ||
|
6486fced34 | ||
|
bc9f2a51a2 | ||
|
9c03b54d75 | ||
|
eae08ea1e4 | ||
|
6f276223c6 | ||
|
21effcaa8b | ||
|
114b31a813 | ||
|
1a1b7a2bc4 | ||
|
c9b213839a | ||
|
4043fa76cc | ||
|
9c8e3bc4c9 | ||
|
18b1f01641 | ||
|
9085c674e4 | ||
|
b5d19d3fb1 | ||
|
cc0477153b | ||
|
76008b41c5 | ||
|
8193fdc304 | ||
|
9d06c81078 | ||
|
cdf85e5eee | ||
|
d774dbc432 | ||
|
0369f5ebc4 | ||
|
1e6b11b27e | ||
|
7a8231435b | ||
|
b1aa7725df | ||
|
bfe0ba3e9a | ||
|
2d39329ee7 | ||
|
761b0063a0 | ||
|
0f27ce3424 | ||
|
2b0c0a6ff7 | ||
|
5bd96f6fe9 | ||
|
37ac6749ba | ||
|
bf955bd87f | ||
|
6bd921d0bc | ||
|
534decea95 | ||
|
267830d463 | ||
|
e82d0c21ec | ||
|
ece6417699 | ||
|
74d5449719 | ||
|
4af7ff9cc3 | ||
|
46dedfcb67 | ||
|
a9fa1a0df6 | ||
|
a8572b4944 | ||
|
91c0d47ad4 | ||
|
fd2611794a | ||
|
1fe1c5321b | ||
|
f063a5db0f | ||
|
3883315447 | ||
|
7679e07957 | ||
|
c39ba37ad8 | ||
|
f1c3840c3b | ||
|
e5c5b36a73 | ||
|
c51f7a8375 | ||
|
e53e2ac31b | ||
|
b72857cd8b | ||
|
cc223b9eab | ||
|
f2c49e8b37 | ||
|
9b6476a6b7 | ||
|
d8898cf9a3 | ||
|
34df5af295 | ||
|
3de88d5345 | ||
|
9ab6ab1bf9 | ||
|
b6de0bdd43 | ||
|
a2b62fd808 | ||
|
fc166dea26 | ||
|
f9c4d0925e | ||
|
1df9370bc2 | ||
|
7d840c7a18 | ||
|
ff12aafc0f | ||
|
c08b4aa6a1 | ||
|
52a6e6357b | ||
|
74c0fd419b | ||
|
6f540e3e58 | ||
|
dead04dce8 | ||
|
886a03fdcd | ||
|
81007c453c | ||
|
6529e06057 | ||
|
55336f96d7 | ||
|
938aabde3d | ||
|
c7f196b579 | ||
|
b28a88dbb2 | ||
|
e6558b7135 | ||
|
2c8fb9aa31 | ||
|
f48c6b6285 | ||
|
4f42f60bde | ||
|
3942647910 | ||
|
e0fbc78925 | ||
|
f3e43d7d94 | ||
|
f36547241c | ||
|
7ad29950a8 | ||
|
cbf91ad45c | ||
|
a039b66533 | ||
|
3a18c249f5 | ||
|
7c0775aa1b | ||
|
6514c34ed8 | ||
|
ba92754669 | ||
|
30afd39129 | ||
|
41699406cf | ||
|
9aa49e59d0 | ||
|
29d5034260 | ||
|
00d1622b3f | ||
|
a1acf19ff3 | ||
|
86328af6b7 | ||
|
36c27bdbf8 | ||
|
c839965c05 | ||
|
e1a9f3435f | ||
|
9f74feb347 | ||
|
f99232095b | ||
|
5044fe4fe4 | ||
|
8e49169e6b | ||
|
c71781d9ab | ||
|
8a2a4052f3 | ||
|
dad557164e | ||
|
e2fb49a8f8 | ||
|
f3241ff86a | ||
|
b9e7973a0f | ||
|
004b1f5288 | ||
|
857bd24c6d | ||
|
904968cf4a | ||
|
83747934ad | ||
|
7f90f5ecd4 | ||
|
12f02b9814 | ||
|
8931388309 | ||
|
25160d7344 | ||
|
ab6bf6edc7 | ||
|
56a4a374cd | ||
|
caa5b4e342 | ||
|
b6172c3965 | ||
|
02ddfa07a7 | ||
|
5022878680 | ||
|
2bfacbb8ba | ||
|
b18d2b0274 | ||
|
f20b496dca | ||
|
cca17f70b8 | ||
|
b8e69718a1 | ||
|
50ed7d2af2 | ||
|
698de932ed | ||
|
a3d8858bb1 | ||
|
83f3ba21b8 | ||
|
2aa729b212 | ||
|
1de70e4474 | ||
|
f2393de59b | ||
|
94ea7cc451 | ||
|
f8dbf57582 | ||
|
c59cd36da6 | ||
|
15e92958d6 | ||
|
96c648c4b4 | ||
|
f56a7d0cb2 | ||
|
01e617bb83 | ||
|
59fd5c69c0 | ||
|
28a9a8c380 | ||
|
6c2796b433 | ||
|
82ad5f7897 | ||
|
bf8ac3b9e6 | ||
|
edcdc9b1b9 | ||
|
4227aaa68a | ||
|
b750ce8be6 | ||
|
03a6a088c5 | ||
|
1e787a7646 | ||
|
766ac3f1fe | ||
|
a9038f2afc | ||
|
9828fa335e | ||
|
0c04d490bb | ||
|
bffffffc95 | ||
|
e9589ff786 | ||
|
c3bd3437f5 | ||
|
01789e6750 | ||
|
c3f7ba1b91 | ||
|
90d72a3683 | ||
|
f9bcf936ed | ||
|
acff177c54 | ||
|
658214a2e2 | ||
|
55f6f02c9b | ||
|
c5ba52910a | ||
|
994ccd6694 | ||
|
4921a83813 | ||
|
a97ba41b86 | ||
|
67e2623d2c | ||
|
4111095da3 | ||
|
6c21ddcedb | ||
|
d86349658f | ||
|
151ce6e3c7 | ||
|
6bdee26c30 | ||
|
5e4b1eed30 | ||
|
ab5cd95ccc | ||
|
a3dc398da5 | ||
|
b70f5d1a1e | ||
|
26363931ed | ||
|
e2438330f5 | ||
|
c5fcdd0657 | ||
|
345f3c07a5 | ||
|
f3477ff28c | ||
|
7ac4fa50b5 | ||
|
2f0a914838 | ||
|
5fc7d9a603 | ||
|
ced68e4e02 | ||
|
80071beaac | ||
|
de1029d5ef | ||
|
ffeb3194a8 | ||
|
95e9f33f6a | ||
|
c599a20b34 | ||
|
ca59528a32 | ||
|
6f4fd06d38 | ||
|
4715c2d006 | ||
|
fcfa43b6f1 | ||
|
56b4c55654 | ||
|
830790eeac | ||
|
39de9c7879 | ||
|
7b6cc14b71 | ||
|
ec749a4033 | ||
|
fe32214613 | ||
|
f6fcb775b7 | ||
|
d209108a95 | ||
|
efc64cf17f | ||
|
2f41ed50c1 | ||
|
fcc8cdd36a | ||
|
248632ce76 | ||
|
25681754bd | ||
|
179c487da9 | ||
|
350989bbec | ||
|
f5293e6c38 | ||
|
70c3515c94 | ||
|
4c7fd5a4e8 | ||
|
9d24341d94 | ||
|
512502ca08 | ||
|
6ce662c7a4 | ||
|
701ea5c46b | ||
|
2e5ff53d72 | ||
|
1229c61ba4 | ||
|
ee54438e92 | ||
|
65af78c85d | ||
|
b4747c3f85 | ||
|
1df074b73e | ||
|
254d30b8df | ||
|
ac5588c7c4 | ||
|
ddb70a89ad | ||
|
f4b2a9625d | ||
|
c2a1317c38 | ||
|
49f1a6933c | ||
|
9b387b8ec3 | ||
|
a45a29432e | ||
|
819d069edc | ||
|
b0a57a5091 | ||
|
d8678d562d | ||
|
34a9035164 | ||
|
0941e0a929 | ||
|
1ee78062d7 | ||
|
09f5609618 | ||
|
098322c564 | ||
|
365e24c1cd | ||
|
b82fdd59e7 | ||
|
6190ac7791 | ||
|
ed3aeb7997 | ||
|
33f92b6bcf | ||
|
9131a72a47 | ||
|
e5617dfe61 | ||
|
e67d67419f | ||
|
17c34716f9 | ||
|
e12f7c3026 | ||
|
af395eccda | ||
|
c403dcdabf | ||
|
c500cc095f | ||
|
6ecda647ad | ||
|
3e7ee1f090 | ||
|
0c120cb7a3 | ||
|
cab6829df9 | ||
|
0efe6df416 | ||
|
a4b6112a31 | ||
|
47debf0134 | ||
|
16ddd1edfc | ||
|
0f1fd0e90d | ||
|
ef76d83d2a | ||
|
df9f6004f2 | ||
|
9a87f99dcd | ||
|
30011db6d7 | ||
|
b6ac132c78 | ||
|
abf87a643d | ||
|
3824ea9079 | ||
|
5e22ce05c5 | ||
|
8fcc7aefa7 | ||
|
0b6ea1d046 | ||
|
22d3981a74 | ||
|
81b4f4928d | ||
|
dd77a38535 | ||
|
d319b53e23 | ||
|
b9627e14d0 | ||
|
56a96d36a1 | ||
|
e60630fa73 | ||
|
5ef6613024 | ||
|
af7e02de27 | ||
|
51d5b9d35d | ||
|
092ca6bcf5 | ||
|
2625cbbfed | ||
|
cedd1d5596 | ||
|
fb9e14a229 | ||
|
4e1bd7b5f0 | ||
|
5dfed8cd00 | ||
|
a2672a0d78 | ||
|
ee5ac6b800 | ||
|
a481d2ab46 | ||
|
c8bb21d12d | ||
|
e817cd7d43 | ||
|
bd6085fffd | ||
|
7efe9a9385 | ||
|
50da40a727 | ||
|
48390a1875 | ||
|
a3d27cd128 | ||
|
589c814ee6 | ||
|
4b60a3cbab | ||
|
1aaf633df8 | ||
|
82771ec64a | ||
|
ada8a402da | ||
|
17956efe35 | ||
|
8378c9f85e | ||
|
324b1079e7 | ||
|
c6da829713 | ||
|
844b0687a6 | ||
|
2ed2dd2fb7 | ||
|
d2f7dd3d5a | ||
|
9f08916cf1 | ||
|
a0e3676e3a | ||
|
2276793629 | ||
|
cfe57f52f4 |
@@ -64,7 +64,8 @@ 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
|
||||
- run: yarn wsrun test:circleci @0xproject/connect
|
||||
@@ -83,6 +84,10 @@ jobs:
|
||||
key: coverage-0xjs-{{ .Environment.CIRCLE_SHA1 }}
|
||||
paths:
|
||||
- ~/repo/packages/0x.js/coverage/lcov.info
|
||||
- save_cache:
|
||||
key: coverage-abi-gen-{{ .Environment.CIRCLE_SHA1 }}
|
||||
paths:
|
||||
- ~/repo/packages/abi-gen/coverage/lcov.info
|
||||
- save_cache:
|
||||
key: coverage-assert-{{ .Environment.CIRCLE_SHA1 }}
|
||||
paths:
|
||||
@@ -148,7 +153,7 @@ jobs:
|
||||
keys:
|
||||
- repo-{{ .Environment.CIRCLE_SHA1 }}
|
||||
- run: yarn prettier:ci
|
||||
- run: yarn lerna:run lint
|
||||
- run: yarn lerna run lint
|
||||
submit-coverage:
|
||||
docker:
|
||||
- image: circleci/node:9
|
||||
@@ -160,6 +165,9 @@ jobs:
|
||||
- restore_cache:
|
||||
keys:
|
||||
- coverage-0xjs-{{ .Environment.CIRCLE_SHA1 }}
|
||||
- restore_cache:
|
||||
keys:
|
||||
- coverage-abi-gen-{{ .Environment.CIRCLE_SHA1 }}
|
||||
- restore_cache:
|
||||
keys:
|
||||
- coverage-assert-{{ .Environment.CIRCLE_SHA1 }}
|
||||
|
5
.gitignore
vendored
5
.gitignore
vendored
@@ -41,6 +41,7 @@ typings/
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
.npmrc
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
@@ -81,8 +82,10 @@ packages/sol-cov/test/fixtures/artifacts/
|
||||
packages/metacoin/artifacts/
|
||||
packages/order-watcher/test/artifacts/
|
||||
packages/contract-wrappers/test/artifacts/
|
||||
packages/contract-wrappers/src/artifacts/
|
||||
packages/order-watcher/src/artifacts/
|
||||
|
||||
# generated contract wrappers
|
||||
# generated contract watcher
|
||||
packages/0x.js/src/generated_contract_wrappers/
|
||||
packages/contracts/generated_contract_wrappers/
|
||||
packages/contract-wrappers/src/contract_wrappers/generated/
|
||||
|
@@ -10,8 +10,10 @@ lib
|
||||
/packages/migrations/src/1.0.0/contract_wrappers
|
||||
/packages/migrations/src/2.0.0/contract_wrappers
|
||||
/packages/migrations/src/2.0.0-beta-testnet/contract_wrappers
|
||||
/packages/0x.js/test/artifacts
|
||||
/packages/0x.js/src/artifacts
|
||||
/packages/contracts/src/artifacts
|
||||
/packages/contract-wrappers/src/artifacts
|
||||
/packages/order-watcher/src/artifacts
|
||||
/packages/metacoin/artifacts
|
||||
/packages/contract-wrappers/test/artifacts
|
||||
/packages/order-watcher/test/artifacts
|
||||
|
@@ -8,20 +8,20 @@
|
||||
|
||||
## Types of changes
|
||||
|
||||
<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->
|
||||
<!--- What types of changes does your code introduce? Uncomment all the bullets that apply: -->
|
||||
|
||||
* [ ] Bug fix (non-breaking change which fixes an issue)
|
||||
* [ ] New feature (non-breaking change which adds functionality)
|
||||
* [ ] Breaking change (fix or feature that would cause existing functionality to change)
|
||||
<!-- * Bug fix (non-breaking change which fixes an issue) -->
|
||||
|
||||
<!-- * New feature (non-breaking change which adds functionality) -->
|
||||
|
||||
<!-- * Breaking change (fix or feature that would cause existing functionality to change) -->
|
||||
|
||||
## Checklist:
|
||||
|
||||
<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
|
||||
<!--- The following points should be used to indicate the progress of your PR. Put an `x` in all the boxes that apply right now, and come back over time and check them off as you make progress. If you're unsure about any of these, don't hesitate to ask. We're here to help! -->
|
||||
|
||||
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->
|
||||
|
||||
* [ ] Change requires a change to the documentation.
|
||||
* [ ] Added tests to cover my changes.
|
||||
* [ ] Prefixed the title of this PR with `[WIP]` if it is a work in progress.
|
||||
* [ ] Prefixed the title of this PR with bracketed package name(s) corresponding to the changed package(s). For example: `[sol-cov] Fixed bug`.
|
||||
* [ ] Added tests to cover my changes, or decided that tests would be too impractical.
|
||||
* [ ] Updated documentation, or decided that no doc change is needed.
|
||||
* [ ] Added new entries to the relevant CHANGELOG.jsons.
|
||||
* [ ] Labeled this PR with the 'WIP' label if it is a work in progress.
|
||||
* [ ] Labeled this PR with the labels corresponding to the changed package.
|
||||
|
11
lerna.json
11
lerna.json
@@ -1,15 +1,10 @@
|
||||
{
|
||||
"lerna": "2.5.1",
|
||||
"lerna": "3.0.0-beta.23",
|
||||
"packages": ["packages/*"],
|
||||
"commands": {
|
||||
"publish": {
|
||||
"allowBranch": "development"
|
||||
}
|
||||
},
|
||||
"version": "independent",
|
||||
"commands": {
|
||||
"command": {
|
||||
"publish": {
|
||||
"ignore": ["test/**/*", "*.md", "scripts", "lib", "tslint.json", "tsconfig.json"]
|
||||
"ignoreChanges": ["test/**/*", "*.md", "scripts", "lib", "tslint.json", "tsconfig.json"]
|
||||
}
|
||||
},
|
||||
"npmClient": "yarn",
|
||||
|
19
package.json
19
package.json
@@ -13,25 +13,26 @@
|
||||
"prettier:ci": "prettier --list-different '**/*.{ts,tsx,json,md}' --config .prettierrc",
|
||||
"report_coverage": "lcov-result-merger 'packages/*/coverage/lcov.info' | coveralls",
|
||||
"test:installation": "node ./packages/monorepo-scripts/lib/test_installation.js",
|
||||
"run:publish": "run-s install:all build:monorepo_scripts script:prepublish_checks rebuild script:publish",
|
||||
"run:publish:dry": "run-s install:all build:monorepo_scripts script:prepublish_checks rebuild script:publish:dry",
|
||||
"test:installation:local": "IS_LOCAL_PUBLISH=true node ./packages/monorepo-scripts/lib/test_installation.js",
|
||||
"run:publish": "run-s install:all build:monorepo_scripts script:prepublish_checks rebuild:no_website script:publish",
|
||||
"run:publish:local": "IS_LOCAL_PUBLISH=true yarn run:publish",
|
||||
"script:prepublish_checks": "node ./packages/monorepo-scripts/lib/prepublish_checks.js",
|
||||
"script:publish": "node ./packages/monorepo-scripts/lib/publish.js",
|
||||
"script:publish:dry": "IS_DRY_RUN=true yarn script:publish",
|
||||
"install:all": "yarn install",
|
||||
"wsrun": "wsrun",
|
||||
"lerna:run": "lerna run",
|
||||
"lerna": "lerna",
|
||||
"watch": "wsrun watch_without_deps $PKG --fast-exit -r --stages --done-criteria='complete|successfully'",
|
||||
"build": "wsrun build $PKG --fast-exit -r --stages",
|
||||
"build:no_website": "wsrun build $PKG --fast-exit -r --stages --exclude @0xproject/website",
|
||||
"build:monorepo_scripts": "PKG=@0xproject/monorepo-scripts yarn build",
|
||||
"clean": "wsrun clean $PKG --fast-exit -r --parallel",
|
||||
"remove_node_modules": "lerna clean --yes; rm -rf node_modules",
|
||||
"rebuild": "run-s clean build",
|
||||
"rebuild:no_website": "run-s clean build:no_website",
|
||||
"test": "wsrun test $PKG --fast-exit --serial --exclude-missing",
|
||||
"stage_docs": "wsrun docs:stage $PKG --fast-exit --parallel --exclude-missing",
|
||||
"lint": "wsrun lint $PKG --fast-exit --parallel --exclude-missing",
|
||||
"comment:postinstall": "HACK: For some reason `yarn` is not setting up symlinks properly for order-utils. We temporarily set them manually. Remove this after V2 refactor is complete.",
|
||||
"postinstall": "rm -rf `pwd`/packages/order-utils/node_modules/@0xproject; mkdir `pwd`/packages/order-utils/node_modules/@0xproject; ln -s `pwd`/packages/json-schemas `pwd`/packages/order-utils/node_modules/@0xproject/json-schemas; ln -s `pwd`/packages/assert `pwd`/packages/order-utils/node_modules/@0xproject/assert; ln -s `pwd`/packages/types `pwd`/packages/order-utils/node_modules/@0xproject/types; rm -f `pwd`/packages/contracts/node_modules/@0xproject/types; ln -s `pwd`/packages/types `pwd`/packages/contracts/node_modules/@0xproject/types; rm -rf `pwd`/packages/fill-scenarios/node_modules/@0xproject; mkdir -p `pwd`/packages/fill-scenarios/node_modules/@0xproject; ln -s `pwd`/packages/types `pwd`/packages/fill-scenarios/node_modules/@0xproject/types; ln -s `pwd`/packages/json-schemas `pwd`/packages/fill-scenarios/node_modules/@0xproject/json-schemas; ln -s `pwd`/packages/order-utils `pwd`/packages/fill-scenarios/node_modules/@0xproject/order-utils; rm -rf `pwd`/packages/contract-wrappers/node_modules/@0xproject; mkdir -p `pwd`/packages/contract-wrappers/node_modules/@0xproject; ln -s `pwd`/packages/order-utils `pwd`/packages/contract-wrappers/node_modules/@0xproject/order-utils; ln -s `pwd`/packages/assert `pwd`/packages/contract-wrappers/node_modules/@0xproject/assert; ln -s `pwd`/packages/json-schemas `pwd`/packages/contract-wrappers/node_modules/@0xproject/json-schemas; ln -s `pwd`/packages/types `pwd`/packages/contract-wrappers/node_modules/@0xproject/types; ln -s `pwd`/packages/fill-scenarios `pwd`/packages/contract-wrappers/node_modules/@0xproject/fill-scenarios; rm -rf `pwd`/packages/assert/node_modules/@0xproject; mkdir -p `pwd`/packages/assert/node_modules/@0xproject; ln -s `pwd`/packages/json-schemas `pwd`/packages/assert/node_modules/@0xproject/json-schemas"
|
||||
"comment:postinstall": "HACK: For some reason `yarn` is not setting up symlinks properly for order-utils. We temporarily set them manually. Remove this after V2 refactor is complete."
|
||||
},
|
||||
"config": {
|
||||
"mnemonic": "concert load couple harbor equip island argue ramp clarify fence smart topic"
|
||||
@@ -41,11 +42,11 @@
|
||||
"coveralls": "^3.0.0",
|
||||
"ganache-cli": "6.1.3",
|
||||
"lcov-result-merger": "^3.0.0",
|
||||
"lerna": "^2.5.1",
|
||||
"@0x-lerna-fork/lerna": "3.0.0-beta.23",
|
||||
"npm-run-all": "^4.1.2",
|
||||
"prettier": "^1.11.1",
|
||||
"wsrun": "^2.2.0",
|
||||
"source-map-support": "^0.5.6"
|
||||
"source-map-support": "^0.5.6",
|
||||
"wsrun": "^2.2.0"
|
||||
},
|
||||
"resolutions": {
|
||||
"ethers": "0xproject/ethers.js#eip-838-reasons"
|
||||
|
@@ -1,4 +1,99 @@
|
||||
[
|
||||
{
|
||||
"version": "1.0.1-rc.2",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Fixed bug caused by importing non-existent dep"
|
||||
}
|
||||
],
|
||||
"timestamp": 1532619515
|
||||
},
|
||||
{
|
||||
"version": "1.0.1-rc.1",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
],
|
||||
"timestamp": 1532605697
|
||||
},
|
||||
{
|
||||
"timestamp": 1532357734,
|
||||
"version": "1.0.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1532043100,
|
||||
"version": "1.0.0-rc.2",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Remove `zeroEx.assetData` and instead re-export it's static functions directly off `ZeroEx`"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1532043000,
|
||||
"version": "1.0.0-rc.1",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Remove tokenRegistry wrapper",
|
||||
"pr": 863
|
||||
},
|
||||
{
|
||||
"note": "Rename `zeroEx.token` to `zeroEx.erc20Token`, and add `zeroEx.erc721Token`",
|
||||
"pr": 863
|
||||
},
|
||||
{
|
||||
"note": "Rename `zeroEx.proxy` to `zeroEx.erc20Proxy` and add `zeroEx.erc721Proxy`",
|
||||
"pr": 863
|
||||
},
|
||||
{
|
||||
"note":
|
||||
"Refactored `ZeroEx.isValidSignature` to `zeroEx.isValidSignatureAsync`. It is now async so that it can verify contract-dependent signature types",
|
||||
"pr": 863
|
||||
},
|
||||
{
|
||||
"note":
|
||||
"Refactored `signOrderHashAsync` to `ecSignOrderHashAsync`. There are now many non-ECSignature ways to sign orders too.",
|
||||
"pr": 863
|
||||
},
|
||||
{
|
||||
"note":
|
||||
"Removed `createOrderWatcherAsync` method. Will be added back once OrderWatcher is refactored for V2",
|
||||
"pr": 863
|
||||
},
|
||||
{
|
||||
"note": "0x.js exports renamed contract events and event arg types",
|
||||
"pr": 863
|
||||
},
|
||||
{
|
||||
"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"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1531149657,
|
||||
"version": "0.38.5",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1529397769,
|
||||
"version": "0.38.4",
|
||||
|
@@ -1,10 +1,45 @@
|
||||
<!--
|
||||
This file is auto-generated using the monorepo-scripts package. Don't edit directly.
|
||||
changelogUtils.file is auto-generated using the monorepo-scripts package. Don't edit directly.
|
||||
Edit the package's CHANGELOG.json file only.
|
||||
-->
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v1.0.1-rc.2 - _July 26, 2018_
|
||||
|
||||
* Fixed bug caused by importing non-existent dep
|
||||
|
||||
## v1.0.1-rc.1 - _July 26, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.0.0 - _July 23, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.0.0-rc.2 - _July 20, 2018_
|
||||
|
||||
* Remove `zeroEx.assetData` and instead re-export it's static functions directly off `ZeroEx`
|
||||
|
||||
## v1.0.0-rc.1 - _July 20, 2018_
|
||||
|
||||
* Remove tokenRegistry wrapper (#863)
|
||||
* Rename `zeroEx.token` to `zeroEx.erc20Token`, and add `zeroEx.erc721Token` (#863)
|
||||
* Rename `zeroEx.proxy` to `zeroEx.erc20Proxy` and add `zeroEx.erc721Proxy` (#863)
|
||||
* Refactored `ZeroEx.isValidSignature` to `zeroEx.isValidSignatureAsync`. It is now async so that it can verify contract-dependent signature types (#863)
|
||||
* Refactored `signOrderHashAsync` to `ecSignOrderHashAsync`. There are now many non-ECSignature ways to sign orders too. (#863)
|
||||
* Removed `createOrderWatcherAsync` method. Will be added back once OrderWatcher is refactored for V2 (#863)
|
||||
* 0x.js exports renamed contract events and event arg types (#863)
|
||||
* Export `ZeroEx.assetData` with methods to decode/encode assetData fields found in 0x orders (#884)
|
||||
|
||||
## v0.38.6 - _July 18, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.38.5 - _July 9, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.38.4 - _June 19, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "0x.js",
|
||||
"version": "0.38.4",
|
||||
"version": "1.0.1-rc.2",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
@@ -18,9 +18,10 @@
|
||||
"watch_without_deps": "yarn pre_build && tsc -w",
|
||||
"build": "yarn pre_build && yarn build:all && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts",
|
||||
"build:all": "run-p build:umd:prod build:commonjs; exit 0;",
|
||||
"pre_build": "run-s generate_contract_wrappers copy_artifacts",
|
||||
"copy_artifacts": "copyfiles -u 2 './src/compact_artifacts/**/*.json' ./lib/src/compact_artifacts",
|
||||
"generate_contract_wrappers": "abi-gen --abis 'src/compact_artifacts/@(Exchange|Token|TokenTransferProxy|EtherToken|TokenRegistry|DummyToken).json' --template ../contract_templates/contract.handlebars --partials '../contract_templates/partials/**/*.handlebars' --output src/generated_contract_wrappers --backend ethers",
|
||||
"pre_build": "run-s update_artifacts generate_contract_wrappers",
|
||||
"copy_artifacts": "copyfiles -u 2 './src/artifacts/**/*.json' ./lib/src/artifacts",
|
||||
"update_artifacts": "for i in ${npm_package_config_contracts}; do copyfiles -u 4 ../migrations/artifacts/2.0.0/$i.json src/artifacts; done;",
|
||||
"generate_contract_wrappers": "abi-gen --abis 'src/artifacts/@(ZRXToken).json' --template ../contract_templates/contract.handlebars --partials '../contract_templates/partials/**/*.handlebars' --output src/generated_contract_wrappers --backend ethers",
|
||||
"lint": "tslint --project . --exclude **/src/generated_contract_wrappers/**/*",
|
||||
"test:circleci": "run-s test:coverage",
|
||||
"test": "yarn run_mocha",
|
||||
@@ -29,7 +30,7 @@
|
||||
"coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info",
|
||||
"clean": "shx rm -rf _bundles lib test_temp scripts src/generated_contract_wrappers",
|
||||
"build:umd:prod": "NODE_ENV=production webpack",
|
||||
"build:commonjs": "tsc && copyfiles -u 2 './src/compact_artifacts/**/*.json' ./lib/src/compact_artifacts && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts",
|
||||
"build:commonjs": "tsc && yarn copy_artifacts && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts",
|
||||
"run_mocha": "mocha --require source-map-support/register --require make-promises-safe lib/test/**/*_test.js lib/test/global_hooks.js --timeout 10000 --bail --exit",
|
||||
"manual:postpublish": "yarn build; node ./scripts/postpublish.js",
|
||||
"docs:stage": "node scripts/stage_docs.js",
|
||||
@@ -37,7 +38,7 @@
|
||||
"upload_docs_json": "aws s3 cp generated_docs/index.json $S3_URL --profile 0xproject --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers --content-type application/json"
|
||||
},
|
||||
"config": {
|
||||
"compact_artifacts": "Exchange DummyToken ZRXToken Token EtherToken TokenTransferProxy TokenRegistry",
|
||||
"contracts": "ZRXToken",
|
||||
"postpublish": {
|
||||
"assets": [
|
||||
"packages/0x.js/_bundles/index.js",
|
||||
@@ -50,13 +51,11 @@
|
||||
"../contract-wrappers/src/types.ts",
|
||||
"../contract-wrappers/src/contract_wrappers/ether_token_wrapper.ts",
|
||||
"../contract-wrappers/src/contract_wrappers/exchange_wrapper.ts",
|
||||
"../contract-wrappers/src/contract_wrappers/token_registry_wrapper.ts",
|
||||
"../contract-wrappers/src/contract_wrappers/token_transfer_proxy_wrapper.ts",
|
||||
"../contract-wrappers/src/contract_wrappers/token_wrapper.ts",
|
||||
"../order-watcher/src/order_watcher/order_watcher.ts",
|
||||
"./src/generated_contract_wrappers/ether_token.ts",
|
||||
"./src/generated_contract_wrappers/token.ts",
|
||||
"./src/generated_contract_wrappers/exchange.ts"
|
||||
"../contract-wrappers/src/contract_wrappers/erc20_proxy_wrapper.ts",
|
||||
"../contract-wrappers/src/contract_wrappers/erc721_proxy_wrapper.ts",
|
||||
"../contract-wrappers/src/contract_wrappers/erc20_token_wrapper.ts",
|
||||
"../contract-wrappers/src/contract_wrappers/erc721_token_wrapper.ts",
|
||||
"../order-watcher/src/order_watcher/order_watcher.ts"
|
||||
],
|
||||
"s3BucketPath": "s3://doc-jsons/0x.js/",
|
||||
"s3StagingBucketPath": "s3://staging-doc-jsons/0x.js/"
|
||||
@@ -69,12 +68,11 @@
|
||||
},
|
||||
"license": "Apache-2.0",
|
||||
"devDependencies": {
|
||||
"@0xproject/abi-gen": "^0.3.2",
|
||||
"@0xproject/dev-utils": "^0.4.4",
|
||||
"@0xproject/migrations": "^0.0.8",
|
||||
"@0xproject/monorepo-scripts": "^0.2.1",
|
||||
"@0xproject/sol-compiler": "^0.5.2",
|
||||
"@0xproject/tslint-config": "^0.4.20",
|
||||
"@0xproject/abi-gen": "^1.0.4",
|
||||
"@0xproject/dev-utils": "^1.0.3",
|
||||
"@0xproject/migrations": "^1.0.3",
|
||||
"@0xproject/monorepo-scripts": "^1.0.4",
|
||||
"@0xproject/tslint-config": "^1.0.4",
|
||||
"@types/lodash": "4.14.104",
|
||||
"@types/mocha": "^2.2.42",
|
||||
"@types/node": "^8.0.53",
|
||||
@@ -94,23 +92,23 @@
|
||||
"shx": "^0.2.2",
|
||||
"sinon": "^4.0.0",
|
||||
"source-map-support": "^0.5.0",
|
||||
"tslint": "5.8.0",
|
||||
"tslint": "5.11.0",
|
||||
"typedoc": "0xProject/typedoc",
|
||||
"typescript": "2.7.1",
|
||||
"webpack": "^3.1.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0xproject/assert": "^0.2.12",
|
||||
"@0xproject/base-contract": "^0.3.4",
|
||||
"@0xproject/contract-wrappers": "^0.0.5",
|
||||
"@0xproject/order-utils": "^0.0.7",
|
||||
"@0xproject/order-watcher": "^0.0.6",
|
||||
"@0xproject/sol-compiler": "^0.5.2",
|
||||
"@0xproject/types": "^0.8.1",
|
||||
"@0xproject/typescript-typings": "^0.4.1",
|
||||
"@0xproject/utils": "^0.7.1",
|
||||
"@0xproject/web3-wrapper": "^0.7.1",
|
||||
"ethereum-types": "^0.0.2",
|
||||
"@0xproject/assert": "^1.0.4",
|
||||
"@0xproject/base-contract": "^1.0.4",
|
||||
"@0xproject/contract-wrappers": "^1.0.1-rc.2",
|
||||
"@0xproject/order-utils": "^1.0.1-rc.2",
|
||||
"@0xproject/sol-compiler": "^1.0.4",
|
||||
"@0xproject/subproviders": "^1.0.4",
|
||||
"@0xproject/types": "^1.0.1-rc.3",
|
||||
"@0xproject/typescript-typings": "^1.0.3",
|
||||
"@0xproject/utils": "^1.0.4",
|
||||
"@0xproject/web3-wrapper": "^1.1.2",
|
||||
"ethereum-types": "^1.0.3",
|
||||
"ethers": "3.0.22",
|
||||
"lodash": "^4.17.4"
|
||||
},
|
||||
|
@@ -2,23 +2,28 @@ import { assert } from '@0xproject/assert';
|
||||
import {
|
||||
ContractWrappers,
|
||||
ContractWrappersConfig,
|
||||
ERC20ProxyWrapper,
|
||||
ERC20TokenWrapper,
|
||||
ERC721ProxyWrapper,
|
||||
ERC721TokenWrapper,
|
||||
EtherTokenWrapper,
|
||||
ExchangeWrapper,
|
||||
TokenRegistryWrapper,
|
||||
TokenTransferProxyWrapper,
|
||||
TokenWrapper,
|
||||
} from '@0xproject/contract-wrappers';
|
||||
import {
|
||||
assetDataUtils,
|
||||
ecSignOrderHashAsync,
|
||||
generatePseudoRandomSalt,
|
||||
getOrderHashHex,
|
||||
isValidOrderHash,
|
||||
isValidSignature,
|
||||
signOrderHashAsync,
|
||||
isValidSignatureAsync,
|
||||
MessagePrefixOpts,
|
||||
orderHashUtils,
|
||||
} from '@0xproject/order-utils';
|
||||
import { OrderWatcher, OrderWatcherConfig } from '@0xproject/order-watcher';
|
||||
import { ECSignature, Order, Provider, SignedOrder, TransactionReceiptWithDecodedLogs } 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';
|
||||
|
||||
import { constants } from './utils/constants';
|
||||
|
||||
@@ -38,25 +43,29 @@ export class ZeroEx {
|
||||
*/
|
||||
public exchange: ExchangeWrapper;
|
||||
/**
|
||||
* An instance of the TokenRegistryWrapper class containing methods for interacting with the 0x
|
||||
* TokenRegistry smart contract.
|
||||
* An instance of the ERC20TokenWrapper class containing methods for interacting with any ERC20 token smart contract.
|
||||
*/
|
||||
public tokenRegistry: TokenRegistryWrapper;
|
||||
public erc20Token: ERC20TokenWrapper;
|
||||
/**
|
||||
* An instance of the TokenWrapper class containing methods for interacting with any ERC20 token smart contract.
|
||||
* An instance of the ERC721TokenWrapper class containing methods for interacting with any ERC721 token smart contract.
|
||||
*/
|
||||
public token: TokenWrapper;
|
||||
public erc721Token: ERC721TokenWrapper;
|
||||
/**
|
||||
* An instance of the EtherTokenWrapper class containing methods for interacting with the
|
||||
* wrapped ETH ERC20 token smart contract.
|
||||
*/
|
||||
public etherToken: EtherTokenWrapper;
|
||||
/**
|
||||
* An instance of the TokenTransferProxyWrapper class containing methods for interacting with the
|
||||
* tokenTransferProxy smart contract.
|
||||
* An instance of the ERC20ProxyWrapper class containing methods for interacting with the
|
||||
* ERC20 proxy smart contract.
|
||||
*/
|
||||
public proxy: TokenTransferProxyWrapper;
|
||||
private _contractWrappers: ContractWrappers;
|
||||
public erc20Proxy: ERC20ProxyWrapper;
|
||||
/**
|
||||
* An instance of the ERC721ProxyWrapper class containing methods for interacting with the
|
||||
* ERC721 proxy smart contract.
|
||||
*/
|
||||
public erc721Proxy: ERC721ProxyWrapper;
|
||||
private readonly _contractWrappers: ContractWrappers;
|
||||
/**
|
||||
* Generates a pseudo-random 256-bit salt.
|
||||
* The salt can be included in a 0x order, ensuring that the order generates a unique orderHash
|
||||
@@ -66,24 +75,13 @@ export class ZeroEx {
|
||||
public static generatePseudoRandomSalt(): BigNumber {
|
||||
return generatePseudoRandomSalt();
|
||||
}
|
||||
/**
|
||||
* Verifies that the elliptic curve signature `signature` was generated
|
||||
* by signing `data` with the private key corresponding to the `signerAddress` address.
|
||||
* @param data The hex encoded data signed by the supplied signature.
|
||||
* @param signature An object containing the elliptic curve signature parameters.
|
||||
* @param signerAddress The hex encoded address that signed the data, producing the supplied signature.
|
||||
* @return Whether the signature is valid for the supplied signerAddress and data.
|
||||
*/
|
||||
public static isValidSignature(data: string, signature: ECSignature, signerAddress: string): boolean {
|
||||
return isValidSignature(data, signature, signerAddress);
|
||||
}
|
||||
/**
|
||||
* Computes the orderHash for a supplied order.
|
||||
* @param order An object that conforms to the Order or SignedOrder interface definitions.
|
||||
* @return The resulting orderHash from hashing the supplied order.
|
||||
*/
|
||||
public static getOrderHashHex(order: Order | SignedOrder): string {
|
||||
return getOrderHashHex(order);
|
||||
return orderHashUtils.getOrderHashHex(order);
|
||||
}
|
||||
/**
|
||||
* Checks if the supplied hex encoded order hash is valid.
|
||||
@@ -93,7 +91,7 @@ export class ZeroEx {
|
||||
* @return Whether the supplied orderHash has the expected format.
|
||||
*/
|
||||
public static isValidOrderHash(orderHash: string): boolean {
|
||||
return isValidOrderHash(orderHash);
|
||||
return orderHashUtils.isValidOrderHash(orderHash);
|
||||
}
|
||||
/**
|
||||
* A unit amount is defined as the amount of a token above the specified decimal places (integer part).
|
||||
@@ -123,6 +121,57 @@ export class ZeroEx {
|
||||
const baseUnitAmount = Web3Wrapper.toBaseUnitAmount(amount, decimals);
|
||||
return baseUnitAmount;
|
||||
}
|
||||
/**
|
||||
* Encodes an ERC20 token address into a hex encoded assetData string, usable in the makerAssetData or
|
||||
* takerAssetData fields in a 0x order.
|
||||
* @param tokenAddress The ERC20 token address to encode
|
||||
* @return The hex encoded assetData string
|
||||
*/
|
||||
public static encodeERC20AssetData(tokenAddress: string): string {
|
||||
return assetDataUtils.encodeERC20AssetData(tokenAddress);
|
||||
}
|
||||
/**
|
||||
* Decodes an ERC20 assetData hex string into it's corresponding ERC20 tokenAddress & assetProxyId
|
||||
* @param assetData Hex encoded assetData string to decode
|
||||
* @return An object containing the decoded tokenAddress & assetProxyId
|
||||
*/
|
||||
public static decodeERC20AssetData(assetData: string): ERC20AssetData {
|
||||
return assetDataUtils.decodeERC20AssetData(assetData);
|
||||
}
|
||||
/**
|
||||
* Encodes an ERC721 token address into a hex encoded assetData string, usable in the makerAssetData or
|
||||
* takerAssetData fields in a 0x order.
|
||||
* @param tokenAddress The ERC721 token address to encode
|
||||
* @param tokenId The ERC721 tokenId to encode
|
||||
* @return The hex encoded assetData string
|
||||
*/
|
||||
public static encodeERC721AssetData(tokenAddress: string, tokenId: BigNumber): string {
|
||||
return assetDataUtils.encodeERC721AssetData(tokenAddress, tokenId);
|
||||
}
|
||||
/**
|
||||
* Decodes an ERC721 assetData hex string into it's corresponding ERC721 tokenAddress, tokenId & assetProxyId
|
||||
* @param assetData Hex encoded assetData string to decode
|
||||
* @return An object containing the decoded tokenAddress, tokenId & assetProxyId
|
||||
*/
|
||||
public static decodeERC721AssetData(assetData: string): ERC721AssetData {
|
||||
return assetDataUtils.decodeERC721AssetData(assetData);
|
||||
}
|
||||
/**
|
||||
* Decode and return the assetProxyId from the assetData
|
||||
* @param assetData Hex encoded assetData string to decode
|
||||
* @return The assetProxyId
|
||||
*/
|
||||
public static decodeAssetProxyId(assetData: string): AssetProxyId {
|
||||
return assetDataUtils.decodeAssetProxyId(assetData);
|
||||
}
|
||||
/**
|
||||
* Decode any assetData into it's corresponding assetData object
|
||||
* @param assetData Hex encoded assetData string to decode
|
||||
* @return Either a ERC20 or ERC721 assetData object
|
||||
*/
|
||||
public static decodeAssetDataOrThrow(assetData: string): ERC20AssetData | ERC721AssetData {
|
||||
return assetDataUtils.decodeAssetDataOrThrow(assetData);
|
||||
}
|
||||
/**
|
||||
* Instantiates a new ZeroEx instance that provides the public interface to the 0x.js library.
|
||||
* @param provider The Provider instance you would like the 0x.js library to use for interacting with
|
||||
@@ -134,12 +183,29 @@ export class ZeroEx {
|
||||
assert.isWeb3Provider('provider', provider);
|
||||
this._contractWrappers = new ContractWrappers(provider, config);
|
||||
|
||||
this.proxy = this._contractWrappers.proxy;
|
||||
this.token = this._contractWrappers.token;
|
||||
this.erc20Proxy = this._contractWrappers.erc20Proxy;
|
||||
this.erc721Proxy = this._contractWrappers.erc721Proxy;
|
||||
this.erc20Token = this._contractWrappers.erc20Token;
|
||||
this.erc721Token = this._contractWrappers.erc721Token;
|
||||
this.exchange = this._contractWrappers.exchange;
|
||||
this.tokenRegistry = this._contractWrappers.tokenRegistry;
|
||||
this.etherToken = this._contractWrappers.etherToken;
|
||||
}
|
||||
/**
|
||||
* Verifies that the provided signature is valid according to the 0x Protocol smart contracts
|
||||
* @param data The hex encoded data signed by the supplied signature.
|
||||
* @param signature The hex encoded signature.
|
||||
* @param signerAddress The hex encoded address that signed the data, producing the supplied signature.
|
||||
* @return Whether the signature is valid for the supplied signerAddress and data.
|
||||
*/
|
||||
public async isValidSignatureAsync(data: string, signature: string, signerAddress: string): Promise<boolean> {
|
||||
const isValid = await isValidSignatureAsync(
|
||||
this._contractWrappers.getProvider(),
|
||||
data,
|
||||
signature,
|
||||
signerAddress,
|
||||
);
|
||||
return isValid;
|
||||
}
|
||||
/**
|
||||
* Sets a new web3 provider for 0x.js. Updating the provider will stop all
|
||||
* subscriptions so you will need to re-subscribe to all events relevant to your app after this call.
|
||||
@@ -172,23 +238,21 @@ export class ZeroEx {
|
||||
* @param orderHash Hex encoded orderHash to sign.
|
||||
* @param signerAddress The hex encoded Ethereum address you wish to sign it with. This address
|
||||
* must be available via the Provider supplied to 0x.js.
|
||||
* @param shouldAddPersonalMessagePrefix Some signers add the personal message prefix `\x19Ethereum Signed Message`
|
||||
* themselves (e.g Parity Signer, Ledger, TestRPC) and others expect it to already be done by the client
|
||||
* (e.g Metamask). Depending on which signer this request is going to, decide on whether to add the prefix
|
||||
* before sending the request.
|
||||
* @param MessagePrefixOpts Options regarding the desired prefix and whether to add it before calling `eth_sign`
|
||||
* @return An object containing the Elliptic curve signature parameters generated by signing the orderHash.
|
||||
*/
|
||||
public async signOrderHashAsync(
|
||||
public async ecSignOrderHashAsync(
|
||||
orderHash: string,
|
||||
signerAddress: string,
|
||||
shouldAddPersonalMessagePrefix: boolean,
|
||||
messagePrefixOpts: MessagePrefixOpts,
|
||||
): Promise<ECSignature> {
|
||||
return signOrderHashAsync(
|
||||
const signature = await ecSignOrderHashAsync(
|
||||
this._contractWrappers.getProvider(),
|
||||
orderHash,
|
||||
signerAddress,
|
||||
shouldAddPersonalMessagePrefix,
|
||||
messagePrefixOpts,
|
||||
);
|
||||
return signature;
|
||||
}
|
||||
/**
|
||||
* Waits for a transaction to be mined and returns the transaction receipt.
|
||||
@@ -211,18 +275,4 @@ export class ZeroEx {
|
||||
);
|
||||
return transactionReceiptWithDecodedLogs;
|
||||
}
|
||||
/**
|
||||
* Instantiates and returns a new OrderWatcher instance.
|
||||
* Defaults to watching the pending state.
|
||||
* @param config The configuration object. Look up the type for the description.
|
||||
* @return An instance of the 0x.js OrderWatcher class.
|
||||
*/
|
||||
public async createOrderWatcherAsync(config?: OrderWatcherConfig): Promise<OrderWatcher> {
|
||||
// Hack: Get Web3Wrapper from ContractWrappers
|
||||
const web3Wrapper: Web3Wrapper = (this._contractWrappers as any)._web3Wrapper;
|
||||
const networkId = await web3Wrapper.getNetworkIdAsync();
|
||||
const provider = this._contractWrappers.getProvider();
|
||||
const orderWatcher = new OrderWatcher(provider, networkId, config);
|
||||
return orderWatcher;
|
||||
}
|
||||
}
|
||||
|
7
packages/0x.js/src/artifacts.ts
Normal file
7
packages/0x.js/src/artifacts.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import { ContractArtifact } from '@0xproject/sol-compiler';
|
||||
|
||||
import * as ZRXToken from './artifacts/ZRXToken.json';
|
||||
|
||||
export const artifacts = {
|
||||
ZRXToken: (ZRXToken as any) as ContractArtifact,
|
||||
};
|
10031
packages/0x.js/src/artifacts/ZRXToken.json
Normal file
10031
packages/0x.js/src/artifacts/ZRXToken.json
Normal file
File diff suppressed because one or more lines are too long
@@ -1,22 +0,0 @@
|
||||
{
|
||||
"contract_name": "DummyToken",
|
||||
"abi": [
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_target",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_value",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "setBalance",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
}
|
||||
]
|
||||
}
|
@@ -1,287 +0,0 @@
|
||||
{
|
||||
"contract_name": "EtherToken",
|
||||
"abi": [
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "name",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_spender",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_value",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "approve",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "totalSupply",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_from",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_to",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_value",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "transferFrom",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "amount",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "withdraw",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "decimals",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint8"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_owner",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "balanceOf",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "symbol",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_to",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_value",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "transfer",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [],
|
||||
"name": "deposit",
|
||||
"outputs": [],
|
||||
"payable": true,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_owner",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_spender",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "allowance",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"payable": true,
|
||||
"type": "fallback"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "_from",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "_to",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "_value",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "Transfer",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "_owner",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "_spender",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "_value",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "Approval",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "_owner",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "_value",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "Deposit",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "_owner",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "_value",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "Withdrawal",
|
||||
"type": "event"
|
||||
}
|
||||
],
|
||||
"networks": {
|
||||
"1": {
|
||||
"address": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
|
||||
},
|
||||
"3": {
|
||||
"address": "0xc00fd9820cd2898cc4c054b7bf142de637ad129a"
|
||||
},
|
||||
"4": {
|
||||
"address": "0xc778417e063141139fce010982780140aa0cd5ab"
|
||||
},
|
||||
"42": {
|
||||
"address": "0x653e49e301e508a13237c0ddc98ae7d4cd2667a1"
|
||||
},
|
||||
"50": {
|
||||
"address": "0x871dd7c2b4b25e1aa18728e9d5f2af4c4e431f5c"
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,610 +0,0 @@
|
||||
{
|
||||
"contract_name": "Exchange",
|
||||
"abi": [
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "numerator",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "denominator",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "target",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "isRoundingError",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"name": "filled",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"name": "cancelled",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "orderAddresses",
|
||||
"type": "address[5][]"
|
||||
},
|
||||
{
|
||||
"name": "orderValues",
|
||||
"type": "uint256[6][]"
|
||||
},
|
||||
{
|
||||
"name": "fillTakerTokenAmount",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "shouldThrowOnInsufficientBalanceOrAllowance",
|
||||
"type": "bool"
|
||||
},
|
||||
{
|
||||
"name": "v",
|
||||
"type": "uint8[]"
|
||||
},
|
||||
{
|
||||
"name": "r",
|
||||
"type": "bytes32[]"
|
||||
},
|
||||
{
|
||||
"name": "s",
|
||||
"type": "bytes32[]"
|
||||
}
|
||||
],
|
||||
"name": "fillOrdersUpTo",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "orderAddresses",
|
||||
"type": "address[5]"
|
||||
},
|
||||
{
|
||||
"name": "orderValues",
|
||||
"type": "uint256[6]"
|
||||
},
|
||||
{
|
||||
"name": "cancelTakerTokenAmount",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "cancelOrder",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "ZRX_TOKEN_CONTRACT",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "orderAddresses",
|
||||
"type": "address[5][]"
|
||||
},
|
||||
{
|
||||
"name": "orderValues",
|
||||
"type": "uint256[6][]"
|
||||
},
|
||||
{
|
||||
"name": "fillTakerTokenAmounts",
|
||||
"type": "uint256[]"
|
||||
},
|
||||
{
|
||||
"name": "v",
|
||||
"type": "uint8[]"
|
||||
},
|
||||
{
|
||||
"name": "r",
|
||||
"type": "bytes32[]"
|
||||
},
|
||||
{
|
||||
"name": "s",
|
||||
"type": "bytes32[]"
|
||||
}
|
||||
],
|
||||
"name": "batchFillOrKillOrders",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "orderAddresses",
|
||||
"type": "address[5]"
|
||||
},
|
||||
{
|
||||
"name": "orderValues",
|
||||
"type": "uint256[6]"
|
||||
},
|
||||
{
|
||||
"name": "fillTakerTokenAmount",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "v",
|
||||
"type": "uint8"
|
||||
},
|
||||
{
|
||||
"name": "r",
|
||||
"type": "bytes32"
|
||||
},
|
||||
{
|
||||
"name": "s",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"name": "fillOrKillOrder",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "orderHash",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"name": "getUnavailableTakerTokenAmount",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "signer",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "hash",
|
||||
"type": "bytes32"
|
||||
},
|
||||
{
|
||||
"name": "v",
|
||||
"type": "uint8"
|
||||
},
|
||||
{
|
||||
"name": "r",
|
||||
"type": "bytes32"
|
||||
},
|
||||
{
|
||||
"name": "s",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"name": "isValidSignature",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "numerator",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "denominator",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "target",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "getPartialAmount",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "TOKEN_TRANSFER_PROXY_CONTRACT",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "orderAddresses",
|
||||
"type": "address[5][]"
|
||||
},
|
||||
{
|
||||
"name": "orderValues",
|
||||
"type": "uint256[6][]"
|
||||
},
|
||||
{
|
||||
"name": "fillTakerTokenAmounts",
|
||||
"type": "uint256[]"
|
||||
},
|
||||
{
|
||||
"name": "shouldThrowOnInsufficientBalanceOrAllowance",
|
||||
"type": "bool"
|
||||
},
|
||||
{
|
||||
"name": "v",
|
||||
"type": "uint8[]"
|
||||
},
|
||||
{
|
||||
"name": "r",
|
||||
"type": "bytes32[]"
|
||||
},
|
||||
{
|
||||
"name": "s",
|
||||
"type": "bytes32[]"
|
||||
}
|
||||
],
|
||||
"name": "batchFillOrders",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "orderAddresses",
|
||||
"type": "address[5][]"
|
||||
},
|
||||
{
|
||||
"name": "orderValues",
|
||||
"type": "uint256[6][]"
|
||||
},
|
||||
{
|
||||
"name": "cancelTakerTokenAmounts",
|
||||
"type": "uint256[]"
|
||||
}
|
||||
],
|
||||
"name": "batchCancelOrders",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "orderAddresses",
|
||||
"type": "address[5]"
|
||||
},
|
||||
{
|
||||
"name": "orderValues",
|
||||
"type": "uint256[6]"
|
||||
},
|
||||
{
|
||||
"name": "fillTakerTokenAmount",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "shouldThrowOnInsufficientBalanceOrAllowance",
|
||||
"type": "bool"
|
||||
},
|
||||
{
|
||||
"name": "v",
|
||||
"type": "uint8"
|
||||
},
|
||||
{
|
||||
"name": "r",
|
||||
"type": "bytes32"
|
||||
},
|
||||
{
|
||||
"name": "s",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"name": "fillOrder",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "filledTakerTokenAmount",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "orderAddresses",
|
||||
"type": "address[5]"
|
||||
},
|
||||
{
|
||||
"name": "orderValues",
|
||||
"type": "uint256[6]"
|
||||
}
|
||||
],
|
||||
"name": "getOrderHash",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "EXTERNAL_QUERY_GAS_LIMIT",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint16"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "VERSION",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_zrxToken",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_tokenTransferProxy",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"type": "constructor"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "maker",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "taker",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "feeRecipient",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "makerToken",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "takerToken",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "filledMakerTokenAmount",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "filledTakerTokenAmount",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "paidMakerFee",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "paidTakerFee",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "tokens",
|
||||
"type": "bytes32"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "orderHash",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"name": "LogFill",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "maker",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "feeRecipient",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "makerToken",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "takerToken",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "cancelledMakerTokenAmount",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "cancelledTakerTokenAmount",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "tokens",
|
||||
"type": "bytes32"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "orderHash",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"name": "LogCancel",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "errorId",
|
||||
"type": "uint8"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "orderHash",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"name": "LogError",
|
||||
"type": "event"
|
||||
}
|
||||
],
|
||||
"networks": {
|
||||
"1": {
|
||||
"address": "0x12459c951127e0c374ff9105dda097662a027093"
|
||||
},
|
||||
"3": {
|
||||
"address": "0x479cc461fecd078f766ecc58533d6f69580cf3ac"
|
||||
},
|
||||
"4": {
|
||||
"address": "0x1d16ef40fac01cec8adac2ac49427b9384192c05"
|
||||
},
|
||||
"42": {
|
||||
"address": "0x90fe2af704b34e0224bf2299c838e04d4dcf1364"
|
||||
},
|
||||
"50": {
|
||||
"address": "0x48bacb9266a570d521063ef5dd96e61686dbe788"
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,172 +0,0 @@
|
||||
{
|
||||
"contract_name": "Token",
|
||||
"abi": [
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_spender",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_value",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "approve",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "success",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "totalSupply",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "supply",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_from",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_to",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_value",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "transferFrom",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "success",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_owner",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "balanceOf",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "balance",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_to",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_value",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "transfer",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "success",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_owner",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_spender",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "allowance",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "remaining",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "_from",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "_to",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "_value",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "Transfer",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "_owner",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "_spender",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "_value",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "Approval",
|
||||
"type": "event"
|
||||
}
|
||||
]
|
||||
}
|
@@ -1,547 +0,0 @@
|
||||
{
|
||||
"contract_name": "TokenRegistry",
|
||||
"abi": [
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_token",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_index",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "removeToken",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_name",
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"name": "getTokenAddressByName",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_symbol",
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"name": "getTokenAddressBySymbol",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_token",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_swarmHash",
|
||||
"type": "bytes"
|
||||
}
|
||||
],
|
||||
"name": "setTokenSwarmHash",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_token",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "getTokenMetaData",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint8"
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"type": "bytes"
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"type": "bytes"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "owner",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_token",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_name",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "_symbol",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "_decimals",
|
||||
"type": "uint8"
|
||||
},
|
||||
{
|
||||
"name": "_ipfsHash",
|
||||
"type": "bytes"
|
||||
},
|
||||
{
|
||||
"name": "_swarmHash",
|
||||
"type": "bytes"
|
||||
}
|
||||
],
|
||||
"name": "addToken",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_token",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_name",
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"name": "setTokenName",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "tokens",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "token",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "name",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "symbol",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "decimals",
|
||||
"type": "uint8"
|
||||
},
|
||||
{
|
||||
"name": "ipfsHash",
|
||||
"type": "bytes"
|
||||
},
|
||||
{
|
||||
"name": "swarmHash",
|
||||
"type": "bytes"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "tokenAddresses",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_name",
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"name": "getTokenByName",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint8"
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"type": "bytes"
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"type": "bytes"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "getTokenAddresses",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address[]"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_token",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_ipfsHash",
|
||||
"type": "bytes"
|
||||
}
|
||||
],
|
||||
"name": "setTokenIpfsHash",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_symbol",
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"name": "getTokenBySymbol",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint8"
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"type": "bytes"
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"type": "bytes"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_token",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_symbol",
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"name": "setTokenSymbol",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "newOwner",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "transferOwnership",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "token",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "name",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "symbol",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "decimals",
|
||||
"type": "uint8"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "ipfsHash",
|
||||
"type": "bytes"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "swarmHash",
|
||||
"type": "bytes"
|
||||
}
|
||||
],
|
||||
"name": "LogAddToken",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "token",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "name",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "symbol",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "decimals",
|
||||
"type": "uint8"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "ipfsHash",
|
||||
"type": "bytes"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "swarmHash",
|
||||
"type": "bytes"
|
||||
}
|
||||
],
|
||||
"name": "LogRemoveToken",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "token",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "oldName",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "newName",
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"name": "LogTokenNameChange",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "token",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "oldSymbol",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "newSymbol",
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"name": "LogTokenSymbolChange",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "token",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "oldIpfsHash",
|
||||
"type": "bytes"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "newIpfsHash",
|
||||
"type": "bytes"
|
||||
}
|
||||
],
|
||||
"name": "LogTokenIpfsHashChange",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "token",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "oldSwarmHash",
|
||||
"type": "bytes"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "newSwarmHash",
|
||||
"type": "bytes"
|
||||
}
|
||||
],
|
||||
"name": "LogTokenSwarmHashChange",
|
||||
"type": "event"
|
||||
}
|
||||
],
|
||||
"networks": {
|
||||
"1": {
|
||||
"address": "0x926a74c5c36adf004c87399e65f75628b0f98d2c"
|
||||
},
|
||||
"3": {
|
||||
"address": "0x6b1a50f0bb5a7995444bd3877b22dc89c62843ed"
|
||||
},
|
||||
"4": {
|
||||
"address": "0x4e9aad8184de8833365fea970cd9149372fdf1e6"
|
||||
},
|
||||
"42": {
|
||||
"address": "0xf18e504561f4347bea557f3d4558f559dddbae7f"
|
||||
},
|
||||
"50": {
|
||||
"address": "0x0b1ba0af832d7c05fd64161e0db78e85978e8082"
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,187 +0,0 @@
|
||||
{
|
||||
"contract_name": "TokenTransferProxy",
|
||||
"abi": [
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "token",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "from",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "to",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "value",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "transferFrom",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "target",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "addAuthorizedAddress",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "authorities",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "target",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "removeAuthorizedAddress",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "owner",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "authorized",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "getAuthorizedAddresses",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address[]"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "newOwner",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "transferOwnership",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "target",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "caller",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "LogAuthorizedAddressAdded",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "target",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "caller",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "LogAuthorizedAddressRemoved",
|
||||
"type": "event"
|
||||
}
|
||||
],
|
||||
"networks": {
|
||||
"1": {
|
||||
"address": "0x8da0d80f5007ef1e431dd2127178d224e32c2ef4"
|
||||
},
|
||||
"3": {
|
||||
"address": "0x4e9aad8184de8833365fea970cd9149372fdf1e6"
|
||||
},
|
||||
"4": {
|
||||
"address": "0xa8e9fa8f91e5ae138c74648c9c304f1c75003a8d"
|
||||
},
|
||||
"42": {
|
||||
"address": "0x087eed4bc1ee3de49befbd66c662b434b15d49d4"
|
||||
},
|
||||
"50": {
|
||||
"address": "0x1dc4c1cefef38a777b15aa20260a54e584b16c48"
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"contract_name": "ZRX",
|
||||
"networks": {
|
||||
"1": {
|
||||
"address": "0xe41d2489571d322189246dafa5ebde1f4699f498"
|
||||
},
|
||||
"3": {
|
||||
"address": "0xa8e9fa8f91e5ae138c74648c9c304f1c75003a8d"
|
||||
},
|
||||
"4": {
|
||||
"address": "0x00f58d6d585f84b2d7267940cede30ce2fe6eae8"
|
||||
},
|
||||
"42": {
|
||||
"address": "0x6ff6c0ff1d68b964901f986d4c9fa3ac68346570"
|
||||
},
|
||||
"50": {
|
||||
"address": "0x1d7022f5b17d2f8b695918fb48fa1089c9f85401"
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,32 +1,38 @@
|
||||
export { ZeroEx } from './0x';
|
||||
|
||||
export { MessagePrefixType, MessagePrefixOpts } from '@0xproject/order-utils';
|
||||
export { Web3ProviderEngine, RPCSubprovider } from '@0xproject/subproviders';
|
||||
|
||||
export {
|
||||
BlockParamLiteral,
|
||||
FilterObject,
|
||||
BlockParam,
|
||||
ContractEventArg,
|
||||
ExchangeContractErrs,
|
||||
LogWithDecodedArgs,
|
||||
Order,
|
||||
Provider,
|
||||
SignedOrder,
|
||||
ECSignature,
|
||||
OrderStateValid,
|
||||
OrderStateInvalid,
|
||||
OrderState,
|
||||
Token,
|
||||
TransactionReceipt,
|
||||
TransactionReceiptWithDecodedLogs,
|
||||
ERC20AssetData,
|
||||
ERC721AssetData,
|
||||
AssetProxyId,
|
||||
} from '@0xproject/types';
|
||||
|
||||
export { OrderWatcherConfig } from '@0xproject/order-watcher';
|
||||
export {
|
||||
BlockParamLiteral,
|
||||
FilterObject,
|
||||
BlockParam,
|
||||
LogWithDecodedArgs,
|
||||
ContractEventArg,
|
||||
Provider,
|
||||
TransactionReceipt,
|
||||
TransactionReceiptWithDecodedLogs,
|
||||
} from 'ethereum-types';
|
||||
|
||||
export {
|
||||
EventCallback,
|
||||
ContractEvent,
|
||||
IndexedFilterValues,
|
||||
BlockRange,
|
||||
OrderCancellationRequest,
|
||||
OrderFillRequest,
|
||||
ContractEventArgs,
|
||||
MethodOpts,
|
||||
@@ -36,18 +42,25 @@ export {
|
||||
DecodedLogEvent,
|
||||
OnOrderStateChangeCallback,
|
||||
ContractWrappersError,
|
||||
EtherTokenContractEventArgs,
|
||||
WithdrawalContractEventArgs,
|
||||
DepositContractEventArgs,
|
||||
EtherTokenEvents,
|
||||
TransferContractEventArgs,
|
||||
ApprovalContractEventArgs,
|
||||
TokenContractEventArgs,
|
||||
TokenEvents,
|
||||
LogErrorContractEventArgs,
|
||||
LogCancelContractEventArgs,
|
||||
LogFillContractEventArgs,
|
||||
ExchangeContractEventArgs,
|
||||
ExchangeEvents,
|
||||
WETH9Events,
|
||||
WETH9WithdrawalEventArgs,
|
||||
WETH9ApprovalEventArgs,
|
||||
WETH9EventArgs,
|
||||
WETH9DepositEventArgs,
|
||||
WETH9TransferEventArgs,
|
||||
ERC20TokenTransferEventArgs,
|
||||
ERC20TokenApprovalEventArgs,
|
||||
ERC20TokenEvents,
|
||||
ERC20TokenEventArgs,
|
||||
ERC721TokenApprovalEventArgs,
|
||||
ERC721TokenApprovalForAllEventArgs,
|
||||
ERC721TokenTransferEventArgs,
|
||||
ERC721TokenEvents,
|
||||
ExchangeCancelUpToEventArgs,
|
||||
ExchangeAssetProxyRegisteredEventArgs,
|
||||
ExchangeFillEventArgs,
|
||||
ExchangeCancelEventArgs,
|
||||
ExchangeEventArgs,
|
||||
ContractWrappersConfig,
|
||||
OrderInfo,
|
||||
} from '@0xproject/contract-wrappers';
|
||||
|
@@ -8,8 +8,8 @@ export const zeroExPrivateNetworkConfigSchema = {
|
||||
gasPrice: { $ref: '/Number' },
|
||||
zrxContractAddress: { $ref: '/Address' },
|
||||
exchangeContractAddress: { $ref: '/Address' },
|
||||
tokenRegistryContractAddress: { $ref: '/Address' },
|
||||
tokenTransferProxyContractAddress: { $ref: '/Address' },
|
||||
erc20ProxyContractAddress: { $ref: '/Address' },
|
||||
erc721ProxyContractAddress: { $ref: '/Address' },
|
||||
orderWatcherConfig: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
@@ -29,7 +29,7 @@ export const zeroExPrivateNetworkConfigSchema = {
|
||||
'networkId',
|
||||
'zrxContractAddress',
|
||||
'exchangeContractAddress',
|
||||
'tokenRegistryContractAddress',
|
||||
'tokenTransferProxyContractAddress',
|
||||
'erc20ProxyContractAddress',
|
||||
'erc721ProxyContractAddress',
|
||||
],
|
||||
};
|
||||
|
@@ -22,8 +22,8 @@ export const zeroExPublicNetworkConfigSchema = {
|
||||
gasPrice: { $ref: '/Number' },
|
||||
zrxContractAddress: { $ref: '/Address' },
|
||||
exchangeContractAddress: { $ref: '/Address' },
|
||||
tokenRegistryContractAddress: { $ref: '/Address' },
|
||||
tokenTransferProxyContractAddress: { $ref: '/Address' },
|
||||
erc20ProxyContractAddress: { $ref: '/Address' },
|
||||
erc721ProxyContractAddress: { $ref: '/Address' },
|
||||
orderWatcherConfig: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
|
@@ -2,14 +2,13 @@ import { ContractWrappers } from '@0xproject/contract-wrappers';
|
||||
import { BlockchainLifecycle } from '@0xproject/dev-utils';
|
||||
import { BigNumber } from '@0xproject/utils';
|
||||
import * as chai from 'chai';
|
||||
import * as _ from 'lodash';
|
||||
import 'mocha';
|
||||
|
||||
import { ApprovalContractEventArgs, LogWithDecodedArgs, TokenEvents, ZeroEx } from '../src';
|
||||
import { ERC20TokenApprovalEventArgs, ERC20TokenEvents, LogWithDecodedArgs, ZeroEx } from '../src';
|
||||
|
||||
import { chaiSetup } from './utils/chai_setup';
|
||||
import { constants } from './utils/constants';
|
||||
import { TokenUtils } from './utils/token_utils';
|
||||
import { tokenUtils } from './utils/token_utils';
|
||||
import { provider, web3Wrapper } from './utils/web3_wrapper';
|
||||
|
||||
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
||||
@@ -28,9 +27,7 @@ describe('ZeroEx library', () => {
|
||||
it('overrides provider in nested web3s and invalidates contractInstances', async () => {
|
||||
// Instantiate the contract instances with the current provider
|
||||
await (zeroEx.exchange as any)._getExchangeContractAsync();
|
||||
await (zeroEx.tokenRegistry as any)._getTokenRegistryContractAsync();
|
||||
expect((zeroEx.exchange as any)._exchangeContractIfExists).to.not.be.undefined();
|
||||
expect((zeroEx.tokenRegistry as any)._tokenRegistryContractIfExists).to.not.be.undefined();
|
||||
|
||||
// Add property to newProvider so that we can differentiate it from old provider
|
||||
(provider as any).zeroExTestId = 1;
|
||||
@@ -38,52 +35,43 @@ describe('ZeroEx library', () => {
|
||||
|
||||
// Check that contractInstances with old provider are removed after provider update
|
||||
expect((zeroEx.exchange as any)._exchangeContractIfExists).to.be.undefined();
|
||||
expect((zeroEx.tokenRegistry as any)._tokenRegistryContractIfExists).to.be.undefined();
|
||||
|
||||
// Check that all nested zeroExContract/web3Wrapper instances return the updated provider
|
||||
const nestedWeb3WrapperProvider = ((zeroEx as any)._contractWrappers as ContractWrappers).getProvider();
|
||||
expect((nestedWeb3WrapperProvider as any).zeroExTestId).to.be.a('number');
|
||||
const exchangeWeb3WrapperProvider = (zeroEx.exchange as any)._web3Wrapper.getProvider();
|
||||
expect(exchangeWeb3WrapperProvider.zeroExTestId).to.be.a('number');
|
||||
const tokenRegistryWeb3WrapperProvider = (zeroEx.tokenRegistry as any)._web3Wrapper.getProvider();
|
||||
expect(tokenRegistryWeb3WrapperProvider.zeroExTestId).to.be.a('number');
|
||||
});
|
||||
});
|
||||
describe('#isValidSignature', () => {
|
||||
// The Exchange smart contract `isValidSignature` method only validates orderHashes and assumes
|
||||
// the length of the data is exactly 32 bytes. Thus for these tests, we use data of this size.
|
||||
const dataHex = '0x6927e990021d23b1eb7b8789f6a6feaf98fe104bb0cf8259421b79f9a34222b0';
|
||||
const signature = {
|
||||
v: 27,
|
||||
r: '0x61a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33',
|
||||
s: '0x40349190569279751135161d22529dc25add4f6069af05be04cacbda2ace2254',
|
||||
};
|
||||
const ethSignSignature =
|
||||
'0x1B61a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc3340349190569279751135161d22529dc25add4f6069af05be04cacbda2ace225403';
|
||||
const address = '0x5409ed021d9299bf6814279a6a1411a7e866a631';
|
||||
it("should return false if the data doesn't pertain to the signature & address", async () => {
|
||||
return expect(
|
||||
(zeroEx.exchange as any)._isValidSignatureUsingContractCallAsync('0x0', signature, address),
|
||||
).to.become(false);
|
||||
return expect((zeroEx.exchange as any).isValidSignatureAsync('0x0', address, ethSignSignature)).to.become(
|
||||
false,
|
||||
);
|
||||
});
|
||||
it("should return false if the address doesn't pertain to the signature & data", async () => {
|
||||
const validUnrelatedAddress = '0x8b0292b11a196601ed2ce54b665cafeca0347d42';
|
||||
return expect(
|
||||
(zeroEx.exchange as any)._isValidSignatureUsingContractCallAsync(
|
||||
dataHex,
|
||||
signature,
|
||||
validUnrelatedAddress,
|
||||
),
|
||||
(zeroEx.exchange as any).isValidSignatureAsync(dataHex, validUnrelatedAddress, ethSignSignature),
|
||||
).to.become(false);
|
||||
});
|
||||
it("should return false if the signature doesn't pertain to the dataHex & address", async () => {
|
||||
const wrongSignature = _.assign({}, signature, { v: 28 });
|
||||
return expect(
|
||||
(zeroEx.exchange as any)._isValidSignatureUsingContractCallAsync(dataHex, wrongSignature, address),
|
||||
).to.become(false);
|
||||
const signatureArray = ethSignSignature.split('');
|
||||
// tslint:disable-next-line:custom-no-magic-numbers
|
||||
signatureArray[5] = 'C'; // V = 28, instead of 27
|
||||
const wrongSignature = signatureArray.join('');
|
||||
return expect((zeroEx.exchange as any).isValidSignatureAsync(dataHex, address, wrongSignature)).to.become(
|
||||
false,
|
||||
);
|
||||
});
|
||||
it('should return true if the signature does pertain to the dataHex & address', async () => {
|
||||
return expect(
|
||||
(zeroEx.exchange as any)._isValidSignatureUsingContractCallAsync(dataHex, signature, address),
|
||||
).to.become(true);
|
||||
return expect((zeroEx.exchange as any).isValidSignatureAsync(dataHex, address, ethSignSignature)).to.become(
|
||||
true,
|
||||
);
|
||||
});
|
||||
});
|
||||
describe('#toUnitAmount', () => {
|
||||
@@ -128,18 +116,16 @@ describe('ZeroEx library', () => {
|
||||
it('returns transaction receipt with decoded logs', async () => {
|
||||
const availableAddresses = await zeroEx.getAvailableAddressesAsync();
|
||||
const coinbase = availableAddresses[0];
|
||||
const tokens = await zeroEx.tokenRegistry.getTokensAsync();
|
||||
const tokenUtils = new TokenUtils(tokens);
|
||||
const zrxTokenAddress = tokenUtils.getProtocolTokenOrThrow().address;
|
||||
const proxyAddress = zeroEx.proxy.getContractAddress();
|
||||
const txHash = await zeroEx.token.setUnlimitedProxyAllowanceAsync(zrxTokenAddress, coinbase);
|
||||
const zrxTokenAddress = tokenUtils.getProtocolTokenAddress();
|
||||
const erc20ProxyAddress = zeroEx.erc20Proxy.getContractAddress();
|
||||
const txHash = await zeroEx.erc20Token.setUnlimitedProxyAllowanceAsync(zrxTokenAddress, coinbase);
|
||||
const txReceiptWithDecodedLogs = await zeroEx.awaitTransactionMinedAsync(txHash);
|
||||
// tslint:disable-next-line:no-unnecessary-type-assertion
|
||||
const log = txReceiptWithDecodedLogs.logs[0] as LogWithDecodedArgs<ApprovalContractEventArgs>;
|
||||
expect(log.event).to.be.equal(TokenEvents.Approval);
|
||||
const log = txReceiptWithDecodedLogs.logs[0] as LogWithDecodedArgs<ERC20TokenApprovalEventArgs>;
|
||||
expect(log.event).to.be.equal(ERC20TokenEvents.Approval);
|
||||
expect(log.args._owner).to.be.equal(coinbase);
|
||||
expect(log.args._spender).to.be.equal(proxyAddress);
|
||||
expect(log.args._value).to.be.bignumber.equal(zeroEx.token.UNLIMITED_ALLOWANCE_IN_BASE_UNITS);
|
||||
expect(log.args._spender).to.be.equal(erc20ProxyAddress);
|
||||
expect(log.args._value).to.be.bignumber.equal(zeroEx.erc20Token.UNLIMITED_ALLOWANCE_IN_BASE_UNITS);
|
||||
});
|
||||
});
|
||||
describe('#config', () => {
|
||||
@@ -151,15 +137,13 @@ describe('ZeroEx library', () => {
|
||||
const zeroExWithWrongExchangeAddress = new ZeroEx(provider, zeroExConfig);
|
||||
expect(zeroExWithWrongExchangeAddress.exchange.getContractAddress()).to.be.equal(ZeroEx.NULL_ADDRESS);
|
||||
});
|
||||
it('allows to specify token registry token contract address', async () => {
|
||||
it('allows to specify erc20Proxy contract address', async () => {
|
||||
const zeroExConfig = {
|
||||
tokenRegistryContractAddress: ZeroEx.NULL_ADDRESS,
|
||||
erc20ProxyContractAddress: ZeroEx.NULL_ADDRESS,
|
||||
networkId: constants.TESTRPC_NETWORK_ID,
|
||||
};
|
||||
const zeroExWithWrongTokenRegistryAddress = new ZeroEx(provider, zeroExConfig);
|
||||
expect(zeroExWithWrongTokenRegistryAddress.tokenRegistry.getContractAddress()).to.be.equal(
|
||||
ZeroEx.NULL_ADDRESS,
|
||||
);
|
||||
const zeroExWithWrongERC20ProxyAddress = new ZeroEx(provider, zeroExConfig);
|
||||
expect(zeroExWithWrongERC20ProxyAddress.erc20Proxy.getContractAddress()).to.be.equal(ZeroEx.NULL_ADDRESS);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -1,48 +0,0 @@
|
||||
import { web3Factory } from '@0xproject/dev-utils';
|
||||
|
||||
import { ZeroEx } from '../src';
|
||||
|
||||
import { chaiSetup } from './utils/chai_setup';
|
||||
import { constants } from './utils/constants';
|
||||
|
||||
chaiSetup.configure();
|
||||
|
||||
// Those tests are slower cause they're talking to a remote node
|
||||
const TIMEOUT = 10000;
|
||||
|
||||
describe('Artifacts', () => {
|
||||
describe('contracts are deployed on kovan', () => {
|
||||
const kovanRpcUrl = constants.KOVAN_RPC_URL;
|
||||
const provider = web3Factory.getRpcProvider({ rpcUrl: kovanRpcUrl });
|
||||
const config = {
|
||||
networkId: constants.KOVAN_NETWORK_ID,
|
||||
};
|
||||
const zeroEx = new ZeroEx(provider, config);
|
||||
it('token registry contract is deployed', async () => {
|
||||
await (zeroEx.tokenRegistry as any)._getTokenRegistryContractAsync();
|
||||
}).timeout(TIMEOUT);
|
||||
it('proxy contract is deployed', async () => {
|
||||
await (zeroEx.proxy as any)._getTokenTransferProxyContractAsync();
|
||||
}).timeout(TIMEOUT);
|
||||
it('exchange contract is deployed', async () => {
|
||||
await (zeroEx.exchange as any)._getExchangeContractAsync();
|
||||
}).timeout(TIMEOUT);
|
||||
});
|
||||
describe('contracts are deployed on ropsten', () => {
|
||||
const ropstenRpcUrl = constants.ROPSTEN_RPC_URL;
|
||||
const provider = web3Factory.getRpcProvider({ rpcUrl: ropstenRpcUrl });
|
||||
const config = {
|
||||
networkId: constants.ROPSTEN_NETWORK_ID,
|
||||
};
|
||||
const zeroEx = new ZeroEx(provider, config);
|
||||
it('token registry contract is deployed', async () => {
|
||||
await (zeroEx.tokenRegistry as any)._getTokenRegistryContractAsync();
|
||||
}).timeout(TIMEOUT);
|
||||
it('proxy contract is deployed', async () => {
|
||||
await (zeroEx.proxy as any)._getTokenTransferProxyContractAsync();
|
||||
}).timeout(TIMEOUT);
|
||||
it('exchange contract is deployed', async () => {
|
||||
await (zeroEx.exchange as any)._getExchangeContractAsync();
|
||||
}).timeout(TIMEOUT);
|
||||
});
|
||||
});
|
@@ -1,5 +1,5 @@
|
||||
import { devConstants } from '@0xproject/dev-utils';
|
||||
import { runV1MigrationsAsync } from '@0xproject/migrations';
|
||||
import { runV2MigrationsAsync } from '@0xproject/migrations';
|
||||
|
||||
import { provider } from './utils/web3_wrapper';
|
||||
|
||||
@@ -7,11 +7,11 @@ before('migrate contracts', async function(): Promise<void> {
|
||||
// HACK: Since the migrations take longer then our global mocha timeout limit
|
||||
// we manually increase it for this before hook.
|
||||
const mochaTestTimeoutMs = 20000;
|
||||
this.timeout(mochaTestTimeoutMs);
|
||||
this.timeout(mochaTestTimeoutMs); // tslint:disable-line:no-invalid-this
|
||||
const txDefaults = {
|
||||
gas: devConstants.GAS_LIMIT,
|
||||
from: devConstants.TESTRPC_FIRST_ADDRESS,
|
||||
};
|
||||
const artifactsDir = `../migrations/artifacts/1.0.0`;
|
||||
await runV1MigrationsAsync(provider, artifactsDir, txDefaults);
|
||||
const artifactsDir = `../migrations/artifacts/2.0.0`;
|
||||
await runV2MigrationsAsync(provider, artifactsDir, txDefaults);
|
||||
});
|
||||
|
@@ -1,34 +1,9 @@
|
||||
import { Token } from '@0xproject/types';
|
||||
import * as _ from 'lodash';
|
||||
import { artifacts } from '../../src/artifacts';
|
||||
|
||||
import { InternalZeroExError } from '../../src/types';
|
||||
import { constants } from './constants';
|
||||
|
||||
const PROTOCOL_TOKEN_SYMBOL = 'ZRX';
|
||||
const WETH_TOKEN_SYMBOL = 'WETH';
|
||||
|
||||
export class TokenUtils {
|
||||
private _tokens: Token[];
|
||||
constructor(tokens: Token[]) {
|
||||
this._tokens = tokens;
|
||||
}
|
||||
public getProtocolTokenOrThrow(): Token {
|
||||
const zrxToken = _.find(this._tokens, { symbol: PROTOCOL_TOKEN_SYMBOL });
|
||||
if (_.isUndefined(zrxToken)) {
|
||||
throw new Error(InternalZeroExError.ZrxNotInTokenRegistry);
|
||||
}
|
||||
return zrxToken;
|
||||
}
|
||||
public getWethTokenOrThrow(): Token {
|
||||
const wethToken = _.find(this._tokens, { symbol: WETH_TOKEN_SYMBOL });
|
||||
if (_.isUndefined(wethToken)) {
|
||||
throw new Error(InternalZeroExError.WethNotInTokenRegistry);
|
||||
}
|
||||
return wethToken;
|
||||
}
|
||||
public getDummyTokens(): Token[] {
|
||||
const dummyTokens = _.filter(this._tokens, token => {
|
||||
return !_.includes([PROTOCOL_TOKEN_SYMBOL, WETH_TOKEN_SYMBOL], token.symbol);
|
||||
});
|
||||
return dummyTokens;
|
||||
}
|
||||
}
|
||||
export const tokenUtils = {
|
||||
getProtocolTokenAddress(): string {
|
||||
return artifacts.ZRXToken.networks[constants.TESTRPC_NETWORK_ID].address;
|
||||
},
|
||||
};
|
||||
|
@@ -1,8 +1,12 @@
|
||||
import { web3Factory } from '@0xproject/dev-utils';
|
||||
import { Provider } from '@0xproject/types';
|
||||
import { devConstants, web3Factory } from '@0xproject/dev-utils';
|
||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||
import { Provider } from 'ethereum-types';
|
||||
|
||||
const txDefaults = {
|
||||
from: devConstants.TESTRPC_FIRST_ADDRESS,
|
||||
gas: devConstants.GAS_LIMIT,
|
||||
};
|
||||
const provider: Provider = web3Factory.getRpcProvider({ shouldUseInProcessGanache: true });
|
||||
const web3Wrapper = new Web3Wrapper(provider);
|
||||
|
||||
export { provider, web3Wrapper };
|
||||
export { provider, web3Wrapper, txDefaults };
|
||||
|
@@ -1,6 +1,44 @@
|
||||
[
|
||||
{
|
||||
"version": "0.4.0",
|
||||
"timestamp": 1532619515,
|
||||
"version": "1.0.4",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1532614997,
|
||||
"version": "1.0.3",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1532605697,
|
||||
"version": "1.0.2",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"version": "1.0.1",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Fix the abi-gen entry point in package.json",
|
||||
"pr": 901
|
||||
}
|
||||
],
|
||||
"timestamp": 1532357734
|
||||
},
|
||||
{
|
||||
"timestamp": 1532043000,
|
||||
"version": "1.0.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Convert e_r_c to erc in generated file names",
|
||||
@@ -9,6 +47,28 @@
|
||||
{
|
||||
"note": "Remove the output directory before writing to it",
|
||||
"pr": 822
|
||||
},
|
||||
{
|
||||
"note": "skip generation of wrappers that are already up to date",
|
||||
"pr": 788
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1531919263,
|
||||
"version": "0.3.4",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1531149657,
|
||||
"version": "0.3.3",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@@ -1,10 +1,40 @@
|
||||
<!--
|
||||
This file is auto-generated using the monorepo-scripts package. Don't edit directly.
|
||||
changelogUtils.file is auto-generated using the monorepo-scripts package. Don't edit directly.
|
||||
Edit the package's CHANGELOG.json file only.
|
||||
-->
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v1.0.4 - _July 26, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.0.3 - _July 26, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.0.2 - _July 26, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.0.1 - _July 23, 2018_
|
||||
|
||||
* Fix the abi-gen entry point in package.json (#901)
|
||||
|
||||
## v1.0.0 - _July 20, 2018_
|
||||
|
||||
* Convert e_r_c to erc in generated file names (#822)
|
||||
* Remove the output directory before writing to it (#822)
|
||||
* skip generation of wrappers that are already up to date (#788)
|
||||
|
||||
## v0.3.4 - _July 18, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.3.3 - _July 9, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.3.2 - _June 19, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
@@ -1,2 +1,2 @@
|
||||
#!/usr/bin/env node
|
||||
require('../lib/index.js')
|
||||
require('../lib/src/index.js');
|
||||
|
0
packages/abi-gen/coverage/.gitkeep
Normal file
0
packages/abi-gen/coverage/.gitkeep
Normal file
@@ -1,17 +1,22 @@
|
||||
{
|
||||
"name": "@0xproject/abi-gen",
|
||||
"version": "0.3.2",
|
||||
"version": "1.0.4",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
"description": "Generate contract wrappers from ABI and handlebars templates",
|
||||
"main": "lib/index.js",
|
||||
"types": "lib/index.d.ts",
|
||||
"main": "lib/src/index.js",
|
||||
"types": "lib/src/index.d.ts",
|
||||
"scripts": {
|
||||
"watch_without_deps": "tsc -w",
|
||||
"lint": "tslint --project .",
|
||||
"clean": "shx rm -rf lib scripts",
|
||||
"build": "tsc && copyfiles -u 2 './lib/monorepo_scripts/**/*' ./scripts",
|
||||
"test": "yarn run_mocha",
|
||||
"run_mocha": "mocha --require source-map-support/register --require make-promises-safe lib/test/**/*_test.js --bail --exit",
|
||||
"test:circleci": "yarn test:coverage",
|
||||
"test:coverage": "nyc npm run test --all && yarn coverage:report:lcov",
|
||||
"coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info",
|
||||
"manual:postpublish": "yarn build; node ./scripts/postpublish.js"
|
||||
},
|
||||
"bin": {
|
||||
@@ -27,32 +32,37 @@
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/0x-monorepo/packages/abi-gen/README.md",
|
||||
"dependencies": {
|
||||
"@0xproject/typescript-typings": "^0.4.1",
|
||||
"@0xproject/utils": "^0.7.1",
|
||||
"ethereum-types": "^0.0.2",
|
||||
"@0xproject/typescript-typings": "^1.0.3",
|
||||
"@0xproject/utils": "^1.0.4",
|
||||
"chalk": "^2.3.0",
|
||||
"ethereum-types": "^1.0.3",
|
||||
"glob": "^7.1.2",
|
||||
"handlebars": "^4.0.11",
|
||||
"lodash": "^4.17.4",
|
||||
"rimraf": "^2.6.2",
|
||||
"mkdirp": "^0.5.1",
|
||||
"sleep": "^5.1.1",
|
||||
"tmp": "^0.0.33",
|
||||
"to-snake-case": "^1.0.0",
|
||||
"yargs": "^10.0.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@0xproject/monorepo-scripts": "^0.2.1",
|
||||
"@0xproject/tslint-config": "^0.4.20",
|
||||
"@types/glob": "^5.0.33",
|
||||
"@types/rimraf": "^2.0.2",
|
||||
"@0xproject/monorepo-scripts": "^1.0.4",
|
||||
"@0xproject/tslint-config": "^1.0.4",
|
||||
"@types/glob": "5.0.35",
|
||||
"@types/handlebars": "^4.0.36",
|
||||
"@types/mkdirp": "^0.5.1",
|
||||
"@types/node": "^8.0.53",
|
||||
"@types/sleep": "^0.0.7",
|
||||
"@types/tmp": "^0.0.33",
|
||||
"@types/yargs": "^10.0.0",
|
||||
"chai": "^4.1.2",
|
||||
"copyfiles": "^1.2.0",
|
||||
"dirty-chai": "^2.0.1",
|
||||
"make-promises-safe": "^1.1.0",
|
||||
"mocha": "^5.2.0",
|
||||
"npm-run-all": "^4.1.2",
|
||||
"shx": "^0.2.2",
|
||||
"tslint": "5.8.0",
|
||||
"tslint": "5.11.0",
|
||||
"typescript": "2.7.1"
|
||||
},
|
||||
"publishConfig": {
|
||||
|
@@ -3,16 +3,12 @@
|
||||
import { abiUtils, logUtils } from '@0xproject/utils';
|
||||
import chalk from 'chalk';
|
||||
import { AbiDefinition, ConstructorAbi, EventAbi, MethodAbi } from 'ethereum-types';
|
||||
import * as fs from 'fs';
|
||||
import { sync as globSync } from 'glob';
|
||||
import * as Handlebars from 'handlebars';
|
||||
import * as _ from 'lodash';
|
||||
import * as mkdirp from 'mkdirp';
|
||||
import * as rimraf from 'rimraf';
|
||||
import * as yargs from 'yargs';
|
||||
|
||||
import toSnakeCase = require('to-snake-case');
|
||||
|
||||
import { ContextData, ContractsBackend, ParamKind } from './types';
|
||||
import { utils } from './utils';
|
||||
|
||||
@@ -71,16 +67,6 @@ function registerPartials(partialsGlob: string): void {
|
||||
}
|
||||
}
|
||||
|
||||
function writeOutputFile(name: string, renderedTsCode: string): void {
|
||||
let fileName = toSnakeCase(name);
|
||||
// HACK: Snake case doesn't make a lot of sense for abbreviated names but we can't reliably detect abbreviations
|
||||
// so we special-case the abbreviations we use.
|
||||
fileName = fileName.replace('z_r_x', 'zrx').replace('e_r_c', 'erc');
|
||||
const filePath = `${args.output}/${fileName}.ts`;
|
||||
fs.writeFileSync(filePath, renderedTsCode);
|
||||
logUtils.log(`Created: ${chalk.bold(filePath)}`);
|
||||
}
|
||||
|
||||
Handlebars.registerHelper('parameterType', utils.solTypeToTsType.bind(utils, ParamKind.Input, args.backend));
|
||||
Handlebars.registerHelper('returnType', utils.solTypeToTsType.bind(utils, ParamKind.Output, args.backend));
|
||||
if (args.partials) {
|
||||
@@ -97,7 +83,6 @@ if (_.isEmpty(abiFileNames)) {
|
||||
process.exit(1);
|
||||
} else {
|
||||
logUtils.log(`Found ${chalk.green(`${abiFileNames.length}`)} ${chalk.bold('ABI')} files`);
|
||||
rimraf.sync(args.output);
|
||||
mkdirp.sync(args.output);
|
||||
}
|
||||
for (const abiFileName of abiFileNames) {
|
||||
@@ -120,6 +105,14 @@ for (const abiFileName of abiFileNames) {
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const outFileName = utils.makeOutputFileName(namedContent.name);
|
||||
const outFilePath = `${args.output}/${outFileName}.ts`;
|
||||
|
||||
if (utils.isOutputFileUpToDate(abiFileName, outFilePath)) {
|
||||
logUtils.log(`Already up to date: ${chalk.bold(outFilePath)}`);
|
||||
continue;
|
||||
}
|
||||
|
||||
let ctor = ABI.find((abi: AbiDefinition) => abi.type === ABI_TYPE_CONSTRUCTOR) as ConstructorAbi;
|
||||
if (_.isUndefined(ctor)) {
|
||||
ctor = utils.getEmptyConstructor(); // The constructor exists, but it's implicit in JSON's ABI definition
|
||||
@@ -154,5 +147,6 @@ for (const abiFileName of abiFileNames) {
|
||||
events: eventAbis,
|
||||
};
|
||||
const renderedTsCode = template(contextData);
|
||||
writeOutputFile(namedContent.name, renderedTsCode);
|
||||
utils.writeOutputFile(outFilePath, renderedTsCode);
|
||||
logUtils.log(`Created: ${chalk.bold(outFilePath)}`);
|
||||
}
|
||||
|
@@ -2,6 +2,7 @@ import { AbiType, ConstructorAbi, DataItem } from 'ethereum-types';
|
||||
import * as fs from 'fs';
|
||||
import * as _ from 'lodash';
|
||||
import * as path from 'path';
|
||||
import toSnakeCase = require('to-snake-case');
|
||||
|
||||
import { ContractsBackend, ParamKind } from './types';
|
||||
|
||||
@@ -92,4 +93,27 @@ export const utils = {
|
||||
inputs: [],
|
||||
};
|
||||
},
|
||||
makeOutputFileName(name: string): string {
|
||||
let fileName = toSnakeCase(name);
|
||||
// HACK: Snake case doesn't make a lot of sense for abbreviated names but we can't reliably detect abbreviations
|
||||
// so we special-case the abbreviations we use.
|
||||
fileName = fileName.replace('z_r_x', 'zrx').replace('e_r_c', 'erc');
|
||||
return fileName;
|
||||
},
|
||||
writeOutputFile(filePath: string, renderedTsCode: string): void {
|
||||
fs.writeFileSync(filePath, renderedTsCode);
|
||||
},
|
||||
isOutputFileUpToDate(abiFile: string, outputFile: string): boolean {
|
||||
const abiFileModTimeMs = fs.statSync(abiFile).mtimeMs;
|
||||
try {
|
||||
const outFileModTimeMs = fs.statSync(outputFile).mtimeMs;
|
||||
return outFileModTimeMs > abiFileModTimeMs;
|
||||
} catch (err) {
|
||||
if (err.code === 'ENOENT') {
|
||||
return false;
|
||||
} else {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
86
packages/abi-gen/test/utils_test.ts
Normal file
86
packages/abi-gen/test/utils_test.ts
Normal file
@@ -0,0 +1,86 @@
|
||||
import * as chai from 'chai';
|
||||
import * as dirtyChai from 'dirty-chai';
|
||||
import * as fs from 'fs';
|
||||
import 'mocha';
|
||||
import * as tmp from 'tmp';
|
||||
|
||||
import { utils } from '../src/utils';
|
||||
|
||||
tmp.setGracefulCleanup(); // remove tmp files even if there are failures
|
||||
|
||||
chai.use(dirtyChai);
|
||||
|
||||
const expect = chai.expect;
|
||||
|
||||
describe('makeOutputFileName()', () => {
|
||||
it('should handle Metacoin usage', () => {
|
||||
expect(utils.makeOutputFileName('Metacoin')).to.equal('metacoin');
|
||||
});
|
||||
it('should handle special zrx_token case', () => {
|
||||
expect(utils.makeOutputFileName('ZRXToken')).to.equal('zrx_token');
|
||||
});
|
||||
it('should handle special erc_token case', () => {
|
||||
expect(utils.makeOutputFileName('ERC20Token')).to.equal('erc20_token');
|
||||
});
|
||||
});
|
||||
|
||||
describe('writeOutputFile()', () => {
|
||||
let tempFilePath: string;
|
||||
before(() => {
|
||||
tempFilePath = tmp.fileSync(
|
||||
{ discardDescriptor: true }, // close file (so we can update it)
|
||||
).name;
|
||||
});
|
||||
it('should write content to output file', () => {
|
||||
const content = 'hello world';
|
||||
|
||||
utils.writeOutputFile(tempFilePath, content);
|
||||
|
||||
expect(fs.readFileSync(tempFilePath).toString()).to.equal(content);
|
||||
});
|
||||
});
|
||||
|
||||
describe('isOutputFileUpToDate()', () => {
|
||||
it('should throw ENOENT when there is no abi file', () => {
|
||||
expect(utils.isOutputFileUpToDate.bind('nonexistant1', 'nonexistant2')).to.throw('ENOENT');
|
||||
});
|
||||
|
||||
describe('when the abi input file exists', () => {
|
||||
let abiFile: string;
|
||||
before(() => {
|
||||
abiFile = tmp.fileSync(
|
||||
{ discardDescriptor: true }, // close file (set timestamp)
|
||||
).name;
|
||||
});
|
||||
|
||||
describe('without an existing output file', () => {
|
||||
it('should return false', () => {
|
||||
expect(utils.isOutputFileUpToDate(abiFile, 'nonexistant_file')).to.be.false();
|
||||
});
|
||||
});
|
||||
|
||||
describe('with an existing output file', () => {
|
||||
let outputFile: string;
|
||||
before(() => {
|
||||
outputFile = tmp.fileSync(
|
||||
{ discardDescriptor: true }, // close file (set timestamp)
|
||||
).name;
|
||||
const abiFileModTimeMs = fs.statSync(abiFile).mtimeMs;
|
||||
const outfileModTimeMs = abiFileModTimeMs + 1;
|
||||
fs.utimesSync(outputFile, outfileModTimeMs, outfileModTimeMs);
|
||||
});
|
||||
|
||||
it('should return true when output file is newer than abi file', async () => {
|
||||
expect(utils.isOutputFileUpToDate(abiFile, outputFile)).to.be.true();
|
||||
});
|
||||
|
||||
it('should return false when output file exists but is older than abi file', () => {
|
||||
const outFileModTimeMs = fs.statSync(outputFile).mtimeMs;
|
||||
const abiFileModTimeMs = outFileModTimeMs + 1;
|
||||
fs.utimesSync(abiFile, abiFileModTimeMs, abiFileModTimeMs);
|
||||
|
||||
expect(utils.isOutputFileUpToDate(abiFile, outputFile)).to.be.false();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
@@ -1,6 +1,43 @@
|
||||
[
|
||||
{
|
||||
"version": "0.2.13",
|
||||
"timestamp": 1532619515,
|
||||
"version": "1.0.4",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1532614997,
|
||||
"version": "1.0.3",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1532605697,
|
||||
"version": "1.0.2",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1532357734,
|
||||
"version": "1.0.1",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1532043000,
|
||||
"version": "1.0.0",
|
||||
"changes": [
|
||||
{
|
||||
"note":
|
||||
@@ -9,6 +46,24 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1531919263,
|
||||
"version": "0.2.14",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1531149657,
|
||||
"version": "0.2.13",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1529397769,
|
||||
"version": "0.2.12",
|
||||
|
@@ -1,10 +1,38 @@
|
||||
<!--
|
||||
This file is auto-generated using the monorepo-scripts package. Don't edit directly.
|
||||
changelogUtils.file is auto-generated using the monorepo-scripts package. Don't edit directly.
|
||||
Edit the package's CHANGELOG.json file only.
|
||||
-->
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v1.0.4 - _July 26, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.0.3 - _July 26, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.0.2 - _July 26, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.0.1 - _July 23, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.0.0 - _July 20, 2018_
|
||||
|
||||
* Fix bug in string enum assertion. We erroneously were checking against the enum keys, not values (#821)
|
||||
|
||||
## v0.2.14 - _July 18, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.2.13 - _July 9, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.2.12 - _June 19, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0xproject/assert",
|
||||
"version": "0.3.0",
|
||||
"version": "1.0.4",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
@@ -13,7 +13,6 @@
|
||||
"clean": "shx rm -rf lib test_temp scripts",
|
||||
"lint": "tslint --project .",
|
||||
"run_mocha": "mocha --require source-map-support/register --require make-promises-safe lib/test/**/*_test.js --exit",
|
||||
"prepublishOnly": "run-p build",
|
||||
"test": "yarn run_mocha",
|
||||
"rebuild_and_test": "run-s clean build test",
|
||||
"test:coverage": "nyc npm run test --all && yarn coverage:report:lcov",
|
||||
@@ -31,8 +30,8 @@
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/0x-monorepo/packages/assert/README.md",
|
||||
"devDependencies": {
|
||||
"@0xproject/monorepo-scripts": "^0.2.1",
|
||||
"@0xproject/tslint-config": "^0.4.20",
|
||||
"@0xproject/monorepo-scripts": "^1.0.4",
|
||||
"@0xproject/tslint-config": "^1.0.4",
|
||||
"@types/lodash": "4.14.104",
|
||||
"@types/mocha": "^2.2.42",
|
||||
"@types/valid-url": "^1.0.2",
|
||||
@@ -44,13 +43,13 @@
|
||||
"npm-run-all": "^4.1.2",
|
||||
"nyc": "^11.0.1",
|
||||
"shx": "^0.2.2",
|
||||
"tslint": "5.8.0",
|
||||
"tslint": "5.11.0",
|
||||
"typescript": "2.7.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0xproject/json-schemas": "^1.0.0",
|
||||
"@0xproject/typescript-typings": "^0.4.1",
|
||||
"@0xproject/utils": "^0.7.1",
|
||||
"@0xproject/json-schemas": "^1.0.1-rc.3",
|
||||
"@0xproject/typescript-typings": "^1.0.3",
|
||||
"@0xproject/utils": "^1.0.4",
|
||||
"lodash": "^4.17.4",
|
||||
"valid-url": "^1.0.9"
|
||||
},
|
||||
|
@@ -8,33 +8,33 @@ const HEX_REGEX = /^0x[0-9A-F]*$/i;
|
||||
export const assert = {
|
||||
isBigNumber(variableName: string, value: BigNumber): void {
|
||||
const isBigNumber = _.isObject(value) && (value as any).isBigNumber;
|
||||
this.assert(isBigNumber, this.typeAssertionMessage(variableName, 'BigNumber', value));
|
||||
assert.assert(isBigNumber, assert.typeAssertionMessage(variableName, 'BigNumber', value));
|
||||
},
|
||||
isValidBaseUnitAmount(variableName: string, value: BigNumber): void {
|
||||
assert.isBigNumber(variableName, value);
|
||||
const isNegative = value.lessThan(0);
|
||||
this.assert(!isNegative, `${variableName} cannot be a negative number, found value: ${value.toNumber()}`);
|
||||
assert.assert(!isNegative, `${variableName} cannot be a negative number, found value: ${value.toNumber()}`);
|
||||
const hasDecimals = value.decimalPlaces() !== 0;
|
||||
this.assert(
|
||||
assert.assert(
|
||||
!hasDecimals,
|
||||
`${variableName} should be in baseUnits (no decimals), found value: ${value.toNumber()}`,
|
||||
);
|
||||
},
|
||||
isString(variableName: string, value: string): void {
|
||||
this.assert(_.isString(value), this.typeAssertionMessage(variableName, 'string', value));
|
||||
assert.assert(_.isString(value), assert.typeAssertionMessage(variableName, 'string', value));
|
||||
},
|
||||
isFunction(variableName: string, value: any): void {
|
||||
this.assert(_.isFunction(value), this.typeAssertionMessage(variableName, 'function', value));
|
||||
assert.assert(_.isFunction(value), assert.typeAssertionMessage(variableName, 'function', value));
|
||||
},
|
||||
isHexString(variableName: string, value: string): void {
|
||||
this.assert(
|
||||
assert.assert(
|
||||
_.isString(value) && HEX_REGEX.test(value),
|
||||
this.typeAssertionMessage(variableName, 'HexString', value),
|
||||
assert.typeAssertionMessage(variableName, 'HexString', value),
|
||||
);
|
||||
},
|
||||
isETHAddressHex(variableName: string, value: string): void {
|
||||
this.assert(_.isString(value), this.typeAssertionMessage(variableName, 'string', value));
|
||||
this.assert(addressUtils.isAddress(value), this.typeAssertionMessage(variableName, 'ETHAddressHex', value));
|
||||
assert.assert(_.isString(value), assert.typeAssertionMessage(variableName, 'string', value));
|
||||
assert.assert(addressUtils.isAddress(value), assert.typeAssertionMessage(variableName, 'ETHAddressHex', value));
|
||||
},
|
||||
doesBelongToStringEnum(
|
||||
variableName: string,
|
||||
@@ -51,17 +51,17 @@ export const assert = {
|
||||
);
|
||||
},
|
||||
hasAtMostOneUniqueValue(value: any[], errMsg: string): void {
|
||||
this.assert(_.uniq(value).length <= 1, errMsg);
|
||||
assert.assert(_.uniq(value).length <= 1, errMsg);
|
||||
},
|
||||
isNumber(variableName: string, value: number): void {
|
||||
this.assert(_.isFinite(value), this.typeAssertionMessage(variableName, 'number', value));
|
||||
assert.assert(_.isFinite(value), assert.typeAssertionMessage(variableName, 'number', value));
|
||||
},
|
||||
isBoolean(variableName: string, value: boolean): void {
|
||||
this.assert(_.isBoolean(value), this.typeAssertionMessage(variableName, 'boolean', value));
|
||||
assert.assert(_.isBoolean(value), assert.typeAssertionMessage(variableName, 'boolean', value));
|
||||
},
|
||||
isWeb3Provider(variableName: string, value: any): void {
|
||||
const isWeb3Provider = _.isFunction(value.send) || _.isFunction(value.sendAsync);
|
||||
this.assert(isWeb3Provider, this.typeAssertionMessage(variableName, 'Provider', value));
|
||||
assert.assert(isWeb3Provider, assert.typeAssertionMessage(variableName, 'Provider', value));
|
||||
},
|
||||
doesConformToSchema(variableName: string, value: any, schema: Schema, subSchemas?: Schema[]): void {
|
||||
if (_.isUndefined(value)) {
|
||||
@@ -76,15 +76,15 @@ export const assert = {
|
||||
const msg = `Expected ${variableName} to conform to schema ${schema.id}
|
||||
Encountered: ${JSON.stringify(value, null, '\t')}
|
||||
Validation errors: ${validationResult.errors.join(', ')}`;
|
||||
this.assert(!hasValidationErrors, msg);
|
||||
assert.assert(!hasValidationErrors, msg);
|
||||
},
|
||||
isWebUri(variableName: string, value: any): void {
|
||||
const isValidUrl = !_.isUndefined(validUrl.isWebUri(value));
|
||||
this.assert(isValidUrl, this.typeAssertionMessage(variableName, 'web uri', value));
|
||||
assert.assert(isValidUrl, assert.typeAssertionMessage(variableName, 'web uri', value));
|
||||
},
|
||||
isUri(variableName: string, value: any): void {
|
||||
const isValidUri = !_.isUndefined(validUrl.isUri(value));
|
||||
this.assert(isValidUri, this.typeAssertionMessage(variableName, 'uri', value));
|
||||
assert.assert(isValidUri, assert.typeAssertionMessage(variableName, 'uri', value));
|
||||
},
|
||||
assert(condition: boolean, message: string): void {
|
||||
if (!condition) {
|
||||
|
@@ -49,7 +49,7 @@ describe('Assertions', () => {
|
||||
});
|
||||
describe('#isFunction', () => {
|
||||
it('should not throw for valid input', () => {
|
||||
const validInputs = [BigNumber, assert.isString];
|
||||
const validInputs = [BigNumber, assert.isString.bind(assert)];
|
||||
validInputs.forEach(input => expect(assert.isFunction.bind(assert, variableName, input)).to.not.throw());
|
||||
});
|
||||
it('should throw for invalid input', () => {
|
||||
|
@@ -1,4 +1,67 @@
|
||||
[
|
||||
{
|
||||
"timestamp": 1532619515,
|
||||
"version": "1.0.4",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1532614997,
|
||||
"version": "1.0.3",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1532605697,
|
||||
"version": "1.0.2",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1532357734,
|
||||
"version": "1.0.1",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1532043000,
|
||||
"version": "1.0.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1531919263,
|
||||
"version": "0.3.6",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1531149657,
|
||||
"version": "0.3.5",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"version": "0.3.4",
|
||||
"changes": [
|
||||
|
@@ -1,10 +1,38 @@
|
||||
<!--
|
||||
This file is auto-generated using the monorepo-scripts package. Don't edit directly.
|
||||
changelogUtils.file is auto-generated using the monorepo-scripts package. Don't edit directly.
|
||||
Edit the package's CHANGELOG.json file only.
|
||||
-->
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v1.0.4 - _July 26, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.0.3 - _July 26, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.0.2 - _July 26, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.0.1 - _July 23, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.0.0 - _July 20, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.3.6 - _July 18, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.3.5 - _July 9, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.3.4 - _June 19, 2018_
|
||||
|
||||
* Update EthersJs to fix the `value.toLowerCase()` is not a function bug caused by `ethers.js` breaking patch version https://github.com/ethers-io/ethers.js/issues/201
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0xproject/base-contract",
|
||||
"version": "0.3.4",
|
||||
"version": "1.0.4",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
@@ -9,7 +9,7 @@
|
||||
"types": "lib/src/index.d.ts",
|
||||
"scripts": {
|
||||
"watch_without_deps": "tsc -w",
|
||||
"build": "tsc && copyfiles -u 2 './lib/monorepo_scripts/**/*' ./scripts",
|
||||
"build": "tsc && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts",
|
||||
"clean": "shx rm -rf lib scripts",
|
||||
"test": "yarn run_mocha",
|
||||
"rebuild_and_test": "run-s clean build test",
|
||||
@@ -30,8 +30,8 @@
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/0x-monorepo/packages/base-contract/README.md",
|
||||
"devDependencies": {
|
||||
"@0xproject/monorepo-scripts": "^0.2.1",
|
||||
"@0xproject/tslint-config": "^0.4.20",
|
||||
"@0xproject/monorepo-scripts": "^1.0.4",
|
||||
"@0xproject/tslint-config": "^1.0.4",
|
||||
"@types/lodash": "4.14.104",
|
||||
"chai": "^4.0.1",
|
||||
"copyfiles": "^1.2.0",
|
||||
@@ -39,14 +39,14 @@
|
||||
"mocha": "^4.0.1",
|
||||
"npm-run-all": "^4.1.2",
|
||||
"shx": "^0.2.2",
|
||||
"tslint": "5.8.0",
|
||||
"tslint": "5.11.0",
|
||||
"typescript": "2.7.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"ethereum-types": "^0.0.2",
|
||||
"@0xproject/typescript-typings": "^0.4.1",
|
||||
"@0xproject/utils": "^0.7.1",
|
||||
"@0xproject/web3-wrapper": "^0.7.1",
|
||||
"@0xproject/typescript-typings": "^1.0.3",
|
||||
"@0xproject/utils": "^1.0.4",
|
||||
"@0xproject/web3-wrapper": "^1.1.2",
|
||||
"ethereum-types": "^1.0.3",
|
||||
"ethers": "3.0.22",
|
||||
"lodash": "^4.17.4"
|
||||
},
|
||||
|
@@ -72,15 +72,13 @@ export class BaseContract {
|
||||
// 1. Optional param passed in to public method call
|
||||
// 2. Global config passed in at library instantiation
|
||||
// 3. Gas estimate calculation + safety margin
|
||||
const removeUndefinedProperties = _.pickBy;
|
||||
const txDataWithDefaults: TxData = {
|
||||
const removeUndefinedProperties = _.pickBy.bind(_);
|
||||
const txDataWithDefaults = {
|
||||
...removeUndefinedProperties(txDefaults),
|
||||
...removeUndefinedProperties(txData as any),
|
||||
// HACK: TS can't prove that T is spreadable.
|
||||
// Awaiting https://github.com/Microsoft/TypeScript/pull/13288 to be merged
|
||||
} as any;
|
||||
...removeUndefinedProperties(txData),
|
||||
};
|
||||
if (_.isUndefined(txDataWithDefaults.gas) && !_.isUndefined(estimateGasAsync)) {
|
||||
txDataWithDefaults.gas = await estimateGasAsync(txDataWithDefaults as any);
|
||||
txDataWithDefaults.gas = await estimateGasAsync(txDataWithDefaults);
|
||||
}
|
||||
return txDataWithDefaults;
|
||||
}
|
||||
|
@@ -1,4 +1,68 @@
|
||||
[
|
||||
{
|
||||
"timestamp": 1532619515,
|
||||
"version": "1.0.4",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1532614997,
|
||||
"version": "1.0.3",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1532605697,
|
||||
"version": "1.0.2",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1532357734,
|
||||
"version": "1.0.1",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1532043000,
|
||||
"version": "1.0.0",
|
||||
"changes": [
|
||||
{
|
||||
"note":
|
||||
"Remove `WebSocketOrderbookChannel` from the public interface and replace with `orderbookChannelFactory`"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1531919263,
|
||||
"version": "0.6.17",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1531149657,
|
||||
"version": "0.6.16",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1529397769,
|
||||
"version": "0.6.15",
|
||||
|
@@ -1,10 +1,38 @@
|
||||
<!--
|
||||
This file is auto-generated using the monorepo-scripts package. Don't edit directly.
|
||||
changelogUtils.file is auto-generated using the monorepo-scripts package. Don't edit directly.
|
||||
Edit the package's CHANGELOG.json file only.
|
||||
-->
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v1.0.4 - _July 26, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.0.3 - _July 26, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.0.2 - _July 26, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.0.1 - _July 23, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.0.0 - _July 20, 2018_
|
||||
|
||||
* Remove `WebSocketOrderbookChannel` from the public interface and replace with `orderbookChannelFactory`
|
||||
|
||||
## v0.6.17 - _July 18, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.6.16 - _July 9, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.6.15 - _June 19, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0xproject/connect",
|
||||
"version": "0.6.15",
|
||||
"version": "1.0.4",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
@@ -51,24 +51,25 @@
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/0x-monorepo/packages/connect/README.md",
|
||||
"dependencies": {
|
||||
"@0xproject/assert": "^0.2.12",
|
||||
"@0xproject/json-schemas": "0.8.1",
|
||||
"@0xproject/types": "^0.8.1",
|
||||
"@0xproject/typescript-typings": "^0.4.1",
|
||||
"@0xproject/utils": "^0.7.1",
|
||||
"isomorphic-fetch": "^2.2.1",
|
||||
"@0xproject/assert": "^0.2.14",
|
||||
"@0xproject/json-schemas": "^0.8.3",
|
||||
"@0xproject/types": "^0.8.2",
|
||||
"@0xproject/typescript-typings": "^1.0.3",
|
||||
"@0xproject/utils": "^1.0.4",
|
||||
"lodash": "^4.17.4",
|
||||
"query-string": "^5.0.1",
|
||||
"sinon": "^4.0.0",
|
||||
"websocket": "^1.0.25"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@0xproject/monorepo-scripts": "^0.2.1",
|
||||
"@0xproject/tslint-config": "^0.4.20",
|
||||
"@types/fetch-mock": "^5.12.1",
|
||||
"@0xproject/monorepo-scripts": "^1.0.4",
|
||||
"@0xproject/tslint-config": "^1.0.4",
|
||||
"@types/fetch-mock": "^5.12.2",
|
||||
"@types/lodash": "4.14.104",
|
||||
"@types/mocha": "^2.2.42",
|
||||
"@types/query-string": "^5.0.1",
|
||||
"@types/websocket": "^0.0.34",
|
||||
"@types/sinon": "^2.2.2",
|
||||
"@types/websocket": "^0.0.39",
|
||||
"async-child-process": "^1.1.1",
|
||||
"chai": "^4.0.1",
|
||||
"chai-as-promised": "^7.1.0",
|
||||
@@ -80,7 +81,7 @@
|
||||
"npm-run-all": "^4.1.2",
|
||||
"nyc": "^11.0.1",
|
||||
"shx": "^0.2.2",
|
||||
"tslint": "5.8.0",
|
||||
"tslint": "5.11.0",
|
||||
"typedoc": "~0.8.0",
|
||||
"typescript": "2.7.1"
|
||||
},
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import { assert } from '@0xproject/assert';
|
||||
import { schemas } from '@0xproject/json-schemas';
|
||||
import { SignedOrder } from '@0xproject/types';
|
||||
import 'isomorphic-fetch';
|
||||
import { fetchAsync } from '@0xproject/utils';
|
||||
import * as _ from 'lodash';
|
||||
import * as queryString from 'query-string';
|
||||
|
||||
@@ -38,7 +38,7 @@ const OPTS_TO_QUERY_FIELD_MAP = {
|
||||
* that implement the standard relayer API v0
|
||||
*/
|
||||
export class HttpClient implements Client {
|
||||
private _apiEndpointUrl: string;
|
||||
private readonly _apiEndpointUrl: string;
|
||||
/**
|
||||
* Format parameters to be appended to http requests into query string form
|
||||
*/
|
||||
@@ -167,7 +167,7 @@ export class HttpClient implements Client {
|
||||
const headers = new Headers({
|
||||
'content-type': 'application/json',
|
||||
});
|
||||
const response = await fetch(url, {
|
||||
const response = await fetchAsync(url, {
|
||||
method: requestType,
|
||||
body: JSON.stringify(payload),
|
||||
headers,
|
||||
|
@@ -1,5 +1,5 @@
|
||||
export { HttpClient } from './http_client';
|
||||
export { WebSocketOrderbookChannel } from './ws_orderbook_channel';
|
||||
export { orderbookChannelFactory } from './orderbook_channel_factory';
|
||||
export {
|
||||
Client,
|
||||
FeesRequest,
|
||||
@@ -14,7 +14,6 @@ export {
|
||||
TokenPairsItem,
|
||||
TokenPairsRequestOpts,
|
||||
TokenTradeInfo,
|
||||
WebSocketOrderbookChannelConfig,
|
||||
} from './types';
|
||||
|
||||
export { Order, SignedOrder } from '@0xproject/types';
|
||||
|
32
packages/connect/src/orderbook_channel_factory.ts
Normal file
32
packages/connect/src/orderbook_channel_factory.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import * as WebSocket from 'websocket';
|
||||
|
||||
import { OrderbookChannel, OrderbookChannelHandler } from './types';
|
||||
import { assert } from './utils/assert';
|
||||
import { WebSocketOrderbookChannel } from './ws_orderbook_channel';
|
||||
|
||||
export const orderbookChannelFactory = {
|
||||
/**
|
||||
* Instantiates a new WebSocketOrderbookChannel instance
|
||||
* @param url The relayer API base WS url you would like to interact with
|
||||
* @param handler An OrderbookChannelHandler instance that responds to various
|
||||
* channel updates
|
||||
* @return An OrderbookChannel Promise
|
||||
*/
|
||||
async createWebSocketOrderbookChannelAsync(
|
||||
url: string,
|
||||
handler: OrderbookChannelHandler,
|
||||
): Promise<OrderbookChannel> {
|
||||
assert.isUri('url', url);
|
||||
assert.isOrderbookChannelHandler('handler', handler);
|
||||
return new Promise<OrderbookChannel>((resolve, reject) => {
|
||||
const client = new WebSocket.w3cwebsocket(url);
|
||||
client.onopen = () => {
|
||||
const orderbookChannel = new WebSocketOrderbookChannel(client, handler);
|
||||
resolve(orderbookChannel);
|
||||
};
|
||||
client.onerror = err => {
|
||||
reject(err);
|
||||
};
|
||||
});
|
||||
},
|
||||
};
|
@@ -3,7 +3,6 @@ import { orderBookRequestSchema } from './orderbook_request_schema';
|
||||
import { ordersRequestOptsSchema } from './orders_request_opts_schema';
|
||||
import { pagedRequestOptsSchema } from './paged_request_opts_schema';
|
||||
import { tokenPairsRequestOptsSchema } from './token_pairs_request_opts_schema';
|
||||
import { webSocketOrderbookChannelConfigSchema } from './websocket_orderbook_channel_config_schema';
|
||||
|
||||
export const schemas = {
|
||||
feesRequestSchema,
|
||||
@@ -11,5 +10,4 @@ export const schemas = {
|
||||
ordersRequestOptsSchema,
|
||||
pagedRequestOptsSchema,
|
||||
tokenPairsRequestOptsSchema,
|
||||
webSocketOrderbookChannelConfigSchema,
|
||||
};
|
||||
|
@@ -1,10 +0,0 @@
|
||||
export const webSocketOrderbookChannelConfigSchema = {
|
||||
id: '/WebSocketOrderbookChannelConfig',
|
||||
type: 'object',
|
||||
properties: {
|
||||
heartbeatIntervalMs: {
|
||||
type: 'number',
|
||||
minimum: 10,
|
||||
},
|
||||
},
|
||||
};
|
@@ -11,17 +11,10 @@ export interface Client {
|
||||
}
|
||||
|
||||
export interface OrderbookChannel {
|
||||
subscribe: (subscriptionOpts: OrderbookChannelSubscriptionOpts, handler: OrderbookChannelHandler) => void;
|
||||
subscribe: (subscriptionOpts: OrderbookChannelSubscriptionOpts) => void;
|
||||
close: () => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* heartbeatInterval: Interval in milliseconds that the orderbook channel should ping the underlying websocket. Default: 15000
|
||||
*/
|
||||
export interface WebSocketOrderbookChannelConfig {
|
||||
heartbeatIntervalMs?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* baseTokenAddress: The address of token designated as the baseToken in the currency pair calculation of price
|
||||
* quoteTokenAddress: The address of token designated as the quoteToken in the currency pair calculation of price
|
||||
@@ -46,8 +39,8 @@ export interface OrderbookChannelHandler {
|
||||
subscriptionOpts: OrderbookChannelSubscriptionOpts,
|
||||
order: SignedOrder,
|
||||
) => void;
|
||||
onError: (channel: OrderbookChannel, subscriptionOpts: OrderbookChannelSubscriptionOpts, err: Error) => void;
|
||||
onClose: (channel: OrderbookChannel, subscriptionOpts: OrderbookChannelSubscriptionOpts) => void;
|
||||
onError: (channel: OrderbookChannel, err: Error, subscriptionOpts?: OrderbookChannelSubscriptionOpts) => void;
|
||||
onClose: (channel: OrderbookChannel) => void;
|
||||
}
|
||||
|
||||
export type OrderbookChannelMessage =
|
||||
|
26
packages/connect/src/utils/assert.ts
Normal file
26
packages/connect/src/utils/assert.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { assert as sharedAssert } from '@0xproject/assert';
|
||||
// HACK: We need those two unused imports because they're actually used by sharedAssert which gets injected here
|
||||
// tslint:disable-next-line:no-unused-variable
|
||||
import { Schema, schemas } from '@0xproject/json-schemas';
|
||||
// tslint:disable-next-line:no-unused-variable
|
||||
import { ECSignature } from '@0xproject/types';
|
||||
// tslint:disable-next-line:no-unused-variable
|
||||
import { BigNumber } from '@0xproject/utils';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
export const assert = {
|
||||
...sharedAssert,
|
||||
isOrderbookChannelSubscriptionOpts(variableName: string, subscriptionOpts: any): void {
|
||||
sharedAssert.doesConformToSchema(
|
||||
variableName,
|
||||
subscriptionOpts,
|
||||
schemas.relayerApiOrderbookChannelSubscribePayload,
|
||||
);
|
||||
},
|
||||
isOrderbookChannelHandler(variableName: string, handler: any): void {
|
||||
sharedAssert.isFunction(`${variableName}.onSnapshot`, _.get(handler, 'onSnapshot'));
|
||||
sharedAssert.isFunction(`${variableName}.onUpdate`, _.get(handler, 'onUpdate'));
|
||||
sharedAssert.isFunction(`${variableName}.onError`, _.get(handler, 'onError'));
|
||||
sharedAssert.isFunction(`${variableName}.onClose`, _.get(handler, 'onClose'));
|
||||
},
|
||||
};
|
@@ -8,10 +8,16 @@ import { relayerResponseJsonParsers } from './relayer_response_json_parsers';
|
||||
|
||||
export const orderbookChannelMessageParser = {
|
||||
parse(utf8Data: string): OrderbookChannelMessage {
|
||||
// parse the message
|
||||
const messageObj = JSON.parse(utf8Data);
|
||||
// ensure we have a type parameter to switch on
|
||||
const type: string = _.get(messageObj, 'type');
|
||||
assert.assert(!_.isUndefined(type), `Message is missing a type parameter: ${utf8Data}`);
|
||||
assert.isString('type', type);
|
||||
// ensure we have a request id for the resulting message
|
||||
const requestId: number = _.get(messageObj, 'requestId');
|
||||
assert.assert(!_.isUndefined(requestId), `Message is missing a requestId parameter: ${utf8Data}`);
|
||||
assert.isNumber('requestId', requestId);
|
||||
switch (type) {
|
||||
case OrderbookChannelMessageTypes.Snapshot: {
|
||||
assert.doesConformToSchema('message', messageObj, schemas.relayerApiOrderbookChannelSnapshotSchema);
|
||||
@@ -28,7 +34,7 @@ export const orderbookChannelMessageParser = {
|
||||
default: {
|
||||
return {
|
||||
type: OrderbookChannelMessageTypes.Unknown,
|
||||
requestId: 0,
|
||||
requestId,
|
||||
payload: undefined,
|
||||
};
|
||||
}
|
||||
|
@@ -6,12 +6,12 @@ export const typeConverters = {
|
||||
const bids = _.get(orderbook, 'bids', []);
|
||||
const asks = _.get(orderbook, 'asks', []);
|
||||
return {
|
||||
bids: bids.map((order: any) => this.convertOrderStringFieldsToBigNumber(order)),
|
||||
asks: asks.map((order: any) => this.convertOrderStringFieldsToBigNumber(order)),
|
||||
bids: bids.map((order: any) => typeConverters.convertOrderStringFieldsToBigNumber(order)),
|
||||
asks: asks.map((order: any) => typeConverters.convertOrderStringFieldsToBigNumber(order)),
|
||||
};
|
||||
},
|
||||
convertOrderStringFieldsToBigNumber(order: any): any {
|
||||
return this.convertStringsFieldsToBigNumbers(order, [
|
||||
return typeConverters.convertStringsFieldsToBigNumbers(order, [
|
||||
'makerTokenAmount',
|
||||
'takerTokenAmount',
|
||||
'makerFee',
|
||||
|
@@ -1,166 +1,105 @@
|
||||
import { assert } from '@0xproject/assert';
|
||||
import { schemas } from '@0xproject/json-schemas';
|
||||
import * as _ from 'lodash';
|
||||
import * as WebSocket from 'websocket';
|
||||
|
||||
import { schemas as clientSchemas } from './schemas/schemas';
|
||||
import {
|
||||
OrderbookChannel,
|
||||
OrderbookChannelHandler,
|
||||
OrderbookChannelMessageTypes,
|
||||
OrderbookChannelSubscriptionOpts,
|
||||
WebsocketClientEventType,
|
||||
WebsocketConnectionEventType,
|
||||
WebSocketOrderbookChannelConfig,
|
||||
} from './types';
|
||||
import { assert } from './utils/assert';
|
||||
import { orderbookChannelMessageParser } from './utils/orderbook_channel_message_parser';
|
||||
|
||||
const DEFAULT_HEARTBEAT_INTERVAL_MS = 15000;
|
||||
const MINIMUM_HEARTBEAT_INTERVAL_MS = 10;
|
||||
|
||||
/**
|
||||
* This class includes all the functionality related to interacting with a websocket endpoint
|
||||
* that implements the standard relayer API v0
|
||||
*/
|
||||
export class WebSocketOrderbookChannel implements OrderbookChannel {
|
||||
private _apiEndpointUrl: string;
|
||||
private _client: WebSocket.client;
|
||||
private _connectionIfExists?: WebSocket.connection;
|
||||
private _heartbeatTimerIfExists?: NodeJS.Timer;
|
||||
private _subscriptionCounter = 0;
|
||||
private _heartbeatIntervalMs: number;
|
||||
private readonly _client: WebSocket.w3cwebsocket;
|
||||
private readonly _handler: OrderbookChannelHandler;
|
||||
private readonly _subscriptionOptsList: OrderbookChannelSubscriptionOpts[] = [];
|
||||
/**
|
||||
* Instantiates a new WebSocketOrderbookChannel instance
|
||||
* @param url The relayer API base WS url you would like to interact with
|
||||
* @param config The configuration object. Look up the type for the description.
|
||||
* @param client A WebSocket client
|
||||
* @param handler An OrderbookChannelHandler instance that responds to various
|
||||
* channel updates
|
||||
* @return An instance of WebSocketOrderbookChannel
|
||||
*/
|
||||
constructor(url: string, config?: WebSocketOrderbookChannelConfig) {
|
||||
assert.isUri('url', url);
|
||||
if (!_.isUndefined(config)) {
|
||||
assert.doesConformToSchema('config', config, clientSchemas.webSocketOrderbookChannelConfigSchema);
|
||||
}
|
||||
this._apiEndpointUrl = url;
|
||||
this._heartbeatIntervalMs =
|
||||
_.isUndefined(config) || _.isUndefined(config.heartbeatIntervalMs)
|
||||
? DEFAULT_HEARTBEAT_INTERVAL_MS
|
||||
: config.heartbeatIntervalMs;
|
||||
this._client = new WebSocket.client();
|
||||
constructor(client: WebSocket.w3cwebsocket, handler: OrderbookChannelHandler) {
|
||||
assert.isOrderbookChannelHandler('handler', handler);
|
||||
// set private members
|
||||
this._client = client;
|
||||
this._handler = handler;
|
||||
// attach client callbacks
|
||||
this._client.onerror = err => {
|
||||
this._handler.onError(this, err);
|
||||
};
|
||||
this._client.onclose = () => {
|
||||
this._handler.onClose(this);
|
||||
};
|
||||
this._client.onmessage = message => {
|
||||
this._handleWebSocketMessage(message);
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Subscribe to orderbook snapshots and updates from the websocket
|
||||
* @param subscriptionOpts An OrderbookChannelSubscriptionOpts instance describing which
|
||||
* token pair to subscribe to
|
||||
* @param handler An OrderbookChannelHandler instance that responds to various
|
||||
* channel updates
|
||||
*/
|
||||
public subscribe(subscriptionOpts: OrderbookChannelSubscriptionOpts, handler: OrderbookChannelHandler): void {
|
||||
assert.doesConformToSchema(
|
||||
'subscriptionOpts',
|
||||
subscriptionOpts,
|
||||
schemas.relayerApiOrderbookChannelSubscribePayload,
|
||||
);
|
||||
assert.isFunction('handler.onSnapshot', _.get(handler, 'onSnapshot'));
|
||||
assert.isFunction('handler.onUpdate', _.get(handler, 'onUpdate'));
|
||||
assert.isFunction('handler.onError', _.get(handler, 'onError'));
|
||||
assert.isFunction('handler.onClose', _.get(handler, 'onClose'));
|
||||
this._subscriptionCounter += 1;
|
||||
public subscribe(subscriptionOpts: OrderbookChannelSubscriptionOpts): void {
|
||||
assert.isOrderbookChannelSubscriptionOpts('subscriptionOpts', subscriptionOpts);
|
||||
assert.assert(this._client.readyState === WebSocket.w3cwebsocket.OPEN, 'WebSocket connection is closed');
|
||||
this._subscriptionOptsList.push(subscriptionOpts);
|
||||
// TODO: update requestId management to use UUIDs for v2
|
||||
const subscribeMessage = {
|
||||
type: 'subscribe',
|
||||
channel: 'orderbook',
|
||||
requestId: this._subscriptionCounter,
|
||||
requestId: this._subscriptionOptsList.length - 1,
|
||||
payload: subscriptionOpts,
|
||||
};
|
||||
this._getConnection((error, connection) => {
|
||||
if (!_.isUndefined(error)) {
|
||||
handler.onError(this, subscriptionOpts, error);
|
||||
} else if (!_.isUndefined(connection) && connection.connected) {
|
||||
connection.on(WebsocketConnectionEventType.Error, wsError => {
|
||||
handler.onError(this, subscriptionOpts, wsError);
|
||||
});
|
||||
connection.on(WebsocketConnectionEventType.Close, (_code: number, _desc: string) => {
|
||||
handler.onClose(this, subscriptionOpts);
|
||||
});
|
||||
connection.on(WebsocketConnectionEventType.Message, message => {
|
||||
this._handleWebSocketMessage(subscribeMessage.requestId, subscriptionOpts, message, handler);
|
||||
});
|
||||
connection.sendUTF(JSON.stringify(subscribeMessage));
|
||||
}
|
||||
});
|
||||
this._client.send(JSON.stringify(subscribeMessage));
|
||||
}
|
||||
/**
|
||||
* Close the websocket and stop receiving updates
|
||||
*/
|
||||
public close(): void {
|
||||
if (!_.isUndefined(this._connectionIfExists)) {
|
||||
this._connectionIfExists.close();
|
||||
}
|
||||
if (!_.isUndefined(this._heartbeatTimerIfExists)) {
|
||||
clearInterval(this._heartbeatTimerIfExists);
|
||||
}
|
||||
this._client.close();
|
||||
}
|
||||
private _getConnection(callback: (error?: Error, connection?: WebSocket.connection) => void): void {
|
||||
if (!_.isUndefined(this._connectionIfExists) && this._connectionIfExists.connected) {
|
||||
callback(undefined, this._connectionIfExists);
|
||||
} else {
|
||||
this._client.on(WebsocketClientEventType.Connect, connection => {
|
||||
this._connectionIfExists = connection;
|
||||
if (this._heartbeatIntervalMs >= MINIMUM_HEARTBEAT_INTERVAL_MS) {
|
||||
this._heartbeatTimerIfExists = setInterval(() => {
|
||||
connection.ping('');
|
||||
}, this._heartbeatIntervalMs);
|
||||
} else {
|
||||
callback(
|
||||
new Error(
|
||||
`Heartbeat interval is ${
|
||||
this._heartbeatIntervalMs
|
||||
}ms which is less than the required minimum of ${MINIMUM_HEARTBEAT_INTERVAL_MS}ms`,
|
||||
),
|
||||
undefined,
|
||||
private _handleWebSocketMessage(message: any): void {
|
||||
if (_.isUndefined(message.data)) {
|
||||
this._handler.onError(this, new Error(`Message does not contain data. Url: ${this._client.url}`));
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const data = message.data;
|
||||
const parserResult = orderbookChannelMessageParser.parse(data);
|
||||
const subscriptionOpts = this._subscriptionOptsList[parserResult.requestId];
|
||||
if (_.isUndefined(subscriptionOpts)) {
|
||||
this._handler.onError(
|
||||
this,
|
||||
new Error(`Message has unknown requestId. Url: ${this._client.url} Message: ${data}`),
|
||||
);
|
||||
return;
|
||||
}
|
||||
switch (parserResult.type) {
|
||||
case OrderbookChannelMessageTypes.Snapshot: {
|
||||
this._handler.onSnapshot(this, subscriptionOpts, parserResult.payload);
|
||||
break;
|
||||
}
|
||||
case OrderbookChannelMessageTypes.Update: {
|
||||
this._handler.onUpdate(this, subscriptionOpts, parserResult.payload);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
this._handler.onError(
|
||||
this,
|
||||
new Error(`Message has unknown type parameter. Url: ${this._client.url} Message: ${data}`),
|
||||
subscriptionOpts,
|
||||
);
|
||||
}
|
||||
callback(undefined, this._connectionIfExists);
|
||||
});
|
||||
this._client.on(WebsocketClientEventType.ConnectFailed, error => {
|
||||
callback(error, undefined);
|
||||
});
|
||||
this._client.connect(this._apiEndpointUrl);
|
||||
}
|
||||
}
|
||||
private _handleWebSocketMessage(
|
||||
requestId: number,
|
||||
subscriptionOpts: OrderbookChannelSubscriptionOpts,
|
||||
message: WebSocket.IMessage,
|
||||
handler: OrderbookChannelHandler,
|
||||
): void {
|
||||
if (!_.isUndefined(message.utf8Data)) {
|
||||
try {
|
||||
const utf8Data = message.utf8Data;
|
||||
const parserResult = orderbookChannelMessageParser.parse(utf8Data);
|
||||
if (parserResult.requestId === requestId) {
|
||||
switch (parserResult.type) {
|
||||
case OrderbookChannelMessageTypes.Snapshot: {
|
||||
handler.onSnapshot(this, subscriptionOpts, parserResult.payload);
|
||||
break;
|
||||
}
|
||||
case OrderbookChannelMessageTypes.Update: {
|
||||
handler.onUpdate(this, subscriptionOpts, parserResult.payload);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
handler.onError(
|
||||
this,
|
||||
subscriptionOpts,
|
||||
new Error(`Message has missing a type parameter: ${utf8Data}`),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
handler.onError(this, subscriptionOpts, error);
|
||||
}
|
||||
} else {
|
||||
handler.onError(this, subscriptionOpts, new Error(`Message does not contain utf8Data`));
|
||||
} catch (error) {
|
||||
this._handler.onError(this, error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
45
packages/connect/test/orderbook_channel_factory_test.ts
Normal file
45
packages/connect/test/orderbook_channel_factory_test.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import * as chai from 'chai';
|
||||
import * as dirtyChai from 'dirty-chai';
|
||||
import * as _ from 'lodash';
|
||||
import 'mocha';
|
||||
|
||||
import { orderbookChannelFactory } from '../src/orderbook_channel_factory';
|
||||
|
||||
chai.config.includeStack = true;
|
||||
chai.use(dirtyChai);
|
||||
const expect = chai.expect;
|
||||
const emptyOrderbookChannelHandler = {
|
||||
onSnapshot: () => {
|
||||
_.noop();
|
||||
},
|
||||
onUpdate: () => {
|
||||
_.noop();
|
||||
},
|
||||
onError: () => {
|
||||
_.noop();
|
||||
},
|
||||
onClose: () => {
|
||||
_.noop();
|
||||
},
|
||||
};
|
||||
|
||||
describe('orderbookChannelFactory', () => {
|
||||
const websocketUrl = 'ws://localhost:8080';
|
||||
describe('#createWebSocketOrderbookChannelAsync', () => {
|
||||
it('throws when input is not a url', () => {
|
||||
const badUrlInput = 54;
|
||||
expect(
|
||||
orderbookChannelFactory.createWebSocketOrderbookChannelAsync(
|
||||
badUrlInput as any,
|
||||
emptyOrderbookChannelHandler,
|
||||
),
|
||||
).to.be.rejected();
|
||||
});
|
||||
it('throws when handler has the incorrect members', () => {
|
||||
const badHandlerInput = {};
|
||||
expect(
|
||||
orderbookChannelFactory.createWebSocketOrderbookChannelAsync(websocketUrl, badHandlerInput as any),
|
||||
).to.be.rejected();
|
||||
});
|
||||
});
|
||||
});
|
@@ -2,60 +2,58 @@ import * as chai from 'chai';
|
||||
import * as dirtyChai from 'dirty-chai';
|
||||
import * as _ from 'lodash';
|
||||
import 'mocha';
|
||||
import * as Sinon from 'sinon';
|
||||
import * as WebSocket from 'websocket';
|
||||
|
||||
import { WebSocketOrderbookChannel } from '../src/ws_orderbook_channel';
|
||||
|
||||
chai.config.includeStack = true;
|
||||
chai.use(dirtyChai);
|
||||
const expect = chai.expect;
|
||||
const emptyOrderbookChannelHandler = {
|
||||
onSnapshot: () => {
|
||||
_.noop();
|
||||
},
|
||||
onUpdate: () => {
|
||||
_.noop();
|
||||
},
|
||||
onError: () => {
|
||||
_.noop();
|
||||
},
|
||||
onClose: () => {
|
||||
_.noop();
|
||||
},
|
||||
};
|
||||
|
||||
describe('WebSocketOrderbookChannel', () => {
|
||||
const websocketUrl = 'ws://localhost:8080';
|
||||
const orderbookChannel = new WebSocketOrderbookChannel(websocketUrl);
|
||||
const openClient = new WebSocket.w3cwebsocket(websocketUrl);
|
||||
Sinon.stub(openClient, 'readyState').get(() => WebSocket.w3cwebsocket.OPEN);
|
||||
Sinon.stub(openClient, 'send').callsFake(_.noop.bind(_));
|
||||
const openOrderbookChannel = new WebSocketOrderbookChannel(openClient, emptyOrderbookChannelHandler);
|
||||
const subscriptionOpts = {
|
||||
baseTokenAddress: '0x323b5d4c32345ced77393b3530b1eed0f346429d',
|
||||
quoteTokenAddress: '0xef7fff64389b814a946f3e92105513705ca6b990',
|
||||
snapshot: true,
|
||||
limit: 100,
|
||||
};
|
||||
const emptyOrderbookChannelHandler = {
|
||||
onSnapshot: () => {
|
||||
_.noop();
|
||||
},
|
||||
onUpdate: () => {
|
||||
_.noop();
|
||||
},
|
||||
onError: () => {
|
||||
_.noop();
|
||||
},
|
||||
onClose: () => {
|
||||
_.noop();
|
||||
},
|
||||
};
|
||||
describe('#subscribe', () => {
|
||||
it('throws when subscriptionOpts does not conform to schema', () => {
|
||||
const badSubscribeCall = orderbookChannel.subscribe.bind(
|
||||
orderbookChannel,
|
||||
{},
|
||||
emptyOrderbookChannelHandler,
|
||||
);
|
||||
const badSubscribeCall = openOrderbookChannel.subscribe.bind(openOrderbookChannel, {});
|
||||
expect(badSubscribeCall).throws(
|
||||
'Expected subscriptionOpts to conform to schema /RelayerApiOrderbookChannelSubscribePayload\nEncountered: {}\nValidation errors: instance requires property "baseTokenAddress", instance requires property "quoteTokenAddress"',
|
||||
);
|
||||
});
|
||||
it('throws when handler has the incorrect members', () => {
|
||||
const badSubscribeCall = orderbookChannel.subscribe.bind(orderbookChannel, subscriptionOpts, {});
|
||||
expect(badSubscribeCall).throws(
|
||||
'Expected handler.onSnapshot to be of type function, encountered: undefined',
|
||||
);
|
||||
});
|
||||
it('does not throw when inputs are of correct types', () => {
|
||||
const goodSubscribeCall = orderbookChannel.subscribe.bind(
|
||||
orderbookChannel,
|
||||
subscriptionOpts,
|
||||
emptyOrderbookChannelHandler,
|
||||
);
|
||||
const goodSubscribeCall = openOrderbookChannel.subscribe.bind(openOrderbookChannel, subscriptionOpts);
|
||||
expect(goodSubscribeCall).to.not.throw();
|
||||
});
|
||||
it('throws when client is closed', () => {
|
||||
const closedClient = new WebSocket.w3cwebsocket(websocketUrl);
|
||||
Sinon.stub(closedClient, 'readyState').get(() => WebSocket.w3cwebsocket.CLOSED);
|
||||
const closedOrderbookChannel = new WebSocketOrderbookChannel(closedClient, emptyOrderbookChannelHandler);
|
||||
const badSubscribeCall = closedOrderbookChannel.subscribe.bind(closedOrderbookChannel, subscriptionOpts);
|
||||
expect(badSubscribeCall).throws('WebSocket connection is closed');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -1,9 +1,38 @@
|
||||
[
|
||||
{
|
||||
"version": "1.0.1-rc.2",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Fixed bug caused by importing non-existent dep"
|
||||
}
|
||||
],
|
||||
"timestamp": 1532619515
|
||||
},
|
||||
{
|
||||
"version": "1.0.1-rc.1",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
],
|
||||
"timestamp": 1532605697
|
||||
},
|
||||
{
|
||||
"timestamp": 1532357734,
|
||||
"version": "1.0.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Update blockstream to v5.0 and propogate up caught errors to active subscriptions"
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1532043000,
|
||||
"version": "1.0.0-rc.1",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Update blockstream to v5.0 and propogate up caught errors to active subscriptions",
|
||||
"pr": 815
|
||||
},
|
||||
{
|
||||
"note": "Update to v2 of 0x rpotocol",
|
||||
@@ -11,6 +40,15 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1531919263,
|
||||
"version": "0.1.1",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1529397769,
|
||||
"version": "0.0.5",
|
||||
|
@@ -1,21 +1,38 @@
|
||||
<!--
|
||||
This file is auto-generated using the monorepo-scripts package. Don't edit directly.
|
||||
changelogUtils.file is auto-generated using the monorepo-scripts package. Don't edit directly.
|
||||
Edit the package's CHANGELOG.json file only.
|
||||
-->
|
||||
|
||||
CHANGELOG
|
||||
|
||||
## v1.0.1-rc.2 - _July 26, 2018_
|
||||
|
||||
* Fixed bug caused by importing non-existent dep
|
||||
|
||||
## v1.0.1-rc.1 - _July 26, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.0.0 - _July 23, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v1.0.0-rc.1 - _July 20, 2018_
|
||||
|
||||
* Update blockstream to v5.0 and propogate up caught errors to active subscriptions (#815)
|
||||
* Update to v2 of 0x rpotocol (#822)
|
||||
|
||||
## v0.1.1 - _July 18, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.0.5 - _June 19, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.0.4 - _May 29, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.0.3 - _May 29, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
* Expose 'abi' ContractAbi property on all contract wrappers
|
||||
|
||||
## v0.0.2 - _May 22, 2018_
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@0xproject/contract-wrappers",
|
||||
"version": "0.0.6",
|
||||
"version": "1.0.1-rc.2",
|
||||
"description": "Smart TS wrappers for 0x smart contracts",
|
||||
"keywords": [
|
||||
"0xproject",
|
||||
@@ -13,7 +13,7 @@
|
||||
"scripts": {
|
||||
"watch_without_deps": "yarn pre_build && tsc -w",
|
||||
"build": "yarn pre_build && tsc && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts",
|
||||
"pre_build": "run-s generate_contract_wrappers update_artifacts",
|
||||
"pre_build": "run-s update_artifacts_v2_beta update_artifacts_v2 generate_contract_wrappers copy_artifacts",
|
||||
"generate_contract_wrappers": "abi-gen --abis 'src/artifacts/@(Exchange|DummyERC20Token|DummyERC721Token|ZRXToken|ERC20Token|ERC721Token|WETH9|ERC20Proxy|ERC721Proxy).json' --template ../contract_templates/contract.handlebars --partials '../contract_templates/partials/**/*.handlebars' --output src/contract_wrappers/generated --backend ethers",
|
||||
"lint": "tslint --project . --exclude **/src/contract_wrappers/**/* --exclude **/lib/**/*",
|
||||
"test:circleci": "run-s test:coverage",
|
||||
@@ -21,18 +21,16 @@
|
||||
"rebuild_and_test": "run-s build test",
|
||||
"test:coverage": "nyc npm run test --all && yarn coverage:report:lcov",
|
||||
"coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info",
|
||||
"update_artifacts": "copyfiles -u 2 './src/artifacts/**/*.json' ./lib/src/artifacts",
|
||||
"clean": "shx rm -rf _bundles lib test_temp scripts test/artifacts src/contract_wrappers/generated",
|
||||
"update_artifacts_v2_beta": "for i in ${npm_package_config_contracts_v2_beta}; do copyfiles -u 4 ../migrations/artifacts/2.0.0-beta-testnet/$i.json src/artifacts; done;",
|
||||
"update_artifacts_v2": "for i in ${npm_package_config_contracts_v2}; do copyfiles -u 4 ../migrations/artifacts/2.0.0/$i.json src/artifacts; done;",
|
||||
"copy_artifacts": "copyfiles -u 2 './src/artifacts/**/*.json' ./lib/src/artifacts",
|
||||
"clean": "shx rm -rf _bundles lib test_temp scripts test/artifacts src/contract_wrappers/generated src/artifacts",
|
||||
"run_mocha": "mocha --require source-map-support/register --require make-promises-safe lib/test/**/*_test.js lib/test/global_hooks.js --timeout 10000 --bail --exit",
|
||||
"manual:postpublish": "yarn build; node ./scripts/postpublish.js"
|
||||
},
|
||||
"config": {
|
||||
"postpublish": {
|
||||
"assets": [
|
||||
"packages/contract-wrappers/_bundles/index.js",
|
||||
"packages/contract-wrappers/_bundles/index.min.js"
|
||||
]
|
||||
}
|
||||
"contracts_v2_beta": "Exchange ERC20Proxy ERC20Token ERC721Proxy ERC721Token WETH9 ZRXToken",
|
||||
"contracts_v2": "DummyERC20Token DummyERC721Token"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -43,13 +41,13 @@
|
||||
"node": ">=6.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@0xproject/abi-gen": "^0.3.2",
|
||||
"@0xproject/dev-utils": "^0.4.4",
|
||||
"@0xproject/migrations": "^0.0.8",
|
||||
"@0xproject/monorepo-scripts": "^0.2.1",
|
||||
"@0xproject/sol-compiler": "^0.5.2",
|
||||
"@0xproject/subproviders": "^0.10.4",
|
||||
"@0xproject/tslint-config": "^0.4.20",
|
||||
"@0xproject/abi-gen": "^1.0.4",
|
||||
"@0xproject/dev-utils": "^1.0.3",
|
||||
"@0xproject/migrations": "^1.0.3",
|
||||
"@0xproject/monorepo-scripts": "^1.0.4",
|
||||
"@0xproject/sol-compiler": "^1.0.4",
|
||||
"@0xproject/subproviders": "^1.0.4",
|
||||
"@0xproject/tslint-config": "^1.0.4",
|
||||
"@types/lodash": "4.14.104",
|
||||
"@types/mocha": "^2.2.42",
|
||||
"@types/node": "^8.0.53",
|
||||
@@ -69,21 +67,21 @@
|
||||
"shx": "^0.2.2",
|
||||
"sinon": "^4.0.0",
|
||||
"source-map-support": "^0.5.0",
|
||||
"tslint": "5.8.0",
|
||||
"tslint": "5.11.0",
|
||||
"typescript": "2.7.1",
|
||||
"web3-provider-engine": "14.0.6"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0xproject/assert": "^0.3.0",
|
||||
"@0xproject/base-contract": "^0.3.4",
|
||||
"@0xproject/order-utils": "^1.0.0",
|
||||
"@0xproject/typescript-typings": "^0.4.1",
|
||||
"@0xproject/utils": "^0.7.1",
|
||||
"@0xproject/web3-wrapper": "^0.7.1",
|
||||
"@0xproject/fill-scenarios": "^1.0.0",
|
||||
"@0xproject/json-schemas": "^1.0.0",
|
||||
"@0xproject/types": "^1.0.0",
|
||||
"ethereum-types": "^0.0.2",
|
||||
"@0xproject/assert": "^1.0.4",
|
||||
"@0xproject/base-contract": "^1.0.4",
|
||||
"@0xproject/fill-scenarios": "^1.0.1-rc.2",
|
||||
"@0xproject/json-schemas": "^1.0.1-rc.3",
|
||||
"@0xproject/order-utils": "^1.0.1-rc.2",
|
||||
"@0xproject/types": "^1.0.1-rc.3",
|
||||
"@0xproject/typescript-typings": "^1.0.3",
|
||||
"@0xproject/utils": "^1.0.4",
|
||||
"@0xproject/web3-wrapper": "^1.1.2",
|
||||
"ethereum-types": "^1.0.3",
|
||||
"ethereumjs-blockstream": "5.0.0",
|
||||
"ethereumjs-util": "^5.1.1",
|
||||
"ethers": "3.0.22",
|
||||
|
@@ -1,306 +0,0 @@
|
||||
{
|
||||
"schemaVersion": "2.0.0",
|
||||
"contractName": "DummyERC20Token",
|
||||
"compilerOutput": {
|
||||
"abi": [
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "name",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_spender",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_value",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "approve",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "totalSupply",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_from",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_to",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_value",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "transferFrom",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "decimals",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_owner",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "balanceOf",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "owner",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "symbol",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_value",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "mint",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_to",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_value",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "transfer",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_owner",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_spender",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "allowance",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_target",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_value",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "setBalance",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "newOwner",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "transferOwnership",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_name",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "_symbol",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "_decimals",
|
||||
"type": "uint8"
|
||||
},
|
||||
{
|
||||
"name": "_totalSupply",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "constructor"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "_from",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "_to",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "_value",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "Transfer",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "_owner",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "_spender",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "_value",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "Approval",
|
||||
"type": "event"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
@@ -1,368 +0,0 @@
|
||||
{
|
||||
"schemaVersion": "2.0.0",
|
||||
"contractName": "DummyERC721Token",
|
||||
"compilerOutput": {
|
||||
"abi": [
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "name",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_tokenId",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "getApproved",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_to",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_tokenId",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "approve",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_from",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_to",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_tokenId",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "transferFrom",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "to",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "tokenId",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "mint",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_from",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_to",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_tokenId",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "safeTransferFrom",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_tokenId",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "exists",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_tokenId",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "ownerOf",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_owner",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "balanceOf",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "owner",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "symbol",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_to",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_approved",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"name": "setApprovalForAll",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_from",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_to",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_tokenId",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "_data",
|
||||
"type": "bytes"
|
||||
}
|
||||
],
|
||||
"name": "safeTransferFrom",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_owner",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_operator",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "isApprovedForAll",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "newOwner",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "transferOwnership",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"name": "name",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "symbol",
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "constructor"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "_from",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "_to",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "_tokenId",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "Transfer",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "_owner",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "_approved",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "_tokenId",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "Approval",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "_owner",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "_operator",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "_approved",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"name": "ApprovalForAll",
|
||||
"type": "event"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
@@ -1,210 +0,0 @@
|
||||
{
|
||||
"contractName": "ERC20Proxy",
|
||||
"compilerOutput": {
|
||||
"abi": [
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "target",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "addAuthorizedAddress",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "authorities",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "target",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "removeAuthorizedAddress",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "owner",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "target",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "index",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "removeAuthorizedAddressAtIndex",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "assetData",
|
||||
"type": "bytes"
|
||||
},
|
||||
{
|
||||
"name": "from",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "to",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "amount",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "transferFrom",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "getProxyId",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bytes4"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "authorized",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "getAuthorizedAddresses",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address[]"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "newOwner",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "transferOwnership",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "target",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "caller",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "AuthorizedAddressAdded",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "target",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "caller",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "AuthorizedAddressRemoved",
|
||||
"type": "event"
|
||||
}
|
||||
]
|
||||
},
|
||||
"networks": {
|
||||
"50": { "address": "0x1dc4c1cefef38a777b15aa20260a54e584b16c48" }
|
||||
}
|
||||
}
|
@@ -1,174 +0,0 @@
|
||||
{
|
||||
"contractName": "ERC20Token",
|
||||
"compilerOutput": {
|
||||
"abi": [
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_spender",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_value",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "approve",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "success",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "totalSupply",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "supply",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_from",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_to",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_value",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "transferFrom",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "success",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_owner",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "balanceOf",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "balance",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_to",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_value",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "transfer",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "success",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_owner",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_spender",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "allowance",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "remaining",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "_from",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "_to",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "_value",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "Transfer",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "_owner",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "_spender",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "_value",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "Approval",
|
||||
"type": "event"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
@@ -1,210 +0,0 @@
|
||||
{
|
||||
"contractName": "ERC20Proxy",
|
||||
"compilerOutput": {
|
||||
"abi": [
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "target",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "addAuthorizedAddress",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "authorities",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "target",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "removeAuthorizedAddress",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "owner",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "target",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "index",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "removeAuthorizedAddressAtIndex",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "assetData",
|
||||
"type": "bytes"
|
||||
},
|
||||
{
|
||||
"name": "from",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "to",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "amount",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "transferFrom",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "getProxyId",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bytes4"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "authorized",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "getAuthorizedAddresses",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address[]"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "newOwner",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "transferOwnership",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "target",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "caller",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "AuthorizedAddressAdded",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "target",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "caller",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "AuthorizedAddressRemoved",
|
||||
"type": "event"
|
||||
}
|
||||
]
|
||||
},
|
||||
"networks": {
|
||||
"50": { "address": "0x1d7022f5b17d2f8b695918fb48fa1089c9f85401" }
|
||||
}
|
||||
}
|
@@ -1,322 +0,0 @@
|
||||
{
|
||||
"schemaVersion": "2.0.0",
|
||||
"contractName": "ERC721Token",
|
||||
"compilerOutput": {
|
||||
"abi": [
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "name",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_tokenId",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "getApproved",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_to",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_tokenId",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "approve",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_from",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_to",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_tokenId",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "transferFrom",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_from",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_to",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_tokenId",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "safeTransferFrom",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_tokenId",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "exists",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_tokenId",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "ownerOf",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_owner",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "balanceOf",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "symbol",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_to",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_approved",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"name": "setApprovalForAll",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_from",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_to",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_tokenId",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "_data",
|
||||
"type": "bytes"
|
||||
}
|
||||
],
|
||||
"name": "safeTransferFrom",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_owner",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_operator",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "isApprovedForAll",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_name",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "_symbol",
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "constructor"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "_from",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "_to",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "_tokenId",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "Transfer",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "_owner",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "_approved",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "_tokenId",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "Approval",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "_owner",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "_operator",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "_approved",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"name": "ApprovalForAll",
|
||||
"type": "event"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@@ -1,301 +0,0 @@
|
||||
{
|
||||
"contractName": "WETH9",
|
||||
"compilerOutput": {
|
||||
"abi": [
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "name",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "guy",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "wad",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "approve",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "totalSupply",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "src",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "dst",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "wad",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "transferFrom",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "wad",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "withdraw",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "decimals",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint8"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "balanceOf",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "symbol",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "dst",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "wad",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "transfer",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [],
|
||||
"name": "deposit",
|
||||
"outputs": [],
|
||||
"payable": true,
|
||||
"stateMutability": "payable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "allowance",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"payable": true,
|
||||
"stateMutability": "payable",
|
||||
"type": "fallback"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "_owner",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "_spender",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "_value",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "Approval",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "_from",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "_to",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "_value",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "Transfer",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "_owner",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "_value",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "Deposit",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "_owner",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "_value",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "Withdrawal",
|
||||
"type": "event"
|
||||
}
|
||||
]
|
||||
},
|
||||
"networks": {
|
||||
"1": {
|
||||
"address": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
|
||||
},
|
||||
"3": {
|
||||
"address": "0xc00fd9820cd2898cc4c054b7bf142de637ad129a"
|
||||
},
|
||||
"4": {
|
||||
"address": "0xc778417e063141139fce010982780140aa0cd5ab"
|
||||
},
|
||||
"42": {
|
||||
"address": "0x653e49e301e508a13237c0ddc98ae7d4cd2667a1"
|
||||
},
|
||||
"50": {
|
||||
"address": "0x0b1ba0af832d7c05fd64161e0db78e85978e8082"
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,23 +0,0 @@
|
||||
{
|
||||
"contractName": "ZRXToken",
|
||||
"compilerOutput": {
|
||||
"abi": []
|
||||
},
|
||||
"networks": {
|
||||
"1": {
|
||||
"address": "0xe41d2489571d322189246dafa5ebde1f4699f498"
|
||||
},
|
||||
"3": {
|
||||
"address": "0xa8e9fa8f91e5ae138c74648c9c304f1c75003a8d"
|
||||
},
|
||||
"4": {
|
||||
"address": "0x00f58d6d585f84b2d7267940cede30ce2fe6eae8"
|
||||
},
|
||||
"42": {
|
||||
"address": "0x6ff6c0ff1d68b964901f986d4c9fa3ac68346570"
|
||||
},
|
||||
"50": {
|
||||
"address": "0x871dd7c2b4b25e1aa18728e9d5f2af4c4e431f5c"
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
import { ContractArtifact } from '@0xproject/sol-compiler';
|
||||
import { AbiDecoder, intervalUtils } from '@0xproject/utils';
|
||||
import { AbiDecoder, intervalUtils, logUtils } from '@0xproject/utils';
|
||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||
import { BlockParamLiteral, ContractAbi, FilterObject, LogEntry, LogWithDecodedArgs, RawLog } from 'ethereum-types';
|
||||
import { Block, BlockAndLogStreamer, Log } from 'ethereumjs-blockstream';
|
||||
@@ -41,6 +41,13 @@ export abstract class ContractWrapper {
|
||||
};
|
||||
private _onLogAddedSubscriptionToken: string | undefined;
|
||||
private _onLogRemovedSubscriptionToken: string | undefined;
|
||||
private static _onBlockAndLogStreamerError(isVerbose: boolean, err: Error): void {
|
||||
// Since Blockstream errors are all recoverable, we simply log them if the verbose
|
||||
// config is passed in.
|
||||
if (isVerbose) {
|
||||
logUtils.warn(err);
|
||||
}
|
||||
}
|
||||
constructor(web3Wrapper: Web3Wrapper, networkId: number, blockPollingIntervalMs?: number) {
|
||||
this._web3Wrapper = web3Wrapper;
|
||||
this._networkId = networkId;
|
||||
@@ -79,10 +86,11 @@ export abstract class ContractWrapper {
|
||||
indexFilterValues: IndexedFilterValues,
|
||||
abi: ContractAbi,
|
||||
callback: EventCallback<ArgsType>,
|
||||
isVerbose: boolean = false,
|
||||
): string {
|
||||
const filter = filterUtils.getFilter(address, eventName, indexFilterValues, abi);
|
||||
if (_.isUndefined(this._blockAndLogStreamerIfExists)) {
|
||||
this._startBlockAndLogStream();
|
||||
this._startBlockAndLogStream(isVerbose);
|
||||
}
|
||||
const filterToken = filterUtils.generateUUID();
|
||||
this._filters[filterToken] = filter;
|
||||
@@ -151,21 +159,21 @@ export abstract class ContractWrapper {
|
||||
}
|
||||
});
|
||||
}
|
||||
private _startBlockAndLogStream(): void {
|
||||
private _startBlockAndLogStream(isVerbose: boolean): void {
|
||||
if (!_.isUndefined(this._blockAndLogStreamerIfExists)) {
|
||||
throw new Error(ContractWrappersError.SubscriptionAlreadyPresent);
|
||||
}
|
||||
this._blockAndLogStreamerIfExists = new BlockAndLogStreamer(
|
||||
this._web3Wrapper.getBlockAsync.bind(this._web3Wrapper),
|
||||
this._web3Wrapper.getLogsAsync.bind(this._web3Wrapper),
|
||||
this._onBlockAndLogStreamerError.bind(this),
|
||||
ContractWrapper._onBlockAndLogStreamerError.bind(this, isVerbose),
|
||||
);
|
||||
const catchAllLogFilter = {};
|
||||
this._blockAndLogStreamerIfExists.addLogFilter(catchAllLogFilter);
|
||||
this._blockAndLogStreamIntervalIfExists = intervalUtils.setAsyncExcludingInterval(
|
||||
this._reconcileBlockAsync.bind(this),
|
||||
this._blockPollingIntervalMs,
|
||||
this._onReconcileBlockError.bind(this),
|
||||
ContractWrapper._onBlockAndLogStreamerError.bind(this, isVerbose),
|
||||
);
|
||||
let isRemoved = false;
|
||||
this._onLogAddedSubscriptionToken = this._blockAndLogStreamerIfExists.subscribeToOnLogAdded(
|
||||
@@ -176,20 +184,10 @@ export abstract class ContractWrapper {
|
||||
this._onLogStateChanged.bind(this, isRemoved),
|
||||
);
|
||||
}
|
||||
private _onBlockAndLogStreamerError(err: Error): void {
|
||||
// Propogate all Blockstream subscriber errors to all
|
||||
// top-level subscriptions
|
||||
const filterCallbacks = _.values(this._filterCallbacks);
|
||||
_.each(filterCallbacks, filterCallback => {
|
||||
filterCallback(err);
|
||||
});
|
||||
}
|
||||
private _onReconcileBlockError(err: Error): void {
|
||||
const filterTokens = _.keys(this._filterCallbacks);
|
||||
_.each(filterTokens, filterToken => {
|
||||
this._unsubscribe(filterToken, err);
|
||||
});
|
||||
}
|
||||
// HACK: This should be a package-scoped method (which doesn't exist in TS)
|
||||
// We don't want this method available in the public interface for all classes
|
||||
// who inherit from ContractWrapper, and it is only used by the internal implementation
|
||||
// of those higher classes.
|
||||
// tslint:disable-next-line:no-unused-variable
|
||||
private _setNetworkId(networkId: number): void {
|
||||
this._networkId = networkId;
|
||||
|
@@ -347,6 +347,7 @@ export class ERC20TokenWrapper extends ContractWrapper {
|
||||
* @param indexFilterValues An object where the keys are indexed args returned by the event and
|
||||
* the value is the value you are interested in. E.g `{maker: aUserAddressHex}`
|
||||
* @param callback Callback that gets called when a log is added/removed
|
||||
* @param isVerbose Enable verbose subscription warnings (e.g recoverable network issues encountered)
|
||||
* @return Subscription token used later to unsubscribe
|
||||
*/
|
||||
public subscribe<ArgsType extends ERC20TokenEventArgs>(
|
||||
@@ -354,6 +355,7 @@ export class ERC20TokenWrapper extends ContractWrapper {
|
||||
eventName: ERC20TokenEvents,
|
||||
indexFilterValues: IndexedFilterValues,
|
||||
callback: EventCallback<ArgsType>,
|
||||
isVerbose: boolean = false,
|
||||
): string {
|
||||
assert.isETHAddressHex('tokenAddress', tokenAddress);
|
||||
assert.doesBelongToStringEnum('eventName', eventName, ERC20TokenEvents);
|
||||
@@ -366,6 +368,7 @@ export class ERC20TokenWrapper extends ContractWrapper {
|
||||
indexFilterValues,
|
||||
artifacts.ERC20Token.compilerOutput.abi,
|
||||
callback,
|
||||
isVerbose,
|
||||
);
|
||||
return subscriptionToken;
|
||||
}
|
||||
|
@@ -4,7 +4,6 @@ import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||
import { ContractAbi, LogWithDecodedArgs } from 'ethereum-types';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { constants } from '../../test/utils/constants';
|
||||
import { artifacts } from '../artifacts';
|
||||
import { methodOptsSchema } from '../schemas/method_opts_schema';
|
||||
import { txOptsSchema } from '../schemas/tx_opts_schema';
|
||||
@@ -17,6 +16,7 @@ import {
|
||||
TransactionOpts,
|
||||
} from '../types';
|
||||
import { assert } from '../utils/assert';
|
||||
import { constants } from '../utils/constants';
|
||||
|
||||
import { ContractWrapper } from './contract_wrapper';
|
||||
import { ERC721ProxyWrapper } from './erc721_proxy_wrapper';
|
||||
@@ -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(
|
||||
@@ -372,6 +374,7 @@ export class ERC721TokenWrapper extends ContractWrapper {
|
||||
* @param indexFilterValues An object where the keys are indexed args returned by the event and
|
||||
* the value is the value you are interested in. E.g `{maker: aUserAddressHex}`
|
||||
* @param callback Callback that gets called when a log is added/removed
|
||||
* @param isVerbose Enable verbose subscription warnings (e.g recoverable network issues encountered)
|
||||
* @return Subscription token used later to unsubscribe
|
||||
*/
|
||||
public subscribe<ArgsType extends ERC721TokenEventArgs>(
|
||||
@@ -379,6 +382,7 @@ export class ERC721TokenWrapper extends ContractWrapper {
|
||||
eventName: ERC721TokenEvents,
|
||||
indexFilterValues: IndexedFilterValues,
|
||||
callback: EventCallback<ArgsType>,
|
||||
isVerbose: boolean = false,
|
||||
): string {
|
||||
assert.isETHAddressHex('tokenAddress', tokenAddress);
|
||||
assert.doesBelongToStringEnum('eventName', eventName, ERC721TokenEvents);
|
||||
@@ -391,6 +395,7 @@ export class ERC721TokenWrapper extends ContractWrapper {
|
||||
indexFilterValues,
|
||||
artifacts.ERC721Token.compilerOutput.abi,
|
||||
callback,
|
||||
isVerbose,
|
||||
);
|
||||
return subscriptionToken;
|
||||
}
|
||||
|
@@ -146,6 +146,7 @@ export class EtherTokenWrapper extends ContractWrapper {
|
||||
* @param indexFilterValues An object where the keys are indexed args returned by the event and
|
||||
* the value is the value you are interested in. E.g `{_owner: aUserAddressHex}`
|
||||
* @param callback Callback that gets called when a log is added/removed
|
||||
* @param isVerbose Enable verbose subscription warnings (e.g recoverable network issues encountered)
|
||||
* @return Subscription token used later to unsubscribe
|
||||
*/
|
||||
public subscribe<ArgsType extends WETH9EventArgs>(
|
||||
@@ -153,6 +154,7 @@ export class EtherTokenWrapper extends ContractWrapper {
|
||||
eventName: WETH9Events,
|
||||
indexFilterValues: IndexedFilterValues,
|
||||
callback: EventCallback<ArgsType>,
|
||||
isVerbose: boolean = false,
|
||||
): string {
|
||||
assert.isETHAddressHex('etherTokenAddress', etherTokenAddress);
|
||||
const normalizedEtherTokenAddress = etherTokenAddress.toLowerCase();
|
||||
@@ -165,6 +167,7 @@ export class EtherTokenWrapper extends ContractWrapper {
|
||||
indexFilterValues,
|
||||
artifacts.EtherToken.compilerOutput.abi,
|
||||
callback,
|
||||
isVerbose,
|
||||
);
|
||||
return subscriptionToken;
|
||||
}
|
||||
|
@@ -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';
|
||||
@@ -988,12 +989,14 @@ export class ExchangeWrapper extends ContractWrapper {
|
||||
* @param indexFilterValues An object where the keys are indexed args returned by the event and
|
||||
* the value is the value you are interested in. E.g `{maker: aUserAddressHex}`
|
||||
* @param callback Callback that gets called when a log is added/removed
|
||||
* @param isVerbose Enable verbose subscription warnings (e.g recoverable network issues encountered)
|
||||
* @return Subscription token used later to unsubscribe
|
||||
*/
|
||||
public subscribe<ArgsType extends ExchangeEventArgs>(
|
||||
eventName: ExchangeEvents,
|
||||
indexFilterValues: IndexedFilterValues,
|
||||
callback: EventCallback<ArgsType>,
|
||||
isVerbose: boolean = false,
|
||||
): string {
|
||||
assert.doesBelongToStringEnum('eventName', eventName, ExchangeEvents);
|
||||
assert.doesConformToSchema('indexFilterValues', indexFilterValues, schemas.indexFilterValuesSchema);
|
||||
@@ -1005,6 +1008,7 @@ export class ExchangeWrapper extends ContractWrapper {
|
||||
indexFilterValues,
|
||||
artifacts.Exchange.compilerOutput.abi,
|
||||
callback,
|
||||
isVerbose,
|
||||
);
|
||||
return subscriptionToken;
|
||||
}
|
||||
@@ -1068,9 +1072,9 @@ export class ExchangeWrapper extends ContractWrapper {
|
||||
* Returns the ZRX asset data used by the exchange contract.
|
||||
* @return ZRX asset data
|
||||
*/
|
||||
public async getZRXAssetDataAsync(): Promise<string> {
|
||||
const exchangeInstance = await this._getExchangeContractAsync();
|
||||
const zrxAssetData = exchangeInstance.ZRX_ASSET_DATA.callAsync();
|
||||
public getZRXAssetData(): string {
|
||||
const zrxTokenAddress = this.getZRXTokenAddress();
|
||||
const zrxAssetData = assetDataUtils.encodeERC20AssetData(zrxTokenAddress);
|
||||
return zrxAssetData;
|
||||
}
|
||||
// tslint:disable:no-unused-variable
|
||||
|
@@ -1,7 +1,10 @@
|
||||
export { ContractWrappers } from './contract_wrappers';
|
||||
export { ERC20TokenWrapper } from './contract_wrappers/erc20_token_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 {
|
||||
ContractWrappersError,
|
||||
@@ -23,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,
|
||||
@@ -57,6 +68,7 @@ export {
|
||||
ERC721TokenApprovalForAllEventArgs,
|
||||
ERC721TokenTransferEventArgs,
|
||||
ERC721TokenEvents,
|
||||
ERC721TokenEventArgs,
|
||||
} from './contract_wrappers/generated/erc721_token';
|
||||
|
||||
export {
|
||||
|
@@ -8,8 +8,8 @@ export const contractWrappersPrivateNetworkConfigSchema = {
|
||||
gasPrice: { $ref: '/Number' },
|
||||
zrxContractAddress: { $ref: '/Address' },
|
||||
exchangeContractAddress: { $ref: '/Address' },
|
||||
tokenRegistryContractAddress: { $ref: '/Address' },
|
||||
tokenTransferProxyContractAddress: { $ref: '/Address' },
|
||||
erc20ProxyContractAddress: { $ref: '/Address' },
|
||||
erc721ProxyContractAddress: { $ref: '/Address' },
|
||||
blockPollingIntervalMs: { type: 'number' },
|
||||
orderWatcherConfig: {
|
||||
type: 'object',
|
||||
@@ -30,7 +30,7 @@ export const contractWrappersPrivateNetworkConfigSchema = {
|
||||
'networkId',
|
||||
'zrxContractAddress',
|
||||
'exchangeContractAddress',
|
||||
'tokenRegistryContractAddress',
|
||||
'tokenTransferProxyContractAddress',
|
||||
'erc20ProxyContractAddress',
|
||||
'erc721ProxyContractAddress',
|
||||
],
|
||||
};
|
||||
|
@@ -22,8 +22,8 @@ export const contractWrappersPublicNetworkConfigSchema = {
|
||||
gasPrice: { $ref: '/Number' },
|
||||
zrxContractAddress: { $ref: '/Address' },
|
||||
exchangeContractAddress: { $ref: '/Address' },
|
||||
tokenRegistryContractAddress: { $ref: '/Address' },
|
||||
tokenTransferProxyContractAddress: { $ref: '/Address' },
|
||||
erc20ProxyContractAddress: { $ref: '/Address' },
|
||||
erc721ProxyContractAddress: { $ref: '/Address' },
|
||||
blockPollingIntervalMs: { type: 'number' },
|
||||
orderWatcherConfig: {
|
||||
type: 'object',
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import { assert as sharedAssert } from '@0xproject/assert';
|
||||
// We need those two unused imports because they're actually used by sharedAssert which gets injected here
|
||||
// HACK: We need those two unused imports because they're actually used by sharedAssert which gets injected here
|
||||
import { Schema } from '@0xproject/json-schemas'; // tslint:disable-line:no-unused-variable
|
||||
import { isValidSignatureAsync } from '@0xproject/order-utils';
|
||||
import { ECSignature } from '@0xproject/types'; // tslint:disable-line:no-unused-variable
|
||||
|
@@ -1,11 +1,10 @@
|
||||
import { BlockchainLifecycle, callbackErrorReporter } from '@0xproject/dev-utils';
|
||||
import { EmptyWalletSubprovider } from '@0xproject/subproviders';
|
||||
import { EmptyWalletSubprovider, Web3ProviderEngine } from '@0xproject/subproviders';
|
||||
import { DoneCallback } from '@0xproject/types';
|
||||
import { BigNumber } from '@0xproject/utils';
|
||||
import * as chai from 'chai';
|
||||
import { Provider } from 'ethereum-types';
|
||||
import 'mocha';
|
||||
import Web3ProviderEngine = require('web3-provider-engine');
|
||||
|
||||
import {
|
||||
BlockParamLiteral,
|
||||
|
@@ -1,11 +1,10 @@
|
||||
import { BlockchainLifecycle, callbackErrorReporter } from '@0xproject/dev-utils';
|
||||
import { EmptyWalletSubprovider } from '@0xproject/subproviders';
|
||||
import { EmptyWalletSubprovider, Web3ProviderEngine } from '@0xproject/subproviders';
|
||||
import { DoneCallback } from '@0xproject/types';
|
||||
import { BigNumber } from '@0xproject/utils';
|
||||
import * as chai from 'chai';
|
||||
import { Provider } from 'ethereum-types';
|
||||
import 'mocha';
|
||||
import Web3ProviderEngine = require('web3-provider-engine');
|
||||
|
||||
import {
|
||||
BlockParamLiteral,
|
||||
|
@@ -336,15 +336,19 @@ describe('EtherTokenWrapper', () => {
|
||||
describe('#getLogsAsync', () => {
|
||||
let etherTokenAddress: string;
|
||||
let erc20ProxyAddress: string;
|
||||
const blockRange: BlockRange = {
|
||||
fromBlock: 0,
|
||||
toBlock: BlockParamLiteral.Latest,
|
||||
};
|
||||
let blockRange: BlockRange;
|
||||
let txHash: string;
|
||||
before(() => {
|
||||
before(async () => {
|
||||
addressWithETH = userAddresses[0];
|
||||
etherTokenAddress = tokenUtils.getWethTokenAddress();
|
||||
erc20ProxyAddress = contractWrappers.erc20Proxy.getContractAddress();
|
||||
// Start the block range after all migrations to avoid unexpected logs
|
||||
const currentBlock = await web3Wrapper.getBlockNumberAsync();
|
||||
const fromBlock = currentBlock + 1;
|
||||
blockRange = {
|
||||
fromBlock,
|
||||
toBlock: BlockParamLiteral.Latest,
|
||||
};
|
||||
});
|
||||
it('should get logs with decoded args emitted by Approval', async () => {
|
||||
txHash = await contractWrappers.erc20Token.setUnlimitedProxyAllowanceAsync(
|
||||
|
@@ -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);
|
||||
});
|
||||
|
@@ -7,7 +7,7 @@ before('migrate contracts', async function(): Promise<void> {
|
||||
// HACK: Since the migrations take longer then our global mocha timeout limit
|
||||
// we manually increase it for this before hook.
|
||||
const mochaTestTimeoutMs = 50000;
|
||||
this.timeout(mochaTestTimeoutMs);
|
||||
this.timeout(mochaTestTimeoutMs); // tslint:disable-line:no-invalid-this
|
||||
const txDefaults = {
|
||||
gas: devConstants.GAS_LIMIT,
|
||||
from: devConstants.TESTRPC_FIRST_ADDRESS,
|
||||
|
@@ -49,44 +49,6 @@ describe('SubscriptionTest', () => {
|
||||
_.each(stubs, s => s.restore());
|
||||
stubs = [];
|
||||
});
|
||||
it('Should receive the Error when an error occurs while fetching the block', (done: DoneCallback) => {
|
||||
(async () => {
|
||||
const errMsg = 'Error fetching block';
|
||||
const callback = callbackErrorReporter.assertNodeCallbackError(done, errMsg);
|
||||
stubs = [Sinon.stub((contractWrappers as any)._web3Wrapper, 'getBlockAsync').throws(new Error(errMsg))];
|
||||
contractWrappers.erc20Token.subscribe(
|
||||
tokenAddress,
|
||||
ERC20TokenEvents.Approval,
|
||||
indexFilterValues,
|
||||
callback,
|
||||
);
|
||||
await contractWrappers.erc20Token.setAllowanceAsync(
|
||||
tokenAddress,
|
||||
coinbase,
|
||||
addressWithoutFunds,
|
||||
allowanceAmount,
|
||||
);
|
||||
})().catch(done);
|
||||
});
|
||||
it('Should receive the Error when an error occurs while reconciling the new block', (done: DoneCallback) => {
|
||||
(async () => {
|
||||
const errMsg = 'Error fetching logs';
|
||||
const callback = callbackErrorReporter.assertNodeCallbackError(done, errMsg);
|
||||
stubs = [Sinon.stub((contractWrappers as any)._web3Wrapper, 'getLogsAsync').throws(new Error(errMsg))];
|
||||
contractWrappers.erc20Token.subscribe(
|
||||
tokenAddress,
|
||||
ERC20TokenEvents.Approval,
|
||||
indexFilterValues,
|
||||
callback,
|
||||
);
|
||||
await contractWrappers.erc20Token.setAllowanceAsync(
|
||||
tokenAddress,
|
||||
coinbase,
|
||||
addressWithoutFunds,
|
||||
allowanceAmount,
|
||||
);
|
||||
})().catch(done);
|
||||
});
|
||||
it('Should allow unsubscribeAll to be called successfully after an error', (done: DoneCallback) => {
|
||||
(async () => {
|
||||
const callback = (err: Error | null, _logEvent?: DecodedLogEvent<ERC20TokenApprovalEventArgs>) =>
|
||||
|
@@ -25,6 +25,7 @@
|
||||
"DummyERC721Token",
|
||||
"ERC20Proxy",
|
||||
"ERC20Token",
|
||||
"ERC721Token",
|
||||
"ERC721Proxy",
|
||||
"Exchange",
|
||||
"ExchangeWrapper",
|
||||
@@ -38,12 +39,13 @@
|
||||
"MultiSigWalletWithTimeLock",
|
||||
"TestAssetProxyOwner",
|
||||
"TestAssetProxyDispatcher",
|
||||
"TestConstants",
|
||||
"TestLibBytes",
|
||||
"TestLibs",
|
||||
"TestSignatureValidator",
|
||||
"TestValidator",
|
||||
"TestWallet",
|
||||
"TokenRegistry",
|
||||
"Validator",
|
||||
"Wallet",
|
||||
"Whitelist",
|
||||
"WETH9",
|
||||
"ZRXToken"
|
||||
|
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"private": true,
|
||||
"name": "contracts",
|
||||
"version": "2.1.33",
|
||||
"version": "2.1.39",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
@@ -33,7 +33,7 @@
|
||||
"lint-contracts": "solhint src/2.0.0/**/**/**/**/*.sol"
|
||||
},
|
||||
"config": {
|
||||
"abis": "../migrations/artifacts/2.0.0/@(AssetProxyOwner|DummyERC20Token|DummyERC721Receiver|DummyERC721Token|ERC20Proxy|ERC721Proxy|Forwarder|Exchange|ExchangeWrapper|IAssetData|IAssetProxy|MixinAuthorizable|MultiSigWallet|MultiSigWalletWithTimeLock|TestAssetProxyOwner|TestAssetProxyDispatcher|TestLibBytes|TestLibs|TestSignatureValidator|TestValidator|TestWallet|TokenRegistry|Whitelist|WETH9|ZRXToken).json"
|
||||
"abis": "../migrations/artifacts/2.0.0/@(AssetProxyOwner|DummyERC20Token|DummyERC721Receiver|DummyERC721Token|ERC20Proxy|ERC721Proxy|Forwarder|Exchange|ExchangeWrapper|IAssetData|IAssetProxy|MixinAuthorizable|MultiSigWallet|MultiSigWalletWithTimeLock|TestAssetProxyOwner|TestAssetProxyDispatcher|TestConstants|TestLibBytes|TestLibs|TestSignatureValidator|Validator|Wallet|TokenRegistry|Whitelist|WETH9|ZRXToken).json"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -46,15 +46,15 @@
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/0x-monorepo/packages/contracts/README.md",
|
||||
"devDependencies": {
|
||||
"@0xproject/abi-gen": "^0.3.2",
|
||||
"@0xproject/dev-utils": "^0.4.4",
|
||||
"@0xproject/tslint-config": "^0.4.20",
|
||||
"@0xproject/subproviders": "^0.10.1",
|
||||
"@0xproject/sol-cov": "^0.1.1",
|
||||
"@types/lodash": "4.14.104",
|
||||
"@0xproject/abi-gen": "^1.0.4",
|
||||
"@0xproject/dev-utils": "^1.0.3",
|
||||
"@0xproject/sol-cov": "^1.0.3",
|
||||
"@0xproject/subproviders": "^1.0.4",
|
||||
"@0xproject/tslint-config": "^1.0.4",
|
||||
"@types/bn.js": "^4.11.0",
|
||||
"@types/node": "^8.0.53",
|
||||
"@types/ethereumjs-abi": "^0.6.0",
|
||||
"@types/lodash": "4.14.104",
|
||||
"@types/node": "^8.0.53",
|
||||
"@types/yargs": "^10.0.0",
|
||||
"chai": "^4.0.1",
|
||||
"chai-as-promised": "^7.1.0",
|
||||
@@ -67,23 +67,23 @@
|
||||
"shx": "^0.2.2",
|
||||
"solc": "^0.4.24",
|
||||
"solhint": "^1.2.1",
|
||||
"tslint": "5.8.0",
|
||||
"tslint": "5.11.0",
|
||||
"typescript": "2.7.1",
|
||||
"yargs": "^10.0.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0xproject/base-contract": "^0.3.4",
|
||||
"@0xproject/order-utils": "^1.0.0",
|
||||
"@0xproject/sol-compiler": "^0.5.2",
|
||||
"@0xproject/types": "^1.0.0",
|
||||
"@0xproject/typescript-typings": "^0.4.1",
|
||||
"@0xproject/utils": "^0.7.1",
|
||||
"@0xproject/web3-wrapper": "^0.7.1",
|
||||
"ethereum-types": "^0.0.2",
|
||||
"@0xproject/base-contract": "^1.0.4",
|
||||
"@0xproject/order-utils": "^1.0.1-rc.2",
|
||||
"@0xproject/sol-compiler": "^1.0.4",
|
||||
"@0xproject/types": "^1.0.1-rc.3",
|
||||
"@0xproject/typescript-typings": "^1.0.3",
|
||||
"@0xproject/utils": "^1.0.4",
|
||||
"@0xproject/web3-wrapper": "^1.1.2",
|
||||
"bn.js": "^4.11.8",
|
||||
"ethereumjs-abi": "^0.6.4",
|
||||
"ethereum-types": "^1.0.3",
|
||||
"ethereumjs-abi": "0.6.5",
|
||||
"ethereumjs-util": "^5.1.1",
|
||||
"ethers": "3.0.22",
|
||||
"lodash": "^4.17.4"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -18,7 +18,7 @@
|
||||
|
||||
pragma solidity ^0.4.10;
|
||||
|
||||
import "../../current/multisig/MultiSigWalletWithTimeLock.sol";
|
||||
import "../../2.0.0/multisig/MultiSigWalletWithTimeLock.sol";
|
||||
|
||||
contract MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress is MultiSigWalletWithTimeLock {
|
||||
|
||||
@@ -79,4 +79,4 @@ contract MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress is MultiSigWall
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -21,7 +21,7 @@ pragma solidity 0.4.24;
|
||||
import "../../protocol/Exchange/interfaces/IValidator.sol";
|
||||
|
||||
|
||||
contract TestValidator is
|
||||
contract Validator is
|
||||
IValidator
|
||||
{
|
||||
|
||||
@@ -29,7 +29,7 @@ contract TestValidator is
|
||||
// solhint-disable-next-line var-name-mixedcase
|
||||
address internal VALID_SIGNER;
|
||||
|
||||
/// @dev constructs a new `TestValidator` with a single valid signer.
|
||||
/// @dev constructs a new `Validator` with a single valid signer.
|
||||
/// @param validSigner The sole, valid signer.
|
||||
constructor (address validSigner) public {
|
||||
VALID_SIGNER = validSigner;
|
@@ -22,7 +22,7 @@ import "../../protocol/Exchange/interfaces/IWallet.sol";
|
||||
import "../../utils/LibBytes/LibBytes.sol";
|
||||
|
||||
|
||||
contract TestWallet is
|
||||
contract Wallet is
|
||||
IWallet
|
||||
{
|
||||
using LibBytes for bytes;
|
||||
@@ -31,7 +31,7 @@ contract TestWallet is
|
||||
// solhint-disable-next-line var-name-mixedcase
|
||||
address internal WALLET_OWNER;
|
||||
|
||||
/// @dev constructs a new `TestWallet` with a single owner.
|
||||
/// @dev constructs a new `Wallet` with a single owner.
|
||||
/// @param walletOwner The owner of this wallet.
|
||||
constructor (address walletOwner) public {
|
||||
WALLET_OWNER = walletOwner;
|
@@ -19,20 +19,19 @@
|
||||
pragma solidity 0.4.24;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "./MixinFees.sol";
|
||||
import "./MixinWeth.sol";
|
||||
import "./MixinForwarderCore.sol";
|
||||
import "./MixinConstants.sol";
|
||||
import "./MixinMarketBuyZrx.sol";
|
||||
import "./MixinExpectedResults.sol";
|
||||
import "./MixinTransfer.sol";
|
||||
import "./libs/LibConstants.sol";
|
||||
import "./MixinAssets.sol";
|
||||
import "./MixinExchangeWrapper.sol";
|
||||
|
||||
|
||||
// solhint-disable no-empty-blocks
|
||||
contract Forwarder is
|
||||
MixinConstants,
|
||||
MixinExpectedResults,
|
||||
MixinFees,
|
||||
MixinMarketBuyZrx,
|
||||
MixinTransfer,
|
||||
LibConstants,
|
||||
MixinWeth,
|
||||
MixinAssets,
|
||||
MixinExchangeWrapper,
|
||||
MixinForwarderCore
|
||||
{
|
||||
|
||||
@@ -40,12 +39,11 @@ contract Forwarder is
|
||||
address _exchange,
|
||||
address _etherToken,
|
||||
address _zrxToken,
|
||||
bytes4 _erc20AssetProxyId,
|
||||
bytes memory _zrxAssetData,
|
||||
bytes memory _wethAssetData
|
||||
)
|
||||
public
|
||||
MixinConstants(
|
||||
LibConstants(
|
||||
_exchange,
|
||||
_etherToken,
|
||||
_zrxToken,
|
||||
|
@@ -19,58 +19,78 @@
|
||||
pragma solidity 0.4.24;
|
||||
|
||||
import "../utils/LibBytes/LibBytes.sol";
|
||||
import "../utils/Ownable/Ownable.sol";
|
||||
import "../tokens/ERC20Token/IERC20Token.sol";
|
||||
import "../tokens/ERC721Token/IERC721Token.sol";
|
||||
import "./mixins/MTransfer.sol";
|
||||
import "./libs/LibConstants.sol";
|
||||
import "./mixins/MAssets.sol";
|
||||
|
||||
|
||||
contract MixinTransfer is
|
||||
MTransfer
|
||||
contract MixinAssets is
|
||||
Ownable,
|
||||
LibConstants,
|
||||
MAssets
|
||||
{
|
||||
|
||||
using LibBytes for bytes;
|
||||
|
||||
bytes4 constant internal ERC20_TRANSFER_SELECTOR = bytes4(keccak256("transfer(address,uint256)"));
|
||||
bytes4 constant internal ERC721_RECEIVED = bytes4(keccak256("onERC721Received(address,uint256,bytes)"));
|
||||
bytes4 constant internal ERC721_RECEIVED_OPERATOR = bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"));
|
||||
|
||||
function onERC721Received(
|
||||
address,
|
||||
uint256,
|
||||
bytes memory
|
||||
)
|
||||
public
|
||||
pure
|
||||
returns(bytes4)
|
||||
{
|
||||
return ERC721_RECEIVED;
|
||||
}
|
||||
|
||||
function onERC721Received(
|
||||
address,
|
||||
address,
|
||||
uint256,
|
||||
bytes memory
|
||||
)
|
||||
public
|
||||
pure
|
||||
returns(bytes4)
|
||||
{
|
||||
return ERC721_RECEIVED_OPERATOR;
|
||||
}
|
||||
|
||||
function transferERC20Token(
|
||||
/// @dev Withdraws ERC20 tokens from this contract. The contract requires a ZRX balance in order to
|
||||
/// function optimally, and this function allows the ZRX to be withdrawn by owner. It may also be
|
||||
/// used to withdraw tokens that were accidentally sent to this contract.
|
||||
/// @param token Address of ERC20 token to withdraw.
|
||||
/// @param amount Amount of ERC20 token to withdraw.
|
||||
function withdrawERC20(
|
||||
address token,
|
||||
address to,
|
||||
uint256 amount
|
||||
)
|
||||
external
|
||||
onlyOwner
|
||||
{
|
||||
require(
|
||||
IERC20Token(token).transfer(msg.sender, amount),
|
||||
"WITHDRAWAL_FAILED"
|
||||
);
|
||||
}
|
||||
|
||||
/// @dev Transfers given amount of asset to sender.
|
||||
/// @param assetData Byte array encoded for the respective asset proxy.
|
||||
/// @param amount Amount of asset to transfer to sender.
|
||||
function transferPurchasedAssetToSender(
|
||||
bytes memory assetData,
|
||||
uint256 amount
|
||||
)
|
||||
internal
|
||||
{
|
||||
bytes4 proxyId = assetData.readBytes4(0);
|
||||
|
||||
if (proxyId == ERC20_DATA_ID) {
|
||||
transferERC20Token(assetData, amount);
|
||||
} else if (proxyId == ERC721_DATA_ID) {
|
||||
transferERC721Token(assetData, amount);
|
||||
} else {
|
||||
revert("UNSUPPORTED_TOKEN_PROXY");
|
||||
}
|
||||
}
|
||||
|
||||
/// @dev Decodes ERC20 assetData and transfers given amount to sender.
|
||||
/// @param assetData Byte array encoded for the respective asset proxy.
|
||||
/// @param amount Amount of asset to transfer to sender.
|
||||
function transferERC20Token(
|
||||
bytes memory assetData,
|
||||
uint256 amount
|
||||
)
|
||||
internal
|
||||
{
|
||||
address token = assetData.readAddress(16);
|
||||
|
||||
// Transfer tokens.
|
||||
// We do a raw call so we can check the success separate
|
||||
// from the return data.
|
||||
bool success = token.call(abi.encodeWithSelector(
|
||||
ERC20_TRANSFER_SELECTOR,
|
||||
to,
|
||||
msg.sender,
|
||||
amount
|
||||
));
|
||||
require(
|
||||
@@ -100,21 +120,28 @@ contract MixinTransfer is
|
||||
);
|
||||
}
|
||||
|
||||
/// @dev Decodes ERC721 assetData and transfers given amount to sender.
|
||||
/// @param assetData Byte array encoded for the respective asset proxy.
|
||||
/// @param amount Amount of asset to transfer to sender.
|
||||
function transferERC721Token(
|
||||
bytes memory assetData,
|
||||
address to
|
||||
uint256 amount
|
||||
)
|
||||
internal
|
||||
{
|
||||
require(
|
||||
amount == 1,
|
||||
"INVALID_AMOUNT"
|
||||
);
|
||||
// Decode asset data.
|
||||
address token = assetData.readAddress(16);
|
||||
uint256 tokenId = assetData.readUint256(36);
|
||||
bytes memory receiverData = assetData.readBytesWithLength(100);
|
||||
IERC721Token(token).safeTransferFrom(
|
||||
|
||||
// Perform transfer.
|
||||
IERC721Token(token).transferFrom(
|
||||
address(this),
|
||||
to,
|
||||
tokenId,
|
||||
receiverData
|
||||
msg.sender,
|
||||
tokenId
|
||||
);
|
||||
}
|
||||
}
|
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
|
||||
Copyright 2018 ZeroEx Intl.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
*/
|
||||
|
||||
// solhint-disable
|
||||
pragma solidity 0.4.24;
|
||||
|
||||
|
||||
/// This contract is intended to serve as a reference, but is not actually used for efficiency reasons.
|
||||
contract MixinErrorMessages {
|
||||
string constant VALUE_GREATER_THAN_ZERO = "VALUE_GREATER_THAN_ZERO";
|
||||
string constant FEE_PROPORTION_TOO_LARGE = "FEE_PROPORTION_TOO_LARGE";
|
||||
string constant TAKER_ASSET_ZRX_REQUIRED = "TAKER_ASSET_ZRX_REQUIRED";
|
||||
string constant TAKER_ASSET_WETH_REQUIRED = "TAKER_ASSET_WETH_REQUIRED";
|
||||
string constant SAME_ASSET_TYPE_REQUIRED = "SAME_ASSET_TYPE_REQUIRED";
|
||||
string constant UNACCEPTABLE_THRESHOLD = "UNACCEPTABLE_THRESHOLD";
|
||||
string constant UNSUPPORTED_TOKEN_PROXY = "UNSUPPORTED_TOKEN_PROXY";
|
||||
string constant ASSET_AMOUNT_MATCH_ORDER_SIZE = "ASSET_AMOUNT_MUST_MATCH_ORDER_SIZE";
|
||||
string constant DEFAULT_FUNCTION_WETH_CONTRACT_ONLY = "DEFAULT_FUNCTION_WETH_CONTRACT_ONLY";
|
||||
string constant INVALID_MSG_VALUE = "INVALID_MSG_VALUE";
|
||||
}
|
253
packages/contracts/src/2.0.0/forwarder/MixinExchangeWrapper.sol
vendored
Normal file
253
packages/contracts/src/2.0.0/forwarder/MixinExchangeWrapper.sol
vendored
Normal file
@@ -0,0 +1,253 @@
|
||||
/*
|
||||
|
||||
Copyright 2018 ZeroEx Intl.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity 0.4.24;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "./libs/LibConstants.sol";
|
||||
import "./mixins/MExchangeWrapper.sol";
|
||||
import "../protocol/Exchange/libs/LibAbiEncoder.sol";
|
||||
import "../protocol/Exchange/libs/LibOrder.sol";
|
||||
import "../protocol/Exchange/libs/LibFillResults.sol";
|
||||
import "../protocol/Exchange/libs/LibMath.sol";
|
||||
|
||||
|
||||
contract MixinExchangeWrapper is
|
||||
LibAbiEncoder,
|
||||
LibFillResults,
|
||||
LibMath,
|
||||
LibConstants,
|
||||
MExchangeWrapper
|
||||
{
|
||||
|
||||
/// @dev Fills the input order.
|
||||
/// Returns false if the transaction would otherwise revert.
|
||||
/// @param order Order struct containing order specifications.
|
||||
/// @param takerAssetFillAmount Desired amount of takerAsset to sell.
|
||||
/// @param signature Proof that order has been created by maker.
|
||||
/// @return Amounts filled and fees paid by maker and taker.
|
||||
function fillOrderNoThrow(
|
||||
LibOrder.Order memory order,
|
||||
uint256 takerAssetFillAmount,
|
||||
bytes memory signature
|
||||
)
|
||||
internal
|
||||
returns (FillResults memory fillResults)
|
||||
{
|
||||
// ABI encode calldata for `fillOrder`
|
||||
bytes memory fillOrderCalldata = abiEncodeFillOrder(
|
||||
order,
|
||||
takerAssetFillAmount,
|
||||
signature
|
||||
);
|
||||
|
||||
address exchange = address(EXCHANGE);
|
||||
|
||||
// Call `fillOrder` and handle any exceptions gracefully
|
||||
assembly {
|
||||
let success := call(
|
||||
gas, // forward all gas, TODO: look into gas consumption of assert/throw
|
||||
exchange, // call address of Exchange contract
|
||||
0, // transfer 0 wei
|
||||
add(fillOrderCalldata, 32), // pointer to start of input (skip array length in first 32 bytes)
|
||||
mload(fillOrderCalldata), // length of input
|
||||
fillOrderCalldata, // write output over input
|
||||
128 // output size is 128 bytes
|
||||
)
|
||||
switch success
|
||||
case 0 {
|
||||
mstore(fillResults, 0)
|
||||
mstore(add(fillResults, 32), 0)
|
||||
mstore(add(fillResults, 64), 0)
|
||||
mstore(add(fillResults, 96), 0)
|
||||
}
|
||||
case 1 {
|
||||
mstore(fillResults, mload(fillOrderCalldata))
|
||||
mstore(add(fillResults, 32), mload(add(fillOrderCalldata, 32)))
|
||||
mstore(add(fillResults, 64), mload(add(fillOrderCalldata, 64)))
|
||||
mstore(add(fillResults, 96), mload(add(fillOrderCalldata, 96)))
|
||||
}
|
||||
}
|
||||
return fillResults;
|
||||
}
|
||||
|
||||
/// @dev Synchronously executes multiple calls of fillOrder until total amount of WETH has been sold by taker.
|
||||
/// Returns false if the transaction would otherwise revert.
|
||||
/// @param orders Array of order specifications.
|
||||
/// @param wethSellAmount Desired amount of WETH to sell.
|
||||
/// @param signatures Proofs that orders have been signed by makers.
|
||||
/// @return Amounts filled and fees paid by makers and taker.
|
||||
function marketSellWeth(
|
||||
LibOrder.Order[] memory orders,
|
||||
uint256 wethSellAmount,
|
||||
bytes[] memory signatures
|
||||
)
|
||||
internal
|
||||
returns (FillResults memory totalFillResults)
|
||||
{
|
||||
bytes memory makerAssetData = orders[0].makerAssetData;
|
||||
bytes memory wethAssetData = WETH_ASSET_DATA;
|
||||
|
||||
uint256 ordersLength = orders.length;
|
||||
for (uint256 i = 0; i != ordersLength; i++) {
|
||||
|
||||
// We assume that asset being bought by taker is the same for each order.
|
||||
// We assume that asset being sold by taker is WETH for each order.
|
||||
orders[i].makerAssetData = makerAssetData;
|
||||
orders[i].takerAssetData = wethAssetData;
|
||||
|
||||
// Calculate the remaining amount of WETH to sell
|
||||
uint256 remainingTakerAssetFillAmount = safeSub(wethSellAmount, totalFillResults.takerAssetFilledAmount);
|
||||
|
||||
// Attempt to sell the remaining amount of WETH
|
||||
FillResults memory singleFillResults = fillOrderNoThrow(
|
||||
orders[i],
|
||||
remainingTakerAssetFillAmount,
|
||||
signatures[i]
|
||||
);
|
||||
|
||||
// Update amounts filled and fees paid by maker and taker
|
||||
addFillResults(totalFillResults, singleFillResults);
|
||||
|
||||
// Stop execution if the entire amount of takerAsset has been sold
|
||||
if (totalFillResults.takerAssetFilledAmount >= wethSellAmount) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return totalFillResults;
|
||||
}
|
||||
|
||||
/// @dev Synchronously executes multiple fill orders in a single transaction until total amount is bought by taker.
|
||||
/// Returns false if the transaction would otherwise revert.
|
||||
/// The asset being sold by taker must always be WETH.
|
||||
/// @param orders Array of order specifications.
|
||||
/// @param makerAssetFillAmount Desired amount of makerAsset to buy.
|
||||
/// @param signatures Proofs that orders have been signed by makers.
|
||||
/// @return Amounts filled and fees paid by makers and taker.
|
||||
function marketBuyWithWeth(
|
||||
LibOrder.Order[] memory orders,
|
||||
uint256 makerAssetFillAmount,
|
||||
bytes[] memory signatures
|
||||
)
|
||||
internal
|
||||
returns (FillResults memory totalFillResults)
|
||||
{
|
||||
bytes memory makerAssetData = orders[0].makerAssetData;
|
||||
bytes memory wethAssetData = WETH_ASSET_DATA;
|
||||
|
||||
uint256 ordersLength = orders.length;
|
||||
for (uint256 i = 0; i != ordersLength; i++) {
|
||||
|
||||
// We assume that asset being bought by taker is the same for each order.
|
||||
// We assume that asset being sold by taker is WETH for each order.
|
||||
orders[i].makerAssetData = makerAssetData;
|
||||
orders[i].takerAssetData = wethAssetData;
|
||||
|
||||
// Calculate the remaining amount of makerAsset to buy
|
||||
uint256 remainingMakerAssetFillAmount = safeSub(makerAssetFillAmount, totalFillResults.makerAssetFilledAmount);
|
||||
|
||||
// Convert the remaining amount of makerAsset to buy into remaining amount
|
||||
// of takerAsset to sell, assuming entire amount can be sold in the current order
|
||||
uint256 remainingTakerAssetFillAmount = getPartialAmount(
|
||||
orders[i].takerAssetAmount,
|
||||
orders[i].makerAssetAmount,
|
||||
remainingMakerAssetFillAmount
|
||||
);
|
||||
|
||||
// Attempt to sell the remaining amount of takerAsset
|
||||
FillResults memory singleFillResults = fillOrderNoThrow(
|
||||
orders[i],
|
||||
remainingTakerAssetFillAmount,
|
||||
signatures[i]
|
||||
);
|
||||
|
||||
// Update amounts filled and fees paid by maker and taker
|
||||
addFillResults(totalFillResults, singleFillResults);
|
||||
|
||||
// Stop execution if the entire amount of makerAsset has been bought
|
||||
if (totalFillResults.makerAssetFilledAmount >= makerAssetFillAmount) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return totalFillResults;
|
||||
}
|
||||
|
||||
/// @dev Buys zrxBuyAmount of ZRX fee tokens, taking into account ZRX fees for each order. This will guarantee
|
||||
/// that at least zrxBuyAmount of ZRX is purchased (sometimes slightly over due to rounding issues).
|
||||
/// It is possible that a request to buy 200 ZRX will require purchasing 202 ZRX
|
||||
/// as 2 ZRX is required to purchase the 200 ZRX fee tokens. This guarantees at least 200 ZRX for future purchases.
|
||||
/// The asset being sold by taker must always be WETH.
|
||||
/// @param orders Array of order specifications containing ZRX as makerAsset and WETH as takerAsset.
|
||||
/// @param zrxBuyAmount Desired amount of ZRX to buy.
|
||||
/// @param signatures Proofs that orders have been created by makers.
|
||||
/// @return totalFillResults Amounts filled and fees paid by maker and taker.
|
||||
function marketBuyZrxWithWeth(
|
||||
LibOrder.Order[] memory orders,
|
||||
uint256 zrxBuyAmount,
|
||||
bytes[] memory signatures
|
||||
)
|
||||
internal
|
||||
returns (FillResults memory totalFillResults)
|
||||
{
|
||||
// Do nothing if zrxBuyAmount == 0
|
||||
if (zrxBuyAmount == 0) {
|
||||
return totalFillResults;
|
||||
}
|
||||
|
||||
bytes memory zrxAssetData = ZRX_ASSET_DATA;
|
||||
bytes memory wethAssetData = WETH_ASSET_DATA;
|
||||
uint256 zrxPurchased = 0;
|
||||
|
||||
uint256 ordersLength = orders.length;
|
||||
for (uint256 i = 0; i != ordersLength; i++) {
|
||||
|
||||
// All of these are ZRX/WETH, so we can drop the respective assetData from calldata.
|
||||
orders[i].makerAssetData = zrxAssetData;
|
||||
orders[i].takerAssetData = wethAssetData;
|
||||
|
||||
// Calculate the remaining amount of ZRX to buy.
|
||||
uint256 remainingZrxBuyAmount = safeSub(zrxBuyAmount, zrxPurchased);
|
||||
|
||||
// Convert the remaining amount of ZRX to buy into remaining amount
|
||||
// of WETH to sell, assuming entire amount can be sold in the current order.
|
||||
uint256 remainingWethSellAmount = getPartialAmount(
|
||||
orders[i].takerAssetAmount,
|
||||
safeSub(orders[i].makerAssetAmount, orders[i].takerFee), // our exchange rate after fees
|
||||
remainingZrxBuyAmount
|
||||
);
|
||||
|
||||
// Attempt to sell the remaining amount of WETH.
|
||||
FillResults memory singleFillResult = fillOrderNoThrow(
|
||||
orders[i],
|
||||
safeAdd(remainingWethSellAmount, 1), // we add 1 wei to the fill amount to make up for rounding errors
|
||||
signatures[i]
|
||||
);
|
||||
|
||||
// Update amounts filled and fees paid by maker and taker.
|
||||
addFillResults(totalFillResults, singleFillResult);
|
||||
zrxPurchased = safeSub(totalFillResults.makerAssetFilledAmount, totalFillResults.takerFeePaid);
|
||||
|
||||
// Stop execution if the entire amount of ZRX has been bought.
|
||||
if (zrxPurchased >= zrxBuyAmount) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return totalFillResults;
|
||||
}
|
||||
}
|
@@ -1,161 +0,0 @@
|
||||
/*
|
||||
|
||||
Copyright 2018 ZeroEx Intl.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity 0.4.24;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "../utils/LibBytes/LibBytes.sol";
|
||||
import "../protocol/Exchange/libs/LibFillResults.sol";
|
||||
import "../protocol/Exchange/libs/LibMath.sol";
|
||||
import "../protocol/Exchange/libs/LibOrder.sol";
|
||||
import "./mixins/MConstants.sol";
|
||||
import "./mixins/MExpectedResults.sol";
|
||||
|
||||
|
||||
contract MixinExpectedResults is
|
||||
LibMath,
|
||||
LibFillResults,
|
||||
MConstants,
|
||||
MExpectedResults
|
||||
{
|
||||
|
||||
/// @dev Calculates a total FillResults for buying makerAssetFillAmount over all orders.
|
||||
/// Including the fees required to be paid.
|
||||
/// @param orders An array of Order struct containing order specifications.
|
||||
/// @param makerAssetFillAmount A number representing the amount of this order to fill.
|
||||
/// @return totalFillResults Amounts filled and fees paid by maker and taker.
|
||||
function calculateMarketBuyResults(
|
||||
LibOrder.Order[] memory orders,
|
||||
uint256 makerAssetFillAmount
|
||||
)
|
||||
public
|
||||
view
|
||||
returns (FillResults memory totalFillResults)
|
||||
{
|
||||
for (uint256 i = 0; i < orders.length; i++) {
|
||||
uint256 remainingMakerAssetFillAmount = safeSub(makerAssetFillAmount, totalFillResults.makerAssetFilledAmount);
|
||||
uint256 remainingTakerAssetFillAmount = getPartialAmount(
|
||||
orders[i].takerAssetAmount,
|
||||
orders[i].makerAssetAmount,
|
||||
remainingMakerAssetFillAmount
|
||||
);
|
||||
FillResults memory singleFillResult = calculateFillResults(orders[i], remainingTakerAssetFillAmount);
|
||||
addFillResults(totalFillResults, singleFillResult);
|
||||
if (totalFillResults.makerAssetFilledAmount == makerAssetFillAmount) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return totalFillResults;
|
||||
}
|
||||
|
||||
/// @dev Calculates a FillResults total for selling takerAssetFillAmount over all orders.
|
||||
/// Including the fees required to be paid.
|
||||
/// @param orders An array of Order struct containing order specifications.
|
||||
/// @param takerAssetFillAmount A number representing the amount of this order to fill.
|
||||
/// @return totalFillResults Amounts filled and fees paid by maker and taker.
|
||||
function calculateMarketSellResults(
|
||||
LibOrder.Order[] memory orders,
|
||||
uint256 takerAssetFillAmount
|
||||
)
|
||||
public
|
||||
view
|
||||
returns (FillResults memory totalFillResults)
|
||||
{
|
||||
for (uint256 i = 0; i < orders.length; i++) {
|
||||
uint256 remainingTakerAssetFillAmount = safeSub(takerAssetFillAmount, totalFillResults.takerAssetFilledAmount);
|
||||
FillResults memory singleFillResult = calculateFillResults(orders[i], remainingTakerAssetFillAmount);
|
||||
addFillResults(totalFillResults, singleFillResult);
|
||||
if (totalFillResults.takerAssetFilledAmount == takerAssetFillAmount) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return totalFillResults;
|
||||
}
|
||||
|
||||
/// @dev Calculates fill results for buyFeeTokens. This handles fees on buying ZRX
|
||||
/// so the end result is the expected amount of ZRX (not less after fees).
|
||||
/// @param orders An array of Order struct containing order specifications.
|
||||
/// @param zrxFillAmount A number representing the amount zrx to buy
|
||||
/// @return totalFillResults Expected fill result amounts from buying fees
|
||||
function calculateMarketBuyZrxResults(
|
||||
LibOrder.Order[] memory orders,
|
||||
uint256 zrxFillAmount
|
||||
)
|
||||
public
|
||||
view
|
||||
returns (FillResults memory totalFillResults)
|
||||
{
|
||||
for (uint256 i = 0; i < orders.length; i++) {
|
||||
uint256 remainingZrxFillAmount = safeSub(zrxFillAmount, totalFillResults.makerAssetFilledAmount);
|
||||
// Convert the remaining amount of makerToken to buy into remaining amount
|
||||
// of takerToken to sell, assuming entire amount can be sold in the current order
|
||||
uint256 remainingWethSellAmount = getPartialAmount(
|
||||
orders[i].takerAssetAmount,
|
||||
safeSub(orders[i].makerAssetAmount, orders[i].takerFee), // our exchange rate after fees
|
||||
remainingZrxFillAmount
|
||||
);
|
||||
FillResults memory singleFillResult = calculateFillResults(orders[i], safeAdd(remainingWethSellAmount, 1));
|
||||
|
||||
singleFillResult.makerAssetFilledAmount = safeSub(singleFillResult.makerAssetFilledAmount, singleFillResult.takerFeePaid);
|
||||
addFillResults(totalFillResults, singleFillResult);
|
||||
// As we compensate for the rounding issue above have slightly more ZRX than the requested zrxFillAmount
|
||||
if (totalFillResults.makerAssetFilledAmount >= zrxFillAmount) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return totalFillResults;
|
||||
}
|
||||
|
||||
/// @dev Simulates the 0x Exchange fillOrder validation and calculations, without performing any state changes.
|
||||
/// @param order An Order struct containing order specifications.
|
||||
/// @param takerAssetFillAmount A number representing the amount of this order to fill.
|
||||
/// @return fillResults Amounts filled and fees paid by maker and taker.
|
||||
function calculateFillResults(
|
||||
LibOrder.Order memory order,
|
||||
uint256 takerAssetFillAmount
|
||||
)
|
||||
internal
|
||||
view
|
||||
returns (FillResults memory fillResults)
|
||||
{
|
||||
LibOrder.OrderInfo memory orderInfo = EXCHANGE.getOrderInfo(order);
|
||||
if (orderInfo.orderStatus != uint8(LibOrder.OrderStatus.FILLABLE)) {
|
||||
return fillResults;
|
||||
}
|
||||
uint256 remainingTakerAssetAmount = safeSub(order.takerAssetAmount, orderInfo.orderTakerAssetFilledAmount);
|
||||
uint256 takerAssetFilledAmount = min256(takerAssetFillAmount, remainingTakerAssetAmount);
|
||||
|
||||
fillResults.takerAssetFilledAmount = takerAssetFilledAmount;
|
||||
fillResults.makerAssetFilledAmount = getPartialAmount(
|
||||
takerAssetFilledAmount,
|
||||
order.takerAssetAmount,
|
||||
order.makerAssetAmount
|
||||
);
|
||||
fillResults.makerFeePaid = getPartialAmount(
|
||||
takerAssetFilledAmount,
|
||||
order.takerAssetAmount,
|
||||
order.makerFee
|
||||
);
|
||||
fillResults.takerFeePaid = getPartialAmount(
|
||||
takerAssetFilledAmount,
|
||||
order.takerAssetAmount,
|
||||
order.takerFee
|
||||
);
|
||||
return fillResults;
|
||||
}
|
||||
}
|
126
packages/contracts/src/2.0.0/forwarder/MixinFees.sol
vendored
126
packages/contracts/src/2.0.0/forwarder/MixinFees.sol
vendored
@@ -1,126 +0,0 @@
|
||||
/*
|
||||
|
||||
Copyright 2018 ZeroEx Intl.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity 0.4.24;
|
||||
|
||||
import "../protocol/Exchange/libs/LibMath.sol";
|
||||
import "./mixins/MConstants.sol";
|
||||
import "./mixins/MFees.sol";
|
||||
|
||||
|
||||
contract MixinFees is
|
||||
LibMath,
|
||||
MConstants,
|
||||
MFees
|
||||
{
|
||||
|
||||
uint16 constant public PERCENTAGE_DENOMINATOR = 10000; // 9800 == 98%, 10000 == 100%
|
||||
uint16 constant public MAX_FEE = 1000; // 10%
|
||||
uint16 constant public ALLOWABLE_EXCHANGE_PERCENTAGE = 9500; // 95%
|
||||
|
||||
/// @dev Default payabale function, this allows us to withdraw WETH
|
||||
function ()
|
||||
public
|
||||
payable
|
||||
{
|
||||
require(
|
||||
msg.sender == address(ETHER_TOKEN),
|
||||
"DEFAULT_FUNCTION_WETH_CONTRACT_ONLY"
|
||||
);
|
||||
}
|
||||
|
||||
/// @dev Pays the feeRecipient feeProportion of the total takerEthAmount, denominated in ETH
|
||||
/// @param takerEthAmount The total amount that was transacted in WETH, fees are calculated from this value.
|
||||
/// @param feeProportion The proportion of fees
|
||||
/// @param feeRecipient The recipient of the fees
|
||||
/// @return ethFeeAmount Amount of ETH paid to feeRecipient as fee.
|
||||
function payEthFee(
|
||||
uint256 takerEthAmount,
|
||||
uint16 feeProportion,
|
||||
address feeRecipient
|
||||
)
|
||||
internal
|
||||
returns (uint256 ethFeeAmount)
|
||||
{
|
||||
if (feeProportion > 0 && feeRecipient != address(0)) {
|
||||
require(
|
||||
feeProportion <= MAX_FEE,
|
||||
"FEE_PROPORTION_TOO_LARGE"
|
||||
);
|
||||
// 1.5% is 150, allowing for 2 decimal precision, i.e 0.05% is 5
|
||||
ethFeeAmount = getPartialAmount(
|
||||
feeProportion,
|
||||
PERCENTAGE_DENOMINATOR,
|
||||
takerEthAmount
|
||||
);
|
||||
feeRecipient.transfer(ethFeeAmount);
|
||||
}
|
||||
return ethFeeAmount;
|
||||
}
|
||||
|
||||
/// @dev Withdraws the remaining WETH, deduct and pay fees from this amount based on the takerTokenAmount to the feeRecipient.
|
||||
/// If a user overpaid ETH initially, the fees are calculated from the amount traded and deducted from withdrawAmount.
|
||||
/// Any remaining ETH is sent back to the user.
|
||||
/// @param ethWithdrawAmount The amount to withdraw from the WETH contract.
|
||||
/// @param wethAmountSold The total amount that was transacted in WETH, fees are calculated from this value.
|
||||
/// @param feeProportion The proportion of fees
|
||||
/// @param feeRecipient The recipient of the fees
|
||||
function withdrawPayAndDeductEthFee(
|
||||
uint256 ethWithdrawAmount,
|
||||
uint256 wethAmountSold,
|
||||
uint16 feeProportion,
|
||||
address feeRecipient
|
||||
)
|
||||
internal
|
||||
{
|
||||
// Return all of the excess WETH if any after deducting fees on the amount
|
||||
if (ethWithdrawAmount > 0) {
|
||||
ETHER_TOKEN.withdraw(ethWithdrawAmount);
|
||||
// Fees proportional to the amount traded
|
||||
uint256 ethFeeAmount = payEthFee(
|
||||
wethAmountSold,
|
||||
feeProportion,
|
||||
feeRecipient
|
||||
);
|
||||
uint256 unspentEthAmount = safeSub(ethWithdrawAmount, ethFeeAmount);
|
||||
if (unspentEthAmount > 0) {
|
||||
msg.sender.transfer(unspentEthAmount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// @dev Checks whether the amount of tokens sold against the amount of tokens requested
|
||||
/// is within a certain threshold. This ensures the caller gets a fair deal when
|
||||
/// performing any token fee abstraction. Threshold is 95%. If fee abstraction costs more than
|
||||
/// 5% of the total transaction, we return false.
|
||||
/// @param requestedSellAmount The amount the user requested, or sent in to a payable function
|
||||
/// @param tokenAmountSold The amount of the token that was sold after fee abstraction
|
||||
/// @return bool of whether this is within an acceptable threshold
|
||||
function isAcceptableThreshold(uint256 requestedSellAmount, uint256 tokenAmountSold)
|
||||
internal
|
||||
pure
|
||||
returns (bool)
|
||||
{
|
||||
uint256 acceptableSellAmount = getPartialAmount(
|
||||
ALLOWABLE_EXCHANGE_PERCENTAGE,
|
||||
PERCENTAGE_DENOMINATOR,
|
||||
requestedSellAmount
|
||||
);
|
||||
return tokenAmountSold >= acceptableSellAmount;
|
||||
}
|
||||
}
|
@@ -19,30 +19,30 @@
|
||||
pragma solidity 0.4.24;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "../utils/LibBytes/LibBytes.sol";
|
||||
import "./mixins/MFees.sol";
|
||||
import "./mixins/MMarketBuyZrx.sol";
|
||||
import "./mixins/MExpectedResults.sol";
|
||||
import "./mixins/MTransfer.sol";
|
||||
import "./mixins/MConstants.sol";
|
||||
import "./libs/LibConstants.sol";
|
||||
import "./mixins/MWeth.sol";
|
||||
import "./mixins/MAssets.sol";
|
||||
import "./mixins/MExchangeWrapper.sol";
|
||||
import "./mixins/MForwarderCore.sol";
|
||||
import "../utils/LibBytes/LibBytes.sol";
|
||||
import "../protocol/Exchange/libs/LibOrder.sol";
|
||||
import "../protocol/Exchange/libs/LibFillResults.sol";
|
||||
import "../protocol/Exchange/libs/LibMath.sol";
|
||||
|
||||
|
||||
contract MixinForwarderCore is
|
||||
LibFillResults,
|
||||
MConstants,
|
||||
MExpectedResults,
|
||||
MFees,
|
||||
MMarketBuyZrx,
|
||||
MTransfer,
|
||||
LibMath,
|
||||
LibConstants,
|
||||
MWeth,
|
||||
MAssets,
|
||||
MExchangeWrapper,
|
||||
MForwarderCore
|
||||
{
|
||||
bytes4 constant internal ERC20_DATA_ID = bytes4(keccak256("ERC20Token(address)"));
|
||||
bytes4 constant internal ERC721_DATA_ID = bytes4(keccak256("ERC721Token(address,uint256,bytes)"));
|
||||
uint256 constant internal MAX_UINT = 2**256 - 1;
|
||||
|
||||
using LibBytes for bytes;
|
||||
|
||||
/// @dev Constructor approves ERC20 proxy to transfer ZRX and WETH on this contract's behalf.
|
||||
constructor ()
|
||||
public
|
||||
{
|
||||
@@ -53,379 +53,202 @@ contract MixinForwarderCore is
|
||||
}
|
||||
}
|
||||
|
||||
/// @dev Market sells ETH for ERC20 tokens, performing fee abstraction if required. This does not support ERC721 tokens. This function is payable
|
||||
/// and will convert all incoming ETH into WETH and perform the trade on behalf of the caller.
|
||||
/// This function allows for a deduction of a proportion of incoming ETH sent to the feeRecipient.
|
||||
/// The caller is sent all tokens from the operation.
|
||||
/// If the purchased token amount does not meet an acceptable threshold then this function reverts.
|
||||
/// @param orders An array of Order struct containing order specifications.
|
||||
/// @param signatures An array of Proof that order has been created by maker.
|
||||
/// @param feeOrders An array of Order struct containing order specifications for fees.
|
||||
/// @param feeSignatures An array of Proof that order has been created by maker for the fee orders.
|
||||
/// @param feeProportion A proportion deducted off the incoming ETH and sent to feeRecipient. The maximum value for this
|
||||
/// is 1000, aka 10%. Supports up to 2 decimal places. I.e 0.59% is 59.
|
||||
/// @param feeRecipient An address of the fee recipient whom receives feeProportion of ETH.
|
||||
/// @return FillResults amounts filled and fees paid by maker and taker.
|
||||
function marketSellEthForERC20(
|
||||
/// @dev Purchases as much of orders' makerAssets as possible by selling up to 95% of transaction's ETH value.
|
||||
/// Any ZRX required to pay fees for primary orders will automatically be purchased by this contract.
|
||||
/// 5% of ETH value is reserved for paying fees to order feeRecipients (in ZRX) and forwarding contract feeRecipient (in ETH).
|
||||
/// Any ETH not spent will be refunded to sender.
|
||||
/// @param orders Array of order specifications used containing desired makerAsset and WETH as takerAsset.
|
||||
/// @param signatures Proofs that orders have been created by makers.
|
||||
/// @param feeOrders Array of order specifications containing ZRX as makerAsset and WETH as takerAsset. Used to purchase ZRX for primary order fees.
|
||||
/// @param feeSignatures Proofs that feeOrders have been created by makers.
|
||||
/// @param feePercentage Percentage of WETH sold that will payed as fee to forwarding contract feeRecipient.
|
||||
/// @param feeRecipient Address that will receive ETH when orders are filled.
|
||||
/// @return Amounts filled and fees paid by maker and taker for both sets of orders.
|
||||
function marketSellOrdersWithEth(
|
||||
LibOrder.Order[] memory orders,
|
||||
bytes[] memory signatures,
|
||||
LibOrder.Order[] memory feeOrders,
|
||||
bytes[] memory feeSignatures,
|
||||
uint16 feeProportion,
|
||||
uint256 feePercentage,
|
||||
address feeRecipient
|
||||
)
|
||||
public
|
||||
payable
|
||||
returns (FillResults memory totalFillResults)
|
||||
returns (
|
||||
FillResults memory orderFillResults,
|
||||
FillResults memory feeOrderFillResults
|
||||
)
|
||||
{
|
||||
uint256 takerEthAmount = msg.value;
|
||||
require(
|
||||
takerEthAmount > 0,
|
||||
"VALUE_GREATER_THAN_ZERO"
|
||||
);
|
||||
// Deduct the fee from the total amount of ETH sent in
|
||||
uint256 ethFeeAmount = payEthFee(
|
||||
takerEthAmount,
|
||||
feeProportion,
|
||||
feeRecipient
|
||||
);
|
||||
uint256 wethSellAmount = safeSub(takerEthAmount, ethFeeAmount);
|
||||
// Convert ETH to WETH.
|
||||
convertEthToWeth();
|
||||
|
||||
// Deposit the remaining to be used for trading
|
||||
ETHER_TOKEN.deposit.value(wethSellAmount)();
|
||||
// Populate the known assetData, as it is always WETH the caller can provide null bytes to save gas
|
||||
// marketSellOrders fills the remaining
|
||||
address makerTokenAddress = LibBytes.readAddress(orders[0].makerAssetData, 16);
|
||||
orders[0].takerAssetData = WETH_ASSET_DATA;
|
||||
if (makerTokenAddress == address(ZRX_TOKEN)) {
|
||||
// If this is ZRX then we market sell from the orders, rather than a 2 step of buying ZRX fees from feeOrders
|
||||
// then buying ZRX from orders
|
||||
totalFillResults = marketSellEthForZRXInternal(
|
||||
uint256 wethSellAmount;
|
||||
uint256 zrxBuyAmount;
|
||||
uint256 makerAssetAmountPurchased;
|
||||
if (orders[0].makerAssetData.equals(ZRX_ASSET_DATA)) {
|
||||
// Calculate amount of WETH that won't be spent on ETH fees.
|
||||
wethSellAmount = getPartialAmount(
|
||||
PERCENTAGE_DENOMINATOR,
|
||||
safeAdd(PERCENTAGE_DENOMINATOR, feePercentage),
|
||||
msg.value
|
||||
);
|
||||
// Market sell available WETH.
|
||||
// ZRX fees are paid with this contract's balance.
|
||||
orderFillResults = marketSellWeth(
|
||||
orders,
|
||||
signatures,
|
||||
wethSellAmount
|
||||
);
|
||||
} else {
|
||||
totalFillResults = marketSellEthForERC20Internal(
|
||||
orders,
|
||||
signatures,
|
||||
feeOrders,
|
||||
feeSignatures,
|
||||
wethSellAmount
|
||||
);
|
||||
}
|
||||
// Prevent accidental WETH owned by this contract and it being spent
|
||||
require(
|
||||
takerEthAmount >= totalFillResults.takerAssetFilledAmount,
|
||||
"INVALID_MSG_VALUE"
|
||||
);
|
||||
// Ensure no WETH is left in this contract
|
||||
require(
|
||||
wethSellAmount == totalFillResults.takerAssetFilledAmount,
|
||||
"UNACCEPTABLE_THRESHOLD"
|
||||
);
|
||||
// Transfer all tokens to msg.sender
|
||||
transferERC20Token(
|
||||
makerTokenAddress,
|
||||
msg.sender,
|
||||
totalFillResults.makerAssetFilledAmount
|
||||
);
|
||||
return totalFillResults;
|
||||
}
|
||||
|
||||
/// @dev Buys the exact amount of assets (ERC20 and ERC721), performing fee abstraction if required.
|
||||
/// All order assets must be of the same type. Deducts a proportional fee to fee recipient.
|
||||
/// This function is payable and will convert all incoming ETH into WETH and perform the trade on behalf of the caller.
|
||||
/// The caller is sent all assets from the fill of orders. This function will revert unless the requested amount of assets are purchased.
|
||||
/// Any excess ETH sent will be returned to the caller
|
||||
/// @param orders An array of Order struct containing order specifications.
|
||||
/// @param signatures An array of Proof that order has been created by maker.
|
||||
/// @param feeOrders An array of Order struct containing order specifications for fees.
|
||||
/// @param makerTokenFillAmount The amount of maker asset to buy.
|
||||
/// @param feeSignatures An array of Proof that order has been created by maker for the fee orders.
|
||||
/// @param feeProportion A proportion deducted off the ETH spent and sent to feeRecipient. The maximum value for this
|
||||
/// is 1000, aka 10%. Supports up to 2 decimal places. I.e 0.59% is 59.
|
||||
/// @param feeRecipient An address of the fee recipient whom receives feeProportion of ETH.
|
||||
/// @return FillResults amounts filled and fees paid by maker and taker.
|
||||
function marketBuyTokensWithEth(
|
||||
LibOrder.Order[] memory orders,
|
||||
bytes[] memory signatures,
|
||||
LibOrder.Order[] memory feeOrders,
|
||||
bytes[] memory feeSignatures,
|
||||
uint256 makerTokenFillAmount,
|
||||
uint16 feeProportion,
|
||||
address feeRecipient
|
||||
)
|
||||
public
|
||||
payable
|
||||
returns (FillResults memory totalFillResults)
|
||||
{
|
||||
uint256 takerEthAmount = msg.value;
|
||||
require(
|
||||
takerEthAmount > 0,
|
||||
"VALUE_GREATER_THAN_ZERO"
|
||||
);
|
||||
require(
|
||||
makerTokenFillAmount > 0,
|
||||
"VALUE_GREATER_THAN_ZERO"
|
||||
);
|
||||
bytes4 assetDataId = LibBytes.readBytes4(orders[0].makerAssetData, 0);
|
||||
require(
|
||||
assetDataId == ERC20_DATA_ID || assetDataId == ERC721_DATA_ID,
|
||||
"UNSUPPORTED_TOKEN_PROXY"
|
||||
);
|
||||
|
||||
ETHER_TOKEN.deposit.value(takerEthAmount)();
|
||||
if (assetDataId == ERC20_DATA_ID) {
|
||||
totalFillResults = marketBuyERC20TokensInternal(
|
||||
orders,
|
||||
signatures,
|
||||
feeOrders,
|
||||
feeSignatures,
|
||||
makerTokenFillAmount
|
||||
);
|
||||
} else if (assetDataId == ERC721_DATA_ID) {
|
||||
totalFillResults = batchBuyERC721TokensInternal(
|
||||
orders,
|
||||
signatures,
|
||||
feeOrders,
|
||||
feeSignatures
|
||||
);
|
||||
}
|
||||
// Prevent accidental WETH owned by this contract and it being spent
|
||||
require(
|
||||
takerEthAmount >= totalFillResults.takerAssetFilledAmount,
|
||||
"INVALID_MSG_VALUE"
|
||||
);
|
||||
withdrawPayAndDeductEthFee(
|
||||
safeSub(takerEthAmount, totalFillResults.takerAssetFilledAmount),
|
||||
totalFillResults.takerAssetFilledAmount,
|
||||
feeProportion,
|
||||
feeRecipient
|
||||
);
|
||||
return totalFillResults;
|
||||
}
|
||||
|
||||
/// @dev Market sells WETH for ERC20 tokens.
|
||||
/// @param orders An array of Order struct containing order specifications.
|
||||
/// @param signatures An array of Proof that order has been created by maker.
|
||||
/// @param feeOrders An array of Order struct containing order specifications for fees.
|
||||
/// @param feeSignatures An array of Proof that order has been created by maker for the fee orders.
|
||||
/// @param wethSellAmount The amount of WETH to sell.
|
||||
/// @return FillResults amounts filled and fees paid by maker and taker.
|
||||
function marketSellEthForERC20Internal(
|
||||
LibOrder.Order[] memory orders,
|
||||
bytes[] memory signatures,
|
||||
LibOrder.Order[] memory feeOrders,
|
||||
bytes[] memory feeSignatures,
|
||||
uint256 wethSellAmount
|
||||
)
|
||||
internal
|
||||
returns (FillResults memory totalFillResults)
|
||||
{
|
||||
uint256 remainingWethSellAmount = wethSellAmount;
|
||||
FillResults memory calculatedMarketSellResults = calculateMarketSellResults(orders, wethSellAmount);
|
||||
if (calculatedMarketSellResults.takerFeePaid > 0) {
|
||||
// Fees are required for these orders. Buy enough ZRX to cover the future market buy
|
||||
FillResults memory feeTokensResults = marketBuyZrxInternal(
|
||||
feeOrders,
|
||||
feeSignatures,
|
||||
calculatedMarketSellResults.takerFeePaid
|
||||
);
|
||||
// Ensure the token abstraction was fair if fees were proportionally too high, we fail
|
||||
require(
|
||||
isAcceptableThreshold(
|
||||
wethSellAmount,
|
||||
safeSub(wethSellAmount, feeTokensResults.takerAssetFilledAmount)
|
||||
),
|
||||
"UNACCEPTABLE_THRESHOLD"
|
||||
);
|
||||
remainingWethSellAmount = safeSub(remainingWethSellAmount, feeTokensResults.takerAssetFilledAmount);
|
||||
totalFillResults.takerFeePaid = feeTokensResults.takerFeePaid;
|
||||
totalFillResults.takerAssetFilledAmount = feeTokensResults.takerAssetFilledAmount;
|
||||
}
|
||||
// Make our market sell to buy the requested tokens with the remaining balance
|
||||
FillResults memory requestedTokensResults = EXCHANGE.marketSellOrders(
|
||||
orders,
|
||||
remainingWethSellAmount,
|
||||
signatures
|
||||
);
|
||||
// Update our return FillResult with the market sell
|
||||
addFillResults(totalFillResults, requestedTokensResults);
|
||||
return totalFillResults;
|
||||
}
|
||||
|
||||
/// @dev Market sells WETH for ZRX tokens.
|
||||
/// @param orders An array of Order struct containing order specifications.
|
||||
/// @param signatures An array of Proof that order has been created by maker.
|
||||
/// @param wethSellAmount The amount of WETH to sell.
|
||||
/// @return FillResults amounts filled and fees paid by maker and taker.
|
||||
function marketSellEthForZRXInternal(
|
||||
LibOrder.Order[] memory orders,
|
||||
bytes[] memory signatures,
|
||||
uint256 wethSellAmount
|
||||
)
|
||||
internal
|
||||
returns (FillResults memory totalFillResults)
|
||||
{
|
||||
// Make our market sell to buy the requested tokens with the remaining balance
|
||||
totalFillResults = EXCHANGE.marketSellOrders(
|
||||
orders,
|
||||
wethSellAmount,
|
||||
signatures
|
||||
);
|
||||
// Exchange does not special case ZRX in the makerAssetFilledAmount, if fees were deducted then using this amount
|
||||
// for future transfers is invalid.
|
||||
uint256 zrxAmountBought = safeSub(totalFillResults.makerAssetFilledAmount, totalFillResults.takerFeePaid);
|
||||
require(
|
||||
isAcceptableThreshold(totalFillResults.makerAssetFilledAmount, zrxAmountBought),
|
||||
"UNACCEPTABLE_THRESHOLD"
|
||||
);
|
||||
totalFillResults.makerAssetFilledAmount = zrxAmountBought;
|
||||
return totalFillResults;
|
||||
}
|
||||
|
||||
/// @dev Buys an exact amount of an ERC20 token using WETH.
|
||||
/// @param orders Orders to fill. The maker asset is the ERC20 token to buy. The taker asset is WETH.
|
||||
/// @param signatures Proof that the orders were created by their respective makers.
|
||||
/// @param feeOrders to fill. The maker asset is ZRX and the taker asset is WETH.
|
||||
/// @param feeSignatures Proof that the feeOrders were created by their respective makers.
|
||||
/// @param makerTokenFillAmount Amount of the ERC20 token to buy.
|
||||
/// @return totalFillResults Aggregated fill results of buying the ERC20 and ZRX tokens.
|
||||
function marketBuyERC20TokensInternal(
|
||||
LibOrder.Order[] memory orders,
|
||||
bytes[] memory signatures,
|
||||
LibOrder.Order[] memory feeOrders,
|
||||
bytes[] memory feeSignatures,
|
||||
uint256 makerTokenFillAmount
|
||||
)
|
||||
internal
|
||||
returns (LibFillResults.FillResults memory totalFillResults)
|
||||
{
|
||||
// We read the maker token address to check if it is ZRX and later use it for transfer
|
||||
address makerTokenAddress = LibBytes.readAddress(orders[0].makerAssetData, 16);
|
||||
// We assume that asset being bought by taker is the same for each order.
|
||||
// Rather than passing this in as calldata, we copy the makerAssetData from the first order onto all later orders.
|
||||
orders[0].takerAssetData = WETH_ASSET_DATA;
|
||||
// We can short cut here for effeciency and use buyFeeTokensInternal if maker asset token is ZRX
|
||||
// this buys us exactly that amount taking into account the fees. This saves gas and calculates the rate correctly
|
||||
FillResults memory marketBuyResults;
|
||||
if (makerTokenAddress == address(ZRX_TOKEN)) {
|
||||
marketBuyResults = marketBuyZrxInternal(
|
||||
orders,
|
||||
signatures,
|
||||
makerTokenFillAmount
|
||||
);
|
||||
// When buying ZRX we round up which can result in a small margin excess
|
||||
require(
|
||||
marketBuyResults.makerAssetFilledAmount >= makerTokenFillAmount,
|
||||
"UNACCEPTABLE_THRESHOLD"
|
||||
);
|
||||
addFillResults(totalFillResults, marketBuyResults);
|
||||
require(
|
||||
isAcceptableThreshold(
|
||||
safeAdd(totalFillResults.makerAssetFilledAmount, totalFillResults.takerFeePaid), // Total ZRX
|
||||
totalFillResults.makerAssetFilledAmount // amount going to msg.sender
|
||||
),
|
||||
"UNACCEPTABLE_THRESHOLD"
|
||||
);
|
||||
} else {
|
||||
FillResults memory calculatedMarketBuyResults = calculateMarketBuyResults(orders, makerTokenFillAmount);
|
||||
if (calculatedMarketBuyResults.takerFeePaid > 0) {
|
||||
// Fees are required for these orders. Buy enough ZRX to cover the future market buy
|
||||
FillResults memory zrxMarketBuyResults = marketBuyZrxInternal(
|
||||
feeOrders,
|
||||
feeSignatures,
|
||||
calculatedMarketBuyResults.takerFeePaid
|
||||
);
|
||||
totalFillResults.takerAssetFilledAmount = zrxMarketBuyResults.takerAssetFilledAmount;
|
||||
totalFillResults.takerFeePaid = zrxMarketBuyResults.takerFeePaid;
|
||||
}
|
||||
// Make our market buy of the requested tokens with the remaining balance
|
||||
marketBuyResults = EXCHANGE.marketBuyOrders(
|
||||
orders,
|
||||
makerTokenFillAmount,
|
||||
wethSellAmount,
|
||||
signatures
|
||||
);
|
||||
require(
|
||||
marketBuyResults.makerAssetFilledAmount == makerTokenFillAmount,
|
||||
"UNACCEPTABLE_THRESHOLD"
|
||||
// The fee amount must be deducted from the amount transfered back to sender.
|
||||
makerAssetAmountPurchased = safeSub(orderFillResults.makerAssetFilledAmount, orderFillResults.takerFeePaid);
|
||||
} else {
|
||||
// 5% of WETH is reserved for filling feeOrders and paying feeRecipient.
|
||||
wethSellAmount = getPartialAmount(
|
||||
MAX_WETH_FILL_PERCENTAGE,
|
||||
PERCENTAGE_DENOMINATOR,
|
||||
msg.value
|
||||
);
|
||||
addFillResults(totalFillResults, marketBuyResults);
|
||||
require(
|
||||
isAcceptableThreshold(
|
||||
totalFillResults.takerAssetFilledAmount,
|
||||
marketBuyResults.takerAssetFilledAmount
|
||||
),
|
||||
"UNACCEPTABLE_THRESHOLD"
|
||||
// Market sell 95% of WETH.
|
||||
// ZRX fees are payed with this contract's balance.
|
||||
orderFillResults = marketSellWeth(
|
||||
orders,
|
||||
wethSellAmount,
|
||||
signatures
|
||||
);
|
||||
// Buy back all ZRX spent on fees.
|
||||
zrxBuyAmount = orderFillResults.takerFeePaid;
|
||||
feeOrderFillResults = marketBuyZrxWithWeth(
|
||||
feeOrders,
|
||||
zrxBuyAmount,
|
||||
feeSignatures
|
||||
);
|
||||
makerAssetAmountPurchased = orderFillResults.makerAssetFilledAmount;
|
||||
}
|
||||
// Transfer all purchased tokens to msg.sender
|
||||
transferERC20Token(
|
||||
makerTokenAddress,
|
||||
msg.sender,
|
||||
marketBuyResults.makerAssetFilledAmount
|
||||
|
||||
// Ensure that all ZRX fees have been repurchased and no extra WETH owned by this contract has been sold.
|
||||
assertValidFillResults(
|
||||
orderFillResults,
|
||||
feeOrderFillResults,
|
||||
zrxBuyAmount
|
||||
);
|
||||
return totalFillResults;
|
||||
|
||||
// Transfer feePercentage of total ETH spent on primary orders to feeRecipient.
|
||||
// Refund remaining ETH to msg.sender.
|
||||
transferEthFeeAndRefund(
|
||||
orderFillResults.takerAssetFilledAmount,
|
||||
feeOrderFillResults.takerAssetFilledAmount,
|
||||
feePercentage,
|
||||
feeRecipient
|
||||
);
|
||||
|
||||
// Transfer purchased assets to msg.sender.
|
||||
transferPurchasedAssetToSender(orders[0].makerAssetData, makerAssetAmountPurchased);
|
||||
}
|
||||
|
||||
/// @dev Buys an all of the ERC721 tokens in the orders.
|
||||
/// @param orders Orders to fill. The maker asset is the ERC721 token to buy. The taker asset is WETH.
|
||||
/// @param signatures Proof that the orders were created by their respective makers.
|
||||
/// @param feeOrders to fill. The maker asset is ZRX and the taker asset is WETH.
|
||||
/// @param feeSignatures Proof that the feeOrders were created by their respective makers.
|
||||
/// @return totalFillResults Aggregated fill results of buying the ERC721 tokens and ZRX tokens.
|
||||
function batchBuyERC721TokensInternal(
|
||||
/// @dev Attempt to purchase makerAssetFillAmount of makerAsset by selling ETH provided with transaction.
|
||||
/// Any ZRX required to pay fees for primary orders will automatically be purchased by this contract.
|
||||
/// Any ETH not spent will be refunded to sender.
|
||||
/// @param orders Array of order specifications used containing desired makerAsset and WETH as takerAsset.
|
||||
/// @param makerAssetFillAmount Desired amount of makerAsset to purchase.
|
||||
/// @param signatures Proofs that orders have been created by makers.
|
||||
/// @param feeOrders Array of order specifications containing ZRX as makerAsset and WETH as takerAsset. Used to purchase ZRX for primary order fees.
|
||||
/// @param feeSignatures Proofs that feeOrders have been created by makers.
|
||||
/// @param feePercentage Percentage of WETH sold that will payed as fee to forwarding contract feeRecipient.
|
||||
/// @param feeRecipient Address that will receive ETH when orders are filled.
|
||||
/// @return Amounts filled and fees paid by maker and taker for both sets of orders.
|
||||
function marketBuyOrdersWithEth(
|
||||
LibOrder.Order[] memory orders,
|
||||
uint256 makerAssetFillAmount,
|
||||
bytes[] memory signatures,
|
||||
LibOrder.Order[] memory feeOrders,
|
||||
bytes[] memory feeSignatures
|
||||
bytes[] memory feeSignatures,
|
||||
uint256 feePercentage,
|
||||
address feeRecipient
|
||||
)
|
||||
public
|
||||
payable
|
||||
returns (
|
||||
FillResults memory orderFillResults,
|
||||
FillResults memory feeOrderFillResults
|
||||
)
|
||||
{
|
||||
// Convert ETH to WETH.
|
||||
convertEthToWeth();
|
||||
|
||||
uint256 zrxBuyAmount;
|
||||
uint256 makerAssetAmountPurchased;
|
||||
if (orders[0].makerAssetData.equals(ZRX_ASSET_DATA)) {
|
||||
// If the makerAsset is ZRX, it is not necessary to pay fees out of this
|
||||
// contracts's ZRX balance because fees are factored into the price of the order.
|
||||
orderFillResults = marketBuyZrxWithWeth(
|
||||
orders,
|
||||
makerAssetFillAmount,
|
||||
signatures
|
||||
);
|
||||
// The fee amount must be deducted from the amount transfered back to sender.
|
||||
makerAssetAmountPurchased = safeSub(orderFillResults.makerAssetFilledAmount, orderFillResults.takerFeePaid);
|
||||
} else {
|
||||
// Attemp to purchase desired amount of makerAsset.
|
||||
// ZRX fees are payed with this contract's balance.
|
||||
orderFillResults = marketBuyWithWeth(
|
||||
orders,
|
||||
makerAssetFillAmount,
|
||||
signatures
|
||||
);
|
||||
// Buy back all ZRX spent on fees.
|
||||
zrxBuyAmount = orderFillResults.takerFeePaid;
|
||||
feeOrderFillResults = marketBuyZrxWithWeth(
|
||||
feeOrders,
|
||||
zrxBuyAmount,
|
||||
feeSignatures
|
||||
);
|
||||
makerAssetAmountPurchased = orderFillResults.makerAssetFilledAmount;
|
||||
}
|
||||
|
||||
// Ensure that all ZRX fees have been repurchased and no extra WETH owned by this contract has been sold.
|
||||
assertValidFillResults(
|
||||
orderFillResults,
|
||||
feeOrderFillResults,
|
||||
zrxBuyAmount
|
||||
);
|
||||
|
||||
// Transfer feePercentage of total ETH spent on primary orders to feeRecipient.
|
||||
// Refund remaining ETH to msg.sender.
|
||||
transferEthFeeAndRefund(
|
||||
orderFillResults.takerAssetFilledAmount,
|
||||
feeOrderFillResults.takerAssetFilledAmount,
|
||||
feePercentage,
|
||||
feeRecipient
|
||||
);
|
||||
|
||||
// Transfer purchased assets to msg.sender.
|
||||
transferPurchasedAssetToSender(orders[0].makerAssetData, makerAssetAmountPurchased);
|
||||
}
|
||||
|
||||
/// @dev Ensures that all ZRX fees have been repurchased and no extra WETH owned by this contract has been sold.
|
||||
/// @param orderFillResults Amounts filled and fees paid for primary orders.
|
||||
/// @param feeOrderFillResults Amounts filled and fees paid for fee orders.
|
||||
/// @param zrxBuyAmount The amount of ZRX that needed to be repurchased after filling primary orders.
|
||||
function assertValidFillResults(
|
||||
FillResults memory orderFillResults,
|
||||
FillResults memory feeOrderFillResults,
|
||||
uint256 zrxBuyAmount
|
||||
)
|
||||
internal
|
||||
returns (LibFillResults.FillResults memory totalFillResults)
|
||||
view
|
||||
{
|
||||
uint256 totalZrxFeeAmount;
|
||||
uint256 ordersLength = orders.length;
|
||||
uint256[] memory takerAssetFillAmounts = new uint256[](ordersLength);
|
||||
for (uint256 i = 0; i < ordersLength; i++) {
|
||||
// Total up the fees
|
||||
totalZrxFeeAmount = safeAdd(totalZrxFeeAmount, orders[i].takerFee);
|
||||
// We assume that asset being bought by taker is the same for each order.
|
||||
// Rather than passing this in as calldata, we set the takerAssetData as WETH asset data
|
||||
orders[i].takerAssetData = WETH_ASSET_DATA;
|
||||
// Populate takerAssetFillAmounts for later batchFill
|
||||
takerAssetFillAmounts[i] = orders[i].takerAssetAmount;
|
||||
}
|
||||
if (totalZrxFeeAmount > 0) {
|
||||
// Fees are required for these orders. Buy enough ZRX to cover the future fill
|
||||
FillResults memory zrxMarketBuyResults = marketBuyZrxInternal(
|
||||
feeOrders,
|
||||
feeSignatures,
|
||||
totalZrxFeeAmount
|
||||
);
|
||||
totalFillResults.takerFeePaid = zrxMarketBuyResults.takerFeePaid;
|
||||
totalFillResults.takerAssetFilledAmount = zrxMarketBuyResults.takerAssetFilledAmount;
|
||||
}
|
||||
FillResults memory batchFillResults = EXCHANGE.batchFillOrKillOrders(
|
||||
orders,
|
||||
takerAssetFillAmounts,
|
||||
signatures
|
||||
);
|
||||
addFillResults(totalFillResults, batchFillResults);
|
||||
// Ensure that all ZRX spent while filling primary orders has been repurchased.
|
||||
uint256 zrxPurchased = safeSub(feeOrderFillResults.makerAssetFilledAmount, feeOrderFillResults.takerFeePaid);
|
||||
require(
|
||||
isAcceptableThreshold(
|
||||
totalFillResults.takerAssetFilledAmount,
|
||||
batchFillResults.takerAssetFilledAmount
|
||||
),
|
||||
"UNACCEPTABLE_THRESHOLD"
|
||||
zrxPurchased >= zrxBuyAmount,
|
||||
"COMPLETE_FILL_FAILED"
|
||||
);
|
||||
|
||||
// Ensure that no extra WETH owned by this contract has been sold.
|
||||
uint256 wethSold = safeAdd(orderFillResults.takerAssetFilledAmount, feeOrderFillResults.takerAssetFilledAmount);
|
||||
require(
|
||||
wethSold <= msg.value,
|
||||
"OVERSOLD_WETH"
|
||||
);
|
||||
// Transfer all of the tokens filled from the batchFill
|
||||
for (i = 0; i < ordersLength; i++) {
|
||||
transferERC721Token(
|
||||
orders[i].makerAssetData,
|
||||
msg.sender
|
||||
);
|
||||
}
|
||||
return totalFillResults;
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user