Compare commits
2572 Commits
@0xproject
...
@0xproject
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 | ||
|
|
a9b320e636 | ||
|
|
ecdc0636d8 | ||
|
|
ea12e34809 | ||
|
|
9fb7865292 | ||
|
|
12f30c78ff | ||
|
|
e3bed5cc71 | ||
|
|
0f8f5ca5ff | ||
|
|
0fe0433b9a | ||
|
|
ab1e38701d | ||
|
|
258fe8ea50 | ||
|
|
813824868e | ||
|
|
028184947f | ||
|
|
14c96e0b97 | ||
|
|
ef03d1ae13 | ||
|
|
f1613d36ac | ||
|
|
8314bbbbac | ||
|
|
462f1f00d8 | ||
|
|
1c80bba4dd | ||
|
|
d22cff0976 | ||
|
|
269b56b907 | ||
|
|
60ebfcf36d | ||
|
|
824c331ea0 | ||
|
|
b9e51d2fad | ||
|
|
9669a4d121 | ||
|
|
e929fb4337 | ||
|
|
80da9cd31f | ||
|
|
5ed7a1baba | ||
|
|
07c111d1f5 | ||
|
|
a2024da955 | ||
|
|
7418926ebb | ||
|
|
4cc33d270e | ||
|
|
f767f5c12c | ||
|
|
0ea3b10efd | ||
|
|
d634775d40 | ||
|
|
c4ab5bc653 | ||
|
|
1d3bdfc374 | ||
|
|
72fb1ee36f | ||
|
|
afbc4989d5 | ||
|
|
d2e422cd5e | ||
|
|
49c7365d93 | ||
|
|
c753e24f0a | ||
|
|
acfbba5476 | ||
|
|
e796734659 | ||
|
|
f172908bde | ||
|
|
16dc4e9f66 | ||
|
|
8eefc89d55 | ||
|
|
20d349cea7 | ||
|
|
22f408f713 | ||
|
|
1e0fa776c1 | ||
|
|
faf5c84082 | ||
|
|
b21f6e4d86 | ||
|
|
bc52303402 | ||
|
|
2da705e81c | ||
|
|
a0601cd052 | ||
|
|
ed2c06508b | ||
|
|
03b3d74748 | ||
|
|
0557d6a9bf | ||
|
|
d975c0cef3 | ||
|
|
188bf000b7 | ||
|
|
608442b2e8 | ||
|
|
aefc122caf | ||
|
|
a72eae7ea8 | ||
|
|
30e3afc0fb | ||
|
|
97809a03eb | ||
|
|
f894ffc0cc | ||
|
|
127fbc6e94 | ||
|
|
9f870b3d4e | ||
|
|
51b86742d1 | ||
|
|
3a85b3212b | ||
|
|
fd6445439e | ||
|
|
51fa8d3e24 | ||
|
|
7b8db1156d | ||
|
|
32ad34d224 | ||
|
|
cfbb1c440e | ||
|
|
ade2f96ca3 | ||
|
|
abb38e1bc0 | ||
|
|
0df36471b7 | ||
|
|
97312c2656 | ||
|
|
e9e4df4891 | ||
|
|
e0f80c5e6a | ||
|
|
f21b042ed1 | ||
|
|
d8c7c9803c | ||
|
|
302b9deef3 | ||
|
|
0c8264801a | ||
|
|
54d1a0359f | ||
|
|
b87e48c113 | ||
|
|
a874cd2424 | ||
|
|
d9e308e53a | ||
|
|
efc3536283 | ||
|
|
4b7e669d29 | ||
|
|
01c6efeaf1 | ||
|
|
22cf7bee5b | ||
|
|
ef890aeac4 | ||
|
|
91e8c00076 | ||
|
|
20bf4d8ef9 | ||
|
|
795da130a2 | ||
|
|
51a625d4af | ||
|
|
ab8544b0ff | ||
|
|
b68d16820f | ||
|
|
61d9cdced0 | ||
|
|
714f9ed207 | ||
|
|
ccccaf8e12 | ||
|
|
c3ce9d6104 | ||
|
|
d3f602f063 | ||
|
|
6b379a8a0f | ||
|
|
d1d636f1ca | ||
|
|
ba9d3cbdb8 | ||
|
|
bcf8d51806 | ||
|
|
66c0d6724a | ||
|
|
0f477607f9 | ||
|
|
c1635f2656 | ||
|
|
029d91bd7a | ||
|
|
03dbad6813 | ||
|
|
c65b2573c4 | ||
|
|
7fbee77875 | ||
|
|
3cc1a952ca | ||
|
|
9c8de3e933 | ||
|
|
cbdce6b67e | ||
|
|
a6746ae5cd | ||
|
|
7111f3ffc6 | ||
|
|
87a7a4ad2d | ||
|
|
1ee2d6ed54 | ||
|
|
1eba78e20a | ||
|
|
a1fb438a8c | ||
|
|
40d1b0a23c | ||
|
|
1c9a657693 | ||
|
|
11747c6cf4 | ||
|
|
2a7b3aecc3 | ||
|
|
75babed693 | ||
|
|
0a32ae6cb5 | ||
|
|
3d67f122a5 | ||
|
|
b0daec8384 | ||
|
|
f5b1fe0e6b | ||
|
|
139d289b01 | ||
|
|
fd242a9cba | ||
|
|
7efa17ef7d | ||
|
|
a0b9c7777b | ||
|
|
5204e4c08d | ||
|
|
1050ecdf3c | ||
|
|
5176d929fa | ||
|
|
d712dc47d9 | ||
|
|
8adc6f0faa | ||
|
|
4e783fba57 | ||
|
|
ade620f4f7 | ||
|
|
5915f8430c | ||
|
|
9e0f06d060 | ||
|
|
ce86ae0191 | ||
|
|
2bec5cb7fd | ||
|
|
cd766ea2a1 | ||
|
|
aeea3817a4 | ||
|
|
0f11ae1875 | ||
|
|
6e87e3e1ac | ||
|
|
4ba108d12f | ||
|
|
8ff17ff960 | ||
|
|
0d56daf7ab | ||
|
|
9db0bc262b | ||
|
|
f410903465 | ||
|
|
5f2c303bd8 | ||
|
|
6aa4984fed | ||
|
|
f5cd1ac82e | ||
|
|
54c0b7b261 | ||
|
|
a7902eca1f | ||
|
|
2b4bb579d4 | ||
|
|
52c956222e | ||
|
|
0900e0c85e | ||
|
|
a5653337c1 | ||
|
|
d097113639 | ||
|
|
9389d64392 | ||
|
|
931e7e7d71 | ||
|
|
cce2fb40a1 | ||
|
|
547cf4bef3 | ||
|
|
d528ce757c | ||
|
|
3b78188fec | ||
|
|
d91b30faef | ||
|
|
dc956020ef | ||
|
|
a52eb81380 | ||
|
|
ab0055d5c6 | ||
|
|
32c25a2034 | ||
|
|
c30b42434a | ||
|
|
3c797a6e11 | ||
|
|
9b864517e2 | ||
|
|
a858e2870b | ||
|
|
ce1542da4f | ||
|
|
d2ebf4a777 | ||
|
|
c5fcea1dbd | ||
|
|
5e8ef070e2 | ||
|
|
2d30c290e9 | ||
|
|
688b34710e | ||
|
|
afbfc8ba1c | ||
|
|
671f29774b | ||
|
|
4c99ac0ca2 | ||
|
|
0e690608d3 | ||
|
|
92f6391df5 | ||
|
|
f2af6e4b3a | ||
|
|
27c03cffe2 | ||
|
|
499915042e | ||
|
|
1a901554cc | ||
|
|
5b64b3ea93 | ||
|
|
6fc5c0cd46 | ||
|
|
328da21420 | ||
|
|
81062d20eb | ||
|
|
835d06dcdc | ||
|
|
8929543b55 | ||
|
|
f62044c1e3 | ||
|
|
a31f7a5112 | ||
|
|
fe68114f39 | ||
|
|
a5231df6d9 | ||
|
|
fd545ec00f | ||
|
|
73d8a2adf7 | ||
|
|
04d11d6fac | ||
|
|
2eede4a09e | ||
|
|
bc7e8ff471 | ||
|
|
73e81c62fb | ||
|
|
8c5dc7cecd | ||
|
|
300c9f09b9 | ||
|
|
06f4427939 | ||
|
|
b1dc20bbb3 | ||
|
|
4887d1d42f | ||
|
|
d247d72e3e | ||
|
|
50957e1d29 | ||
|
|
6aad12a52f | ||
|
|
db0944acde | ||
|
|
e553ef83de | ||
|
|
a619949a56 | ||
|
|
1346fa792a | ||
|
|
b763cdbd4c | ||
|
|
e4eac14dc9 | ||
|
|
bdda1f2992 | ||
|
|
9c7289d7a3 | ||
|
|
d861caca23 | ||
|
|
590033bcb2 | ||
|
|
af1e4574a8 | ||
|
|
7b806fe84d | ||
|
|
e54e2ac67b | ||
|
|
de9f0732a0 | ||
|
|
20acdbf6c3 | ||
|
|
6a6d2f73a8 | ||
|
|
f5a8f00af8 | ||
|
|
018a437d62 | ||
|
|
32d75b6483 | ||
|
|
cb6cace910 | ||
|
|
0326ddd79d | ||
|
|
d6f40a9281 | ||
|
|
687802394a | ||
|
|
ad570b8ae1 | ||
|
|
b9165c03af | ||
|
|
cfe57f52f4 | ||
|
|
86d4ffe7e5 | ||
|
|
2dea179333 | ||
|
|
5a7908984e | ||
|
|
955fdf5d13 | ||
|
|
a6f40d4187 | ||
|
|
6daf754f5b | ||
|
|
da8cf9981e | ||
|
|
be64184cfa | ||
|
|
3031598843 | ||
|
|
b9b00e10d3 | ||
|
|
6c34255a3e | ||
|
|
41064adc66 | ||
|
|
2fcc36bbad | ||
|
|
762c0143eb | ||
|
|
6c6f34ee72 | ||
|
|
42b7b0dab9 | ||
|
|
e58e35e098 | ||
|
|
654b048602 | ||
|
|
3ece72af49 | ||
|
|
2ef31991c7 | ||
|
|
d3293a5571 | ||
|
|
854752acdf | ||
|
|
0c889385f1 | ||
|
|
6e1a549fcb | ||
|
|
5f0a2953c6 | ||
|
|
78b513c52a | ||
|
|
8ffce78827 | ||
|
|
d4852092b8 | ||
|
|
622ce0bf2e | ||
|
|
6a197a64e6 | ||
|
|
1e4c3ed22b | ||
|
|
e3521c6388 | ||
|
|
9d81e069dc | ||
|
|
8623a30763 | ||
|
|
6cf39896f1 | ||
|
|
44b6adaa29 | ||
|
|
762a6199b2 | ||
|
|
8da42b12f4 | ||
|
|
c473a0444c | ||
|
|
e693629bbd | ||
|
|
0dbe883c3b | ||
|
|
cc12bc9247 | ||
|
|
ddec01e6c1 | ||
|
|
03bc7bb935 | ||
|
|
5207dfdc0e | ||
|
|
fc40efb761 | ||
|
|
50556e2609 | ||
|
|
7a22298597 | ||
|
|
36cadaae46 | ||
|
|
09e921a562 | ||
|
|
13cbaf56b2 | ||
|
|
62910c8e89 | ||
|
|
f20e1acad9 | ||
|
|
5dea432ebf | ||
|
|
016d82d766 | ||
|
|
260c72cc20 | ||
|
|
3d7bcd7ecb | ||
|
|
ac9175bf88 | ||
|
|
294d3bbdc1 | ||
|
|
6db614251e | ||
|
|
bcc588efe7 | ||
|
|
f7b3fc58bc | ||
|
|
de40497330 | ||
|
|
d84bb7ed7e | ||
|
|
f02ada2d11 | ||
|
|
48970d3424 | ||
|
|
8940b1759d | ||
|
|
91a50d0f53 | ||
|
|
ed4f8c5b66 | ||
|
|
2f07ee0a8f | ||
|
|
8dd00a8eef | ||
|
|
d7845a177e | ||
|
|
7a3be0a320 | ||
|
|
14cebce304 | ||
|
|
9fcf9f2504 | ||
|
|
c466ab6cf2 | ||
|
|
01bf789ad4 | ||
|
|
1a1ab5af54 | ||
|
|
4089ad7b4b | ||
|
|
2adc299c78 | ||
|
|
3aef323c13 | ||
|
|
a655cd046c | ||
|
|
9c8701f5f6 | ||
|
|
7ac84aff0a | ||
|
|
fd13c8f68c | ||
|
|
532964af42 | ||
|
|
52d1407215 | ||
|
|
ecb7356345 | ||
|
|
edda7dae94 | ||
|
|
32da0a376a | ||
|
|
073e76ee90 | ||
|
|
ceba82260f | ||
|
|
a5a61c87fc | ||
|
|
d34feb1e0a | ||
|
|
6cc5e45183 | ||
|
|
618c7ef48a | ||
|
|
14047f9c7b | ||
|
|
f439f162d2 | ||
|
|
5b685b32bd | ||
|
|
6ce151c676 | ||
|
|
eb79b5d651 | ||
|
|
608e1c8960 | ||
|
|
f8772d8850 | ||
|
|
ce2f408864 | ||
|
|
c2a362e3ea | ||
|
|
eafdd4d42d | ||
|
|
1a2c58494f | ||
|
|
68c00976f1 | ||
|
|
aa2616b307 | ||
|
|
3062c18ebd | ||
|
|
a83f5241dc | ||
|
|
f89acb49be | ||
|
|
2b5f45676f | ||
|
|
aedd51a61b | ||
|
|
0b5a49c17d | ||
|
|
08f7666d21 | ||
|
|
81ff99276b | ||
|
|
e71862676c | ||
|
|
67777c586d | ||
|
|
9ada8e4ddf | ||
|
|
0142e7fa8f | ||
|
|
467e9abf5f | ||
|
|
512980d9bd | ||
|
|
e235a63119 | ||
|
|
4c28b66539 | ||
|
|
46d79e5115 | ||
|
|
d79994fbb2 | ||
|
|
518a2da027 | ||
|
|
71fa92dbeb | ||
|
|
172d2353dd | ||
|
|
3315006c45 | ||
|
|
6700745585 | ||
|
|
0ff18058ab | ||
|
|
1a11283086 | ||
|
|
ed559be47c | ||
|
|
a60dd1cbaf | ||
|
|
7ee37fb62a | ||
|
|
2970e103db | ||
|
|
78333b3026 | ||
|
|
1ca182e741 | ||
|
|
8419db53bb | ||
|
|
f76c9bc226 | ||
|
|
6a39a69afe | ||
|
|
2474d1d2f4 | ||
|
|
e4188f5d4c | ||
|
|
0fcbd02d50 | ||
|
|
4969797c23 | ||
|
|
0e932286d2 | ||
|
|
366a9502dd | ||
|
|
988a334758 | ||
|
|
4fe6269043 | ||
|
|
646927962a | ||
|
|
b56baefaa6 | ||
|
|
f49a507297 | ||
|
|
c20549e88d | ||
|
|
cd16986942 | ||
|
|
e481404a14 | ||
|
|
3dfde15133 | ||
|
|
4454cfa65d | ||
|
|
382839464f | ||
|
|
cce5585795 | ||
|
|
26a9fe9127 | ||
|
|
47a267c3fa | ||
|
|
36836eb942 | ||
|
|
aad0804a1e | ||
|
|
3c68d9c297 | ||
|
|
ffdc7d13a9 | ||
|
|
c5085d8364 | ||
|
|
00ad7bc470 | ||
|
|
360927ec77 | ||
|
|
b6f546ebe0 | ||
|
|
2a092143dc | ||
|
|
de50407953 | ||
|
|
57d5fbfbd8 | ||
|
|
92322c0e07 | ||
|
|
97ed453eb4 | ||
|
|
654b782810 | ||
|
|
51211a21ba | ||
|
|
133b6fe240 | ||
|
|
c824fe8718 | ||
|
|
26d3a487a5 | ||
|
|
e0a2afc068 | ||
|
|
f6e97bb284 | ||
|
|
6c8b998505 | ||
|
|
f9fab216e9 | ||
|
|
c308359f59 | ||
|
|
375d667144 | ||
|
|
84bd54ba40 | ||
|
|
73c36fe2d2 | ||
|
|
ec3e9efdaa | ||
|
|
d5c389b7dc | ||
|
|
7f233dcb15 | ||
|
|
6a2421c683 | ||
|
|
d66ca7b5cb | ||
|
|
5e38cbd69c | ||
|
|
b6d8dcb6e1 | ||
|
|
08ee1ab2e6 | ||
|
|
26edec5773 | ||
|
|
d72e06842f | ||
|
|
0a0da63ac7 | ||
|
|
873ec898d8 | ||
|
|
97a70d14a3 | ||
|
|
394fbebfa8 | ||
|
|
b79588c4a0 | ||
|
|
3b46e82625 | ||
|
|
dbaf1fcd43 | ||
|
|
4caf1271e4 | ||
|
|
6921943aff | ||
|
|
3ce90b8257 | ||
|
|
3866154b50 | ||
|
|
64ed2464cf | ||
|
|
e27780aee9 | ||
|
|
744e6e60c5 | ||
|
|
f70c1ff009 | ||
|
|
3a808fe7fd | ||
|
|
2ca169b3c4 | ||
|
|
098d486291 | ||
|
|
ec4fb70b80 | ||
|
|
2a82807be4 | ||
|
|
43ae868c69 | ||
|
|
1bc742aed1 | ||
|
|
6dc852774e | ||
|
|
7967ebed57 | ||
|
|
105b927397 | ||
|
|
9219f9d8ae | ||
|
|
f780e6f235 | ||
|
|
27670f4da6 | ||
|
|
e051743a3d | ||
|
|
fb03003b3a | ||
|
|
e52d0a3512 | ||
|
|
cba92a01b6 | ||
|
|
0a87364101 | ||
|
|
a89908540f | ||
|
|
c4e2dcafa4 | ||
|
|
0163984ea4 | ||
|
|
db3ce08cab | ||
|
|
1076959006 | ||
|
|
5127cbb22c | ||
|
|
9175b43542 | ||
|
|
562fec01d8 | ||
|
|
b8051c8fed | ||
|
|
4df66a4802 | ||
|
|
a2ff63daa5 | ||
|
|
7ce0f9682f | ||
|
|
3c6d0dc3e0 | ||
|
|
64a6fb2344 | ||
|
|
07734a5184 | ||
|
|
32d4994219 | ||
|
|
08d22d2f3c | ||
|
|
b7b0185baf | ||
|
|
7b0c13c121 | ||
|
|
a98ecc05af | ||
|
|
f7337c1a05 | ||
|
|
53e2cda4c8 | ||
|
|
8064914bb7 | ||
|
|
6bb2203f79 | ||
|
|
3d56817da1 | ||
|
|
31e3b9ff8b | ||
|
|
b2e32aaf58 | ||
|
|
699de9174e | ||
|
|
1dd9ec4d5a | ||
|
|
87d66ccf6c | ||
|
|
1134ff1075 | ||
|
|
178676ef8c | ||
|
|
94740155e5 | ||
|
|
9341afe764 | ||
|
|
7ce1e9b18d | ||
|
|
1821f60fb5 | ||
|
|
235d78565e | ||
|
|
db5880539b | ||
|
|
76f4d67f33 | ||
|
|
e59c57106c | ||
|
|
bb4c748bf1 | ||
|
|
92cb9c3807 | ||
|
|
1a4e99431b | ||
|
|
ec9d1ca57e | ||
|
|
71c9b98896 | ||
|
|
71bac8c60b | ||
|
|
7b0f7c2e5c | ||
|
|
ad67a6add5 | ||
|
|
1353723b58 | ||
|
|
f811c07454 | ||
|
|
bb85382824 | ||
|
|
3ed4a1ba20 | ||
|
|
c50da5d034 | ||
|
|
9b196ba68c | ||
|
|
df79fb19af | ||
|
|
f8bde5ab9b | ||
|
|
0cd37cbf7e | ||
|
|
d621e4201d | ||
|
|
82af1df3c3 | ||
|
|
ea8c2b8d69 | ||
|
|
8ddcb6c841 | ||
|
|
1681361aed | ||
|
|
6a6f98299d | ||
|
|
19ba272d62 | ||
|
|
2f8ceca2ef | ||
|
|
ba1baafca5 | ||
|
|
20a07494f6 | ||
|
|
c66477c690 | ||
|
|
5c612a186f | ||
|
|
943e556f43 | ||
|
|
4bf4f96f47 | ||
|
|
384cd2f605 | ||
|
|
425af46f98 | ||
|
|
c83ee04662 | ||
|
|
2054cd78da | ||
|
|
88982f98ff | ||
|
|
2ea0b839d3 | ||
|
|
afd83e59b8 | ||
|
|
7f84049538 | ||
|
|
98840c9c5f | ||
|
|
26cacfa247 | ||
|
|
4b2d27b5e5 | ||
|
|
69625946b1 | ||
|
|
f7fe9b0961 | ||
|
|
7fcd34eb36 | ||
|
|
1f5848ba82 | ||
|
|
bbd414bdcd | ||
|
|
a1737a28d0 | ||
|
|
66be42d1f8 | ||
|
|
c984c0f2c0 | ||
|
|
89d2bb7ecd | ||
|
|
9f8cad93f7 | ||
|
|
a207260fe0 | ||
|
|
1ef4a47255 | ||
|
|
b8aa68b4d1 | ||
|
|
61edbac6e5 | ||
|
|
d315133d34 | ||
|
|
82d59dbea8 | ||
|
|
42884e0871 | ||
|
|
7fb8b546f9 | ||
|
|
80fe1938b8 | ||
|
|
2409afae95 | ||
|
|
06705f9e88 | ||
|
|
2b408e71ac | ||
|
|
b097193486 | ||
|
|
543f2c91fe | ||
|
|
05c0088445 | ||
|
|
2f6f815d81 | ||
|
|
1e03fbe1a8 | ||
|
|
4409f11b24 | ||
|
|
7a216901be | ||
|
|
0e7c254b93 | ||
|
|
ba14850c9a | ||
|
|
59d3a21993 | ||
|
|
d2faa49bf4 | ||
|
|
438c0e27ea | ||
|
|
4c14372b4a | ||
|
|
8b4077d7de | ||
|
|
914b009361 | ||
|
|
b2a4b7eb88 | ||
|
|
daa50442c9 | ||
|
|
76fd7f47eb | ||
|
|
fbf840cb68 | ||
|
|
798a647b71 | ||
|
|
26a0b09064 | ||
|
|
98570b5da1 | ||
|
|
e923d7dafb | ||
|
|
64b6861880 | ||
|
|
c46e11cae2 | ||
|
|
82ccfa21e1 | ||
|
|
13f7fc1fd2 | ||
|
|
018cc14a87 | ||
|
|
3ce295a2af | ||
|
|
a30107ab86 | ||
|
|
d8df6968d3 | ||
|
|
0515c6acde | ||
|
|
607b44e01d | ||
|
|
5c0bae2070 | ||
|
|
4012e31115 | ||
|
|
2d8e9eda56 | ||
|
|
4375a0e07e | ||
|
|
a07cfb7abc | ||
|
|
c131d82699 | ||
|
|
de2dcbae5a | ||
|
|
b0000bb276 | ||
|
|
82789d5315 | ||
|
|
3df5882711 | ||
|
|
b6765b849c | ||
|
|
df94e5f164 | ||
|
|
79edc12c76 | ||
|
|
bd03151c2a | ||
|
|
7c0fdc7ecf | ||
|
|
b333ed91de | ||
|
|
6a073d5f86 | ||
|
|
c7159b2be4 | ||
|
|
2d98193c83 | ||
|
|
685756f9d5 | ||
|
|
535bb364b6 | ||
|
|
c740539f48 | ||
|
|
4cf331067b | ||
|
|
a3ba7683f4 | ||
|
|
5edfec68cf | ||
|
|
eb494f78fa | ||
|
|
d963941be0 | ||
|
|
8ab65fdde4 | ||
|
|
8e2c0bb977 | ||
|
|
f1f1064f70 | ||
|
|
88500e3714 | ||
|
|
eae2a4df8b | ||
|
|
ade8e95d2e | ||
|
|
a0b225b8b1 | ||
|
|
323e8756ba | ||
|
|
ada5428df7 | ||
|
|
7869c19245 | ||
|
|
5706b29c8c | ||
|
|
8ff7b2405f | ||
|
|
eaabe15863 | ||
|
|
63b2ae743b | ||
|
|
c5ea985a70 | ||
|
|
11b35b89f5 | ||
|
|
6d5b16725d | ||
|
|
c34897036e | ||
|
|
1e51af1d4b | ||
|
|
8ee6e26608 | ||
|
|
4d36f38f96 | ||
|
|
d31ca444e1 | ||
|
|
090b3014c0 | ||
|
|
491a322ceb | ||
|
|
12e16d532b | ||
|
|
7814a391d8 | ||
|
|
322151b0d5 | ||
|
|
4a136cafda | ||
|
|
d0df25d9e2 | ||
|
|
8d003dbc30 | ||
|
|
2c7358d64f | ||
|
|
94e260cec6 | ||
|
|
783ac3c105 | ||
|
|
d46e3f6778 | ||
|
|
6fe3158778 | ||
|
|
bbd12e33ec | ||
|
|
e4d55242d8 | ||
|
|
dedddcfcf5 | ||
|
|
613a78bcf6 | ||
|
|
f5decb1d7e | ||
|
|
47b4c236c3 | ||
|
|
39ccb2df0b | ||
|
|
5bfdffda11 | ||
|
|
247f8c8557 | ||
|
|
3ce449e167 | ||
|
|
663f9657ea | ||
|
|
457f951aaf | ||
|
|
feafd57027 | ||
|
|
5c0183c71e | ||
|
|
fb7d425244 | ||
|
|
3fab40efe5 | ||
|
|
0bbdbc9e63 | ||
|
|
9bc481ff62 | ||
|
|
32dea43d2e | ||
|
|
632da71a8d | ||
|
|
2ffab22185 | ||
|
|
5541327968 | ||
|
|
096eaa20d7 | ||
|
|
e5fe6b915e | ||
|
|
512bd84cc2 | ||
|
|
ebbcbeedd2 | ||
|
|
be17308e50 | ||
|
|
25fa29e6e1 | ||
|
|
bddc47f9b2 | ||
|
|
51948d7760 | ||
|
|
5817a30031 | ||
|
|
e216eb1e7b | ||
|
|
549c6afa0a | ||
|
|
6b08e6b809 | ||
|
|
0438fdde49 | ||
|
|
be4ea18119 | ||
|
|
a75d6531f2 | ||
|
|
da69ddc19b | ||
|
|
e92926e881 | ||
|
|
7dd208fb49 | ||
|
|
5305db689d | ||
|
|
2338c7a3b3 | ||
|
|
829bc96209 | ||
|
|
7454e16aae | ||
|
|
e4acad60e9 | ||
|
|
f35af1fb6d | ||
|
|
c0e008c601 | ||
|
|
9acf4458c0 | ||
|
|
70de264d4d | ||
|
|
1a0b9e4612 | ||
|
|
66dc70c057 | ||
|
|
6641f34d76 | ||
|
|
f3ae5d8160 | ||
|
|
d937541aa0 | ||
|
|
21707d7ff6 | ||
|
|
3002bc0eee | ||
|
|
df50232ed9 | ||
|
|
17d49067e9 | ||
|
|
9a2e023a51 | ||
|
|
9c747f3160 | ||
|
|
08ea71cb24 | ||
|
|
a96abe2422 | ||
|
|
84a4a888e6 | ||
|
|
e3299b546e | ||
|
|
f2e0f1b2f1 | ||
|
|
2a4456b9ca | ||
|
|
560a55bfd1 | ||
|
|
d32f0fad12 | ||
|
|
031e7d270d | ||
|
|
3b73a0e269 | ||
|
|
0bfcf79e79 | ||
|
|
bdd299dd9e | ||
|
|
f97e605bf6 | ||
|
|
db9ff76754 | ||
|
|
49f5495c45 | ||
|
|
9e431df848 | ||
|
|
12476c52a4 | ||
|
|
8fd9aebcb9 | ||
|
|
8c83f4ba3b | ||
|
|
25b6d1a232 | ||
|
|
880cbd88c2 | ||
|
|
dcd53c3c5b | ||
|
|
3e64b3da39 | ||
|
|
9a748c8bf1 | ||
|
|
53eae14763 | ||
|
|
074c42e8b6 | ||
|
|
8633fa7024 | ||
|
|
19668b9b48 | ||
|
|
3f02631b98 | ||
|
|
da46eefe2e | ||
|
|
a3ca3ed33f | ||
|
|
efaa33c4d5 | ||
|
|
0cdfe7f458 | ||
|
|
190eafc30e | ||
|
|
d4ee0e8622 | ||
|
|
96c90e6295 | ||
|
|
ff95da411b | ||
|
|
2ad411ea29 | ||
|
|
55cbcd728d | ||
|
|
8880860105 | ||
|
|
0c238448fd | ||
|
|
8a76fdc126 | ||
|
|
433f830cf3 | ||
|
|
8893bc102c | ||
|
|
0cf9927132 | ||
|
|
5993125cc7 | ||
|
|
0c34309133 | ||
|
|
3d6ce0fb76 | ||
|
|
54f79c2798 | ||
|
|
8bac1706a1 | ||
|
|
d0a3779091 | ||
|
|
ff0960b174 | ||
|
|
7032825e35 | ||
|
|
d118533d87 | ||
|
|
35f4f75733 | ||
|
|
ef61c3543f | ||
|
|
897560745a | ||
|
|
5a8539a122 | ||
|
|
d9292a70bf | ||
|
|
a9c23b7c28 | ||
|
|
2cc7289b7b | ||
|
|
81d6df925e | ||
|
|
263bfb1bda | ||
|
|
677e77d0ae | ||
|
|
0d0c1af7f7 | ||
|
|
fb55def54f | ||
|
|
eea86757d5 | ||
|
|
e7eb220c50 | ||
|
|
7d67005820 | ||
|
|
fadd91b6a2 | ||
|
|
5fa6a2848f | ||
|
|
7ab921669b | ||
|
|
4811dfa663 | ||
|
|
7a41a5249f | ||
|
|
f9e05d0cad | ||
|
|
15a63c4bc5 | ||
|
|
4a2e4d2b55 | ||
|
|
12033abe09 | ||
|
|
f9410d5d00 | ||
|
|
c232a32991 | ||
|
|
57f37939d5 | ||
|
|
432ff58107 | ||
|
|
2c7d6a7711 | ||
|
|
d31b051fc5 | ||
|
|
98405a39db | ||
|
|
0e354e5ea1 | ||
|
|
d172a97247 | ||
|
|
8a3df7e434 | ||
|
|
eafcbabaa2 | ||
|
|
14071ea119 | ||
|
|
6239686afa | ||
|
|
45186b70ec | ||
|
|
b4fead9606 | ||
|
|
61243b418e | ||
|
|
fe75660e88 | ||
|
|
946e6c1644 | ||
|
|
3eb232b3fc | ||
|
|
38de1c9a31 | ||
|
|
78dcb87a75 | ||
|
|
421e568232 | ||
|
|
4efd28c092 | ||
|
|
d0bbee7e8c | ||
|
|
7640563991 | ||
|
|
90cf85c3f0 | ||
|
|
f1a98693d0 | ||
|
|
2794d64d3e | ||
|
|
82743cca92 | ||
|
|
d0c348e595 | ||
|
|
f50d3088dc | ||
|
|
0917fa0d75 | ||
|
|
cfb73dd534 | ||
|
|
ef497b7989 | ||
|
|
9d9341901f | ||
|
|
155e3d225d | ||
|
|
ca41f100ab | ||
|
|
084285a760 | ||
|
|
982391cd7c | ||
|
|
d206d0a3ae | ||
|
|
627ea6c860 | ||
|
|
bcc76b3764 | ||
|
|
39692a8b3f | ||
|
|
eba8b4bf00 | ||
|
|
f149665660 | ||
|
|
e3bb64cf35 | ||
|
|
33f0669100 | ||
|
|
3a5f3e8b55 | ||
|
|
a0a90afbc0 | ||
|
|
2f96cb257c | ||
|
|
5910bec52e | ||
|
|
764b1c35cb | ||
|
|
ee8c9b764d | ||
|
|
7080f0c35a | ||
|
|
679d60cd5a | ||
|
|
bc36c0faed | ||
|
|
3c073bc360 | ||
|
|
c52d5e1084 | ||
|
|
b7bb27fa21 | ||
|
|
087aaa2f94 | ||
|
|
474b93a22f | ||
|
|
0c2f002a7d | ||
|
|
3d76d83a39 | ||
|
|
787015f537 | ||
|
|
fb624fddc4 | ||
|
|
605ddacb71 | ||
|
|
71934f05a8 | ||
|
|
534a0d6836 | ||
|
|
746b1d0c4d | ||
|
|
387c80e00a | ||
|
|
05c914691f | ||
|
|
94398d70f4 | ||
|
|
915ddb2b2b | ||
|
|
b916e7f7ef | ||
|
|
3cc30f91a9 | ||
|
|
f4a61b4c70 | ||
|
|
6eebd693ce | ||
|
|
7e78f5941a | ||
|
|
bc0ae6be31 | ||
|
|
c03119d10a | ||
|
|
e1879ef4d9 | ||
|
|
b6df727efb | ||
|
|
fe58b44916 | ||
|
|
0a2694811d | ||
|
|
31fe232bac | ||
|
|
682f6d273c | ||
|
|
83ddaccf4a | ||
|
|
e0c0584c59 | ||
|
|
60f5a52964 | ||
|
|
7e5866ce3f | ||
|
|
89b7b56a2c | ||
|
|
ae54b13d4b | ||
|
|
927ccc489c | ||
|
|
21f7722f10 | ||
|
|
e4afe603f9 | ||
|
|
30d15a1438 | ||
|
|
c84586dd66 | ||
|
|
e9f87c2026 | ||
|
|
afa27a3c2a | ||
|
|
ce6078ed94 | ||
|
|
82d1412d45 | ||
|
|
6d5949ba9c | ||
|
|
cdb165af7f | ||
|
|
88a3f8e4aa | ||
|
|
1c3dc757c3 | ||
|
|
25866095db | ||
|
|
b6c8d8e971 | ||
|
|
ab94b0b231 | ||
|
|
760bab8f86 | ||
|
|
817c332d11 | ||
|
|
05fbc8e6b0 | ||
|
|
c39301b6da | ||
|
|
add9a9db9b | ||
|
|
05123ea6f4 | ||
|
|
a8d328bfc9 | ||
|
|
d62ff34a5a | ||
|
|
a8b8d53d9d | ||
|
|
0d4ff5a916 | ||
|
|
8ace41d144 | ||
|
|
5bb7219f4b | ||
|
|
f0200ab697 | ||
|
|
f457a56d4a | ||
|
|
db086de84a | ||
|
|
37684c6af0 | ||
|
|
3c75d4f1dd | ||
|
|
b19276bb0f | ||
|
|
774d831fae | ||
|
|
a1b49d8389 | ||
|
|
12e2bfc794 | ||
|
|
6e5abade3c | ||
|
|
e4e3676095 | ||
|
|
3ed13150e1 | ||
|
|
f03e5c6bd1 | ||
|
|
8496c1cdd3 | ||
|
|
3c3851c221 | ||
|
|
05f1e9e3b8 | ||
|
|
249a1e6d8d | ||
|
|
e042e0ad32 | ||
|
|
5db15ca54c | ||
|
|
069b89b208 | ||
|
|
63014aeb6b | ||
|
|
31e21db5b5 | ||
|
|
7f21872510 | ||
|
|
27351c9a90 | ||
|
|
76b918d40e | ||
|
|
f5bc0b205c | ||
|
|
b3c253ea2a | ||
|
|
d17e031259 | ||
|
|
842363200b | ||
|
|
d9f9895b2b | ||
|
|
bc0edd4042 | ||
|
|
9b82e2df58 | ||
|
|
3d65341080 | ||
|
|
80215ea181 | ||
|
|
78d8526e41 | ||
|
|
0ddaabe377 | ||
|
|
20f9318597 | ||
|
|
9bc6ebde4e | ||
|
|
011f14d115 | ||
|
|
62a5cbb5ce | ||
|
|
5aaf87d612 | ||
|
|
96b31f3974 | ||
|
|
09e387bf09 | ||
|
|
05fe8792ea | ||
|
|
18ed45597a | ||
|
|
b646c84414 | ||
|
|
a200eaacaa | ||
|
|
f5ad553be3 | ||
|
|
7b7664bd66 | ||
|
|
4f4acc04fe | ||
|
|
dee0fec9e9 | ||
|
|
73cc2a140c | ||
|
|
6058a74da5 | ||
|
|
ab5e021bda | ||
|
|
bd3b652cfc | ||
|
|
73429fc720 | ||
|
|
10478a6b2f | ||
|
|
0fc9814004 | ||
|
|
e0bc01eea1 | ||
|
|
2af6d3f6bc | ||
|
|
cbe5438a31 | ||
|
|
67c4ad128c | ||
|
|
870eca0d9f | ||
|
|
d299458084 | ||
|
|
e0cf68f1d5 | ||
|
|
64906a1ba5 | ||
|
|
e75721016e | ||
|
|
e0d5b9daf8 | ||
|
|
5989844f1c | ||
|
|
14e3f413a2 | ||
|
|
a97d77064a | ||
|
|
3342dd4001 | ||
|
|
785b9811f3 | ||
|
|
643c77ded0 | ||
|
|
e617da3bbf | ||
|
|
76f01511a3 | ||
|
|
dd8727d3ae | ||
|
|
b933946f33 | ||
|
|
5d2f9d7a33 | ||
|
|
3baf14b793 | ||
|
|
c57e4ba508 | ||
|
|
98656289ea | ||
|
|
167a38e27d | ||
|
|
ba6806df5d | ||
|
|
fe12101278 | ||
|
|
d6d7f4e875 | ||
|
|
63caddea62 | ||
|
|
36b01fbdcf | ||
|
|
45a3d8b75a | ||
|
|
bca62c813d | ||
|
|
ae1cf74dcd | ||
|
|
577a8dd005 | ||
|
|
5900899c01 | ||
|
|
2dfc468094 | ||
|
|
98ffe9931d | ||
|
|
2004c0d739 | ||
|
|
cd7cb025ad | ||
|
|
96da267778 | ||
|
|
5816e410e9 | ||
|
|
31c98fc0db | ||
|
|
00bf957b53 | ||
|
|
5b999c2f7d | ||
|
|
1cc9d9c071 | ||
|
|
72fb8460e9 | ||
|
|
577156fe5f | ||
|
|
612cc96e41 | ||
|
|
da3f783a9f | ||
|
|
b1e8545981 | ||
|
|
6a2da6dc06 | ||
|
|
58603e2a5a | ||
|
|
d97184880c | ||
|
|
625f40cfa6 | ||
|
|
49049b8c12 | ||
|
|
037912ccab | ||
|
|
8b05b864fb | ||
|
|
319135c8fe | ||
|
|
61d9e418e8 | ||
|
|
475bb2845d | ||
|
|
42f39de0f9 | ||
|
|
3898b8e8ab | ||
|
|
b1fd005c95 | ||
|
|
cf8fdd3a70 | ||
|
|
cb754ee125 | ||
|
|
cea81df969 | ||
|
|
af1d5fce6e | ||
|
|
54b86b6131 | ||
|
|
ec2b83515b | ||
|
|
2f2724dff5 | ||
|
|
271fa26890 | ||
|
|
fe437da751 | ||
|
|
129876d1be | ||
|
|
f2ced67a8d | ||
|
|
787eec8be4 | ||
|
|
cc39eea999 | ||
|
|
cbfed99bc6 | ||
|
|
2b4cd8b2ec | ||
|
|
b5dc72b126 | ||
|
|
ab4d2faea3 | ||
|
|
1677817d9f | ||
|
|
03854baf53 | ||
|
|
61dc253de1 | ||
|
|
a0e8f410d1 | ||
|
|
2865f63c5d | ||
|
|
3f19ab1a87 | ||
|
|
d75fec0cee | ||
|
|
39570a9663 | ||
|
|
479c18e21f | ||
|
|
fd4453d85e | ||
|
|
7ee7f99780 | ||
|
|
4c0b8e3113 | ||
|
|
e0af60d8a7 | ||
|
|
afcb7f00da | ||
|
|
a59e9f024e | ||
|
|
e1b06bfce2 | ||
|
|
8de3f03b49 | ||
|
|
db8f018b42 | ||
|
|
59cb2132f2 | ||
|
|
25f62daf14 | ||
|
|
05b9dfbe30 | ||
|
|
3db4e2ee2f | ||
|
|
86a6a5b826 | ||
|
|
cc6338d048 | ||
|
|
57b65726d6 | ||
|
|
44a736c53b | ||
|
|
38cbd42d81 | ||
|
|
28d019f824 | ||
|
|
54b8e1be89 | ||
|
|
9778695b4a | ||
|
|
44b6285268 | ||
|
|
6c6fb2e287 | ||
|
|
ecdfde8c38 | ||
|
|
ea2d5b9d4a | ||
|
|
4670cc1a5f | ||
|
|
1e0522fe8f | ||
|
|
70858603ed | ||
|
|
3c508c1d27 | ||
|
|
5c44db341f | ||
|
|
cf73363016 | ||
|
|
351173e554 | ||
|
|
342432dc76 | ||
|
|
c4538cada7 | ||
|
|
de532bb2fc | ||
|
|
f525afa5de | ||
|
|
9fba470364 | ||
|
|
6cd5bf31c9 | ||
|
|
321c0a8537 | ||
|
|
b9bc58ef10 | ||
|
|
7bcf05fd19 | ||
|
|
f816bdf541 | ||
|
|
79472552aa | ||
|
|
c5e5c8288e | ||
|
|
fd1c7f7169 | ||
|
|
9212d67e2f | ||
|
|
f5c74d123a | ||
|
|
c8421efcd3 | ||
|
|
f382609d01 | ||
|
|
f9615c18a1 | ||
|
|
a74597c7cd | ||
|
|
d50fbac5f9 | ||
|
|
95086a75e6 | ||
|
|
073a96cf63 | ||
|
|
d3c64bd5b4 | ||
|
|
7024a7468a | ||
|
|
62e60e2ba6 | ||
|
|
fb3860757c | ||
|
|
e4a8b17522 | ||
|
|
448df1bb9c | ||
|
|
bf6900fb2a | ||
|
|
50552546f3 | ||
|
|
324fab8186 | ||
|
|
7ab80f01b5 | ||
|
|
9ce4a5c7b1 | ||
|
|
c9a0525a10 | ||
|
|
83465bb7f5 | ||
|
|
e8771fb36a | ||
|
|
d4d03f3d7f | ||
|
|
d567d667e8 | ||
|
|
3d55bbbc29 | ||
|
|
2f8e52f905 | ||
|
|
a5896ac6b6 | ||
|
|
94b9d5644c | ||
|
|
06e5fc233c | ||
|
|
aefb922a05 | ||
|
|
a22434fd73 | ||
|
|
c41846805d | ||
|
|
b7b45b69a6 | ||
|
|
ed5528664c | ||
|
|
fe88d3c225 | ||
|
|
aed4ee8694 | ||
|
|
817d9b0d3e | ||
|
|
df9cfe7840 | ||
|
|
8cd4578d83 | ||
|
|
9ca41b9536 | ||
|
|
559743c911 | ||
|
|
3a7f26f620 | ||
|
|
04a0eae241 | ||
|
|
0500d2fb6e | ||
|
|
31f1a9e5aa | ||
|
|
6387aae471 | ||
|
|
152082e182 | ||
|
|
08eb2b3df7 | ||
|
|
846ec87249 | ||
|
|
62690b5159 | ||
|
|
719c432ca8 | ||
|
|
e654616b6d | ||
|
|
f0473b0320 | ||
|
|
fcc627e6e1 | ||
|
|
fe17802cd2 | ||
|
|
384c05ccc7 | ||
|
|
193e4f3275 | ||
|
|
6fd87568e7 | ||
|
|
484fd68495 | ||
|
|
792be54443 | ||
|
|
00df102c29 | ||
|
|
90e68ddd73 | ||
|
|
df27f4f118 | ||
|
|
bee26daf0c | ||
|
|
b76c738785 | ||
|
|
8ca9fb0251 | ||
|
|
3b26a656f7 | ||
|
|
2f5ac5d993 | ||
|
|
a2fc9a964b | ||
|
|
b8a267370d | ||
|
|
fa3d011f68 | ||
|
|
a7fc9caacb | ||
|
|
c284f6dcd4 | ||
|
|
368d59c3ca | ||
|
|
94ee82e076 | ||
|
|
bfefb6e696 | ||
|
|
95b7601e2b | ||
|
|
f9c8bd868c | ||
|
|
a773973b1b | ||
|
|
a60006366b | ||
|
|
a66bb7889a | ||
|
|
adfba06e85 | ||
|
|
6ee4e954f6 | ||
|
|
a11d139ff6 | ||
|
|
85a3e66314 | ||
|
|
1a3958ed60 | ||
|
|
743c957918 | ||
|
|
224a6c192b | ||
|
|
ae47da3801 | ||
|
|
a6d669453f | ||
|
|
0beab9eec4 | ||
|
|
aa997f1be5 | ||
|
|
4eb58a70bb | ||
|
|
5b31d0aa36 | ||
|
|
79e7c44884 | ||
|
|
1382c1243a | ||
|
|
8f2fd9b603 | ||
|
|
d625b65a09 | ||
|
|
101e9be7b9 | ||
|
|
9f93d8f533 | ||
|
|
6050a59e4a | ||
|
|
e5b7e29113 | ||
|
|
ecdd0ce9f2 | ||
|
|
fc5c598f8f | ||
|
|
18ebed3c5d | ||
|
|
822e319efe | ||
|
|
6d462fc961 | ||
|
|
4b71c65aea | ||
|
|
34ab53173d | ||
|
|
d6be6f79ce | ||
|
|
87d36f06fd | ||
|
|
3eb05b4505 | ||
|
|
0789c6a3d8 | ||
|
|
b587f076fe | ||
|
|
a5a7217c8f | ||
|
|
c0cf55b40b | ||
|
|
9200ed2216 | ||
|
|
e1f7dd1372 | ||
|
|
32833b7301 | ||
|
|
3302c89284 | ||
|
|
e18d61b31a | ||
|
|
61cd1ae525 | ||
|
|
064608a8ef | ||
|
|
5a840c88b5 | ||
|
|
b14c3fe48d | ||
|
|
4874d55d03 | ||
|
|
b20e40dd6f | ||
|
|
bc28a08dd0 | ||
|
|
0d3010f6fc | ||
|
|
399a651fa3 | ||
|
|
30ac5fcb5e | ||
|
|
92cb5e10be | ||
|
|
10faa47495 | ||
|
|
f0bbf2cab0 | ||
|
|
338e8be327 | ||
|
|
a4726a0e0d | ||
|
|
d4a366aeb1 | ||
|
|
98652997f9 | ||
|
|
f5a39c2f7b | ||
|
|
9854db0a63 | ||
|
|
cc7b0f4623 | ||
|
|
549e6d57c4 | ||
|
|
dea322e2c5 | ||
|
|
ed5b9c2b56 | ||
|
|
c31ca4af90 | ||
|
|
2c9ec4bee8 | ||
|
|
6dcfc36a4a | ||
|
|
76579a3004 | ||
|
|
1d68692bb6 | ||
|
|
790af0fd72 | ||
|
|
39008372e5 | ||
|
|
1026952f26 | ||
|
|
9631927a8c | ||
|
|
b0e6ce581a | ||
|
|
e575323c60 | ||
|
|
809ac3340c | ||
|
|
f0af638874 | ||
|
|
b49148ec54 | ||
|
|
c7f5e77b3f | ||
|
|
817248369a | ||
|
|
654698b208 | ||
|
|
4e5bfae332 | ||
|
|
895a9093aa | ||
|
|
35121f0b78 | ||
|
|
c4a7574f7b | ||
|
|
4ee636ecca | ||
|
|
662dc12877 | ||
|
|
3cc8af819c | ||
|
|
fcf4a958c3 | ||
|
|
65676c22f9 | ||
|
|
3e907d7f4f | ||
|
|
9fa567aa78 | ||
|
|
237ebb0716 | ||
|
|
fdea260e41 | ||
|
|
9af77dc835 | ||
|
|
d4aacd218a | ||
|
|
326a566db2 | ||
|
|
84257dac2b | ||
|
|
22ad9e1e1a | ||
|
|
cc44f5f75d | ||
|
|
23df5cc201 | ||
|
|
dab2d5db44 | ||
|
|
1717c5c00d | ||
|
|
ea3f82ccc2 | ||
|
|
fd6ce470e7 | ||
|
|
6d3fbbe256 | ||
|
|
45c4de16d2 | ||
|
|
92b0efff5a | ||
|
|
bc550c3265 | ||
|
|
b39aa5d359 | ||
|
|
f8f8bd95ca | ||
|
|
d057b77dc5 | ||
|
|
27d637195d | ||
|
|
46919ce797 | ||
|
|
b4e1ce59f9 | ||
|
|
7af77d3eb0 | ||
|
|
de1ff52de3 | ||
|
|
69c1df68c8 | ||
|
|
62431fee8e | ||
|
|
357201869a | ||
|
|
a88e8ffe79 | ||
|
|
5c88f43e15 | ||
|
|
2f7ab3e32d | ||
|
|
3ec05bb5d8 | ||
|
|
59890f2c83 | ||
|
|
2c70162bee | ||
|
|
2f1a4042bf | ||
|
|
4af7740907 | ||
|
|
f64ea361d4 | ||
|
|
9c850d152c | ||
|
|
71266c0220 | ||
|
|
0801457ff0 | ||
|
|
ba7c9ceccc | ||
|
|
f6f2818a02 | ||
|
|
b05a3b7aed | ||
|
|
3fe94891d3 | ||
|
|
9d11028fce | ||
|
|
f6b81f588d | ||
|
|
513007a82c | ||
|
|
bf18a90da7 | ||
|
|
2ddd53b355 | ||
|
|
c9aef16649 | ||
|
|
6a77e0fe56 | ||
|
|
0a725415a4 | ||
|
|
af0d9439d4 | ||
|
|
65f09d0528 | ||
|
|
48e6695447 | ||
|
|
e3604c1662 | ||
|
|
5913d654bd | ||
|
|
f3fe9661f6 | ||
|
|
17cfd7b001 | ||
|
|
e941bdd945 | ||
|
|
e7e8773cd4 | ||
|
|
ebc750d5bf | ||
|
|
3507fe6d5b | ||
|
|
f9ef6491e6 | ||
|
|
61e487224f | ||
|
|
85eb82acb2 | ||
|
|
4d364ea261 | ||
|
|
577528bb9c | ||
|
|
d49f2c40ae | ||
|
|
706bfafe74 | ||
|
|
1b8204dabe | ||
|
|
05cabded02 | ||
|
|
1578402cbe | ||
|
|
49ee56b22c | ||
|
|
8c7f0902c0 | ||
|
|
056ef9ccd1 | ||
|
|
dfc635b451 | ||
|
|
68321362c5 | ||
|
|
f7560036b8 | ||
|
|
fc87caa348 | ||
|
|
6e0aef5f2b | ||
|
|
127b3e7d60 | ||
|
|
9740199870 | ||
|
|
06be580d2c | ||
|
|
6540343f45 | ||
|
|
447b305e3c | ||
|
|
0c53d276f8 | ||
|
|
83c37c6a7a | ||
|
|
ac52ad88a1 | ||
|
|
84a1b5612d | ||
|
|
fa4e694859 | ||
|
|
f8c628b0c7 | ||
|
|
2f35e4789c | ||
|
|
253bada643 | ||
|
|
e4fe497504 | ||
|
|
5c9bde203e | ||
|
|
d9907f227e | ||
|
|
08b08ef1d0 | ||
|
|
334ef5c3eb | ||
|
|
ac925aa226 | ||
|
|
86f17fb466 | ||
|
|
6aafda4517 | ||
|
|
8267950dbc | ||
|
|
56d1b0103f | ||
|
|
1ff34bd0f4 | ||
|
|
b86248f13f | ||
|
|
427a29145d | ||
|
|
974575b695 | ||
|
|
60b1fdd367 | ||
|
|
842f2ea5cc | ||
|
|
ae220c37df | ||
|
|
6f57f52ac2 | ||
|
|
4897513d7d | ||
|
|
c8dad01137 | ||
|
|
5a09063adb | ||
|
|
9de9bf651b | ||
|
|
09d80b1e50 | ||
|
|
2b793f372a | ||
|
|
4cfeb6b8ac | ||
|
|
9373451ca8 | ||
|
|
15c199d5a2 | ||
|
|
cde85243d6 | ||
|
|
c579db1a7b | ||
|
|
61fa34e2ce | ||
|
|
96febf6639 | ||
|
|
09e59cf677 | ||
|
|
9119ee14b6 | ||
|
|
2ac2ae3eee | ||
|
|
a682b5d90e | ||
|
|
e26c0c58ae | ||
|
|
187fa71526 | ||
|
|
031f97e97c | ||
|
|
b9e1c3c34f | ||
|
|
1a35107a1d | ||
|
|
d3e086c850 | ||
|
|
4a0c8d72b0 | ||
|
|
ab9cfd293b | ||
|
|
cc840a6911 | ||
|
|
5456187dd0 | ||
|
|
73c95c328d | ||
|
|
4a971be168 | ||
|
|
f657a3d811 | ||
|
|
b39f75a2e3 | ||
|
|
1dad14f8ea | ||
|
|
5cc2e8de7b | ||
|
|
d0abc60176 | ||
|
|
130e83d9b2 | ||
|
|
ed8acdb11c | ||
|
|
26370da13d | ||
|
|
c4a2f70017 | ||
|
|
a5d315ee2a | ||
|
|
4fa57f55e6 | ||
|
|
2c496a92ad | ||
|
|
4ca8903a21 | ||
|
|
d460c0e8b9 | ||
|
|
11b6d290da | ||
|
|
d83902834f | ||
|
|
0fdf32cf6f | ||
|
|
f4ebbfabf4 | ||
|
|
b5bcfc8fe7 | ||
|
|
d13c08cc0d | ||
|
|
89abd76570 | ||
|
|
8c1ae35088 | ||
|
|
bb74789b42 | ||
|
|
dbbd32d2ce | ||
|
|
80285a300d | ||
|
|
2eb5819851 | ||
|
|
e748e1891b | ||
|
|
28bb11217c | ||
|
|
636dae6a79 | ||
|
|
c8f65a1bf9 | ||
|
|
ce177ae6f6 | ||
|
|
c79f3501cd | ||
|
|
80114edc71 | ||
|
|
71483e2865 | ||
|
|
93087324d9 | ||
|
|
061facdcce | ||
|
|
3e6e7fb272 | ||
|
|
12d8c2398f | ||
|
|
bb73963421 | ||
|
|
1dd7688bdd | ||
|
|
5735095521 | ||
|
|
fa7570352c | ||
|
|
f378406d15 | ||
|
|
68fa7ae2a3 | ||
|
|
9b1015bbce | ||
|
|
a4c821eb60 | ||
|
|
c70540e7f4 | ||
|
|
e291146443 | ||
|
|
faa2b6237f | ||
|
|
26661f3091 | ||
|
|
e6e8d49d72 | ||
|
|
b9ca055586 | ||
|
|
9ce7be050a | ||
|
|
1d2617c826 | ||
|
|
7c8e9ddc42 | ||
|
|
157764c0d9 | ||
|
|
317ff81744 | ||
|
|
bd7fc780cb | ||
|
|
4b343d9dcf | ||
|
|
7a6a5d7595 | ||
|
|
85020c74cf | ||
|
|
0137c0da8c | ||
|
|
407731ab16 | ||
|
|
72503c0689 | ||
|
|
e9e570db4f | ||
|
|
5bc83fceaa | ||
|
|
e7fd501200 | ||
|
|
ea0067d999 | ||
|
|
ec49ca6480 | ||
|
|
a26cc7c14d | ||
|
|
c9d3041460 | ||
|
|
943b7d39c6 | ||
|
|
6b1a911604 | ||
|
|
3d4e03f2cd | ||
|
|
48b0b54819 | ||
|
|
00515eb6f9 | ||
|
|
63e7391981 | ||
|
|
b6776f53ab | ||
|
|
6a0cda7396 | ||
|
|
09692dc70e | ||
|
|
e0482f5400 | ||
|
|
c787dc7356 | ||
|
|
ea948ac2c8 | ||
|
|
d6e321e97f | ||
|
|
807250510a | ||
|
|
ef1e974346 | ||
|
|
55d1228abb | ||
|
|
9e76d2ca63 | ||
|
|
d53915e7e3 | ||
|
|
7fab782907 | ||
|
|
cf7967e629 | ||
|
|
0eacbac8f6 | ||
|
|
cec76c33b6 | ||
|
|
18dcf98998 | ||
|
|
251218af8b | ||
|
|
e2cbe42ed0 | ||
|
|
c06ed58582 | ||
|
|
78623ae3bd | ||
|
|
4de6221825 | ||
|
|
136c6d01b3 | ||
|
|
22f3f57f44 | ||
|
|
b2f362225c | ||
|
|
40ed59ce28 | ||
|
|
839db68571 | ||
|
|
fec6ac3ff0 | ||
|
|
45fa26dc6c | ||
|
|
f49d432fdc | ||
|
|
1a31ceff8e | ||
|
|
cc486cb86d | ||
|
|
7a45a579c0 | ||
|
|
dc58d539c2 | ||
|
|
2ba78eb740 | ||
|
|
f43b275f16 | ||
|
|
509a81a572 | ||
|
|
184232ba4f | ||
|
|
9e0471bfbb | ||
|
|
0bc338ba42 | ||
|
|
406e91d387 | ||
|
|
473acafd14 | ||
|
|
7474e6b1c9 | ||
|
|
323955277c | ||
|
|
03b5b09122 | ||
|
|
fe00c06d4b | ||
|
|
ca08dd9705 | ||
|
|
b3e53b609b | ||
|
|
fdeab0475c | ||
|
|
f86cc0dc7a | ||
|
|
0457c959dd | ||
|
|
c520b7f1fb | ||
|
|
5422bf5733 | ||
|
|
a703160226 | ||
|
|
d0905eda49 | ||
|
|
da60008048 | ||
|
|
7c023233f2 | ||
|
|
1e7003a307 | ||
|
|
8cb074657d | ||
|
|
5f72b86ce4 | ||
|
|
09d33792f3 | ||
|
|
a6773b85d2 | ||
|
|
5f678acf46 | ||
|
|
76f9ad0705 | ||
|
|
478f6ed011 | ||
|
|
c94d1b2275 | ||
|
|
7d60356fac | ||
|
|
58fa35641d | ||
|
|
b74957acdf | ||
|
|
6aed4fb1ae | ||
|
|
ad8e12eeae | ||
|
|
31763a018c | ||
|
|
bc20f8a004 | ||
|
|
3f6876c419 | ||
|
|
fb9c774558 | ||
|
|
7df9393d29 | ||
|
|
c6439def2c | ||
|
|
273d3445e4 | ||
|
|
bc3dc52377 | ||
|
|
ef1d484d9e | ||
|
|
63cd5a6296 | ||
|
|
657dc785ea | ||
|
|
461e74d8be | ||
|
|
a7daea1728 | ||
|
|
c4416f9696 | ||
|
|
f9ad34170d | ||
|
|
45f2a8ad06 | ||
|
|
3dad802c90 | ||
|
|
735166f06c | ||
|
|
042df52e5c | ||
|
|
294a65f842 | ||
|
|
bf8550ae1e | ||
|
|
91549ef28c | ||
|
|
95956eff64 | ||
|
|
bcae71dfa4 | ||
|
|
d370296e82 | ||
|
|
f42f608f3f | ||
|
|
f78b5741c3 | ||
|
|
733fe5b335 | ||
|
|
c093aab350 | ||
|
|
44f17c1706 | ||
|
|
8302e1687a | ||
|
|
7ad4380653 | ||
|
|
bea185ce8b | ||
|
|
5a73b8a8e6 | ||
|
|
da62a0af3b | ||
|
|
1137abfd33 | ||
|
|
e972ed8456 | ||
|
|
2e1c2d9dfe | ||
|
|
83dd333eba | ||
|
|
f854f3ee2b | ||
|
|
1055ca6d44 | ||
|
|
a5fea3b9c3 | ||
|
|
62f1430a2c | ||
|
|
1dec6a442e | ||
|
|
97831e3702 | ||
|
|
7eb9444458 | ||
|
|
ebc296ea31 | ||
|
|
75d24dea0e | ||
|
|
a6f72de09d | ||
|
|
96037aed52 | ||
|
|
f9d80adaee | ||
|
|
422e5a19d4 | ||
|
|
3d58b38e4e | ||
|
|
0a044199a1 | ||
|
|
cd5f00ac4d | ||
|
|
23c4027c83 | ||
|
|
eeb08b7fae | ||
|
|
20beb2bdb6 | ||
|
|
c6882d0bd8 | ||
|
|
ce47e83939 | ||
|
|
832e1e2cf7 | ||
|
|
6d61616492 | ||
|
|
d5304fb5bd | ||
|
|
13a61db289 | ||
|
|
93b74cc766 | ||
|
|
28e83c21e2 | ||
|
|
33ed5cd437 | ||
|
|
37c8e21f25 | ||
|
|
7b726650e9 | ||
|
|
d3adb48c2e | ||
|
|
9838124abc | ||
|
|
4df847c349 | ||
|
|
f9d2689a12 | ||
|
|
c64ad1af28 | ||
|
|
e83b056bd4 | ||
|
|
eba6dcc497 | ||
|
|
017b5a23d8 | ||
|
|
c7a147f49d | ||
|
|
f84a466d16 | ||
|
|
382a805c7e | ||
|
|
0b38e575d6 | ||
|
|
209266dbed | ||
|
|
20f6d8d3d0 | ||
|
|
09b26645ee | ||
|
|
9f2258ebd9 | ||
|
|
9744b1906a | ||
|
|
71e2ee62e4 | ||
|
|
6c8ee4d55d | ||
|
|
5198c56db9 | ||
|
|
f94d4b492d | ||
|
|
e01a4fcbb4 | ||
|
|
5ed9b8b1dc | ||
|
|
17f3d5f6ba | ||
|
|
607d738342 | ||
|
|
1b102f9ed3 | ||
|
|
6c38481550 | ||
|
|
9cbd151658 | ||
|
|
419b670aa3 | ||
|
|
a44874d2eb | ||
|
|
e9d70b7b1e | ||
|
|
73c6f11c9c | ||
|
|
7e7364fc83 | ||
|
|
a9c5488620 | ||
|
|
906af858a5 | ||
|
|
b699a61f56 | ||
|
|
8eabc49e9d | ||
|
|
9e67e12732 | ||
|
|
2d30183d65 | ||
|
|
fcb0a05880 | ||
|
|
fad7dc9f04 | ||
|
|
7c1e05d33c | ||
|
|
02147f546e | ||
|
|
3d51bc1ada | ||
|
|
95df4433dc | ||
|
|
0f1589a43f | ||
|
|
27262c4e56 | ||
|
|
c9b8f2a397 | ||
|
|
72b2a1c66f | ||
|
|
395d060427 | ||
|
|
bbf088d903 | ||
|
|
69a6166b6a | ||
|
|
bf87b1a6af | ||
|
|
2e8a5602b2 | ||
|
|
0ec1c4ad6d | ||
|
|
15a3a8c62f | ||
|
|
f001181e39 | ||
|
|
2c659d3d82 | ||
|
|
5ffff7397e | ||
|
|
1a36459ab8 | ||
|
|
33cc79c13b | ||
|
|
b4cb21b55e | ||
|
|
ae68c3abe4 | ||
|
|
939e2c70c4 | ||
|
|
14b29172b1 | ||
|
|
58794fc8e9 | ||
|
|
91fdd6fc29 | ||
|
|
8dd9124863 | ||
|
|
3fc99dbad5 | ||
|
|
01dd84dced | ||
|
|
6b92ef733c | ||
|
|
fe0f4ae257 | ||
|
|
cf9555debc | ||
|
|
528008b1a9 | ||
|
|
5e3576ed69 | ||
|
|
c84be8ddb3 | ||
|
|
853b5e1b72 | ||
|
|
3355a39fe0 | ||
|
|
28ee9e247e | ||
|
|
a054b485d0 | ||
|
|
3585326d7e | ||
|
|
a6046af024 | ||
|
|
adaff92c92 | ||
|
|
0499541e11 | ||
|
|
f08738e133 | ||
|
|
0cb357a0e9 | ||
|
|
668dcb7cf0 | ||
|
|
1fbdc14734 | ||
|
|
3e683162e9 | ||
|
|
8e7937bdb6 | ||
|
|
b36587fac8 | ||
|
|
3a1f9d01e8 | ||
|
|
b5c4b81aac | ||
|
|
c849c8ef08 | ||
|
|
bbb3d5bb67 | ||
|
|
1131d66b3d | ||
|
|
63ad2ebf0b | ||
|
|
7104ae4752 | ||
|
|
2403323463 | ||
|
|
feb7dfffa1 | ||
|
|
005e633e2a | ||
|
|
127fe971e9 | ||
|
|
3c4bde6ea1 | ||
|
|
dc19690863 | ||
|
|
e4f8ea2f7c | ||
|
|
599d34f1c0 | ||
|
|
31411dd11b | ||
|
|
b7781108ae | ||
|
|
35ca7d1826 | ||
|
|
9ddec32260 | ||
|
|
185e7d43fb | ||
|
|
0e0a46f373 | ||
|
|
732202fe8e | ||
|
|
47604384d4 | ||
|
|
e1cab78c09 | ||
|
|
9dc4ec6fb5 | ||
|
|
c69984e309 | ||
|
|
0baaf1767b | ||
|
|
eab76c5819 | ||
|
|
ebd6f7ace0 | ||
|
|
a6d5cd4b39 | ||
|
|
4c5a632095 | ||
|
|
b8c611de2b | ||
|
|
870693b968 | ||
|
|
b24b98a365 | ||
|
|
fd041e2997 | ||
|
|
9c827a0298 | ||
|
|
766aeaa9e1 | ||
|
|
27a44f0e77 | ||
|
|
567768c66a | ||
|
|
deaa5f3211 | ||
|
|
5682cd0048 | ||
|
|
11f1ccf3ff | ||
|
|
2896110d4d | ||
|
|
d05b175e04 | ||
|
|
10a379077c | ||
|
|
ffd9b79100 | ||
|
|
04c07d9006 | ||
|
|
a3cc5c1dd7 | ||
|
|
941342cc24 | ||
|
|
cc471dd127 | ||
|
|
432b064601 | ||
|
|
a8a0a5cbfb | ||
|
|
32e77753b5 | ||
|
|
f427a736a3 | ||
|
|
afb02b8bd1 | ||
|
|
48b44342ab | ||
|
|
1f968fa4fd | ||
|
|
ebf5077e1a | ||
|
|
7d26b96d42 | ||
|
|
08208acf53 | ||
|
|
9b535e3cec | ||
|
|
9656895726 | ||
|
|
121b6949a1 | ||
|
|
fb31c49317 | ||
|
|
e51f9b3593 | ||
|
|
46653a0268 | ||
|
|
fcef1819b1 | ||
|
|
3335fc7baf | ||
|
|
63abf34664 | ||
|
|
120ca5b1ec | ||
|
|
1c94ab7cc3 | ||
|
|
aa3be51980 | ||
|
|
fe6c77cafb | ||
|
|
67117913dd | ||
|
|
e532f2c165 | ||
|
|
a0c7da95c2 | ||
|
|
95dbc0f5bc | ||
|
|
ab13ce96cc | ||
|
|
ac0c35424b | ||
|
|
41242a6660 | ||
|
|
e80f203efc | ||
|
|
dbd65cdb04 | ||
|
|
e4dd33a675 | ||
|
|
0e3544e1f9 | ||
|
|
f4589b5bd4 | ||
|
|
3b7068e8d0 | ||
|
|
2a8fc705c7 | ||
|
|
c19fb1dffc | ||
|
|
436a6605fb | ||
|
|
84eddc3d94 | ||
|
|
dfe6b2844b | ||
|
|
6be5fe928e | ||
|
|
167654c9a0 | ||
|
|
6d6179fb2c | ||
|
|
80d06d358a | ||
|
|
1cace49b74 | ||
|
|
7ab5442163 | ||
|
|
4d42f64fa3 | ||
|
|
8d83243378 | ||
|
|
e1a74b6bdd | ||
|
|
44919c353e | ||
|
|
cf8523da5f | ||
|
|
10707ebc3a | ||
|
|
8374a51e6a | ||
|
|
4e48de1116 | ||
|
|
b3b29f527e | ||
|
|
37cfeed0f5 | ||
|
|
cb27fe17cd | ||
|
|
682ab76ba1 | ||
|
|
c811b710eb | ||
|
|
d0930b9048 | ||
|
|
591645758a | ||
|
|
4e093369f6 | ||
|
|
be8e8791b7 | ||
|
|
b13a2e71ad | ||
|
|
28678214d2 | ||
|
|
f75d03c9ae | ||
|
|
51508a732d | ||
|
|
326d8d3976 | ||
|
|
f559a5510b | ||
|
|
bf8b123dfc | ||
|
|
32a7442845 | ||
|
|
a0dfdefd16 | ||
|
|
e7b0c24d9d | ||
|
|
1707f1940d | ||
|
|
5dd708aae8 | ||
|
|
2477ea2fcf | ||
|
|
9b624a884b | ||
|
|
bc7672652e | ||
|
|
cc77f8489e | ||
|
|
564ddff4c7 | ||
|
|
023ea94f07 | ||
|
|
adad76eca6 | ||
|
|
772bb65237 | ||
|
|
d72a731865 | ||
|
|
f35fe56d9b | ||
|
|
1ab70f130d | ||
|
|
86f79949ea | ||
|
|
219d6c294d | ||
|
|
78d81f193f | ||
|
|
b9e0cd4512 | ||
|
|
f9d4966000 | ||
|
|
ad2289935d | ||
|
|
fd47b3fac5 | ||
|
|
84d836f22b | ||
|
|
5d05a2da74 | ||
|
|
2f639b77bb | ||
|
|
8b5b371821 | ||
|
|
0c74a3bc66 | ||
|
|
75f77f3e86 | ||
|
|
7a66da5a51 | ||
|
|
3541f5e1da | ||
|
|
8f809e3a29 | ||
|
|
3f76985435 | ||
|
|
751f9b9240 | ||
|
|
1efba5979f | ||
|
|
bf3c4f4743 | ||
|
|
aeb0742434 | ||
|
|
e98b4ea26d | ||
|
|
1729cfaea9 | ||
|
|
56ade9c44e | ||
|
|
6db0b2e398 | ||
|
|
2bd1ddd129 | ||
|
|
20a37bdd1d | ||
|
|
234447cb3d | ||
|
|
97232145a4 | ||
|
|
056ec6d2b3 | ||
|
|
2c44c7ea83 | ||
|
|
9cc1956b4b | ||
|
|
a35138e2b9 | ||
|
|
49f6c20b20 | ||
|
|
6bfc02d79d | ||
|
|
7b166837d3 | ||
|
|
3ff8a319c5 | ||
|
|
cd8f8e1e4a | ||
|
|
ed43d8d08b | ||
|
|
ca786cdd11 | ||
|
|
3e659f0de8 | ||
|
|
795a357595 | ||
|
|
5737365b2d | ||
|
|
8dff54de42 | ||
|
|
c1b8a7fbb7 | ||
|
|
6f3c6f7599 | ||
|
|
246eca91aa | ||
|
|
5fd378e4ce | ||
|
|
382f24c556 | ||
|
|
0773fcf66f | ||
|
|
650a24ba87 | ||
|
|
d2be2ee6cd | ||
|
|
7d63c5d982 | ||
|
|
a4f294c090 | ||
|
|
58c5e800d0 | ||
|
|
6d7097eed5 | ||
|
|
55da59a537 | ||
|
|
012ee310a4 | ||
|
|
1e07fcacac | ||
|
|
69ab913bc6 | ||
|
|
83a63f64b1 | ||
|
|
8f7e67367a | ||
|
|
0dad3fecb6 | ||
|
|
09b99bbf8b | ||
|
|
92e112dc63 | ||
|
|
6f5a84703e | ||
|
|
c0de35e71c | ||
|
|
f7dd6f7a7e | ||
|
|
655c1eb90f | ||
|
|
af6885db81 | ||
|
|
78e216d157 | ||
|
|
61726d84ac | ||
|
|
60d3bed393 | ||
|
|
3133ca0081 | ||
|
|
0f720223a9 | ||
|
|
6bb93b8170 | ||
|
|
d0f32d1865 | ||
|
|
2fe4e380d1 | ||
|
|
a7f4701698 | ||
|
|
f12e4f8889 | ||
|
|
df99a360fb | ||
|
|
4c76ad072a | ||
|
|
edf837ed62 | ||
|
|
7201a74aea | ||
|
|
9e2f8bead9 | ||
|
|
942867179c | ||
|
|
6b897f6fd2 | ||
|
|
389f1cde51 | ||
|
|
1ad31ab007 | ||
|
|
914db52c4d | ||
|
|
fe51ec906e | ||
|
|
85551f4994 | ||
|
|
fc1cfcceca | ||
|
|
6b4d4b9246 | ||
|
|
b06ba55be3 | ||
|
|
d08bfbf705 | ||
|
|
a10e466fed | ||
|
|
35bb010c35 | ||
|
|
0046a0762c | ||
|
|
c453012a8e | ||
|
|
1f82c7eadf | ||
|
|
b6fb8dbb52 | ||
|
|
30256cbe51 | ||
|
|
7f46e9af2c | ||
|
|
417cec9e04 | ||
|
|
62a55c0135 | ||
|
|
72336eb393 | ||
|
|
12d8c0b6af | ||
|
|
5c232b6a8d | ||
|
|
f6fd4281a4 | ||
|
|
4bee63afc6 | ||
|
|
d186f6148b | ||
|
|
2b15c03b9a | ||
|
|
60d879e045 | ||
|
|
858d1768ce | ||
|
|
fc2b7f747b | ||
|
|
207019c7f3 | ||
|
|
b264bbea84 | ||
|
|
32efb3e280 | ||
|
|
1a0d68d49a | ||
|
|
7dd3b2d38b | ||
|
|
4bc65faf1a | ||
|
|
8634551f53 | ||
|
|
089663ccc1 | ||
|
|
d1d26f8bf6 | ||
|
|
1ca86730fa | ||
|
|
12ae7c009d | ||
|
|
51b2fce8c1 | ||
|
|
62fcb51e1a | ||
|
|
cbc55f2ef8 | ||
|
|
679f828e4e | ||
|
|
4a8b4e7398 | ||
|
|
b6a11ca31e | ||
|
|
a30ccf2b25 | ||
|
|
2574405699 | ||
|
|
3ba78553f0 | ||
|
|
4d485fc424 | ||
|
|
39c0064ffb |
@@ -3,7 +3,7 @@ version: 2
|
||||
jobs:
|
||||
build:
|
||||
docker:
|
||||
- image: circleci/node:6.12
|
||||
- image: circleci/node:9
|
||||
environment:
|
||||
CONTRACTS_COMMIT_HASH: '9ed05f5'
|
||||
working_directory: ~/repo
|
||||
@@ -11,103 +11,99 @@ jobs:
|
||||
- checkout
|
||||
- run: echo 'export PATH=$HOME/CIRCLE_PROJECT_REPONAME/node_modules/.bin:$PATH' >> $BASH_ENV
|
||||
- restore_cache:
|
||||
key: dependency-cache-{{ checksum "package.json" }}
|
||||
name: Restore Yarn Package Cache
|
||||
keys:
|
||||
- yarn-packages-{{ .Branch }}-{{ checksum "yarn.lock" }}
|
||||
- yarn-packages-{{ .Branch }}
|
||||
- yarn-packages-master
|
||||
- yarn-packages-
|
||||
- run:
|
||||
name: yarn
|
||||
command: yarn --frozen-lockfile
|
||||
command: yarn --frozen-lockfile install
|
||||
- save_cache:
|
||||
key: dependency-cache-{{ checksum "package.json" }}
|
||||
name: Save Yarn Package Cache
|
||||
key: yarn-packages-{{ .Branch }}-{{ checksum "yarn.lock" }}
|
||||
paths:
|
||||
- ./node_modules
|
||||
- run: wget https://s3.amazonaws.com/testrpc-shapshots/${CONTRACTS_COMMIT_HASH}.zip
|
||||
- run: unzip ${CONTRACTS_COMMIT_HASH}.zip -d testrpc_snapshot
|
||||
- run: node ./node_modules/lerna/bin/lerna.js bootstrap
|
||||
- run: yarn lerna:run build
|
||||
- node_modules/
|
||||
- run: >
|
||||
if [ -z "$(git diff --name-only v2-prototype packages/website)" ]; then
|
||||
yarn build --exclude website
|
||||
else
|
||||
yarn build
|
||||
fi
|
||||
- save_cache:
|
||||
key: repo-{{ .Environment.CIRCLE_SHA1 }}
|
||||
paths:
|
||||
- ~/repo
|
||||
test-installation:
|
||||
test-contracts-ganache:
|
||||
docker:
|
||||
- image: circleci/node:6.12
|
||||
- image: circleci/node:9
|
||||
working_directory: ~/repo
|
||||
steps:
|
||||
- restore_cache:
|
||||
keys:
|
||||
- repo-{{ .Environment.CIRCLE_SHA1 }}
|
||||
- run: yarn test:installation
|
||||
test-0xjs:
|
||||
- run: yarn wsrun test:circleci contracts
|
||||
test-contracts-geth:
|
||||
docker:
|
||||
- image: circleci/node:6.12
|
||||
- image: circleci/node:9
|
||||
- image: albrow/0x-devnet
|
||||
working_directory: ~/repo
|
||||
steps:
|
||||
- restore_cache:
|
||||
keys:
|
||||
- repo-{{ .Environment.CIRCLE_SHA1 }}
|
||||
- run:
|
||||
name: testrpc
|
||||
command: npm run testrpc -- --db testrpc_snapshot
|
||||
background: true
|
||||
- run: yarn lerna:run --scope 0x.js test:circleci
|
||||
# HACK(albrow): we need to sleep 10 seconds to ensure the devnet is
|
||||
# initialized
|
||||
- run: sleep 10 && TEST_PROVIDER=geth yarn wsrun test contracts
|
||||
test-rest:
|
||||
docker:
|
||||
- image: circleci/node:9
|
||||
working_directory: ~/repo
|
||||
steps:
|
||||
- restore_cache:
|
||||
keys:
|
||||
- repo-{{ .Environment.CIRCLE_SHA1 }}
|
||||
- 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
|
||||
- run: yarn wsrun test:circleci @0xproject/contract-wrappers
|
||||
- run: yarn wsrun test:circleci @0xproject/dev-utils
|
||||
- run: yarn wsrun test:circleci @0xproject/json-schemas
|
||||
- run: yarn wsrun test:circleci @0xproject/metacoin
|
||||
- run: yarn wsrun test:circleci @0xproject/order-utils
|
||||
- run: yarn wsrun test:circleci @0xproject/order-watcher
|
||||
- run: yarn wsrun test:circleci @0xproject/sol-compiler
|
||||
- run: yarn wsrun test:circleci @0xproject/sol-cov
|
||||
- run: yarn wsrun test:circleci @0xproject/sra-report
|
||||
- run: yarn wsrun test:circleci @0xproject/subproviders
|
||||
- run: yarn wsrun test:circleci @0xproject/web3-wrapper
|
||||
- save_cache:
|
||||
key: coverage-0xjs-{{ .Environment.CIRCLE_SHA1 }}
|
||||
paths:
|
||||
- ~/repo/packages/0x.js/coverage/lcov.info
|
||||
test-contracts:
|
||||
docker:
|
||||
- image: circleci/node:6.12
|
||||
working_directory: ~/repo
|
||||
steps:
|
||||
- restore_cache:
|
||||
keys:
|
||||
- repo-{{ .Environment.CIRCLE_SHA1 }}
|
||||
- run:
|
||||
name: testrpc
|
||||
command: npm run testrpc -- --db testrpc_snapshot
|
||||
background: true
|
||||
- run: yarn lerna:run --scope contracts test:circleci
|
||||
- save_cache:
|
||||
key: coverage-contracts-{{ .Environment.CIRCLE_SHA1 }}
|
||||
key: coverage-abi-gen-{{ .Environment.CIRCLE_SHA1 }}
|
||||
paths:
|
||||
- ~/repo/packages/contracts/coverage/lcov.info
|
||||
test-deployer:
|
||||
docker:
|
||||
- image: circleci/node:6.12
|
||||
working_directory: ~/repo
|
||||
steps:
|
||||
- restore_cache:
|
||||
keys:
|
||||
- repo-{{ .Environment.CIRCLE_SHA1 }}
|
||||
- run:
|
||||
name: testrpc
|
||||
command: npm run testrpc -- --db testrpc_snapshot
|
||||
background: true
|
||||
- run: yarn lerna:run --scope @0xproject/deployer test:circleci
|
||||
- save_cache:
|
||||
key: coverage-deployer-{{ .Environment.CIRCLE_SHA1 }}
|
||||
paths:
|
||||
- ~/repo/packages/deployer/coverage/lcov.info
|
||||
test-rest:
|
||||
docker:
|
||||
- image: circleci/node:6.12
|
||||
working_directory: ~/repo
|
||||
steps:
|
||||
- restore_cache:
|
||||
keys:
|
||||
- repo-{{ .Environment.CIRCLE_SHA1 }}
|
||||
- run:
|
||||
name: testrpc
|
||||
command: npm run testrpc -- --db testrpc_snapshot
|
||||
background: true
|
||||
- run: yarn lerna:run --ignore contracts --ignore 0x.js --ignore @0xproject/deployer test:circleci
|
||||
- ~/repo/packages/abi-gen/coverage/lcov.info
|
||||
- save_cache:
|
||||
key: coverage-assert-{{ .Environment.CIRCLE_SHA1 }}
|
||||
paths:
|
||||
- ~/repo/packages/assert/coverage/lcov.info
|
||||
- save_cache:
|
||||
key: coverage-base-contract-{{ .Environment.CIRCLE_SHA1 }}
|
||||
paths:
|
||||
- ~/repo/packages/base-contract/coverage/lcov.info
|
||||
- save_cache:
|
||||
key: coverage-connect-{{ .Environment.CIRCLE_SHA1 }}
|
||||
paths:
|
||||
- ~/repo/packages/connect/coverage/lcov.info
|
||||
- save_cache:
|
||||
key: coverage-contract-wrappers-{{ .Environment.CIRCLE_SHA1 }}
|
||||
paths:
|
||||
- ~/repo/packages/contract-wrappers/coverage/lcov.info
|
||||
- save_cache:
|
||||
key: coverage-dev-utils-{{ .Environment.CIRCLE_SHA1 }}
|
||||
paths:
|
||||
@@ -117,38 +113,50 @@ jobs:
|
||||
paths:
|
||||
- ~/repo/packages/json-schemas/coverage/lcov.info
|
||||
- save_cache:
|
||||
key: coverage-subproviders-{{ .Environment.CIRCLE_SHA1 }}
|
||||
key: coverage-metacoin-{{ .Environment.CIRCLE_SHA1 }}
|
||||
paths:
|
||||
- ~/repo/packages/subproviders/coverage/lcov.info
|
||||
- ~/repo/packages/metacoin/coverage/lcov.info
|
||||
- save_cache:
|
||||
key: coverage-order-utils-{{ .Environment.CIRCLE_SHA1 }}
|
||||
paths:
|
||||
- ~/repo/packages/order-utils/coverage/lcov.info
|
||||
- save_cache:
|
||||
key: coverage-order-watcher-{{ .Environment.CIRCLE_SHA1 }}
|
||||
paths:
|
||||
- ~/repo/packages/order-watcher/coverage/lcov.info
|
||||
- save_cache:
|
||||
key: coverage-sol-compiler-{{ .Environment.CIRCLE_SHA1 }}
|
||||
paths:
|
||||
- ~/repo/packages/sol-compiler/coverage/lcov.info
|
||||
- save_cache:
|
||||
key: coverage-sol-cov-{{ .Environment.CIRCLE_SHA1 }}
|
||||
paths:
|
||||
- ~/repo/packages/sol-cov/coverage/lcov.info
|
||||
- save_cache:
|
||||
key: coverage-metacoin-{{ .Environment.CIRCLE_SHA1 }}
|
||||
key: coverage-sra-report-{{ .Environment.CIRCLE_SHA1 }}
|
||||
paths:
|
||||
- ~/repo/packages/metacoin/coverage/lcov.info
|
||||
lint:
|
||||
- ~/repo/packages/sra-report/coverage/lcov.info
|
||||
- save_cache:
|
||||
key: coverage-subproviders-{{ .Environment.CIRCLE_SHA1 }}
|
||||
paths:
|
||||
- ~/repo/packages/subproviders/coverage/lcov.info
|
||||
- save_cache:
|
||||
key: coverage-web3-wrapper-{{ .Environment.CIRCLE_SHA1 }}
|
||||
paths:
|
||||
- ~/repo/packages/web3-wrapper/coverage/lcov.info
|
||||
static-tests:
|
||||
working_directory: ~/repo
|
||||
docker:
|
||||
- image: circleci/node:6.12
|
||||
steps:
|
||||
- restore_cache:
|
||||
keys:
|
||||
- repo-{{ .Environment.CIRCLE_SHA1 }}
|
||||
- run: yarn lerna:run lint
|
||||
prettier:
|
||||
working_directory: ~/repo
|
||||
docker:
|
||||
- image: circleci/node:6.12
|
||||
- image: circleci/node:9
|
||||
steps:
|
||||
- restore_cache:
|
||||
keys:
|
||||
- repo-{{ .Environment.CIRCLE_SHA1 }}
|
||||
- run: yarn prettier:ci
|
||||
- run: yarn lerna run lint
|
||||
submit-coverage:
|
||||
docker:
|
||||
- image: circleci/node:6.12
|
||||
- image: circleci/node:9
|
||||
working_directory: ~/repo
|
||||
steps:
|
||||
- restore_cache:
|
||||
@@ -156,13 +164,22 @@ jobs:
|
||||
- repo-{{ .Environment.CIRCLE_SHA1 }}
|
||||
- restore_cache:
|
||||
keys:
|
||||
- coverage-contracts-{{ .Environment.CIRCLE_SHA1 }}
|
||||
- coverage-0xjs-{{ .Environment.CIRCLE_SHA1 }}
|
||||
- restore_cache:
|
||||
keys:
|
||||
- coverage-abi-gen-{{ .Environment.CIRCLE_SHA1 }}
|
||||
- restore_cache:
|
||||
keys:
|
||||
- coverage-assert-{{ .Environment.CIRCLE_SHA1 }}
|
||||
- restore_cache:
|
||||
keys:
|
||||
- coverage-base-contract-{{ .Environment.CIRCLE_SHA1 }}
|
||||
- restore_cache:
|
||||
keys:
|
||||
- coverage-connect-{{ .Environment.CIRCLE_SHA1 }}
|
||||
- restore_cache:
|
||||
keys:
|
||||
- coverage-contract-wrappers-{{ .Environment.CIRCLE_SHA1 }}
|
||||
- restore_cache:
|
||||
keys:
|
||||
- coverage-dev-utils-{{ .Environment.CIRCLE_SHA1 }}
|
||||
@@ -171,49 +188,49 @@ jobs:
|
||||
- coverage-json-schemas-{{ .Environment.CIRCLE_SHA1 }}
|
||||
- restore_cache:
|
||||
keys:
|
||||
- coverage-subproviders-{{ .Environment.CIRCLE_SHA1 }}
|
||||
- coverage-metacoin-{{ .Environment.CIRCLE_SHA1 }}
|
||||
- restore_cache:
|
||||
keys:
|
||||
- coverage-order-utils-{{ .Environment.CIRCLE_SHA1 }}
|
||||
- restore_cache:
|
||||
keys:
|
||||
- coverage-order-watcher-{{ .Environment.CIRCLE_SHA1 }}
|
||||
- restore_cache:
|
||||
keys:
|
||||
- coverage-sol-compiler-{{ .Environment.CIRCLE_SHA1 }}
|
||||
- restore_cache:
|
||||
keys:
|
||||
- coverage-sol-cov-{{ .Environment.CIRCLE_SHA1 }}
|
||||
- restore_cache:
|
||||
keys:
|
||||
- coverage-deployer-{{ .Environment.CIRCLE_SHA1 }}
|
||||
- coverage-sra-report-{{ .Environment.CIRCLE_SHA1 }}
|
||||
- restore_cache:
|
||||
keys:
|
||||
- coverage-0xjs-{{ .Environment.CIRCLE_SHA1 }}
|
||||
- coverage-subproviders-{{ .Environment.CIRCLE_SHA1 }}
|
||||
- restore_cache:
|
||||
keys:
|
||||
- coverage-metacoin-{{ .Environment.CIRCLE_SHA1 }}
|
||||
- coverage-web3-wrapper-{{ .Environment.CIRCLE_SHA1 }}
|
||||
- restore_cache:
|
||||
keys:
|
||||
- coverage-contracts-{{ .Environment.CIRCLE_SHA1 }}
|
||||
- run: yarn report_coverage
|
||||
workflows:
|
||||
version: 2
|
||||
main:
|
||||
jobs:
|
||||
- build
|
||||
- test-installation:
|
||||
- test-contracts-ganache:
|
||||
requires:
|
||||
- build
|
||||
- test-0xjs:
|
||||
requires:
|
||||
- build
|
||||
- test-contracts:
|
||||
requires:
|
||||
- build
|
||||
- test-deployer:
|
||||
- test-contracts-geth:
|
||||
requires:
|
||||
- build
|
||||
- test-rest:
|
||||
requires:
|
||||
- build
|
||||
- prettier:
|
||||
requires:
|
||||
- build
|
||||
- lint:
|
||||
- static-tests:
|
||||
requires:
|
||||
- build
|
||||
- submit-coverage:
|
||||
requires:
|
||||
- test-0xjs
|
||||
- test-deployer
|
||||
- test-rest
|
||||
- test-contracts
|
||||
|
||||
37
.gitignore
vendored
37
.gitignore
vendored
@@ -41,6 +41,7 @@ typings/
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
.npmrc
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
@@ -67,25 +68,37 @@ generated_docs/
|
||||
|
||||
TODO.md
|
||||
|
||||
# VSCode file
|
||||
.vscode
|
||||
|
||||
packages/website/public/bundle*
|
||||
packages/react-docs/example/public/bundle*
|
||||
|
||||
# generated binaries
|
||||
bin/
|
||||
# server cli
|
||||
packages/testnet-faucets/server/
|
||||
|
||||
# generated contract artifacts
|
||||
packages/sol-cov/test/fixtures/artifacts
|
||||
packages/metacoin/artifacts
|
||||
packages/0x.js/test/artifacts
|
||||
packages/migrations/src/artifacts
|
||||
# generated contract artifacts/
|
||||
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
|
||||
packages/0x.js/src/contract_wrappers/generated/
|
||||
packages/contracts/src/contract_wrappers/generated/
|
||||
# generated contract watcher
|
||||
packages/0x.js/src/generated_contract_wrappers/
|
||||
packages/contracts/generated_contract_wrappers/
|
||||
packages/contract-wrappers/src/contract_wrappers/generated/
|
||||
packages/metacoin/src/contract_wrappers
|
||||
packages/fill-scenarios/src/generated_contract_wrappers/
|
||||
packages/order-watcher/src/generated_contract_wrappers/
|
||||
packages/order-utils/src/generated_contract_wrappers/
|
||||
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
|
||||
|
||||
# solc-bin in deployer
|
||||
packages/deployer/solc_bin/
|
||||
# solc-bin in sol-compiler
|
||||
packages/sol-compiler/solc_bin/
|
||||
|
||||
# Monorepo scripts
|
||||
packages/*/scripts/
|
||||
|
||||
@@ -1,7 +1,24 @@
|
||||
lib
|
||||
.nyc_output
|
||||
/packages/contract-wrappers/src/contract_wrappers/generated/
|
||||
/packages/metacoin/src/contract_wrappers
|
||||
/packages/0x.js/src/generated_contract_wrappers/
|
||||
/packages/contracts/generated_contract_wrappers/
|
||||
/packages/fill-scenarios/src/generated_contract_wrappers/
|
||||
/packages/order-watcher/src/generated_contract_wrappers/
|
||||
/packages/order-utils/src/generated_contract_wrappers/
|
||||
/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/src/artifacts
|
||||
/packages/contracts/src/artifacts
|
||||
/packages/contract-wrappers/src/artifacts
|
||||
/packages/order-watcher/src/artifacts
|
||||
/packages/metacoin/artifacts
|
||||
/packages/migrations/src/artifacts
|
||||
/packages/contract-wrappers/test/artifacts
|
||||
/packages/order-watcher/test/artifacts
|
||||
/packages/migrations/artifacts/1.0.0
|
||||
/packages/migrations/artifacts/2.0.0
|
||||
/packages/migrations/artifacts/2.0.0-beta-testnet
|
||||
package.json
|
||||
scripts/postpublish_utils.js
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
* @abandeali1 @BMillman19 @dekz @fabioberger @LogvinovLeon @Recmo
|
||||
46
CODE_OF_CONDUCT.md
Normal file
46
CODE_OF_CONDUCT.md
Normal file
@@ -0,0 +1,46 @@
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment include:
|
||||
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery and unwelcome sexual attention or advances
|
||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic address, without explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a professional setting
|
||||
|
||||
## Our Responsibilities
|
||||
|
||||
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at team@0xproject.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
|
||||
|
||||
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
|
||||
|
||||
[homepage]: http://contributor-covenant.org
|
||||
[version]: http://contributor-covenant.org/version/1/4/
|
||||
@@ -21,6 +21,18 @@ If you're adding a new public function/member, make sure you document it with Ja
|
||||
|
||||
If the sub-package you are modifying has a `CHANGELOG.md` file, make sure to add an entry in it for the change made to the package. For published packages, only changes that modify the public interface or behavior of the package need a CHANGELOG entry.
|
||||
|
||||
#### Enabling code coverage checks on your fork
|
||||
|
||||
If you simply fork the repo and then create a PR sourced from it, your PR will fail its test coverage check. This is because the 0x CircleCI configuration sets the `COVERALLS_REPO_TOKEN` environment variable to the token for 0xProject/0x-monorepo, but when running the check against your fork the token needs to match the repo that is your fork, rather than the 0x repo.
|
||||
|
||||
To facilitate this check, after creating your fork, but before creating the branch for your PR, do the following:
|
||||
|
||||
1. Log in to [coveralls.io](https://coveralls.io/), go to Add Repos, and enable your fork. Then go to the settings for that repo, and copy the Repo Token identifier.
|
||||
2. Log in to [CircleCI](https://circleci.com/login), go to Add Projects, click the Set Up Project button corresponding to your fork, and then click Start Building. (Aside from step 3 below, no actual set up is needed, since it will use the `.circleci/config.yml` file in 0x-monorepo, so you can ignore all of the instruction/explanation given on the page with the Start Building button.)
|
||||
3. In CircleCI, configure your project to add an Environment Variable, with name `COVERALLS_REPO_TOKEN`, and for the value paste in the Repo Token you copied in step 1.
|
||||
|
||||
Now, when you push to your branch, CircleCI will automatically run all of the checks in your own instance, and the coverage check will work since it has the proper Repo Token, and the PR will magically refer to your own checks rather than running them in the 0x CircleCI instance.
|
||||
|
||||
### Styleguide
|
||||
|
||||
We use [TSLint](https://palantir.github.io/tslint/) with [custom configs](https://github.com/0xProject/0x-monorepo/tree/development/packages/tslint-config) to keep our code style consistent.
|
||||
|
||||
@@ -1,41 +1,27 @@
|
||||
<!--- Thank you for taking the time to submit a Pull Request -->
|
||||
|
||||
<!--- Provide a general summary of the issue in the Title above -->
|
||||
|
||||
## Description
|
||||
|
||||
<!--- Describe your changes in detail -->
|
||||
|
||||
## Motivation and Context
|
||||
## Testing instructions
|
||||
|
||||
<!--- Why is this change required? What problem does it solve? -->
|
||||
|
||||
<!--- If it fixes an open issue, please link to the issue here. -->
|
||||
|
||||
## How Has This Been Tested?
|
||||
|
||||
<!--- Please describe in detail how you tested your changes. -->
|
||||
|
||||
<!--- Include details of your testing environment, and the tests you ran to -->
|
||||
|
||||
<!--- see how your change affects other areas of the code, etc. -->
|
||||
<!--- Please describe how reviewers can test your changes -->
|
||||
|
||||
## 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.
|
||||
|
||||
126
README.md
126
README.md
@@ -6,8 +6,11 @@
|
||||
|
||||
This repository is a monorepo including the 0x protocol smart contracts and numerous developer tools. Each public sub-package is independently published to NPM.
|
||||
|
||||
If you're developing on 0x now or are interested in using 0x infrastructure in the future, please join our [developer mailing list][dev-mailing-list-url] for updates.
|
||||
|
||||
[website-url]: https://0xproject.com/
|
||||
[whitepaper-url]: https://0xproject.com/pdfs/0x_white_paper.pdf
|
||||
[dev-mailing-list-url]: http://eepurl.com/dx4cPf
|
||||
|
||||
[](https://circleci.com/gh/0xProject/0x-monorepo)
|
||||
[](https://coveralls.io/github/0xProject/0x-monorepo?branch=development)
|
||||
@@ -17,27 +20,27 @@ This repository is a monorepo including the 0x protocol smart contracts and nume
|
||||
|
||||
### Published Packages
|
||||
|
||||
| Package | Version | Description |
|
||||
| --------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------- |
|
||||
| [`0x.js`](/packages/0x.js) | [](https://www.npmjs.com/package/0x.js) | A Javascript library for interacting with the 0x protocol |
|
||||
| [`@0xproject/abi-gen`](/packages/abi-gen) | [](https://www.npmjs.com/package/@0xproject/abi-gen) | Tool to generate TS wrappers from smart contract ABIs |
|
||||
| [`@0xproject/assert`](/packages/assert) | [](https://www.npmjs.com/package/@0xproject/assert) | Type and schema assertions used by our packages |
|
||||
| [`@0xproject/base-contract`](/packages/base-contract) | [](https://www.npmjs.com/package/@0xproject/base-contract) | BaseContract used by auto-generated `abi-gen` wrapper contracts |
|
||||
| [`@0xproject/connect`](/packages/connect) | [](https://www.npmjs.com/package/@0xproject/connect) | A Javascript library for interacting with the Standard Relayer API |
|
||||
| [`@0xproject/deployer`](/packages/deployer) | [](https://www.npmjs.com/package/@0xproject/deployer) | Solidity project compiler and deployer framework |
|
||||
| [`@0xproject/dev-utils`](/packages/dev-utils) | [](https://www.npmjs.com/package/@0xproject/dev-utils) | Dev utils to be shared across 0x projects and packages |
|
||||
| [`@0xproject/json-schemas`](/packages/json-schemas) | [](https://www.npmjs.com/package/@0xproject/json-schemas) | 0x-related json schemas |
|
||||
| [`@0xproject/monorepo-scripts`](/packages/monorepo-scripts) | [](https://www.npmjs.com/package/@0xproject/monorepo-scripts) | Monorepo scripts |
|
||||
| [`@0xproject/react-docs`](/packages/react-docs) | [](https://www.npmjs.com/package/@0xproject/react-docs) | React documentation component for rendering TypeDoc & Doxity generated JSON |
|
||||
| [`@0xproject/react-shared`](/packages/react-shared) | [](https://www.npmjs.com/package/@0xproject/react-shared) | 0x shared react components |
|
||||
| [`@0xproject/sra-report`](/packages/sra-report) | [](https://www.npmjs.com/package/@0xproject/sra-report) | Generate reports for standard relayer API compliance |
|
||||
| [`@0xproject/sol-cov`](/packages/sol-cov) | [](https://www.npmjs.com/package/@0xproject/sol-cov) | Solidity test coverage tool |
|
||||
| [`@0xproject/subproviders`](/packages/subproviders) | [](https://www.npmjs.com/package/@0xproject/subproviders) | Useful web3 subproviders (e.g LedgerSubprovider) |
|
||||
| [`@0xproject/tslint-config`](/packages/tslint-config) | [](https://www.npmjs.com/package/@0xproject/tslint-config) | Custom 0x development TSLint rules |
|
||||
| [`@0xproject/types`](/packages/types) | [](https://www.npmjs.com/package/@0xproject/types) | Shared type declarations |
|
||||
| [`@0xproject/typescript-typings`](/packages/typescript-typings) | [](https://www.npmjs.com/package/@0xproject/typescript-typings) | Repository of types for external packages |
|
||||
| [`@0xproject/utils`](/packages/utils) | [](https://www.npmjs.com/package/@0xproject/utils) | Shared utilities |
|
||||
| [`@0xproject/web3-wrapper`](/packages/web3-wrapper) | [](https://www.npmjs.com/package/@0xproject/web3-wrapper) | Web3 wrapper |
|
||||
| Package | Version | Description |
|
||||
| --------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
|
||||
| [`0x.js`](/packages/0x.js) | [](https://www.npmjs.com/package/0x.js) | A Javascript library for interacting with the 0x protocol |
|
||||
| [`@0xproject/abi-gen`](/packages/abi-gen) | [](https://www.npmjs.com/package/@0xproject/abi-gen) | Tool to generate TS wrappers from smart contract ABIs |
|
||||
| [`@0xproject/assert`](/packages/assert) | [](https://www.npmjs.com/package/@0xproject/assert) | Type and schema assertions used by our packages |
|
||||
| [`@0xproject/base-contract`](/packages/base-contract) | [](https://www.npmjs.com/package/@0xproject/base-contract) | BaseContract used by auto-generated `abi-gen` wrapper contracts |
|
||||
| [`@0xproject/connect`](/packages/connect) | [](https://www.npmjs.com/package/@0xproject/connect) | A Javascript library for interacting with the Standard Relayer API |
|
||||
| [`@0xproject/sol-compiler`](/packages/sol-compiler) | [](https://www.npmjs.com/package/@0xproject/sol-compiler) | A thin wrapper around Solc.js that outputs artifacts, resolves imports, only re-compiles when needed, and other niceties. |
|
||||
| [`@0xproject/dev-utils`](/packages/dev-utils) | [](https://www.npmjs.com/package/@0xproject/dev-utils) | Dev utils to be shared across 0x projects and packages |
|
||||
| [`@0xproject/json-schemas`](/packages/json-schemas) | [](https://www.npmjs.com/package/@0xproject/json-schemas) | 0x-related json schemas |
|
||||
| [`@0xproject/monorepo-scripts`](/packages/monorepo-scripts) | [](https://www.npmjs.com/package/@0xproject/monorepo-scripts) | Monorepo scripts |
|
||||
| [`@0xproject/react-docs`](/packages/react-docs) | [](https://www.npmjs.com/package/@0xproject/react-docs) | React documentation component for rendering TypeDoc & Doxity generated JSON |
|
||||
| [`@0xproject/react-shared`](/packages/react-shared) | [](https://www.npmjs.com/package/@0xproject/react-shared) | 0x shared react components |
|
||||
| [`@0xproject/sra-report`](/packages/sra-report) | [](https://www.npmjs.com/package/@0xproject/sra-report) | Generate reports for standard relayer API compliance |
|
||||
| [`@0xproject/sol-cov`](/packages/sol-cov) | [](https://www.npmjs.com/package/@0xproject/sol-cov) | Solidity test coverage tool |
|
||||
| [`@0xproject/subproviders`](/packages/subproviders) | [](https://www.npmjs.com/package/@0xproject/subproviders) | Useful web3 subproviders (e.g LedgerSubprovider) |
|
||||
| [`@0xproject/tslint-config`](/packages/tslint-config) | [](https://www.npmjs.com/package/@0xproject/tslint-config) | Custom 0x development TSLint rules |
|
||||
| [`@0xproject/types`](/packages/types) | [](https://www.npmjs.com/package/@0xproject/types) | Shared type declarations |
|
||||
| [`@0xproject/typescript-typings`](/packages/typescript-typings) | [](https://www.npmjs.com/package/@0xproject/typescript-typings) | Repository of types for external packages |
|
||||
| [`@0xproject/utils`](/packages/utils) | [](https://www.npmjs.com/package/@0xproject/utils) | Shared utilities |
|
||||
| [`@0xproject/web3-wrapper`](/packages/web3-wrapper) | [](https://www.npmjs.com/package/@0xproject/web3-wrapper) | Web3 wrapper |
|
||||
|
||||
### Private Packages
|
||||
|
||||
@@ -56,12 +59,14 @@ Dedicated documentation pages:
|
||||
* [0x Connect](https://0xproject.com/docs/connect)
|
||||
* [Smart contracts](https://0xproject.com/docs/contracts)
|
||||
* [Subproviders](https://0xproject.com/docs/subproviders)
|
||||
* [Deployer](https://0xproject.com/docs/deployer)
|
||||
* [Sol Compiler](https://0xproject.com/docs/sol-compiler)
|
||||
* [Web3-wrapper](https://0xproject.com/docs/web3-wrapper)
|
||||
* [JSON-schemas](https://0xproject.com/docs/json-schemas)
|
||||
* [Sol-cov](https://0xproject.com/docs/sol-cov)
|
||||
* [Standard Relayer API](https://github.com/0xProject/standard-relayer-api/blob/master/README.md)
|
||||
|
||||
Node version >= 6.12 is required.
|
||||
|
||||
Most of the packages require additional typings for external dependencies.
|
||||
You can include those by prepending @0xproject/typescript-typings package to your [`typeRoots`](http://www.typescriptlang.org/docs/handbook/tsconfig-json.html) config.
|
||||
|
||||
@@ -91,32 +96,87 @@ yarn install
|
||||
|
||||
### Build
|
||||
|
||||
Build all packages. You need to do this before working on any given package. Although these packages
|
||||
as independent, when run from within the monorepo, they are internally symlinked, to make development
|
||||
easier. You can change several packages and run the changes without publishing them first to NPM. When
|
||||
running `rebuild`, Lerna will figure out the dependency order of all the packages, and build them in
|
||||
this order.
|
||||
To build all packages:
|
||||
|
||||
```bash
|
||||
yarn lerna:rebuild
|
||||
yarn build
|
||||
```
|
||||
|
||||
Or continuously rebuild on change:
|
||||
To build a specific package:
|
||||
|
||||
```bash
|
||||
yarn dev
|
||||
PKG=@0xproject/web3-wrapper yarn build
|
||||
```
|
||||
|
||||
### Watch
|
||||
|
||||
To re-build all packages on change:
|
||||
|
||||
```bash
|
||||
yarn watch
|
||||
```
|
||||
|
||||
To watch a specific package and all it's dependent packages:
|
||||
|
||||
```bash
|
||||
PKG=[NPM_PACKAGE_NAME] yarn watch
|
||||
|
||||
e.g
|
||||
PKG=@0xproject/web3-wrapper yarn watch
|
||||
```
|
||||
|
||||
### Clean
|
||||
|
||||
Clean all packages:
|
||||
|
||||
```bash
|
||||
yarn clean
|
||||
```
|
||||
|
||||
Clean a specific package
|
||||
|
||||
```bash
|
||||
PKG=0x.js yarn clean
|
||||
```
|
||||
|
||||
### Rebuild
|
||||
|
||||
To re-build (clean & build) all packages:
|
||||
|
||||
```bash
|
||||
yarn rebuild
|
||||
```
|
||||
|
||||
To re-build (clean & build) a specific package & it's deps:
|
||||
|
||||
```bash
|
||||
PKG=0x.js yarn rebuild
|
||||
```
|
||||
|
||||
### Lint
|
||||
|
||||
Lint all packages
|
||||
Lint all packages:
|
||||
|
||||
```bash
|
||||
yarn lerna:run lint
|
||||
yarn lint
|
||||
```
|
||||
|
||||
Lint a specific package:
|
||||
|
||||
```bash
|
||||
PKG=0x.js yarn lint
|
||||
```
|
||||
|
||||
### Run Tests
|
||||
|
||||
Run all tests:
|
||||
|
||||
```bash
|
||||
yarn lerna:test
|
||||
yarn test
|
||||
```
|
||||
|
||||
Run a specific package's test:
|
||||
|
||||
```bash
|
||||
PKG=@0xproject/web3-wrapper yarn test
|
||||
```
|
||||
|
||||
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",
|
||||
|
||||
48
package.json
48
package.json
@@ -1,27 +1,38 @@
|
||||
{
|
||||
"private": true,
|
||||
"name": "0x-monorepo",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
"workspaces": [
|
||||
"packages/*"
|
||||
],
|
||||
"scripts": {
|
||||
"dev": "lerna run --parallel build:watch",
|
||||
"testrpc": "testrpc -p 8545 --networkId 50 -m \"${npm_package_config_mnemonic}\"",
|
||||
"ganache": "ganache-cli -p 8545 --networkId 50 -m \"${npm_package_config_mnemonic}\"",
|
||||
"prettier": "prettier --write '**/*.{ts,tsx,json,md}' --config .prettierrc",
|
||||
"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",
|
||||
"lerna:install": "yarn install",
|
||||
"lerna:run": "lerna run",
|
||||
"lerna:test": "lerna run test",
|
||||
"lerna:clean": "lerna run clean",
|
||||
"lerna:build": "lerna run build",
|
||||
"lerna:rebuild": "run-s lerna:clean lerna:build",
|
||||
"lerna:publish": "run-s lerna:install lerna:rebuild script:publish",
|
||||
"lerna:publish:dry": "run-s lerna:install lerna:rebuild script:publish:dry",
|
||||
"lerna:stage_docs": "lerna run docs:stage",
|
||||
"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": "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."
|
||||
},
|
||||
"config": {
|
||||
"mnemonic": "concert load couple harbor equip island argue ramp clarify fence smart topic"
|
||||
@@ -29,10 +40,15 @@
|
||||
"devDependencies": {
|
||||
"async-child-process": "^1.1.1",
|
||||
"coveralls": "^3.0.0",
|
||||
"ethereumjs-testrpc": "^6.0.3",
|
||||
"lcov-result-merger": "^2.0.0",
|
||||
"lerna": "^2.5.1",
|
||||
"ganache-cli": "6.1.3",
|
||||
"lcov-result-merger": "^3.0.0",
|
||||
"@0x-lerna-fork/lerna": "3.0.0-beta.23",
|
||||
"npm-run-all": "^4.1.2",
|
||||
"prettier": "^1.11.1"
|
||||
"prettier": "^1.11.1",
|
||||
"source-map-support": "^0.5.6",
|
||||
"wsrun": "^2.2.0"
|
||||
},
|
||||
"resolutions": {
|
||||
"ethers": "0xproject/ethers.js#eip-838-reasons"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,208 @@
|
||||
[
|
||||
{
|
||||
"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",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1527617805,
|
||||
"version": "0.38.3",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1527617227,
|
||||
"version": "0.38.2",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1527616612,
|
||||
"version": "0.38.1",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"version": "0.38.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Renamed createOrderStateWatcher to createOrderWatcherAsync since it is now async",
|
||||
"pr": 579
|
||||
},
|
||||
{
|
||||
"note":
|
||||
"Renamed ZeroExError to ContractWrappersErrors since they now lives in the @0xproject/contract-wrappers subpackage",
|
||||
"pr": 579
|
||||
}
|
||||
],
|
||||
"timestamp": 1527008270
|
||||
},
|
||||
{
|
||||
"timestamp": 1525477860,
|
||||
"version": "0.37.2",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1525453812,
|
||||
"version": "0.37.1",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"version": "0.37.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Fixed expiration watcher comparator to handle orders with equal expiration times",
|
||||
"pr": 526
|
||||
},
|
||||
{
|
||||
"note": "Update Web3 Provider Engine to 14.0.4",
|
||||
"pr": 555
|
||||
},
|
||||
{
|
||||
"note": "Add `zeroEx.getProvider()`",
|
||||
"pr": 559
|
||||
},
|
||||
{
|
||||
"note": "Move `ZeroExError.InvalidSignature` to `@0xproject/order-utils` `OrderError.InvalidSignature`",
|
||||
"pr": 559
|
||||
}
|
||||
],
|
||||
"timestamp": 1525428773
|
||||
},
|
||||
{
|
||||
"version": "0.36.3",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Move @0xproject/migrations to devDependencies"
|
||||
}
|
||||
],
|
||||
"timestamp": 1524079658
|
||||
},
|
||||
{
|
||||
"timestamp": 1524073495,
|
||||
"version": "0.36.2",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"version": "0.36.1",
|
||||
"changes": [
|
||||
|
||||
@@ -1,16 +1,95 @@
|
||||
<!--
|
||||
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
|
||||
|
||||
## v0.38.3 - _May 29, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.38.2 - _May 29, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.38.1 - _May 29, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.38.0 - _May 22, 2018_
|
||||
|
||||
* Renamed createOrderStateWatcher to createOrderWatcherAsync since it is now async (#579)
|
||||
* Renamed ZeroExError to ContractWrappersErrors since they now lives in the @0xproject/contract-wrappers subpackage (#579)
|
||||
|
||||
## v0.37.2 - _May 5, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.37.1 - _May 4, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.37.0 - _May 4, 2018_
|
||||
|
||||
* Fixed expiration watcher comparator to handle orders with equal expiration times (#526)
|
||||
* Update Web3 Provider Engine to 14.0.4 (#555)
|
||||
* Add `zeroEx.getProvider()` (#559)
|
||||
* Move `ZeroExError.InvalidSignature` to `@0xproject/order-utils` `OrderError.InvalidSignature` (#559)
|
||||
|
||||
## v0.36.3 - _April 18, 2018_
|
||||
|
||||
* Move @0xproject/migrations to devDependencies
|
||||
|
||||
## v0.36.2 - _April 18, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.36.1 - _April 18, 2018_
|
||||
|
||||
* Internal changes and refactoring
|
||||
* Fix redundant expired order removal bug (#527)
|
||||
|
||||
## v0.36.0 - _April 12, 2018_
|
||||
## v0.36.0 - _April 11, 2018_
|
||||
|
||||
* Moved Web3.Provider to `@0xproject/types:Provider` (#501)
|
||||
* Add `zeroEx.exchange.getOrderStateAsync` to allow obtaining current OrderState for a signedOrder (#510)
|
||||
@@ -26,16 +105,16 @@ CHANGELOG
|
||||
* Add `zeroEx.createOrderStateWatcher` to allow creating arbitrary number of OrderStateWatchers (#488)
|
||||
* Added `stateLayer` setting to `OrderStateWatcherConfig` so OrderStateWatcher can be set to monitor different blockchain state layers (#488)
|
||||
|
||||
## v0.33.2 - _March 18, 2018_
|
||||
## v0.33.2 - _March 17, 2018_
|
||||
|
||||
* Consolidate all `console.log` calls into `logUtils` in the `@0xproject/utils` package (#452)
|
||||
* Consolidate `Order`, `SignedOrder`, and `ECSignature` into the `@0xproject/types` package (#456)
|
||||
|
||||
## v0.33.1 - _March 8, 2018_
|
||||
## v0.33.1 - _March 7, 2018_
|
||||
|
||||
* Add missing EthersJs typescript typings as dependency
|
||||
|
||||
## v0.33.0 - _March 4, 2018_
|
||||
## v0.33.0 - _March 3, 2018_
|
||||
|
||||
* Validate and lowercase all addresses in public methods (#373)
|
||||
* Improve validation to force passing contract addresses on private networks (#385)
|
||||
@@ -43,54 +122,54 @@ CHANGELOG
|
||||
* Rename all public `_unsubscribeAll` methods to `unsubscribeAll` (#415)
|
||||
* Move web3 typings from devDep to dep since cannot use this package without it (#429)
|
||||
|
||||
## v0.32.2 - _February 9, 2018_
|
||||
## v0.32.2 - _February 8, 2018_
|
||||
|
||||
* Fix publishing issue where .npmignore was not properly excluding undesired content (#389)
|
||||
|
||||
## v0.32.1 - _February 7, 2018_
|
||||
## v0.32.1 - _February 6, 2018_
|
||||
|
||||
* Reorganized `BlockParamLiteral` export into `@0xproject/types` package (#355)
|
||||
* Now using `abi-gen` package to generate ContractEventArgs types (#371)
|
||||
|
||||
## v0.32.0 - _February 5, 2018_
|
||||
## v0.32.0 - _February 4, 2018_
|
||||
|
||||
* Add `zeroEx.etherToken.getContractAddressIfExists` (#350)
|
||||
* Fixed the bug causing order watcher to throw if there is an event with the same signature but different indexed fields (#366)
|
||||
|
||||
## v0.31.1 - _February 1, 2018_
|
||||
## v0.31.1 - _January 31, 2018_
|
||||
|
||||
* Fix the bug causing order watcher to throw if makerToken === zrx (#357)
|
||||
|
||||
## v0.31.0 - _January 30, 2018_
|
||||
## v0.31.0 - _January 29, 2018_
|
||||
|
||||
* Add the `shouldAddPersonalMessagePrefix` parameter to `signOrderHashAsync` so that the caller can decide on whether to add the personalMessage prefix before relaying the request to the signer. Parity Signer, Ledger and TestRPC add the prefix themselves, Metamask expects it to have already been added. (#349)
|
||||
|
||||
## v0.30.2 - _January 29, 2018_
|
||||
## v0.30.2 - _January 28, 2018_
|
||||
|
||||
* Add Rinkeby testnet addresses to artifacts (#337)
|
||||
* Move @0xproject/types to dependencies from devDependencies fixing missing type errors
|
||||
|
||||
## v0.30.1 - _January 24, 2018_
|
||||
## v0.30.1 - _January 23, 2018_
|
||||
|
||||
* Fix a bug allowing negative fill values (#212)
|
||||
* Fix a bug that made it impossible to pass a custom ZRX address (#341)
|
||||
|
||||
## v0.30.0 - _January 17, 2018_
|
||||
## v0.30.0 - _January 16, 2018_
|
||||
|
||||
* Add an error parameter to the order watcher callback (#312)
|
||||
* Fix a bug making it impossible to catch some errors from awaitTransactionMinedAsync (#312)
|
||||
* Fix a bug in fillOrdersUpTo validation making it impossible to fill up to if user doesn't have enough balance to fully fill all the orders (#321)
|
||||
|
||||
## v0.29.1 - _January 11, 2018_
|
||||
## v0.29.1 - _January 10, 2018_
|
||||
|
||||
* Fixed bignumber config issue #301 (#305)
|
||||
|
||||
## v0.29.0 - _December 28, 2017_
|
||||
## v0.29.0 - _December 27, 2017_
|
||||
|
||||
* Assert baseUnit amount supplied to `toUnitAmount` is integer amount. (#287)
|
||||
* `toBaseUnitAmount` throws if amount supplied has too many decimals (#287)
|
||||
|
||||
## v0.28.0 - _December 20, 2017_
|
||||
## v0.28.0 - _December 19, 2017_
|
||||
|
||||
* Add `etherTokenAddress` arg to `depositAsync` and `withdrawAsync` methods on `zeroEx.etherToken` (#267)
|
||||
* Removed accidentally included `unsubscribeAll` method from `zeroEx.proxy`, `zeroEx.etherToken` and `zeroEx.tokenRegistry` (#267)
|
||||
@@ -102,11 +181,11 @@ CHANGELOG
|
||||
* Support `Deposit` and `Withdraw` events on etherToken (#277)
|
||||
* Improve the error message when taker is not a string (#278)
|
||||
|
||||
## v0.27.1 - _November 28, 2017_
|
||||
## v0.27.1 - _November 27, 2017_
|
||||
|
||||
* Export `TransactionOpts` type
|
||||
|
||||
## v0.27.0 - _November 28, 2017_
|
||||
## v0.27.0 - _November 27, 2017_
|
||||
|
||||
* Make `ZeroExConfig` required parameter of `ZeroEx` constructor (#233)
|
||||
* Add a required property `networkId` to `ZeroExConfig` (#233)
|
||||
@@ -118,65 +197,65 @@ CHANGELOG
|
||||
* All transaction sending methods now call `estimateGas` if no gas amount was supplied (#235)
|
||||
* Modify order validation methods to validate against the `latest` block, not against the `pending` block (#236)
|
||||
|
||||
## v0.26.0 - _November 21, 2017_
|
||||
## v0.26.0 - _November 20, 2017_
|
||||
|
||||
* Add post-formatter for logs converting `blockNumber`, `logIndex`, `transactionIndex` from hexes to numbers (#231)
|
||||
* Remove support for Async callback types when used in Subscribe functions (#222)
|
||||
* In OrderWatcher subscribe to ZRX Token Transfer and Approval events when maker token is different (#225)
|
||||
|
||||
## v0.25.1 - _November 13, 2017_
|
||||
## v0.25.1 - _November 12, 2017_
|
||||
|
||||
* Standardise on Cancelled over Canceled (#217)
|
||||
* Add missing `DecodedLogEvent` type to exported types (#205)
|
||||
* Normalized the transactionReceipt status to be `null|0|1`, 1 meaning transaction execution successful, 0 unsuccessful and `null` if it is a pre-byzantinium transaction. (#200)
|
||||
|
||||
## v0.23.0 - _November 12, 2017_
|
||||
## v0.23.0 - _November 11, 2017_
|
||||
|
||||
* Fixed unhandled promise rejection error in subscribe methods (#209)
|
||||
* Subscribe callbacks now receive an error object as their first argument
|
||||
|
||||
## v0.22.6 - _November 10, 2017_
|
||||
## v0.22.6 - _November 9, 2017_
|
||||
|
||||
* Add a timeout parameter to transaction awaiting (#206)
|
||||
|
||||
## v0.22.5 - _November 7, 2017_
|
||||
## v0.22.5 - _November 6, 2017_
|
||||
|
||||
* Re-publish v0.22.4 to fix publishing issue
|
||||
|
||||
## v0.22.4 - _October 25, 2017_
|
||||
## v0.22.4 - _October 24, 2017_
|
||||
|
||||
* Upgraded bignumber.js to a new version that ships with native typings
|
||||
|
||||
## v0.22.3 - _October 25, 2017_
|
||||
## v0.22.3 - _October 24, 2017_
|
||||
|
||||
* Fixed an issue with new version of testrpc and unlimited proxy allowance (#199)
|
||||
|
||||
## v0.22.2 - _October 24, 2017_
|
||||
## v0.22.2 - _October 23, 2017_
|
||||
|
||||
* Fixed rounding of maker fill amount and incorrect validation of partial fees (#197)
|
||||
|
||||
## v0.22.0 - _October 16, 2017_
|
||||
## v0.22.0 - _October 15, 2017_
|
||||
|
||||
* Started using `OrderFillRequest` interface instead of `OrderFillOrKillRequest` interface for `zeroEx.exchange.batchFillOrKill` (#187)
|
||||
* Removed `OrderFillOrKillRequest` (#187)
|
||||
|
||||
## v0.21.4 - _October 13, 2017_
|
||||
## v0.21.4 - _October 12, 2017_
|
||||
|
||||
* Made 0x.js more type-safe by making `getLogsAsync` and `subscribe/subscribeAsync` generics parametrized with arg type (#194)
|
||||
|
||||
## v0.21.3 - _October 12, 2017_
|
||||
## v0.21.3 - _October 11, 2017_
|
||||
|
||||
* Fixed a bug causing order fills to throw `INSUFFICIENT_TAKER_ALLOWANCE` (#193)
|
||||
|
||||
## v0.21.2 - _October 11, 2017_
|
||||
## v0.21.2 - _October 10, 2017_
|
||||
|
||||
* Exported `ContractEventArg` as a public type (#190)
|
||||
|
||||
## v0.21.1 - _October 11, 2017_
|
||||
## v0.21.1 - _October 10, 2017_
|
||||
|
||||
* Fixed a bug in subscriptions (#189)
|
||||
|
||||
## v0.21.0 - _October 10, 2017_
|
||||
## v0.21.0 - _October 9, 2017_
|
||||
|
||||
* Complete rewrite of subscription logic (#182)
|
||||
* Subscriptions no longer return historical logs. If you want them - use `getLogsAsync`
|
||||
@@ -191,27 +270,27 @@ CHANGELOG
|
||||
* Renamed `zeroEx.token.stopWatchingAllEventsAsync` to `zeroEx.token.unsubscribeAll`
|
||||
* Fixed the batch fills validation by emulating all balance & proxy allowance changes (#185)
|
||||
|
||||
## v0.20.0 - _October 5, 2017_
|
||||
## v0.20.0 - _October 4, 2017_
|
||||
|
||||
* Add `zeroEx.token.getLogsAsync` (#178)
|
||||
* Add `zeroEx.exchange.getLogsAsync` (#178)
|
||||
* Fixed fees validation when one of the tokens transferred is ZRX (#181)
|
||||
|
||||
## v0.19.0 - _September 29, 2017_
|
||||
## v0.19.0 - _September 28, 2017_
|
||||
|
||||
* Made order validation optional (#172)
|
||||
* Added Ropsten testnet support (#173)
|
||||
* Fixed a bug causing awaitTransactionMinedAsync to DDos backend nodes (#175)
|
||||
|
||||
## v0.18.0 - _September 26, 2017_
|
||||
## v0.18.0 - _September 25, 2017_
|
||||
|
||||
* Added `zeroEx.exchange.validateOrderFillableOrThrowAsync` to simplify orderbook pruning (#170)
|
||||
|
||||
## v0.17.0 - _September 26, 2017_
|
||||
## v0.17.0 - _September 25, 2017_
|
||||
|
||||
* Made `zeroEx.exchange.getZRXTokenAddressAsync` public (#171)
|
||||
|
||||
## v0.16.0 - _September 20, 2017_
|
||||
## v0.16.0 - _September 19, 2017_
|
||||
|
||||
* Added the ability to specify custom contract addresses to be used with 0x.js (#165)
|
||||
* ZeroExConfig.exchangeContractAddress
|
||||
@@ -219,48 +298,48 @@ CHANGELOG
|
||||
* ZeroExConfig.etherTokenContractAddress
|
||||
* Added `zeroEx.tokenRegistry.getContractAddressAsync` (#165)
|
||||
|
||||
## v0.15.0 - _September 8, 2017_
|
||||
## v0.15.0 - _September 7, 2017_
|
||||
|
||||
* Added the ability to specify a historical `blockNumber` at which to query the blockchain's state when calling a token or exchange method (#161)
|
||||
|
||||
## v0.14.2 - _September 7, 2017_
|
||||
## v0.14.2 - _September 6, 2017_
|
||||
|
||||
* Fixed an issue with bignumber.js types not found (#160)
|
||||
|
||||
## v0.14.1 - _September 7, 2017_
|
||||
## v0.14.1 - _September 6, 2017_
|
||||
|
||||
* Fixed an issue with Artifact type not found (#159)
|
||||
|
||||
## v0.14.0 - _September 6, 2017_
|
||||
## v0.14.0 - _September 5, 2017_
|
||||
|
||||
* Added `zeroEx.exchange.throwLogErrorsAsErrors` method to public interface (#157)
|
||||
* Fixed an issue with overlapping async intervals in `zeroEx.awaitTransactionMinedAsync` (#157)
|
||||
* Fixed an issue with log decoder returning `BigNumber`s as `strings` (#157)
|
||||
|
||||
## v0.13.0 - _September 6, 2017_
|
||||
## v0.13.0 - _September 5, 2017_
|
||||
|
||||
* Made all the functions submitting transactions to the network to immediately return transaction hash (#151)
|
||||
* Added `zeroEx.awaitTransactionMinedAsync` (#151)
|
||||
* Added `TransactionReceiptWithDecodedLogs`, `LogWithDecodedArgs`, `DecodedLogArgs` to public types (#151)
|
||||
* Added signature validation to `validateFillOrderThrowIfInvalidAsync` (#152)
|
||||
|
||||
## v0.12.1 - _September 2, 2017_
|
||||
## v0.12.1 - _September 1, 2017_
|
||||
|
||||
* Added the support for web3@1.x.x provider (#142)
|
||||
* Added the optional `zeroExConfig` parameter to the constructor of `ZeroEx` (#139)
|
||||
* Added the ability to specify `gasPrice` when instantiating `ZeroEx` (#139)
|
||||
|
||||
## v0.11.0 - _August 24, 2017_
|
||||
## v0.11.0 - _August 23, 2017_
|
||||
|
||||
* Added `zeroEx.token.setUnlimitedProxyAllowanceAsync` (#137)
|
||||
* Added `zeroEx.token.setUnlimitedAllowanceAsync` (#137)
|
||||
* Added `zeroEx.token.UNLIMITED_ALLOWANCE_IN_BASE_UNITS` (#137)
|
||||
|
||||
## v0.10.4 - _August 24, 2017_
|
||||
## v0.10.4 - _August 23, 2017_
|
||||
|
||||
* Fixed a bug where checksummed addresses were being pulled from artifacts and not lower-cased. (#135)
|
||||
|
||||
## v0.10.1 - _August 24, 2017_
|
||||
## v0.10.1 - _August 23, 2017_
|
||||
|
||||
* Added `zeroEx.exchange.validateFillOrderThrowIfInvalidAsync` (#128)
|
||||
* Added `zeroEx.exchange.validateFillOrKillOrderThrowIfInvalidAsync` (#128)
|
||||
@@ -275,20 +354,20 @@ CHANGELOG
|
||||
* Added clear error message when checksummed address is passed to a public method (#124)
|
||||
* Fixes the description of `shouldThrowOnInsufficientBalanceOrAllowance` in docs (#127)
|
||||
|
||||
## v0.9.3 - _August 22, 2017_
|
||||
## v0.9.3 - _August 21, 2017_
|
||||
|
||||
* Update contract artifacts to include latest Kovan and Mainnet deploys (#118)
|
||||
|
||||
## v0.9.2 - _August 21, 2017_
|
||||
## v0.9.2 - _August 20, 2017_
|
||||
|
||||
* *This version was unpublished because of a publishing issue.*
|
||||
* Update contract artifacts to include latest Kovan and Mainnet deploys (#118)
|
||||
|
||||
## v0.9.1 - _August 16, 2017_
|
||||
## v0.9.1 - _August 15, 2017_
|
||||
|
||||
* Fixed the bug causing `zeroEx.token.getBalanceAsync()` to fail if no addresses available (#120)
|
||||
|
||||
## v0.9.0 - _July 26, 2017_
|
||||
## v0.9.0 - _July 25, 2017_
|
||||
|
||||
* Migrated to the new version of smart contracts (#101)
|
||||
* Removed the ability to call methods on multiple authorized Exchange smart contracts (#106)
|
||||
@@ -299,7 +378,7 @@ CHANGELOG
|
||||
* Updated to typescript v2.4 (#104)
|
||||
* Fixed an issue with incorrect balance/allowance validation when ZRX is one of the tokens traded (#109)
|
||||
|
||||
## v0.8.0 - _July 4, 2017_
|
||||
## v0.8.0 - _July 3, 2017_
|
||||
|
||||
* Added the ability to call methods on different authorized versions of the Exchange smart contract (#82)
|
||||
* Updated contract artifacts to reflect latest changes to the smart contracts (0xproject/contracts#59)
|
||||
@@ -312,35 +391,35 @@ CHANGELOG
|
||||
* `zeroEx.tokenRegistry.invalidateContractInstance`
|
||||
* Fixed the bug where `zeroEx.setProviderAsync` didn't invalidate etherToken contract's instance
|
||||
|
||||
## v0.7.1 - _June 26, 2017_
|
||||
## v0.7.1 - _June 25, 2017_
|
||||
|
||||
* Added the ability to convert Ether to wrapped Ether tokens and back via `zeroEx.etherToken.depostAsync` and `zeroEx.etherToken.withdrawAsync` (#81)
|
||||
|
||||
## v0.7.0 - _June 22, 2017_
|
||||
## v0.7.0 - _June 21, 2017_
|
||||
|
||||
* Added Kovan smart contract artifacts (#78)
|
||||
* Started returning fillAmount from `fillOrderAsync` and `fillUpToAsync` (#72)
|
||||
* Started returning cancelledAmount from `cancelOrderAsync` (#72)
|
||||
* Renamed type `LogCancelArgs` to `LogCancelContractEventArgs` and `LogFillArgs` to `LogFillContractEventArgs`
|
||||
|
||||
## v0.6.2 - _June 21, 2017_
|
||||
## v0.6.2 - _June 20, 2017_
|
||||
|
||||
* Reduced bundle size
|
||||
* Improved documentation
|
||||
|
||||
## v0.6.1 - _June 19, 2017_
|
||||
## v0.6.1 - _June 18, 2017_
|
||||
|
||||
* Improved documentation
|
||||
|
||||
## v0.6.0 - _June 19, 2017_
|
||||
## v0.6.0 - _June 18, 2017_
|
||||
|
||||
* Made `ZeroEx` class accept `Web3Provider` instance instead of `Web3` instance
|
||||
* Added types for contract event arguments
|
||||
|
||||
## v0.5.2 - _June 15, 2017_
|
||||
## v0.5.2 - _June 14, 2017_
|
||||
|
||||
* Fixed the bug in `postpublish` script that caused that only unminified UMD bundle was uploaded to release page
|
||||
|
||||
## v0.5.1 - _June 15, 2017_
|
||||
## v0.5.1 - _June 14, 2017_
|
||||
|
||||
* Added `postpublish` script to publish to Github Releases with assets.
|
||||
|
||||
@@ -44,7 +44,7 @@ Download the UMD module from our [releases page](https://github.com/0xProject/0x
|
||||
|
||||
## Contributing
|
||||
|
||||
We strongly recommend that the community help us make improvements and determine the future direction of the protocol. To report bugs within this package, please create an issue in this repository.
|
||||
We strongly recommend that the community help us make improvements and determine the future direction of 0x protocol. To report bugs within this package, please create an issue in this repository.
|
||||
|
||||
Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started.
|
||||
|
||||
@@ -64,28 +64,16 @@ yarn install
|
||||
|
||||
### Build
|
||||
|
||||
If this is your **first** time building this package, you must first build **all** packages within the monorepo. This is because packages that depend on other packages located inside this monorepo are symlinked when run from **within** the monorepo. This allows you to make changes across multiple packages without first publishing dependent packages to NPM. To build all packages, run the following from the monorepo root directory:
|
||||
To build this package and all other monorepo packages that it depends on, run the following from the monorepo root directory:
|
||||
|
||||
```bash
|
||||
yarn lerna:rebuild
|
||||
PKG=0x.js yarn build
|
||||
```
|
||||
|
||||
Or continuously rebuild on change:
|
||||
|
||||
```bash
|
||||
yarn dev
|
||||
```
|
||||
|
||||
You can also build this specific package by running the following from within its directory:
|
||||
|
||||
```bash
|
||||
yarn build
|
||||
```
|
||||
|
||||
or continuously rebuild on change:
|
||||
|
||||
```bash
|
||||
yarn build:watch
|
||||
PKG=0x.js yarn watch
|
||||
```
|
||||
|
||||
### Clean
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
{
|
||||
"name": "0x.js",
|
||||
"version": "0.36.0",
|
||||
"version": "1.0.1-rc.1",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
"description": "A javascript library for interacting with the 0x protocol",
|
||||
"keywords": [
|
||||
"0x.js",
|
||||
@@ -12,29 +15,30 @@
|
||||
"main": "lib/src/index.js",
|
||||
"types": "lib/src/index.d.ts",
|
||||
"scripts": {
|
||||
"build:watch": "tsc -w",
|
||||
"prebuild": "run-s clean generate_contract_wrappers",
|
||||
"build": "run-p build:umd:prod build:commonjs; exit 0;",
|
||||
"generate_contract_wrappers": "node ../abi-gen/lib/index.js --abis 'src/compact_artifacts/@(Exchange|Token|TokenTransferProxy|EtherToken|TokenRegistry|DummyToken).json' --template ../contract_templates/contract.handlebars --partials '../contract_templates/partials/**/*.handlebars' --output src/contract_wrappers/generated --backend ethers && prettier --write 'src/contract_wrappers/generated/**.ts'",
|
||||
"lint": "tslint --project . 'src/**/*.ts' 'test/**/*.ts'",
|
||||
"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 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": "run-s clean test:commonjs",
|
||||
"test": "yarn run_mocha",
|
||||
"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": "for i in ${npm_package_config_contracts}; do copyfiles -u 4 ../migrations/src/artifacts/$i.json test/artifacts; done;",
|
||||
"clean": "shx rm -rf _bundles lib test_temp scripts",
|
||||
"clean": "shx rm -rf _bundles lib test_temp scripts src/generated_contract_wrappers",
|
||||
"build:umd:prod": "NODE_ENV=production webpack",
|
||||
"build:commonjs": "tsc && yarn update_artifacts && copyfiles -u 2 './src/compact_artifacts/**/*.json' ./lib/src/compact_artifacts && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts",
|
||||
"test:commonjs": "run-s build:commonjs run_mocha",
|
||||
"run_mocha": "mocha lib/test/**/*_test.js --timeout 10000 --bail --exit",
|
||||
"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": "yarn build && node ./scripts/stage_docs.js",
|
||||
"docs:stage": "node scripts/stage_docs.js",
|
||||
"docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --json $JSON_FILE_PATH $PROJECT_FILES",
|
||||
"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": "Exchange DummyToken ZRXToken Token WETH9 TokenTransferProxy MultiSigWallet MultiSigWalletWithTimeLock MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress MaliciousToken TokenRegistry Arbitrage EtherDelta AccountLevels",
|
||||
"contracts": "ZRXToken",
|
||||
"postpublish": {
|
||||
"assets": [
|
||||
"packages/0x.js/_bundles/index.js",
|
||||
@@ -43,9 +47,15 @@
|
||||
"docPublishConfigs": {
|
||||
"extraFileIncludes": [
|
||||
"../types/src/index.ts",
|
||||
"./src/contract_wrappers/generated/ether_token.ts",
|
||||
"./src/contract_wrappers/generated/token.ts",
|
||||
"./src/contract_wrappers/generated/exchange.ts"
|
||||
"../ethereum-types/src/index.ts",
|
||||
"../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/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/"
|
||||
@@ -57,22 +67,16 @@
|
||||
"url": "https://github.com/0xProject/0x-monorepo"
|
||||
},
|
||||
"license": "Apache-2.0",
|
||||
"engines": {
|
||||
"node": ">=6.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@0xproject/deployer": "^0.4.0",
|
||||
"@0xproject/dev-utils": "^0.3.5",
|
||||
"@0xproject/monorepo-scripts": "^0.1.17",
|
||||
"@0xproject/subproviders": "^0.8.4",
|
||||
"@0xproject/tslint-config": "^0.4.15",
|
||||
"@types/bintrees": "^1.0.2",
|
||||
"@0xproject/abi-gen": "^1.0.3",
|
||||
"@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",
|
||||
"@types/request": "2.47.0",
|
||||
"@types/sinon": "^2.2.2",
|
||||
"@types/uuid": "^3.4.2",
|
||||
"awesome-typescript-loader": "^3.1.3",
|
||||
"chai": "^4.0.1",
|
||||
"chai-as-promised": "^7.1.0",
|
||||
@@ -80,42 +84,33 @@
|
||||
"copyfiles": "^1.2.0",
|
||||
"dirty-chai": "^2.0.1",
|
||||
"json-loader": "^0.5.4",
|
||||
"make-promises-safe": "^1.1.0",
|
||||
"mocha": "^4.0.1",
|
||||
"npm-run-all": "^4.1.2",
|
||||
"nyc": "^11.0.1",
|
||||
"opn-cli": "^3.1.0",
|
||||
"prettier": "^1.11.1",
|
||||
"request": "^2.81.0",
|
||||
"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",
|
||||
"web3-provider-engine": "^13.0.1",
|
||||
"webpack": "^3.1.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0xproject/assert": "^0.2.6",
|
||||
"@0xproject/base-contract": "^0.2.0",
|
||||
"@0xproject/json-schemas": "^0.7.20",
|
||||
"@0xproject/types": "^0.6.0",
|
||||
"@0xproject/typescript-typings": "^0.1.0",
|
||||
"@0xproject/utils": "^0.5.1",
|
||||
"@0xproject/web3-wrapper": "^0.6.0",
|
||||
"bintrees": "^1.0.2",
|
||||
"bn.js": "^4.11.8",
|
||||
"ethereumjs-abi": "^0.6.4",
|
||||
"ethereumjs-blockstream": "^2.0.6",
|
||||
"ethereumjs-util": "^5.1.1",
|
||||
"ethers-contracts": "^2.2.1",
|
||||
"js-sha3": "^0.7.0",
|
||||
"lodash": "^4.17.4",
|
||||
"uuid": "^3.1.0",
|
||||
"web3": "^0.20.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@0xproject/migrations": "^0.0.1"
|
||||
"@0xproject/assert": "^1.0.3",
|
||||
"@0xproject/base-contract": "^1.0.3",
|
||||
"@0xproject/contract-wrappers": "^1.0.1-rc.2",
|
||||
"@0xproject/order-utils": "^1.0.1-rc.2",
|
||||
"@0xproject/sol-compiler": "^1.0.3",
|
||||
"@0xproject/subproviders": "^1.0.3",
|
||||
"@0xproject/types": "^1.0.1-rc.2",
|
||||
"@0xproject/typescript-typings": "^1.0.3",
|
||||
"@0xproject/utils": "^1.0.3",
|
||||
"@0xproject/web3-wrapper": "^1.1.1",
|
||||
"ethereum-types": "^1.0.3",
|
||||
"ethers": "3.0.22",
|
||||
"lodash": "^4.17.4"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
|
||||
@@ -1,26 +1,31 @@
|
||||
import { schemas, SchemaValidator } from '@0xproject/json-schemas';
|
||||
import { ECSignature, Order, Provider, SignedOrder, TransactionReceiptWithDecodedLogs } from '@0xproject/types';
|
||||
import { AbiDecoder, BigNumber, intervalUtils } from '@0xproject/utils';
|
||||
import { assert } from '@0xproject/assert';
|
||||
import {
|
||||
ContractWrappers,
|
||||
ContractWrappersConfig,
|
||||
ERC20ProxyWrapper,
|
||||
ERC20TokenWrapper,
|
||||
ERC721ProxyWrapper,
|
||||
ERC721TokenWrapper,
|
||||
EtherTokenWrapper,
|
||||
ExchangeWrapper,
|
||||
} from '@0xproject/contract-wrappers';
|
||||
import {
|
||||
assetDataUtils,
|
||||
ecSignOrderHashAsync,
|
||||
generatePseudoRandomSalt,
|
||||
isValidSignatureAsync,
|
||||
MessagePrefixOpts,
|
||||
orderHashUtils,
|
||||
} from '@0xproject/order-utils';
|
||||
// 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 * as ethUtil from 'ethereumjs-util';
|
||||
import * as _ from 'lodash';
|
||||
import { Provider, TransactionReceiptWithDecodedLogs } from 'ethereum-types';
|
||||
|
||||
import { artifacts } from './artifacts';
|
||||
import { EtherTokenWrapper } from './contract_wrappers/ether_token_wrapper';
|
||||
import { ExchangeWrapper } from './contract_wrappers/exchange_wrapper';
|
||||
import { TokenRegistryWrapper } from './contract_wrappers/token_registry_wrapper';
|
||||
import { TokenTransferProxyWrapper } from './contract_wrappers/token_transfer_proxy_wrapper';
|
||||
import { TokenWrapper } from './contract_wrappers/token_wrapper';
|
||||
import { OrderStateWatcher } from './order_watcher/order_state_watcher';
|
||||
import { zeroExConfigSchema } from './schemas/zero_ex_config_schema';
|
||||
import { zeroExPrivateNetworkConfigSchema } from './schemas/zero_ex_private_network_config_schema';
|
||||
import { zeroExPublicNetworkConfigSchema } from './schemas/zero_ex_public_network_config_schema';
|
||||
import { OrderStateWatcherConfig, ZeroExConfig, ZeroExError } from './types';
|
||||
import { assert } from './utils/assert';
|
||||
import { constants } from './utils/constants';
|
||||
import { decorators } from './utils/decorators';
|
||||
import { signatureUtils } from './utils/signature_utils';
|
||||
import { utils } from './utils/utils';
|
||||
|
||||
/**
|
||||
* The ZeroEx class is the single entry-point into the 0x.js library. It contains all of the library's functionality
|
||||
@@ -33,48 +38,34 @@ export class ZeroEx {
|
||||
* this constant for your convenience.
|
||||
*/
|
||||
public static NULL_ADDRESS = constants.NULL_ADDRESS;
|
||||
|
||||
/**
|
||||
* An instance of the ExchangeWrapper class containing methods for interacting with the 0x Exchange smart contract.
|
||||
*/
|
||||
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 _web3Wrapper: Web3Wrapper;
|
||||
public erc20Proxy: ERC20ProxyWrapper;
|
||||
/**
|
||||
* 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.
|
||||
* An instance of the ERC721ProxyWrapper class containing methods for interacting with the
|
||||
* ERC721 proxy smart contract.
|
||||
*/
|
||||
public static isValidSignature(data: string, signature: ECSignature, signerAddress: string): boolean {
|
||||
assert.isHexString('data', data);
|
||||
assert.doesConformToSchema('signature', signature, schemas.ecSignatureSchema);
|
||||
assert.isETHAddressHex('signerAddress', signerAddress);
|
||||
const normalizedSignerAddress = signerAddress.toLowerCase();
|
||||
|
||||
const isValidSignature = signatureUtils.isValidSignature(data, signature, normalizedSignerAddress);
|
||||
return isValidSignature;
|
||||
}
|
||||
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
|
||||
@@ -82,12 +73,15 @@ export class ZeroEx {
|
||||
* @return A pseudo-random 256-bit number that can be used as a salt.
|
||||
*/
|
||||
public static generatePseudoRandomSalt(): BigNumber {
|
||||
// BigNumber.random returns a pseudo-random number between 0 & 1 with a passed in number of decimal places.
|
||||
// Source: https://mikemcl.github.io/bignumber.js/#random
|
||||
const randomNumber = BigNumber.random(constants.MAX_DIGITS_IN_UNSIGNED_256_INT);
|
||||
const factor = new BigNumber(10).pow(constants.MAX_DIGITS_IN_UNSIGNED_256_INT - 1);
|
||||
const salt = randomNumber.times(factor).round();
|
||||
return salt;
|
||||
return generatePseudoRandomSalt();
|
||||
}
|
||||
/**
|
||||
* 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 orderHashUtils.getOrderHashHex(order);
|
||||
}
|
||||
/**
|
||||
* Checks if the supplied hex encoded order hash is valid.
|
||||
@@ -97,12 +91,7 @@ export class ZeroEx {
|
||||
* @return Whether the supplied orderHash has the expected format.
|
||||
*/
|
||||
public static isValidOrderHash(orderHash: string): boolean {
|
||||
// Since this method can be called to check if any arbitrary string conforms to an orderHash's
|
||||
// format, we only assert that we were indeed passed a string.
|
||||
assert.isString('orderHash', orderHash);
|
||||
const schemaValidator = new SchemaValidator();
|
||||
const isValidOrderHash = schemaValidator.validate(orderHash, schemas.orderHashSchema).valid;
|
||||
return isValidOrderHash;
|
||||
return orderHashUtils.isValidOrderHash(orderHash);
|
||||
}
|
||||
/**
|
||||
* A unit amount is defined as the amount of a token above the specified decimal places (integer part).
|
||||
@@ -133,15 +122,55 @@ export class ZeroEx {
|
||||
return baseUnitAmount;
|
||||
}
|
||||
/**
|
||||
* 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.
|
||||
* 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
|
||||
*/
|
||||
@decorators.syncZeroExErrorHandler
|
||||
public static getOrderHashHex(order: Order | SignedOrder): string {
|
||||
assert.doesConformToSchema('order', order, schemas.orderSchema);
|
||||
const orderHashHex = utils.getOrderHashHex(order);
|
||||
return orderHashHex;
|
||||
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.
|
||||
@@ -150,40 +179,32 @@ export class ZeroEx {
|
||||
* @param config The configuration object. Look up the type for the description.
|
||||
* @return An instance of the 0x.js ZeroEx class.
|
||||
*/
|
||||
constructor(provider: Provider, config: ZeroExConfig) {
|
||||
constructor(provider: Provider, config: ContractWrappersConfig) {
|
||||
assert.isWeb3Provider('provider', provider);
|
||||
assert.doesConformToSchema('config', config, zeroExConfigSchema, [
|
||||
zeroExPrivateNetworkConfigSchema,
|
||||
zeroExPublicNetworkConfigSchema,
|
||||
]);
|
||||
const artifactJSONs = _.values(artifacts);
|
||||
const abiArrays = _.map(artifactJSONs, artifact => artifact.abi);
|
||||
const defaults = {
|
||||
gasPrice: config.gasPrice,
|
||||
};
|
||||
this._web3Wrapper = new Web3Wrapper(provider, defaults);
|
||||
_.forEach(abiArrays, abi => {
|
||||
this._web3Wrapper.abiDecoder.addABI(abi);
|
||||
});
|
||||
this.proxy = new TokenTransferProxyWrapper(
|
||||
this._web3Wrapper,
|
||||
config.networkId,
|
||||
config.tokenTransferProxyContractAddress,
|
||||
this._contractWrappers = new ContractWrappers(provider, config);
|
||||
|
||||
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.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,
|
||||
);
|
||||
this.token = new TokenWrapper(this._web3Wrapper, config.networkId, this.proxy);
|
||||
this.exchange = new ExchangeWrapper(
|
||||
this._web3Wrapper,
|
||||
config.networkId,
|
||||
this.token,
|
||||
config.exchangeContractAddress,
|
||||
config.zrxContractAddress,
|
||||
);
|
||||
this.tokenRegistry = new TokenRegistryWrapper(
|
||||
this._web3Wrapper,
|
||||
config.networkId,
|
||||
config.tokenRegistryContractAddress,
|
||||
);
|
||||
this.etherToken = new EtherTokenWrapper(this._web3Wrapper, config.networkId, this.token);
|
||||
return isValid;
|
||||
}
|
||||
/**
|
||||
* Sets a new web3 provider for 0x.js. Updating the provider will stop all
|
||||
@@ -192,24 +213,23 @@ export class ZeroEx {
|
||||
* @param networkId The id of the network your provider is connected to
|
||||
*/
|
||||
public setProvider(provider: Provider, networkId: number): void {
|
||||
this._web3Wrapper.setProvider(provider);
|
||||
(this.exchange as any)._invalidateContractInstances();
|
||||
(this.exchange as any)._setNetworkId(networkId);
|
||||
(this.tokenRegistry as any)._invalidateContractInstance();
|
||||
(this.tokenRegistry as any)._setNetworkId(networkId);
|
||||
(this.token as any)._invalidateContractInstances();
|
||||
(this.token as any)._setNetworkId(networkId);
|
||||
(this.proxy as any)._invalidateContractInstance();
|
||||
(this.proxy as any)._setNetworkId(networkId);
|
||||
(this.etherToken as any)._invalidateContractInstance();
|
||||
(this.etherToken as any)._setNetworkId(networkId);
|
||||
this._contractWrappers.setProvider(provider, networkId);
|
||||
}
|
||||
/**
|
||||
* Get the provider instance currently used by 0x.js
|
||||
* @return Web3 provider instance
|
||||
*/
|
||||
public getProvider(): Provider {
|
||||
return this._contractWrappers.getProvider();
|
||||
}
|
||||
/**
|
||||
* Get user Ethereum addresses available through the supplied web3 provider available for sending transactions.
|
||||
* @return An array of available user Ethereum addresses.
|
||||
*/
|
||||
public async getAvailableAddressesAsync(): Promise<string[]> {
|
||||
const availableAddresses = await this._web3Wrapper.getAvailableAddressesAsync();
|
||||
// Hack: Get Web3Wrapper from ContractWrappers
|
||||
const web3Wrapper: Web3Wrapper = (this._contractWrappers as any)._web3Wrapper;
|
||||
const availableAddresses = await web3Wrapper.getAvailableAddressesAsync();
|
||||
return availableAddresses;
|
||||
}
|
||||
/**
|
||||
@@ -218,52 +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> {
|
||||
assert.isHexString('orderHash', orderHash);
|
||||
await assert.isSenderAddressAsync('signerAddress', signerAddress, this._web3Wrapper);
|
||||
const normalizedSignerAddress = signerAddress.toLowerCase();
|
||||
|
||||
let msgHashHex = orderHash;
|
||||
if (shouldAddPersonalMessagePrefix) {
|
||||
const orderHashBuff = ethUtil.toBuffer(orderHash);
|
||||
const msgHashBuff = ethUtil.hashPersonalMessage(orderHashBuff);
|
||||
msgHashHex = ethUtil.bufferToHex(msgHashBuff);
|
||||
}
|
||||
|
||||
const signature = await this._web3Wrapper.signMessageAsync(normalizedSignerAddress, msgHashHex);
|
||||
|
||||
// HACK: There is no consensus on whether the signatureHex string should be formatted as
|
||||
// v + r + s OR r + s + v, and different clients (even different versions of the same client)
|
||||
// return the signature params in different orders. In order to support all client implementations,
|
||||
// we parse the signature in both ways, and evaluate if either one is a valid signature.
|
||||
const validVParamValues = [27, 28];
|
||||
const ecSignatureVRS = signatureUtils.parseSignatureHexAsVRS(signature);
|
||||
if (_.includes(validVParamValues, ecSignatureVRS.v)) {
|
||||
const isValidVRSSignature = ZeroEx.isValidSignature(orderHash, ecSignatureVRS, normalizedSignerAddress);
|
||||
if (isValidVRSSignature) {
|
||||
return ecSignatureVRS;
|
||||
}
|
||||
}
|
||||
|
||||
const ecSignatureRSV = signatureUtils.parseSignatureHexAsRSV(signature);
|
||||
if (_.includes(validVParamValues, ecSignatureRSV.v)) {
|
||||
const isValidRSVSignature = ZeroEx.isValidSignature(orderHash, ecSignatureRSV, normalizedSignerAddress);
|
||||
if (isValidRSVSignature) {
|
||||
return ecSignatureRSV;
|
||||
}
|
||||
}
|
||||
|
||||
throw new Error(ZeroExError.InvalidSignature);
|
||||
const signature = await ecSignOrderHashAsync(
|
||||
this._contractWrappers.getProvider(),
|
||||
orderHash,
|
||||
signerAddress,
|
||||
messagePrefixOpts,
|
||||
);
|
||||
return signature;
|
||||
}
|
||||
/**
|
||||
* Waits for a transaction to be mined and returns the transaction receipt.
|
||||
@@ -274,33 +263,16 @@ export class ZeroEx {
|
||||
*/
|
||||
public async awaitTransactionMinedAsync(
|
||||
txHash: string,
|
||||
pollingIntervalMs = 1000,
|
||||
pollingIntervalMs: number = 1000,
|
||||
timeoutMs?: number,
|
||||
): Promise<TransactionReceiptWithDecodedLogs> {
|
||||
const transactionReceiptWithDecodedLogs = await this._web3Wrapper.awaitTransactionMinedAsync(
|
||||
// Hack: Get Web3Wrapper from ContractWrappers
|
||||
const web3Wrapper: Web3Wrapper = (this._contractWrappers as any)._web3Wrapper;
|
||||
const transactionReceiptWithDecodedLogs = await web3Wrapper.awaitTransactionMinedAsync(
|
||||
txHash,
|
||||
pollingIntervalMs,
|
||||
timeoutMs,
|
||||
);
|
||||
return transactionReceiptWithDecodedLogs;
|
||||
}
|
||||
/**
|
||||
* Instantiates and returns a new OrderStateWatcher 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 OrderStateWatcher class.
|
||||
*/
|
||||
public createOrderStateWatcher(config?: OrderStateWatcherConfig) {
|
||||
return new OrderStateWatcher(this._web3Wrapper, this.token, this.exchange, config);
|
||||
}
|
||||
/*
|
||||
* HACK: `TokenWrapper` needs a token transfer proxy address. `TokenTransferProxy` address is fetched from
|
||||
* an `ExchangeWrapper`. `ExchangeWrapper` needs `TokenWrapper` to validate orders, creating a dependency cycle.
|
||||
* In order to break this - we create this function here and pass it as a parameter to the `TokenWrapper`
|
||||
* and `ProxyWrapper`.
|
||||
*/
|
||||
private async _getTokenTransferProxyAddressAsync(): Promise<string> {
|
||||
const tokenTransferProxyAddress = await (this.exchange as any)._getTokenTransferProxyAddressAsync();
|
||||
return tokenTransferProxyAddress;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
import { BigNumber } from '@0xproject/utils';
|
||||
|
||||
export abstract class BalanceAndProxyAllowanceFetcher {
|
||||
public abstract async getBalanceAsync(tokenAddress: string, userAddress: string): Promise<BigNumber>;
|
||||
public abstract async getProxyAllowanceAsync(tokenAddress: string, userAddress: string): Promise<BigNumber>;
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
import { BigNumber } from '@0xproject/utils';
|
||||
|
||||
export abstract class OrderFilledCancelledFetcher {
|
||||
public abstract async getFilledTakerAmountAsync(orderHash: string): Promise<BigNumber>;
|
||||
public abstract async getCancelledTakerAmountAsync(orderHash: string): Promise<BigNumber>;
|
||||
}
|
||||
@@ -1,18 +1,7 @@
|
||||
import * as DummyTokenArtifact from './compact_artifacts/DummyToken.json';
|
||||
import * as EtherTokenArtifact from './compact_artifacts/EtherToken.json';
|
||||
import * as ExchangeArtifact from './compact_artifacts/Exchange.json';
|
||||
import * as TokenArtifact from './compact_artifacts/Token.json';
|
||||
import * as TokenRegistryArtifact from './compact_artifacts/TokenRegistry.json';
|
||||
import * as TokenTransferProxyArtifact from './compact_artifacts/TokenTransferProxy.json';
|
||||
import * as ZRXArtifact from './compact_artifacts/ZRX.json';
|
||||
import { Artifact } from './types';
|
||||
import { ContractArtifact } from '@0xproject/sol-compiler';
|
||||
|
||||
import * as ZRXToken from './artifacts/ZRXToken.json';
|
||||
|
||||
export const artifacts = {
|
||||
ZRXArtifact: (ZRXArtifact as any) as Artifact,
|
||||
DummyTokenArtifact: (DummyTokenArtifact as any) as Artifact,
|
||||
TokenArtifact: (TokenArtifact as any) as Artifact,
|
||||
ExchangeArtifact: (ExchangeArtifact as any) as Artifact,
|
||||
EtherTokenArtifact: (EtherTokenArtifact as any) as Artifact,
|
||||
TokenRegistryArtifact: (TokenRegistryArtifact as any) as Artifact,
|
||||
TokenTransferProxyArtifact: (TokenTransferProxyArtifact as any) as Artifact,
|
||||
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,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,963 +0,0 @@
|
||||
import { schemas } from '@0xproject/json-schemas';
|
||||
import {
|
||||
BlockParamLiteral,
|
||||
DecodedLogArgs,
|
||||
ECSignature,
|
||||
LogEntry,
|
||||
LogWithDecodedArgs,
|
||||
Order,
|
||||
SignedOrder,
|
||||
} from '@0xproject/types';
|
||||
import { AbiDecoder, BigNumber } from '@0xproject/utils';
|
||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { artifacts } from '../artifacts';
|
||||
import { SimpleBalanceAndProxyAllowanceFetcher } from '../fetchers/simple_balance_and_proxy_allowance_fetcher';
|
||||
import { SimpleOrderFilledCancelledFetcher } from '../fetchers/simple_order_filled_cancelled_fetcher';
|
||||
import {
|
||||
BlockRange,
|
||||
EventCallback,
|
||||
ExchangeContractErrCodes,
|
||||
ExchangeContractErrs,
|
||||
IndexedFilterValues,
|
||||
MethodOpts,
|
||||
OrderAddresses,
|
||||
OrderCancellationRequest,
|
||||
OrderFillRequest,
|
||||
OrderState,
|
||||
OrderTransactionOpts,
|
||||
OrderValues,
|
||||
ValidateOrderFillableOpts,
|
||||
} from '../types';
|
||||
import { assert } from '../utils/assert';
|
||||
import { decorators } from '../utils/decorators';
|
||||
import { ExchangeTransferSimulator } from '../utils/exchange_transfer_simulator';
|
||||
import { OrderStateUtils } from '../utils/order_state_utils';
|
||||
import { OrderValidationUtils } from '../utils/order_validation_utils';
|
||||
import { utils } from '../utils/utils';
|
||||
|
||||
import { ContractWrapper } from './contract_wrapper';
|
||||
import {
|
||||
ExchangeContract,
|
||||
ExchangeContractEventArgs,
|
||||
ExchangeEvents,
|
||||
LogErrorContractEventArgs,
|
||||
} from './generated/exchange';
|
||||
import { TokenWrapper } from './token_wrapper';
|
||||
const SHOULD_VALIDATE_BY_DEFAULT = true;
|
||||
|
||||
interface ExchangeContractErrCodesToMsgs {
|
||||
[exchangeContractErrCodes: number]: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* This class includes all the functionality related to calling methods and subscribing to
|
||||
* events of the 0x Exchange smart contract.
|
||||
*/
|
||||
export class ExchangeWrapper extends ContractWrapper {
|
||||
private _exchangeContractIfExists?: ExchangeContract;
|
||||
private _orderValidationUtils: OrderValidationUtils;
|
||||
private _tokenWrapper: TokenWrapper;
|
||||
private _exchangeContractErrCodesToMsg: ExchangeContractErrCodesToMsgs = {
|
||||
[ExchangeContractErrCodes.ERROR_FILL_EXPIRED]: ExchangeContractErrs.OrderFillExpired,
|
||||
[ExchangeContractErrCodes.ERROR_CANCEL_EXPIRED]: ExchangeContractErrs.OrderFillExpired,
|
||||
[ExchangeContractErrCodes.ERROR_FILL_NO_VALUE]: ExchangeContractErrs.OrderRemainingFillAmountZero,
|
||||
[ExchangeContractErrCodes.ERROR_CANCEL_NO_VALUE]: ExchangeContractErrs.OrderRemainingFillAmountZero,
|
||||
[ExchangeContractErrCodes.ERROR_FILL_TRUNCATION]: ExchangeContractErrs.OrderFillRoundingError,
|
||||
[ExchangeContractErrCodes.ERROR_FILL_BALANCE_ALLOWANCE]: ExchangeContractErrs.FillBalanceAllowanceError,
|
||||
};
|
||||
private _contractAddressIfExists?: string;
|
||||
private _zrxContractAddressIfExists?: string;
|
||||
private static _getOrderAddressesAndValues(order: Order): [OrderAddresses, OrderValues] {
|
||||
const orderAddresses: OrderAddresses = [
|
||||
order.maker,
|
||||
order.taker,
|
||||
order.makerTokenAddress,
|
||||
order.takerTokenAddress,
|
||||
order.feeRecipient,
|
||||
];
|
||||
const orderValues: OrderValues = [
|
||||
order.makerTokenAmount,
|
||||
order.takerTokenAmount,
|
||||
order.makerFee,
|
||||
order.takerFee,
|
||||
order.expirationUnixTimestampSec,
|
||||
order.salt,
|
||||
];
|
||||
return [orderAddresses, orderValues];
|
||||
}
|
||||
constructor(
|
||||
web3Wrapper: Web3Wrapper,
|
||||
networkId: number,
|
||||
tokenWrapper: TokenWrapper,
|
||||
contractAddressIfExists?: string,
|
||||
zrxContractAddressIfExists?: string,
|
||||
) {
|
||||
super(web3Wrapper, networkId);
|
||||
this._tokenWrapper = tokenWrapper;
|
||||
this._orderValidationUtils = new OrderValidationUtils(this);
|
||||
this._contractAddressIfExists = contractAddressIfExists;
|
||||
this._zrxContractAddressIfExists = zrxContractAddressIfExists;
|
||||
}
|
||||
/**
|
||||
* Returns the unavailable takerAmount of an order. Unavailable amount is defined as the total
|
||||
* amount that has been filled or cancelled. The remaining takerAmount can be calculated by
|
||||
* subtracting the unavailable amount from the total order takerAmount.
|
||||
* @param orderHash The hex encoded orderHash for which you would like to retrieve the
|
||||
* unavailable takerAmount.
|
||||
* @param methodOpts Optional arguments this method accepts.
|
||||
* @return The amount of the order (in taker tokens) that has either been filled or cancelled.
|
||||
*/
|
||||
public async getUnavailableTakerAmountAsync(orderHash: string, methodOpts?: MethodOpts): Promise<BigNumber> {
|
||||
assert.doesConformToSchema('orderHash', orderHash, schemas.orderHashSchema);
|
||||
|
||||
const exchangeContract = await this._getExchangeContractAsync();
|
||||
const defaultBlock = _.isUndefined(methodOpts) ? undefined : methodOpts.defaultBlock;
|
||||
const txData = {};
|
||||
let unavailableTakerTokenAmount = await exchangeContract.getUnavailableTakerTokenAmount.callAsync(
|
||||
orderHash,
|
||||
txData,
|
||||
defaultBlock,
|
||||
);
|
||||
// Wrap BigNumbers returned from web3 with our own (later) version of BigNumber
|
||||
unavailableTakerTokenAmount = new BigNumber(unavailableTakerTokenAmount);
|
||||
return unavailableTakerTokenAmount;
|
||||
}
|
||||
/**
|
||||
* Retrieve the takerAmount of an order that has already been filled.
|
||||
* @param orderHash The hex encoded orderHash for which you would like to retrieve the filled takerAmount.
|
||||
* @param methodOpts Optional arguments this method accepts.
|
||||
* @return The amount of the order (in taker tokens) that has already been filled.
|
||||
*/
|
||||
public async getFilledTakerAmountAsync(orderHash: string, methodOpts?: MethodOpts): Promise<BigNumber> {
|
||||
assert.doesConformToSchema('orderHash', orderHash, schemas.orderHashSchema);
|
||||
|
||||
const exchangeContract = await this._getExchangeContractAsync();
|
||||
const defaultBlock = _.isUndefined(methodOpts) ? undefined : methodOpts.defaultBlock;
|
||||
const txData = {};
|
||||
let fillAmountInBaseUnits = await exchangeContract.filled.callAsync(orderHash, txData, defaultBlock);
|
||||
// Wrap BigNumbers returned from web3 with our own (later) version of BigNumber
|
||||
fillAmountInBaseUnits = new BigNumber(fillAmountInBaseUnits);
|
||||
return fillAmountInBaseUnits;
|
||||
}
|
||||
/**
|
||||
* Retrieve the takerAmount of an order that has been cancelled.
|
||||
* @param orderHash The hex encoded orderHash for which you would like to retrieve the
|
||||
* cancelled takerAmount.
|
||||
* @param methodOpts Optional arguments this method accepts.
|
||||
* @return The amount of the order (in taker tokens) that has been cancelled.
|
||||
*/
|
||||
public async getCancelledTakerAmountAsync(orderHash: string, methodOpts?: MethodOpts): Promise<BigNumber> {
|
||||
assert.doesConformToSchema('orderHash', orderHash, schemas.orderHashSchema);
|
||||
|
||||
const exchangeContract = await this._getExchangeContractAsync();
|
||||
const defaultBlock = _.isUndefined(methodOpts) ? undefined : methodOpts.defaultBlock;
|
||||
const txData = {};
|
||||
let cancelledAmountInBaseUnits = await exchangeContract.cancelled.callAsync(orderHash, txData, defaultBlock);
|
||||
// Wrap BigNumbers returned from web3 with our own (later) version of BigNumber
|
||||
cancelledAmountInBaseUnits = new BigNumber(cancelledAmountInBaseUnits);
|
||||
return cancelledAmountInBaseUnits;
|
||||
}
|
||||
/**
|
||||
* Fills a signed order with an amount denominated in baseUnits of the taker token.
|
||||
* Since the order in which transactions are included in the next block is indeterminate, race-conditions
|
||||
* could arise where a users balance or allowance changes before the fillOrder executes. Because of this,
|
||||
* we allow you to specify `shouldThrowOnInsufficientBalanceOrAllowance`.
|
||||
* If false, the smart contract will not throw if the parties
|
||||
* do not have sufficient balances/allowances, preserving gas costs. Setting it to true forgoes this check
|
||||
* and causes the smart contract to throw (using all the gas supplied) instead.
|
||||
* @param signedOrder An object that conforms to the SignedOrder interface.
|
||||
* @param fillTakerTokenAmount The amount of the order (in taker tokens baseUnits) that
|
||||
* you wish to fill.
|
||||
* @param shouldThrowOnInsufficientBalanceOrAllowance Whether or not you wish for the contract call to throw
|
||||
* if upon execution the tokens cannot be transferred.
|
||||
* @param takerAddress The user Ethereum address who would like to fill this order.
|
||||
* Must be available via the supplied Provider
|
||||
* passed to 0x.js.
|
||||
* @param orderTransactionOpts Optional arguments this method accepts.
|
||||
* @return Transaction hash.
|
||||
*/
|
||||
@decorators.asyncZeroExErrorHandler
|
||||
public async fillOrderAsync(
|
||||
signedOrder: SignedOrder,
|
||||
fillTakerTokenAmount: BigNumber,
|
||||
shouldThrowOnInsufficientBalanceOrAllowance: boolean,
|
||||
takerAddress: string,
|
||||
orderTransactionOpts: OrderTransactionOpts = {},
|
||||
): Promise<string> {
|
||||
assert.doesConformToSchema('signedOrder', signedOrder, schemas.signedOrderSchema);
|
||||
assert.isValidBaseUnitAmount('fillTakerTokenAmount', fillTakerTokenAmount);
|
||||
assert.isBoolean('shouldThrowOnInsufficientBalanceOrAllowance', shouldThrowOnInsufficientBalanceOrAllowance);
|
||||
await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper);
|
||||
const normalizedTakerAddress = takerAddress.toLowerCase();
|
||||
|
||||
const exchangeInstance = await this._getExchangeContractAsync();
|
||||
const shouldValidate = _.isUndefined(orderTransactionOpts.shouldValidate)
|
||||
? SHOULD_VALIDATE_BY_DEFAULT
|
||||
: orderTransactionOpts.shouldValidate;
|
||||
if (shouldValidate) {
|
||||
const zrxTokenAddress = this.getZRXTokenAddress();
|
||||
const exchangeTradeEmulator = new ExchangeTransferSimulator(this._tokenWrapper, BlockParamLiteral.Latest);
|
||||
await this._orderValidationUtils.validateFillOrderThrowIfInvalidAsync(
|
||||
exchangeTradeEmulator,
|
||||
signedOrder,
|
||||
fillTakerTokenAmount,
|
||||
normalizedTakerAddress,
|
||||
zrxTokenAddress,
|
||||
);
|
||||
}
|
||||
|
||||
const [orderAddresses, orderValues] = ExchangeWrapper._getOrderAddressesAndValues(signedOrder);
|
||||
|
||||
const txHash: string = await exchangeInstance.fillOrder.sendTransactionAsync(
|
||||
orderAddresses,
|
||||
orderValues,
|
||||
fillTakerTokenAmount,
|
||||
shouldThrowOnInsufficientBalanceOrAllowance,
|
||||
signedOrder.ecSignature.v,
|
||||
signedOrder.ecSignature.r,
|
||||
signedOrder.ecSignature.s,
|
||||
{
|
||||
from: normalizedTakerAddress,
|
||||
gas: orderTransactionOpts.gasLimit,
|
||||
gasPrice: orderTransactionOpts.gasPrice,
|
||||
},
|
||||
);
|
||||
return txHash;
|
||||
}
|
||||
/**
|
||||
* Sequentially and atomically fills signedOrders up to the specified takerTokenFillAmount.
|
||||
* If the fill amount is reached - it succeeds and does not fill the rest of the orders.
|
||||
* If fill amount is not reached - it fills as much of the fill amount as possible and succeeds.
|
||||
* @param signedOrders The array of signedOrders that you would like to fill until
|
||||
* takerTokenFillAmount is reached.
|
||||
* @param fillTakerTokenAmount The total amount of the takerTokens you would like to fill.
|
||||
* @param shouldThrowOnInsufficientBalanceOrAllowance Whether or not you wish for the contract call to throw if
|
||||
* upon execution any of the tokens cannot be transferred.
|
||||
* If set to false, the call will continue to fill subsequent
|
||||
* signedOrders even when some cannot be filled.
|
||||
* @param takerAddress The user Ethereum address who would like to fill these
|
||||
* orders. Must be available via the supplied Provider
|
||||
* passed to 0x.js.
|
||||
* @param orderTransactionOpts Optional arguments this method accepts.
|
||||
* @return Transaction hash.
|
||||
*/
|
||||
@decorators.asyncZeroExErrorHandler
|
||||
public async fillOrdersUpToAsync(
|
||||
signedOrders: SignedOrder[],
|
||||
fillTakerTokenAmount: BigNumber,
|
||||
shouldThrowOnInsufficientBalanceOrAllowance: boolean,
|
||||
takerAddress: string,
|
||||
orderTransactionOpts: OrderTransactionOpts = {},
|
||||
): Promise<string> {
|
||||
assert.doesConformToSchema('signedOrders', signedOrders, schemas.signedOrdersSchema);
|
||||
const takerTokenAddresses = _.map(signedOrders, signedOrder => signedOrder.takerTokenAddress);
|
||||
assert.hasAtMostOneUniqueValue(
|
||||
takerTokenAddresses,
|
||||
ExchangeContractErrs.MultipleTakerTokensInFillUpToDisallowed,
|
||||
);
|
||||
const exchangeContractAddresses = _.map(signedOrders, signedOrder => signedOrder.exchangeContractAddress);
|
||||
assert.hasAtMostOneUniqueValue(
|
||||
exchangeContractAddresses,
|
||||
ExchangeContractErrs.BatchOrdersMustHaveSameExchangeAddress,
|
||||
);
|
||||
assert.isValidBaseUnitAmount('fillTakerTokenAmount', fillTakerTokenAmount);
|
||||
assert.isBoolean('shouldThrowOnInsufficientBalanceOrAllowance', shouldThrowOnInsufficientBalanceOrAllowance);
|
||||
await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper);
|
||||
const normalizedTakerAddress = takerAddress.toLowerCase();
|
||||
|
||||
const shouldValidate = _.isUndefined(orderTransactionOpts.shouldValidate)
|
||||
? SHOULD_VALIDATE_BY_DEFAULT
|
||||
: orderTransactionOpts.shouldValidate;
|
||||
if (shouldValidate) {
|
||||
let filledTakerTokenAmount = new BigNumber(0);
|
||||
const zrxTokenAddress = this.getZRXTokenAddress();
|
||||
const exchangeTradeEmulator = new ExchangeTransferSimulator(this._tokenWrapper, BlockParamLiteral.Latest);
|
||||
for (const signedOrder of signedOrders) {
|
||||
const singleFilledTakerTokenAmount = await this._orderValidationUtils.validateFillOrderThrowIfInvalidAsync(
|
||||
exchangeTradeEmulator,
|
||||
signedOrder,
|
||||
fillTakerTokenAmount.minus(filledTakerTokenAmount),
|
||||
normalizedTakerAddress,
|
||||
zrxTokenAddress,
|
||||
);
|
||||
filledTakerTokenAmount = filledTakerTokenAmount.plus(singleFilledTakerTokenAmount);
|
||||
if (filledTakerTokenAmount.eq(fillTakerTokenAmount)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (_.isEmpty(signedOrders)) {
|
||||
throw new Error(ExchangeContractErrs.BatchOrdersMustHaveAtLeastOneItem);
|
||||
}
|
||||
|
||||
const orderAddressesValuesAndSignatureArray = _.map(signedOrders, signedOrder => {
|
||||
return [
|
||||
...ExchangeWrapper._getOrderAddressesAndValues(signedOrder),
|
||||
signedOrder.ecSignature.v,
|
||||
signedOrder.ecSignature.r,
|
||||
signedOrder.ecSignature.s,
|
||||
];
|
||||
});
|
||||
// We use _.unzip<any> because _.unzip doesn't type check if values have different types :'(
|
||||
const [orderAddressesArray, orderValuesArray, vArray, rArray, sArray] = _.unzip<any>(
|
||||
orderAddressesValuesAndSignatureArray,
|
||||
);
|
||||
|
||||
const exchangeInstance = await this._getExchangeContractAsync();
|
||||
const txHash = await exchangeInstance.fillOrdersUpTo.sendTransactionAsync(
|
||||
orderAddressesArray,
|
||||
orderValuesArray,
|
||||
fillTakerTokenAmount,
|
||||
shouldThrowOnInsufficientBalanceOrAllowance,
|
||||
vArray,
|
||||
rArray,
|
||||
sArray,
|
||||
{
|
||||
from: normalizedTakerAddress,
|
||||
gas: orderTransactionOpts.gasLimit,
|
||||
gasPrice: orderTransactionOpts.gasPrice,
|
||||
},
|
||||
);
|
||||
return txHash;
|
||||
}
|
||||
/**
|
||||
* Batch version of fillOrderAsync.
|
||||
* Executes multiple fills atomically in a single transaction.
|
||||
* If shouldThrowOnInsufficientBalanceOrAllowance is set to false, it will continue filling subsequent orders even
|
||||
* when earlier ones fail.
|
||||
* When shouldThrowOnInsufficientBalanceOrAllowance is set to true, if any fill fails, the entire batch fails.
|
||||
* @param orderFillRequests An array of objects that conform to the
|
||||
* OrderFillRequest interface.
|
||||
* @param shouldThrowOnInsufficientBalanceOrAllowance Whether or not you wish for the contract call to throw
|
||||
* if upon execution any of the tokens cannot be
|
||||
* transferred. If set to false, the call will continue to
|
||||
* fill subsequent signedOrders even when some
|
||||
* cannot be filled.
|
||||
* @param takerAddress The user Ethereum address who would like to fill
|
||||
* these orders. Must be available via the supplied
|
||||
* Provider passed to 0x.js.
|
||||
* @param orderTransactionOpts Optional arguments this method accepts.
|
||||
* @return Transaction hash.
|
||||
*/
|
||||
@decorators.asyncZeroExErrorHandler
|
||||
public async batchFillOrdersAsync(
|
||||
orderFillRequests: OrderFillRequest[],
|
||||
shouldThrowOnInsufficientBalanceOrAllowance: boolean,
|
||||
takerAddress: string,
|
||||
orderTransactionOpts: OrderTransactionOpts = {},
|
||||
): Promise<string> {
|
||||
assert.doesConformToSchema('orderFillRequests', orderFillRequests, schemas.orderFillRequestsSchema);
|
||||
const exchangeContractAddresses = _.map(
|
||||
orderFillRequests,
|
||||
orderFillRequest => orderFillRequest.signedOrder.exchangeContractAddress,
|
||||
);
|
||||
assert.hasAtMostOneUniqueValue(
|
||||
exchangeContractAddresses,
|
||||
ExchangeContractErrs.BatchOrdersMustHaveSameExchangeAddress,
|
||||
);
|
||||
assert.isBoolean('shouldThrowOnInsufficientBalanceOrAllowance', shouldThrowOnInsufficientBalanceOrAllowance);
|
||||
await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper);
|
||||
const normalizedTakerAddress = takerAddress.toLowerCase();
|
||||
const shouldValidate = _.isUndefined(orderTransactionOpts.shouldValidate)
|
||||
? SHOULD_VALIDATE_BY_DEFAULT
|
||||
: orderTransactionOpts.shouldValidate;
|
||||
if (shouldValidate) {
|
||||
const zrxTokenAddress = this.getZRXTokenAddress();
|
||||
const exchangeTradeEmulator = new ExchangeTransferSimulator(this._tokenWrapper, BlockParamLiteral.Latest);
|
||||
for (const orderFillRequest of orderFillRequests) {
|
||||
await this._orderValidationUtils.validateFillOrderThrowIfInvalidAsync(
|
||||
exchangeTradeEmulator,
|
||||
orderFillRequest.signedOrder,
|
||||
orderFillRequest.takerTokenFillAmount,
|
||||
normalizedTakerAddress,
|
||||
zrxTokenAddress,
|
||||
);
|
||||
}
|
||||
}
|
||||
if (_.isEmpty(orderFillRequests)) {
|
||||
throw new Error(ExchangeContractErrs.BatchOrdersMustHaveAtLeastOneItem);
|
||||
}
|
||||
|
||||
const orderAddressesValuesAmountsAndSignatureArray = _.map(orderFillRequests, orderFillRequest => {
|
||||
return [
|
||||
...ExchangeWrapper._getOrderAddressesAndValues(orderFillRequest.signedOrder),
|
||||
orderFillRequest.takerTokenFillAmount,
|
||||
orderFillRequest.signedOrder.ecSignature.v,
|
||||
orderFillRequest.signedOrder.ecSignature.r,
|
||||
orderFillRequest.signedOrder.ecSignature.s,
|
||||
];
|
||||
});
|
||||
// We use _.unzip<any> because _.unzip doesn't type check if values have different types :'(
|
||||
const [orderAddressesArray, orderValuesArray, fillTakerTokenAmounts, vArray, rArray, sArray] = _.unzip<any>(
|
||||
orderAddressesValuesAmountsAndSignatureArray,
|
||||
);
|
||||
|
||||
const exchangeInstance = await this._getExchangeContractAsync();
|
||||
const txHash = await exchangeInstance.batchFillOrders.sendTransactionAsync(
|
||||
orderAddressesArray,
|
||||
orderValuesArray,
|
||||
fillTakerTokenAmounts,
|
||||
shouldThrowOnInsufficientBalanceOrAllowance,
|
||||
vArray,
|
||||
rArray,
|
||||
sArray,
|
||||
{
|
||||
from: normalizedTakerAddress,
|
||||
gas: orderTransactionOpts.gasLimit,
|
||||
gasPrice: orderTransactionOpts.gasPrice,
|
||||
},
|
||||
);
|
||||
return txHash;
|
||||
}
|
||||
/**
|
||||
* Attempts to fill a specific amount of an order. If the entire amount specified cannot be filled,
|
||||
* the fill order is abandoned.
|
||||
* @param signedOrder An object that conforms to the SignedOrder interface. The
|
||||
* signedOrder you wish to fill.
|
||||
* @param fillTakerTokenAmount The total amount of the takerTokens you would like to fill.
|
||||
* @param takerAddress The user Ethereum address who would like to fill this order.
|
||||
* Must be available via the supplied Provider passed to 0x.js.
|
||||
* @param orderTransactionOpts Optional arguments this method accepts.
|
||||
* @return Transaction hash.
|
||||
*/
|
||||
@decorators.asyncZeroExErrorHandler
|
||||
public async fillOrKillOrderAsync(
|
||||
signedOrder: SignedOrder,
|
||||
fillTakerTokenAmount: BigNumber,
|
||||
takerAddress: string,
|
||||
orderTransactionOpts: OrderTransactionOpts = {},
|
||||
): Promise<string> {
|
||||
assert.doesConformToSchema('signedOrder', signedOrder, schemas.signedOrderSchema);
|
||||
assert.isValidBaseUnitAmount('fillTakerTokenAmount', fillTakerTokenAmount);
|
||||
await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper);
|
||||
const normalizedTakerAddress = takerAddress.toLowerCase();
|
||||
|
||||
const exchangeInstance = await this._getExchangeContractAsync();
|
||||
|
||||
const shouldValidate = _.isUndefined(orderTransactionOpts.shouldValidate)
|
||||
? SHOULD_VALIDATE_BY_DEFAULT
|
||||
: orderTransactionOpts.shouldValidate;
|
||||
if (shouldValidate) {
|
||||
const zrxTokenAddress = this.getZRXTokenAddress();
|
||||
const exchangeTradeEmulator = new ExchangeTransferSimulator(this._tokenWrapper, BlockParamLiteral.Latest);
|
||||
await this._orderValidationUtils.validateFillOrKillOrderThrowIfInvalidAsync(
|
||||
exchangeTradeEmulator,
|
||||
signedOrder,
|
||||
fillTakerTokenAmount,
|
||||
normalizedTakerAddress,
|
||||
zrxTokenAddress,
|
||||
);
|
||||
}
|
||||
|
||||
const [orderAddresses, orderValues] = ExchangeWrapper._getOrderAddressesAndValues(signedOrder);
|
||||
const txHash = await exchangeInstance.fillOrKillOrder.sendTransactionAsync(
|
||||
orderAddresses,
|
||||
orderValues,
|
||||
fillTakerTokenAmount,
|
||||
signedOrder.ecSignature.v,
|
||||
signedOrder.ecSignature.r,
|
||||
signedOrder.ecSignature.s,
|
||||
{
|
||||
from: normalizedTakerAddress,
|
||||
gas: orderTransactionOpts.gasLimit,
|
||||
gasPrice: orderTransactionOpts.gasPrice,
|
||||
},
|
||||
);
|
||||
return txHash;
|
||||
}
|
||||
/**
|
||||
* Batch version of fillOrKill. Allows a taker to specify a batch of orders that will either be atomically
|
||||
* filled (each to the specified fillAmount) or aborted.
|
||||
* @param orderFillRequests An array of objects that conform to the OrderFillRequest interface.
|
||||
* @param takerAddress The user Ethereum address who would like to fill there orders.
|
||||
* Must be available via the supplied Provider passed to 0x.js.
|
||||
* @param orderTransactionOpts Optional arguments this method accepts.
|
||||
* @return Transaction hash.
|
||||
*/
|
||||
@decorators.asyncZeroExErrorHandler
|
||||
public async batchFillOrKillAsync(
|
||||
orderFillRequests: OrderFillRequest[],
|
||||
takerAddress: string,
|
||||
orderTransactionOpts: OrderTransactionOpts = {},
|
||||
): Promise<string> {
|
||||
assert.doesConformToSchema('orderFillRequests', orderFillRequests, schemas.orderFillRequestsSchema);
|
||||
const exchangeContractAddresses = _.map(
|
||||
orderFillRequests,
|
||||
orderFillRequest => orderFillRequest.signedOrder.exchangeContractAddress,
|
||||
);
|
||||
assert.hasAtMostOneUniqueValue(
|
||||
exchangeContractAddresses,
|
||||
ExchangeContractErrs.BatchOrdersMustHaveSameExchangeAddress,
|
||||
);
|
||||
await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper);
|
||||
const normalizedTakerAddress = takerAddress.toLowerCase();
|
||||
if (_.isEmpty(orderFillRequests)) {
|
||||
throw new Error(ExchangeContractErrs.BatchOrdersMustHaveAtLeastOneItem);
|
||||
}
|
||||
const exchangeInstance = await this._getExchangeContractAsync();
|
||||
|
||||
const shouldValidate = _.isUndefined(orderTransactionOpts.shouldValidate)
|
||||
? SHOULD_VALIDATE_BY_DEFAULT
|
||||
: orderTransactionOpts.shouldValidate;
|
||||
if (shouldValidate) {
|
||||
const zrxTokenAddress = this.getZRXTokenAddress();
|
||||
const exchangeTradeEmulator = new ExchangeTransferSimulator(this._tokenWrapper, BlockParamLiteral.Latest);
|
||||
for (const orderFillRequest of orderFillRequests) {
|
||||
await this._orderValidationUtils.validateFillOrKillOrderThrowIfInvalidAsync(
|
||||
exchangeTradeEmulator,
|
||||
orderFillRequest.signedOrder,
|
||||
orderFillRequest.takerTokenFillAmount,
|
||||
normalizedTakerAddress,
|
||||
zrxTokenAddress,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const orderAddressesValuesAndTakerTokenFillAmounts = _.map(orderFillRequests, request => {
|
||||
return [
|
||||
...ExchangeWrapper._getOrderAddressesAndValues(request.signedOrder),
|
||||
request.takerTokenFillAmount,
|
||||
request.signedOrder.ecSignature.v,
|
||||
request.signedOrder.ecSignature.r,
|
||||
request.signedOrder.ecSignature.s,
|
||||
];
|
||||
});
|
||||
|
||||
// We use _.unzip<any> because _.unzip doesn't type check if values have different types :'(
|
||||
const [orderAddresses, orderValues, fillTakerTokenAmounts, vParams, rParams, sParams] = _.unzip<any>(
|
||||
orderAddressesValuesAndTakerTokenFillAmounts,
|
||||
);
|
||||
const txHash = await exchangeInstance.batchFillOrKillOrders.sendTransactionAsync(
|
||||
orderAddresses,
|
||||
orderValues,
|
||||
fillTakerTokenAmounts,
|
||||
vParams,
|
||||
rParams,
|
||||
sParams,
|
||||
{
|
||||
from: normalizedTakerAddress,
|
||||
gas: orderTransactionOpts.gasLimit,
|
||||
gasPrice: orderTransactionOpts.gasPrice,
|
||||
},
|
||||
);
|
||||
return txHash;
|
||||
}
|
||||
/**
|
||||
* Cancel a given fill amount of an order. Cancellations are cumulative.
|
||||
* @param order An object that conforms to the Order or SignedOrder interface.
|
||||
* The order you would like to cancel.
|
||||
* @param cancelTakerTokenAmount The amount (specified in taker tokens) that you would like to cancel.
|
||||
* @param transactionOpts Optional arguments this method accepts.
|
||||
* @return Transaction hash.
|
||||
*/
|
||||
@decorators.asyncZeroExErrorHandler
|
||||
public async cancelOrderAsync(
|
||||
order: Order | SignedOrder,
|
||||
cancelTakerTokenAmount: BigNumber,
|
||||
orderTransactionOpts: OrderTransactionOpts = {},
|
||||
): Promise<string> {
|
||||
assert.doesConformToSchema('order', order, schemas.orderSchema);
|
||||
assert.isValidBaseUnitAmount('takerTokenCancelAmount', cancelTakerTokenAmount);
|
||||
await assert.isSenderAddressAsync('order.maker', order.maker, this._web3Wrapper);
|
||||
const normalizedMakerAddress = order.maker.toLowerCase();
|
||||
|
||||
const exchangeInstance = await this._getExchangeContractAsync();
|
||||
|
||||
const shouldValidate = _.isUndefined(orderTransactionOpts.shouldValidate)
|
||||
? SHOULD_VALIDATE_BY_DEFAULT
|
||||
: orderTransactionOpts.shouldValidate;
|
||||
if (shouldValidate) {
|
||||
const orderHash = utils.getOrderHashHex(order);
|
||||
const unavailableTakerTokenAmount = await this.getUnavailableTakerAmountAsync(orderHash);
|
||||
OrderValidationUtils.validateCancelOrderThrowIfInvalid(
|
||||
order,
|
||||
cancelTakerTokenAmount,
|
||||
unavailableTakerTokenAmount,
|
||||
);
|
||||
}
|
||||
|
||||
const [orderAddresses, orderValues] = ExchangeWrapper._getOrderAddressesAndValues(order);
|
||||
const txHash = await exchangeInstance.cancelOrder.sendTransactionAsync(
|
||||
orderAddresses,
|
||||
orderValues,
|
||||
cancelTakerTokenAmount,
|
||||
{
|
||||
from: normalizedMakerAddress,
|
||||
gas: orderTransactionOpts.gasLimit,
|
||||
gasPrice: orderTransactionOpts.gasPrice,
|
||||
},
|
||||
);
|
||||
return txHash;
|
||||
}
|
||||
/**
|
||||
* Batch version of cancelOrderAsync. Atomically cancels multiple orders in a single transaction.
|
||||
* All orders must be from the same maker.
|
||||
* @param orderCancellationRequests An array of objects that conform to the OrderCancellationRequest
|
||||
* interface.
|
||||
* @param transactionOpts Optional arguments this method accepts.
|
||||
* @return Transaction hash.
|
||||
*/
|
||||
@decorators.asyncZeroExErrorHandler
|
||||
public async batchCancelOrdersAsync(
|
||||
orderCancellationRequests: OrderCancellationRequest[],
|
||||
orderTransactionOpts: OrderTransactionOpts = {},
|
||||
): Promise<string> {
|
||||
assert.doesConformToSchema(
|
||||
'orderCancellationRequests',
|
||||
orderCancellationRequests,
|
||||
schemas.orderCancellationRequestsSchema,
|
||||
);
|
||||
const exchangeContractAddresses = _.map(
|
||||
orderCancellationRequests,
|
||||
orderCancellationRequest => orderCancellationRequest.order.exchangeContractAddress,
|
||||
);
|
||||
assert.hasAtMostOneUniqueValue(
|
||||
exchangeContractAddresses,
|
||||
ExchangeContractErrs.BatchOrdersMustHaveSameExchangeAddress,
|
||||
);
|
||||
const makers = _.map(orderCancellationRequests, cancellationRequest => cancellationRequest.order.maker);
|
||||
assert.hasAtMostOneUniqueValue(makers, ExchangeContractErrs.MultipleMakersInSingleCancelBatchDisallowed);
|
||||
const maker = makers[0];
|
||||
await assert.isSenderAddressAsync('maker', maker, this._web3Wrapper);
|
||||
const normalizedMakerAddress = maker.toLowerCase();
|
||||
|
||||
const shouldValidate = _.isUndefined(orderTransactionOpts.shouldValidate)
|
||||
? SHOULD_VALIDATE_BY_DEFAULT
|
||||
: orderTransactionOpts.shouldValidate;
|
||||
if (shouldValidate) {
|
||||
for (const orderCancellationRequest of orderCancellationRequests) {
|
||||
const orderHash = utils.getOrderHashHex(orderCancellationRequest.order);
|
||||
const unavailableTakerTokenAmount = await this.getUnavailableTakerAmountAsync(orderHash);
|
||||
OrderValidationUtils.validateCancelOrderThrowIfInvalid(
|
||||
orderCancellationRequest.order,
|
||||
orderCancellationRequest.takerTokenCancelAmount,
|
||||
unavailableTakerTokenAmount,
|
||||
);
|
||||
}
|
||||
}
|
||||
if (_.isEmpty(orderCancellationRequests)) {
|
||||
throw new Error(ExchangeContractErrs.BatchOrdersMustHaveAtLeastOneItem);
|
||||
}
|
||||
const exchangeInstance = await this._getExchangeContractAsync();
|
||||
const orderAddressesValuesAndTakerTokenCancelAmounts = _.map(orderCancellationRequests, cancellationRequest => {
|
||||
return [
|
||||
...ExchangeWrapper._getOrderAddressesAndValues(cancellationRequest.order),
|
||||
cancellationRequest.takerTokenCancelAmount,
|
||||
];
|
||||
});
|
||||
// We use _.unzip<any> because _.unzip doesn't type check if values have different types :'(
|
||||
const [orderAddresses, orderValues, cancelTakerTokenAmounts] = _.unzip<any>(
|
||||
orderAddressesValuesAndTakerTokenCancelAmounts,
|
||||
);
|
||||
const txHash = await exchangeInstance.batchCancelOrders.sendTransactionAsync(
|
||||
orderAddresses,
|
||||
orderValues,
|
||||
cancelTakerTokenAmounts,
|
||||
{
|
||||
from: normalizedMakerAddress,
|
||||
gas: orderTransactionOpts.gasLimit,
|
||||
gasPrice: orderTransactionOpts.gasPrice,
|
||||
},
|
||||
);
|
||||
return txHash;
|
||||
}
|
||||
/**
|
||||
* Subscribe to an event type emitted by the Exchange contract.
|
||||
* @param eventName The exchange contract event you would like to subscribe to.
|
||||
* @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
|
||||
* @return Subscription token used later to unsubscribe
|
||||
*/
|
||||
public subscribe<ArgsType extends ExchangeContractEventArgs>(
|
||||
eventName: ExchangeEvents,
|
||||
indexFilterValues: IndexedFilterValues,
|
||||
callback: EventCallback<ArgsType>,
|
||||
): string {
|
||||
assert.doesBelongToStringEnum('eventName', eventName, ExchangeEvents);
|
||||
assert.doesConformToSchema('indexFilterValues', indexFilterValues, schemas.indexFilterValuesSchema);
|
||||
assert.isFunction('callback', callback);
|
||||
const exchangeContractAddress = this.getContractAddress();
|
||||
const subscriptionToken = this._subscribe<ArgsType>(
|
||||
exchangeContractAddress,
|
||||
eventName,
|
||||
indexFilterValues,
|
||||
artifacts.ExchangeArtifact.abi,
|
||||
callback,
|
||||
);
|
||||
return subscriptionToken;
|
||||
}
|
||||
/**
|
||||
* Cancel a subscription
|
||||
* @param subscriptionToken Subscription token returned by `subscribe()`
|
||||
*/
|
||||
public unsubscribe(subscriptionToken: string): void {
|
||||
this._unsubscribe(subscriptionToken);
|
||||
}
|
||||
/**
|
||||
* Cancels all existing subscriptions
|
||||
*/
|
||||
public unsubscribeAll(): void {
|
||||
super._unsubscribeAll();
|
||||
}
|
||||
/**
|
||||
* Gets historical logs without creating a subscription
|
||||
* @param eventName The exchange contract event you would like to subscribe to.
|
||||
* @param blockRange Block range to get logs from.
|
||||
* @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 `{_from: aUserAddressHex}`
|
||||
* @return Array of logs that match the parameters
|
||||
*/
|
||||
public async getLogsAsync<ArgsType extends ExchangeContractEventArgs>(
|
||||
eventName: ExchangeEvents,
|
||||
blockRange: BlockRange,
|
||||
indexFilterValues: IndexedFilterValues,
|
||||
): Promise<Array<LogWithDecodedArgs<ArgsType>>> {
|
||||
assert.doesBelongToStringEnum('eventName', eventName, ExchangeEvents);
|
||||
assert.doesConformToSchema('blockRange', blockRange, schemas.blockRangeSchema);
|
||||
assert.doesConformToSchema('indexFilterValues', indexFilterValues, schemas.indexFilterValuesSchema);
|
||||
const exchangeContractAddress = this.getContractAddress();
|
||||
const logs = await this._getLogsAsync<ArgsType>(
|
||||
exchangeContractAddress,
|
||||
eventName,
|
||||
blockRange,
|
||||
indexFilterValues,
|
||||
artifacts.ExchangeArtifact.abi,
|
||||
);
|
||||
return logs;
|
||||
}
|
||||
/**
|
||||
* Retrieves the Ethereum address of the Exchange contract deployed on the network
|
||||
* that the user-passed web3 provider is connected to.
|
||||
* @returns The Ethereum address of the Exchange contract being used.
|
||||
*/
|
||||
public getContractAddress(): string {
|
||||
const contractAddress = this._getContractAddress(artifacts.ExchangeArtifact, this._contractAddressIfExists);
|
||||
return contractAddress;
|
||||
}
|
||||
/**
|
||||
* Checks if order is still fillable and throws an error otherwise. Useful for orderbook
|
||||
* pruning where you want to remove stale orders without knowing who the taker will be.
|
||||
* @param signedOrder An object that conforms to the SignedOrder interface. The
|
||||
* signedOrder you wish to validate.
|
||||
* @param opts An object that conforms to the ValidateOrderFillableOpts
|
||||
* interface. Allows specifying a specific fillTakerTokenAmount
|
||||
* to validate for.
|
||||
*/
|
||||
public async validateOrderFillableOrThrowAsync(
|
||||
signedOrder: SignedOrder,
|
||||
opts?: ValidateOrderFillableOpts,
|
||||
): Promise<void> {
|
||||
assert.doesConformToSchema('signedOrder', signedOrder, schemas.signedOrderSchema);
|
||||
const zrxTokenAddress = this.getZRXTokenAddress();
|
||||
const expectedFillTakerTokenAmount = !_.isUndefined(opts) ? opts.expectedFillTakerTokenAmount : undefined;
|
||||
const exchangeTradeEmulator = new ExchangeTransferSimulator(this._tokenWrapper, BlockParamLiteral.Latest);
|
||||
await this._orderValidationUtils.validateOrderFillableOrThrowAsync(
|
||||
exchangeTradeEmulator,
|
||||
signedOrder,
|
||||
zrxTokenAddress,
|
||||
expectedFillTakerTokenAmount,
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Checks if order fill will succeed and throws an error otherwise.
|
||||
* @param signedOrder An object that conforms to the SignedOrder interface. The
|
||||
* signedOrder you wish to fill.
|
||||
* @param fillTakerTokenAmount The total amount of the takerTokens you would like to fill.
|
||||
* @param takerAddress The user Ethereum address who would like to fill this order.
|
||||
* Must be available via the supplied Provider passed to 0x.js.
|
||||
*/
|
||||
public async validateFillOrderThrowIfInvalidAsync(
|
||||
signedOrder: SignedOrder,
|
||||
fillTakerTokenAmount: BigNumber,
|
||||
takerAddress: string,
|
||||
): Promise<void> {
|
||||
assert.doesConformToSchema('signedOrder', signedOrder, schemas.signedOrderSchema);
|
||||
assert.isValidBaseUnitAmount('fillTakerTokenAmount', fillTakerTokenAmount);
|
||||
await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper);
|
||||
const normalizedTakerAddress = takerAddress.toLowerCase();
|
||||
const zrxTokenAddress = this.getZRXTokenAddress();
|
||||
const exchangeTradeEmulator = new ExchangeTransferSimulator(this._tokenWrapper, BlockParamLiteral.Latest);
|
||||
await this._orderValidationUtils.validateFillOrderThrowIfInvalidAsync(
|
||||
exchangeTradeEmulator,
|
||||
signedOrder,
|
||||
fillTakerTokenAmount,
|
||||
normalizedTakerAddress,
|
||||
zrxTokenAddress,
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Checks if cancelling a given order will succeed and throws an informative error if it won't.
|
||||
* @param order An object that conforms to the Order or SignedOrder interface.
|
||||
* The order you would like to cancel.
|
||||
* @param cancelTakerTokenAmount The amount (specified in taker tokens) that you would like to cancel.
|
||||
*/
|
||||
public async validateCancelOrderThrowIfInvalidAsync(
|
||||
order: Order,
|
||||
cancelTakerTokenAmount: BigNumber,
|
||||
): Promise<void> {
|
||||
assert.doesConformToSchema('order', order, schemas.orderSchema);
|
||||
assert.isValidBaseUnitAmount('cancelTakerTokenAmount', cancelTakerTokenAmount);
|
||||
const orderHash = utils.getOrderHashHex(order);
|
||||
const unavailableTakerTokenAmount = await this.getUnavailableTakerAmountAsync(orderHash);
|
||||
OrderValidationUtils.validateCancelOrderThrowIfInvalid(
|
||||
order,
|
||||
cancelTakerTokenAmount,
|
||||
unavailableTakerTokenAmount,
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Checks if calling fillOrKill on a given order will succeed and throws an informative error if it won't.
|
||||
* @param signedOrder An object that conforms to the SignedOrder interface. The
|
||||
* signedOrder you wish to fill.
|
||||
* @param fillTakerTokenAmount The total amount of the takerTokens you would like to fill.
|
||||
* @param takerAddress The user Ethereum address who would like to fill this order.
|
||||
* Must be available via the supplied Provider passed to 0x.js.
|
||||
*/
|
||||
public async validateFillOrKillOrderThrowIfInvalidAsync(
|
||||
signedOrder: SignedOrder,
|
||||
fillTakerTokenAmount: BigNumber,
|
||||
takerAddress: string,
|
||||
): Promise<void> {
|
||||
assert.doesConformToSchema('signedOrder', signedOrder, schemas.signedOrderSchema);
|
||||
assert.isValidBaseUnitAmount('fillTakerTokenAmount', fillTakerTokenAmount);
|
||||
await assert.isSenderAddressAsync('takerAddress', takerAddress, this._web3Wrapper);
|
||||
const normalizedTakerAddress = takerAddress.toLowerCase();
|
||||
const zrxTokenAddress = this.getZRXTokenAddress();
|
||||
const exchangeTradeEmulator = new ExchangeTransferSimulator(this._tokenWrapper, BlockParamLiteral.Latest);
|
||||
await this._orderValidationUtils.validateFillOrKillOrderThrowIfInvalidAsync(
|
||||
exchangeTradeEmulator,
|
||||
signedOrder,
|
||||
fillTakerTokenAmount,
|
||||
normalizedTakerAddress,
|
||||
zrxTokenAddress,
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Checks if rounding error will be > 0.1% when computing makerTokenAmount by doing:
|
||||
* `(fillTakerTokenAmount * makerTokenAmount) / takerTokenAmount`.
|
||||
* 0x Protocol does not accept any trades that result in large rounding errors. This means that tokens with few or
|
||||
* no decimals can only be filled in quantities and ratios that avoid large rounding errors.
|
||||
* @param fillTakerTokenAmount The amount of the order (in taker tokens baseUnits) that you wish to fill.
|
||||
* @param takerTokenAmount The order size on the taker side
|
||||
* @param makerTokenAmount The order size on the maker side
|
||||
*/
|
||||
public async isRoundingErrorAsync(
|
||||
fillTakerTokenAmount: BigNumber,
|
||||
takerTokenAmount: BigNumber,
|
||||
makerTokenAmount: BigNumber,
|
||||
): Promise<boolean> {
|
||||
assert.isValidBaseUnitAmount('fillTakerTokenAmount', fillTakerTokenAmount);
|
||||
assert.isValidBaseUnitAmount('takerTokenAmount', takerTokenAmount);
|
||||
assert.isValidBaseUnitAmount('makerTokenAmount', makerTokenAmount);
|
||||
const exchangeInstance = await this._getExchangeContractAsync();
|
||||
const isRoundingError = await exchangeInstance.isRoundingError.callAsync(
|
||||
fillTakerTokenAmount,
|
||||
takerTokenAmount,
|
||||
makerTokenAmount,
|
||||
);
|
||||
return isRoundingError;
|
||||
}
|
||||
/**
|
||||
* Checks if logs contain LogError, which is emitted by Exchange contract on transaction failure.
|
||||
* @param logs Transaction logs as returned by `zeroEx.awaitTransactionMinedAsync`
|
||||
*/
|
||||
public throwLogErrorsAsErrors(logs: Array<LogWithDecodedArgs<DecodedLogArgs> | LogEntry>): void {
|
||||
const errLog = _.find(logs, {
|
||||
event: ExchangeEvents.LogError,
|
||||
});
|
||||
if (!_.isUndefined(errLog)) {
|
||||
const logArgs = (errLog as LogWithDecodedArgs<LogErrorContractEventArgs>).args;
|
||||
const errCode = logArgs.errorId;
|
||||
const errMessage = this._exchangeContractErrCodesToMsg[errCode];
|
||||
throw new Error(errMessage);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Gets the latest OrderState of a signedOrder
|
||||
* @param signedOrder The signedOrder
|
||||
* @param stateLayer Optional, desired blockchain state layer (defaults to latest).
|
||||
* @return OrderState of the signedOrder
|
||||
*/
|
||||
public async getOrderStateAsync(
|
||||
signedOrder: SignedOrder,
|
||||
stateLayer: BlockParamLiteral = BlockParamLiteral.Latest,
|
||||
): Promise<OrderState> {
|
||||
const simpleBalanceAndProxyAllowanceFetcher = new SimpleBalanceAndProxyAllowanceFetcher(
|
||||
this._tokenWrapper,
|
||||
stateLayer,
|
||||
);
|
||||
const simpleOrderFilledCancelledFetcher = new SimpleOrderFilledCancelledFetcher(this, stateLayer);
|
||||
const orderStateUtils = new OrderStateUtils(
|
||||
simpleBalanceAndProxyAllowanceFetcher,
|
||||
simpleOrderFilledCancelledFetcher,
|
||||
);
|
||||
const orderState = orderStateUtils.getOrderStateAsync(signedOrder);
|
||||
return orderState;
|
||||
}
|
||||
/**
|
||||
* Returns the ZRX token address used by the exchange contract.
|
||||
* @return Address of ZRX token
|
||||
*/
|
||||
public getZRXTokenAddress(): string {
|
||||
const contractAddress = this._getContractAddress(artifacts.ZRXArtifact, this._zrxContractAddressIfExists);
|
||||
return contractAddress;
|
||||
}
|
||||
private _invalidateContractInstances(): void {
|
||||
this.unsubscribeAll();
|
||||
delete this._exchangeContractIfExists;
|
||||
}
|
||||
private async _isValidSignatureUsingContractCallAsync(
|
||||
dataHex: string,
|
||||
ecSignature: ECSignature,
|
||||
signerAddressHex: string,
|
||||
): Promise<boolean> {
|
||||
assert.isHexString('dataHex', dataHex);
|
||||
assert.doesConformToSchema('ecSignature', ecSignature, schemas.ecSignatureSchema);
|
||||
assert.isETHAddressHex('signerAddressHex', signerAddressHex);
|
||||
const normalizedSignerAddress = signerAddressHex.toLowerCase();
|
||||
|
||||
const exchangeInstance = await this._getExchangeContractAsync();
|
||||
|
||||
const isValidSignature = await exchangeInstance.isValidSignature.callAsync(
|
||||
normalizedSignerAddress,
|
||||
dataHex,
|
||||
ecSignature.v,
|
||||
ecSignature.r,
|
||||
ecSignature.s,
|
||||
);
|
||||
return isValidSignature;
|
||||
}
|
||||
private async _getOrderHashHexUsingContractCallAsync(order: Order | SignedOrder): Promise<string> {
|
||||
const exchangeInstance = await this._getExchangeContractAsync();
|
||||
const [orderAddresses, orderValues] = ExchangeWrapper._getOrderAddressesAndValues(order);
|
||||
const orderHashHex = await exchangeInstance.getOrderHash.callAsync(orderAddresses, orderValues);
|
||||
return orderHashHex;
|
||||
}
|
||||
private async _getExchangeContractAsync(): Promise<ExchangeContract> {
|
||||
if (!_.isUndefined(this._exchangeContractIfExists)) {
|
||||
return this._exchangeContractIfExists;
|
||||
}
|
||||
const [abi, address] = await this._getContractAbiAndAddressFromArtifactsAsync(
|
||||
artifacts.ExchangeArtifact,
|
||||
this._contractAddressIfExists,
|
||||
);
|
||||
const contractInstance = new ExchangeContract(
|
||||
abi,
|
||||
address,
|
||||
this._web3Wrapper.getProvider(),
|
||||
this._web3Wrapper.getContractDefaults(),
|
||||
);
|
||||
this._exchangeContractIfExists = contractInstance;
|
||||
return this._exchangeContractIfExists;
|
||||
}
|
||||
private async _getTokenTransferProxyAddressAsync(): Promise<string> {
|
||||
const exchangeInstance = await this._getExchangeContractAsync();
|
||||
const tokenTransferProxyAddress = await exchangeInstance.TOKEN_TRANSFER_PROXY_CONTRACT.callAsync();
|
||||
const tokenTransferProxyAddressLowerCase = tokenTransferProxyAddress.toLowerCase();
|
||||
return tokenTransferProxyAddressLowerCase;
|
||||
}
|
||||
} // tslint:disable:max-file-line-count
|
||||
@@ -1,133 +0,0 @@
|
||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { artifacts } from '../artifacts';
|
||||
import { Token, TokenMetadata } from '../types';
|
||||
import { assert } from '../utils/assert';
|
||||
import { constants } from '../utils/constants';
|
||||
|
||||
import { ContractWrapper } from './contract_wrapper';
|
||||
import { TokenRegistryContract } from './generated/token_registry';
|
||||
|
||||
/**
|
||||
* This class includes all the functionality related to interacting with the 0x Token Registry smart contract.
|
||||
*/
|
||||
export class TokenRegistryWrapper extends ContractWrapper {
|
||||
private _tokenRegistryContractIfExists?: TokenRegistryContract;
|
||||
private _contractAddressIfExists?: string;
|
||||
private static _createTokenFromMetadata(metadata: TokenMetadata): Token | undefined {
|
||||
if (metadata[0] === constants.NULL_ADDRESS) {
|
||||
return undefined;
|
||||
}
|
||||
const token = {
|
||||
address: metadata[0],
|
||||
name: metadata[1],
|
||||
symbol: metadata[2],
|
||||
decimals: metadata[3],
|
||||
};
|
||||
return token;
|
||||
}
|
||||
constructor(web3Wrapper: Web3Wrapper, networkId: number, contractAddressIfExists?: string) {
|
||||
super(web3Wrapper, networkId);
|
||||
this._contractAddressIfExists = contractAddressIfExists;
|
||||
}
|
||||
/**
|
||||
* Retrieves all the tokens currently listed in the Token Registry smart contract
|
||||
* @return An array of objects that conform to the Token interface.
|
||||
*/
|
||||
public async getTokensAsync(): Promise<Token[]> {
|
||||
const addresses = await this.getTokenAddressesAsync();
|
||||
const tokenPromises: Array<Promise<Token | undefined>> = _.map(addresses, async (address: string) =>
|
||||
this.getTokenIfExistsAsync(address),
|
||||
);
|
||||
const tokens = await Promise.all(tokenPromises);
|
||||
return tokens as Token[];
|
||||
}
|
||||
/**
|
||||
* Retrieves all the addresses of the tokens currently listed in the Token Registry smart contract
|
||||
* @return An array of token addresses.
|
||||
*/
|
||||
public async getTokenAddressesAsync(): Promise<string[]> {
|
||||
const tokenRegistryContract = await this._getTokenRegistryContractAsync();
|
||||
const addresses = await tokenRegistryContract.getTokenAddresses.callAsync();
|
||||
const lowerCaseAddresses = _.map(addresses, address => address.toLowerCase());
|
||||
return lowerCaseAddresses;
|
||||
}
|
||||
/**
|
||||
* Retrieves a token by address currently listed in the Token Registry smart contract
|
||||
* @return An object that conforms to the Token interface or undefined if token not found.
|
||||
*/
|
||||
public async getTokenIfExistsAsync(address: string): Promise<Token | undefined> {
|
||||
assert.isETHAddressHex('address', address);
|
||||
const normalizedAddress = address.toLowerCase();
|
||||
|
||||
const tokenRegistryContract = await this._getTokenRegistryContractAsync();
|
||||
const metadata = await tokenRegistryContract.getTokenMetaData.callAsync(normalizedAddress);
|
||||
const token = TokenRegistryWrapper._createTokenFromMetadata(metadata);
|
||||
return token;
|
||||
}
|
||||
public async getTokenAddressBySymbolIfExistsAsync(symbol: string): Promise<string | undefined> {
|
||||
assert.isString('symbol', symbol);
|
||||
const tokenRegistryContract = await this._getTokenRegistryContractAsync();
|
||||
const addressIfExists = await tokenRegistryContract.getTokenAddressBySymbol.callAsync(symbol);
|
||||
if (addressIfExists === constants.NULL_ADDRESS) {
|
||||
return undefined;
|
||||
}
|
||||
return addressIfExists;
|
||||
}
|
||||
public async getTokenAddressByNameIfExistsAsync(name: string): Promise<string | undefined> {
|
||||
assert.isString('name', name);
|
||||
const tokenRegistryContract = await this._getTokenRegistryContractAsync();
|
||||
const addressIfExists = await tokenRegistryContract.getTokenAddressByName.callAsync(name);
|
||||
if (addressIfExists === constants.NULL_ADDRESS) {
|
||||
return undefined;
|
||||
}
|
||||
return addressIfExists;
|
||||
}
|
||||
public async getTokenBySymbolIfExistsAsync(symbol: string): Promise<Token | undefined> {
|
||||
assert.isString('symbol', symbol);
|
||||
const tokenRegistryContract = await this._getTokenRegistryContractAsync();
|
||||
const metadata = await tokenRegistryContract.getTokenBySymbol.callAsync(symbol);
|
||||
const token = TokenRegistryWrapper._createTokenFromMetadata(metadata);
|
||||
return token;
|
||||
}
|
||||
public async getTokenByNameIfExistsAsync(name: string): Promise<Token | undefined> {
|
||||
assert.isString('name', name);
|
||||
const tokenRegistryContract = await this._getTokenRegistryContractAsync();
|
||||
const metadata = await tokenRegistryContract.getTokenByName.callAsync(name);
|
||||
const token = TokenRegistryWrapper._createTokenFromMetadata(metadata);
|
||||
return token;
|
||||
}
|
||||
/**
|
||||
* Retrieves the Ethereum address of the TokenRegistry contract deployed on the network
|
||||
* that the user-passed web3 provider is connected to.
|
||||
* @returns The Ethereum address of the TokenRegistry contract being used.
|
||||
*/
|
||||
public getContractAddress(): string {
|
||||
const contractAddress = this._getContractAddress(
|
||||
artifacts.TokenRegistryArtifact,
|
||||
this._contractAddressIfExists,
|
||||
);
|
||||
return contractAddress;
|
||||
}
|
||||
private _invalidateContractInstance(): void {
|
||||
delete this._tokenRegistryContractIfExists;
|
||||
}
|
||||
private async _getTokenRegistryContractAsync(): Promise<TokenRegistryContract> {
|
||||
if (!_.isUndefined(this._tokenRegistryContractIfExists)) {
|
||||
return this._tokenRegistryContractIfExists;
|
||||
}
|
||||
const [abi, address] = await this._getContractAbiAndAddressFromArtifactsAsync(
|
||||
artifacts.TokenRegistryArtifact,
|
||||
this._contractAddressIfExists,
|
||||
);
|
||||
const contractInstance = new TokenRegistryContract(
|
||||
abi,
|
||||
address,
|
||||
this._web3Wrapper.getProvider(),
|
||||
this._web3Wrapper.getContractDefaults(),
|
||||
);
|
||||
this._tokenRegistryContractIfExists = contractInstance;
|
||||
return this._tokenRegistryContractIfExists;
|
||||
}
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { artifacts } from '../artifacts';
|
||||
import { assert } from '../utils/assert';
|
||||
|
||||
import { ContractWrapper } from './contract_wrapper';
|
||||
import { TokenTransferProxyContract } from './generated/token_transfer_proxy';
|
||||
|
||||
/**
|
||||
* This class includes the functionality related to interacting with the TokenTransferProxy contract.
|
||||
*/
|
||||
export class TokenTransferProxyWrapper extends ContractWrapper {
|
||||
private _tokenTransferProxyContractIfExists?: TokenTransferProxyContract;
|
||||
private _contractAddressIfExists?: string;
|
||||
constructor(web3Wrapper: Web3Wrapper, networkId: number, contractAddressIfExists?: string) {
|
||||
super(web3Wrapper, networkId);
|
||||
this._contractAddressIfExists = contractAddressIfExists;
|
||||
}
|
||||
/**
|
||||
* Check if the Exchange contract address is authorized by the TokenTransferProxy contract.
|
||||
* @param exchangeContractAddress The hex encoded address of the Exchange contract to call.
|
||||
* @return Whether the exchangeContractAddress is authorized.
|
||||
*/
|
||||
public async isAuthorizedAsync(exchangeContractAddress: string): Promise<boolean> {
|
||||
assert.isETHAddressHex('exchangeContractAddress', exchangeContractAddress);
|
||||
const normalizedExchangeContractAddress = exchangeContractAddress.toLowerCase();
|
||||
const tokenTransferProxyContractInstance = await this._getTokenTransferProxyContractAsync();
|
||||
const isAuthorized = await tokenTransferProxyContractInstance.authorized.callAsync(
|
||||
normalizedExchangeContractAddress,
|
||||
);
|
||||
return isAuthorized;
|
||||
}
|
||||
/**
|
||||
* Get the list of all Exchange contract addresses authorized by the TokenTransferProxy contract.
|
||||
* @return The list of authorized addresses.
|
||||
*/
|
||||
public async getAuthorizedAddressesAsync(): Promise<string[]> {
|
||||
const tokenTransferProxyContractInstance = await this._getTokenTransferProxyContractAsync();
|
||||
const authorizedAddresses = await tokenTransferProxyContractInstance.getAuthorizedAddresses.callAsync();
|
||||
return authorizedAddresses;
|
||||
}
|
||||
/**
|
||||
* Retrieves the Ethereum address of the TokenTransferProxy contract deployed on the network
|
||||
* that the user-passed web3 provider is connected to.
|
||||
* @returns The Ethereum address of the TokenTransferProxy contract being used.
|
||||
*/
|
||||
public getContractAddress(): string {
|
||||
const contractAddress = this._getContractAddress(
|
||||
artifacts.TokenTransferProxyArtifact,
|
||||
this._contractAddressIfExists,
|
||||
);
|
||||
return contractAddress;
|
||||
}
|
||||
private _invalidateContractInstance(): void {
|
||||
delete this._tokenTransferProxyContractIfExists;
|
||||
}
|
||||
private async _getTokenTransferProxyContractAsync(): Promise<TokenTransferProxyContract> {
|
||||
if (!_.isUndefined(this._tokenTransferProxyContractIfExists)) {
|
||||
return this._tokenTransferProxyContractIfExists;
|
||||
}
|
||||
const [abi, address] = await this._getContractAbiAndAddressFromArtifactsAsync(
|
||||
artifacts.TokenTransferProxyArtifact,
|
||||
this._contractAddressIfExists,
|
||||
);
|
||||
const contractInstance = new TokenTransferProxyContract(
|
||||
abi,
|
||||
address,
|
||||
this._web3Wrapper.getProvider(),
|
||||
this._web3Wrapper.getContractDefaults(),
|
||||
);
|
||||
this._tokenTransferProxyContractIfExists = contractInstance;
|
||||
return this._tokenTransferProxyContractIfExists;
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
import { BlockParamLiteral } from '@0xproject/types';
|
||||
import { BigNumber } from '@0xproject/utils';
|
||||
|
||||
import { BalanceAndProxyAllowanceFetcher } from '../abstract/balance_and_proxy_allowance_fetcher';
|
||||
import { TokenWrapper } from '../contract_wrappers/token_wrapper';
|
||||
|
||||
export class SimpleBalanceAndProxyAllowanceFetcher implements BalanceAndProxyAllowanceFetcher {
|
||||
private _tokenWrapper: TokenWrapper;
|
||||
private _defaultBlock: BlockParamLiteral;
|
||||
constructor(token: TokenWrapper, defaultBlock: BlockParamLiteral) {
|
||||
this._tokenWrapper = token;
|
||||
this._defaultBlock = defaultBlock;
|
||||
}
|
||||
public async getBalanceAsync(tokenAddress: string, userAddress: string): Promise<BigNumber> {
|
||||
const methodOpts = {
|
||||
defaultBlock: this._defaultBlock,
|
||||
};
|
||||
const balance = this._tokenWrapper.getBalanceAsync(tokenAddress, userAddress, methodOpts);
|
||||
return balance;
|
||||
}
|
||||
public async getProxyAllowanceAsync(tokenAddress: string, userAddress: string): Promise<BigNumber> {
|
||||
const methodOpts = {
|
||||
defaultBlock: this._defaultBlock,
|
||||
};
|
||||
const proxyAllowance = this._tokenWrapper.getProxyAllowanceAsync(tokenAddress, userAddress, methodOpts);
|
||||
return proxyAllowance;
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
import { BlockParamLiteral } from '@0xproject/types';
|
||||
import { BigNumber } from '@0xproject/utils';
|
||||
|
||||
import { OrderFilledCancelledFetcher } from '../abstract/order_filled_cancelled_fetcher';
|
||||
import { ExchangeWrapper } from '../contract_wrappers/exchange_wrapper';
|
||||
|
||||
export class SimpleOrderFilledCancelledFetcher implements OrderFilledCancelledFetcher {
|
||||
private _exchangeWrapper: ExchangeWrapper;
|
||||
private _defaultBlock: BlockParamLiteral;
|
||||
constructor(exchange: ExchangeWrapper, defaultBlock: BlockParamLiteral) {
|
||||
this._exchangeWrapper = exchange;
|
||||
this._defaultBlock = defaultBlock;
|
||||
}
|
||||
public async getFilledTakerAmountAsync(orderHash: string): Promise<BigNumber> {
|
||||
const methodOpts = {
|
||||
defaultBlock: this._defaultBlock,
|
||||
};
|
||||
const filledTakerAmount = this._exchangeWrapper.getFilledTakerAmountAsync(orderHash, methodOpts);
|
||||
return filledTakerAmount;
|
||||
}
|
||||
public async getCancelledTakerAmountAsync(orderHash: string): Promise<BigNumber> {
|
||||
const methodOpts = {
|
||||
defaultBlock: this._defaultBlock,
|
||||
};
|
||||
const cancelledTakerAmount = this._exchangeWrapper.getCancelledTakerAmountAsync(orderHash, methodOpts);
|
||||
return cancelledTakerAmount;
|
||||
}
|
||||
}
|
||||
@@ -1,61 +1,66 @@
|
||||
export { ZeroEx } from './0x';
|
||||
|
||||
export { MessagePrefixType, MessagePrefixOpts } from '@0xproject/order-utils';
|
||||
export { Web3ProviderEngine, RPCSubprovider } from '@0xproject/subproviders';
|
||||
|
||||
export {
|
||||
ZeroExError,
|
||||
EventCallback,
|
||||
ExchangeContractErrs,
|
||||
ContractEvent,
|
||||
Token,
|
||||
IndexedFilterValues,
|
||||
BlockRange,
|
||||
OrderCancellationRequest,
|
||||
OrderFillRequest,
|
||||
ContractEventArgs,
|
||||
ZeroExConfig,
|
||||
MethodOpts,
|
||||
OrderTransactionOpts,
|
||||
TransactionOpts,
|
||||
LogEvent,
|
||||
DecodedLogEvent,
|
||||
EventWatcherCallback,
|
||||
OnOrderStateChangeCallback,
|
||||
Order,
|
||||
SignedOrder,
|
||||
ECSignature,
|
||||
OrderStateValid,
|
||||
OrderStateInvalid,
|
||||
OrderState,
|
||||
} from './types';
|
||||
Token,
|
||||
ERC20AssetData,
|
||||
ERC721AssetData,
|
||||
AssetProxyId,
|
||||
} from '@0xproject/types';
|
||||
|
||||
export {
|
||||
BlockParamLiteral,
|
||||
FilterObject,
|
||||
BlockParam,
|
||||
ContractEventArg,
|
||||
LogWithDecodedArgs,
|
||||
Order,
|
||||
ContractEventArg,
|
||||
Provider,
|
||||
SignedOrder,
|
||||
ECSignature,
|
||||
TransactionReceipt,
|
||||
TransactionReceiptWithDecodedLogs,
|
||||
} from '@0xproject/types';
|
||||
} from 'ethereum-types';
|
||||
|
||||
export {
|
||||
EtherTokenContractEventArgs,
|
||||
WithdrawalContractEventArgs,
|
||||
DepositContractEventArgs,
|
||||
EtherTokenEvents,
|
||||
} from './contract_wrappers/generated/ether_token';
|
||||
|
||||
export {
|
||||
TransferContractEventArgs,
|
||||
ApprovalContractEventArgs,
|
||||
TokenContractEventArgs,
|
||||
TokenEvents,
|
||||
} from './contract_wrappers/generated/token';
|
||||
|
||||
export {
|
||||
LogErrorContractEventArgs,
|
||||
LogCancelContractEventArgs,
|
||||
LogFillContractEventArgs,
|
||||
ExchangeContractEventArgs,
|
||||
ExchangeEvents,
|
||||
} from './contract_wrappers/generated/exchange';
|
||||
EventCallback,
|
||||
ContractEvent,
|
||||
IndexedFilterValues,
|
||||
BlockRange,
|
||||
OrderFillRequest,
|
||||
ContractEventArgs,
|
||||
MethodOpts,
|
||||
OrderTransactionOpts,
|
||||
TransactionOpts,
|
||||
LogEvent,
|
||||
DecodedLogEvent,
|
||||
OnOrderStateChangeCallback,
|
||||
ContractWrappersError,
|
||||
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';
|
||||
|
||||
@@ -1,99 +0,0 @@
|
||||
import { BlockParamLiteral, LogEntry } from '@0xproject/types';
|
||||
import { intervalUtils } from '@0xproject/utils';
|
||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { EventWatcherCallback, ZeroExError } from '../types';
|
||||
import { assert } from '../utils/assert';
|
||||
|
||||
const DEFAULT_EVENT_POLLING_INTERVAL_MS = 200;
|
||||
|
||||
enum LogEventState {
|
||||
Removed,
|
||||
Added,
|
||||
}
|
||||
|
||||
/**
|
||||
* The EventWatcher watches for blockchain events at the specified block confirmation
|
||||
* depth.
|
||||
*/
|
||||
export class EventWatcher {
|
||||
private _web3Wrapper: Web3Wrapper;
|
||||
private _pollingIntervalMs: number;
|
||||
private _intervalIdIfExists?: NodeJS.Timer;
|
||||
private _lastEvents: LogEntry[] = [];
|
||||
private _stateLayer: BlockParamLiteral;
|
||||
constructor(
|
||||
web3Wrapper: Web3Wrapper,
|
||||
pollingIntervalIfExistsMs: undefined | number,
|
||||
stateLayer: BlockParamLiteral = BlockParamLiteral.Latest,
|
||||
) {
|
||||
this._web3Wrapper = web3Wrapper;
|
||||
this._stateLayer = stateLayer;
|
||||
this._pollingIntervalMs = _.isUndefined(pollingIntervalIfExistsMs)
|
||||
? DEFAULT_EVENT_POLLING_INTERVAL_MS
|
||||
: pollingIntervalIfExistsMs;
|
||||
}
|
||||
public subscribe(callback: EventWatcherCallback): void {
|
||||
assert.isFunction('callback', callback);
|
||||
if (!_.isUndefined(this._intervalIdIfExists)) {
|
||||
throw new Error(ZeroExError.SubscriptionAlreadyPresent);
|
||||
}
|
||||
this._intervalIdIfExists = intervalUtils.setAsyncExcludingInterval(
|
||||
this._pollForBlockchainEventsAsync.bind(this, callback),
|
||||
this._pollingIntervalMs,
|
||||
(err: Error) => {
|
||||
this.unsubscribe();
|
||||
callback(err);
|
||||
},
|
||||
);
|
||||
}
|
||||
public unsubscribe(): void {
|
||||
this._lastEvents = [];
|
||||
if (!_.isUndefined(this._intervalIdIfExists)) {
|
||||
intervalUtils.clearAsyncExcludingInterval(this._intervalIdIfExists);
|
||||
delete this._intervalIdIfExists;
|
||||
}
|
||||
}
|
||||
private async _pollForBlockchainEventsAsync(callback: EventWatcherCallback): Promise<void> {
|
||||
const pendingEvents = await this._getEventsAsync();
|
||||
if (_.isUndefined(pendingEvents)) {
|
||||
// HACK: This should never happen, but happens frequently on CI due to a ganache bug
|
||||
return;
|
||||
}
|
||||
if (pendingEvents.length === 0) {
|
||||
// HACK: Sometimes when node rebuilds the pending block we get back the empty result.
|
||||
// We don't want to emit a lot of removal events and bring them back after a couple of miliseconds,
|
||||
// that's why we just ignore those cases.
|
||||
return;
|
||||
}
|
||||
const removedEvents = _.differenceBy(this._lastEvents, pendingEvents, JSON.stringify);
|
||||
const newEvents = _.differenceBy(pendingEvents, this._lastEvents, JSON.stringify);
|
||||
await this._emitDifferencesAsync(removedEvents, LogEventState.Removed, callback);
|
||||
await this._emitDifferencesAsync(newEvents, LogEventState.Added, callback);
|
||||
this._lastEvents = pendingEvents;
|
||||
}
|
||||
private async _getEventsAsync(): Promise<LogEntry[]> {
|
||||
const eventFilter = {
|
||||
fromBlock: this._stateLayer,
|
||||
toBlock: this._stateLayer,
|
||||
};
|
||||
const events = await this._web3Wrapper.getLogsAsync(eventFilter);
|
||||
return events;
|
||||
}
|
||||
private async _emitDifferencesAsync(
|
||||
logs: LogEntry[],
|
||||
logEventState: LogEventState,
|
||||
callback: EventWatcherCallback,
|
||||
): Promise<void> {
|
||||
for (const log of logs) {
|
||||
const logEvent = {
|
||||
removed: logEventState === LogEventState.Removed,
|
||||
...log,
|
||||
};
|
||||
if (!_.isUndefined(this._intervalIdIfExists)) {
|
||||
callback(null, logEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,381 +0,0 @@
|
||||
import { schemas } from '@0xproject/json-schemas';
|
||||
import { BlockParamLiteral, LogWithDecodedArgs, SignedOrder } from '@0xproject/types';
|
||||
import { AbiDecoder, intervalUtils } from '@0xproject/utils';
|
||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { ZeroEx } from '../0x';
|
||||
import { ExchangeWrapper } from '../contract_wrappers/exchange_wrapper';
|
||||
import {
|
||||
DepositContractEventArgs,
|
||||
EtherTokenEvents,
|
||||
WithdrawalContractEventArgs,
|
||||
} from '../contract_wrappers/generated/ether_token';
|
||||
import {
|
||||
ExchangeEvents,
|
||||
LogCancelContractEventArgs,
|
||||
LogFillContractEventArgs,
|
||||
} from '../contract_wrappers/generated/exchange';
|
||||
import {
|
||||
ApprovalContractEventArgs,
|
||||
TokenEvents,
|
||||
TransferContractEventArgs,
|
||||
} from '../contract_wrappers/generated/token';
|
||||
import { TokenWrapper } from '../contract_wrappers/token_wrapper';
|
||||
import { BalanceAndProxyAllowanceLazyStore } from '../stores/balance_proxy_allowance_lazy_store';
|
||||
import { OrderFilledCancelledLazyStore } from '../stores/order_filled_cancelled_lazy_store';
|
||||
import {
|
||||
ContractEventArgs,
|
||||
ExchangeContractErrs,
|
||||
LogEvent,
|
||||
OnOrderStateChangeCallback,
|
||||
OrderState,
|
||||
OrderStateWatcherConfig,
|
||||
ZeroExError,
|
||||
} from '../types';
|
||||
import { assert } from '../utils/assert';
|
||||
import { OrderStateUtils } from '../utils/order_state_utils';
|
||||
import { utils } from '../utils/utils';
|
||||
|
||||
import { EventWatcher } from './event_watcher';
|
||||
import { ExpirationWatcher } from './expiration_watcher';
|
||||
|
||||
interface DependentOrderHashes {
|
||||
[makerAddress: string]: {
|
||||
[makerToken: string]: Set<string>;
|
||||
};
|
||||
}
|
||||
|
||||
interface OrderByOrderHash {
|
||||
[orderHash: string]: SignedOrder;
|
||||
}
|
||||
|
||||
interface OrderStateByOrderHash {
|
||||
[orderHash: string]: OrderState;
|
||||
}
|
||||
|
||||
const DEFAULT_CLEANUP_JOB_INTERVAL_MS = 1000 * 60 * 60; // 1h
|
||||
|
||||
/**
|
||||
* This class includes all the functionality related to watching a set of orders
|
||||
* for potential changes in order validity/fillability. The orderWatcher notifies
|
||||
* the subscriber of these changes so that a final decision can be made on whether
|
||||
* the order should be deemed invalid.
|
||||
*/
|
||||
export class OrderStateWatcher {
|
||||
private _orderStateByOrderHashCache: OrderStateByOrderHash = {};
|
||||
private _orderByOrderHash: OrderByOrderHash = {};
|
||||
private _dependentOrderHashes: DependentOrderHashes = {};
|
||||
private _callbackIfExists?: OnOrderStateChangeCallback;
|
||||
private _eventWatcher: EventWatcher;
|
||||
private _web3Wrapper: Web3Wrapper;
|
||||
private _expirationWatcher: ExpirationWatcher;
|
||||
private _orderStateUtils: OrderStateUtils;
|
||||
private _orderFilledCancelledLazyStore: OrderFilledCancelledLazyStore;
|
||||
private _balanceAndProxyAllowanceLazyStore: BalanceAndProxyAllowanceLazyStore;
|
||||
private _cleanupJobInterval: number;
|
||||
private _cleanupJobIntervalIdIfExists?: NodeJS.Timer;
|
||||
constructor(
|
||||
web3Wrapper: Web3Wrapper,
|
||||
token: TokenWrapper,
|
||||
exchange: ExchangeWrapper,
|
||||
config?: OrderStateWatcherConfig,
|
||||
) {
|
||||
this._web3Wrapper = web3Wrapper;
|
||||
const pollingIntervalIfExistsMs = _.isUndefined(config) ? undefined : config.eventPollingIntervalMs;
|
||||
const stateLayer =
|
||||
_.isUndefined(config) || _.isUndefined(config.stateLayer) ? BlockParamLiteral.Latest : config.stateLayer;
|
||||
this._eventWatcher = new EventWatcher(web3Wrapper, pollingIntervalIfExistsMs, stateLayer);
|
||||
this._balanceAndProxyAllowanceLazyStore = new BalanceAndProxyAllowanceLazyStore(token, stateLayer);
|
||||
this._orderFilledCancelledLazyStore = new OrderFilledCancelledLazyStore(exchange, stateLayer);
|
||||
this._orderStateUtils = new OrderStateUtils(
|
||||
this._balanceAndProxyAllowanceLazyStore,
|
||||
this._orderFilledCancelledLazyStore,
|
||||
);
|
||||
const orderExpirationCheckingIntervalMsIfExists = _.isUndefined(config)
|
||||
? undefined
|
||||
: config.orderExpirationCheckingIntervalMs;
|
||||
const expirationMarginIfExistsMs = _.isUndefined(config) ? undefined : config.expirationMarginMs;
|
||||
this._expirationWatcher = new ExpirationWatcher(
|
||||
expirationMarginIfExistsMs,
|
||||
orderExpirationCheckingIntervalMsIfExists,
|
||||
);
|
||||
this._cleanupJobInterval =
|
||||
_.isUndefined(config) || _.isUndefined(config.cleanupJobIntervalMs)
|
||||
? DEFAULT_CLEANUP_JOB_INTERVAL_MS
|
||||
: config.cleanupJobIntervalMs;
|
||||
}
|
||||
/**
|
||||
* Add an order to the orderStateWatcher. Before the order is added, it's
|
||||
* signature is verified.
|
||||
* @param signedOrder The order you wish to start watching.
|
||||
*/
|
||||
public addOrder(signedOrder: SignedOrder): void {
|
||||
assert.doesConformToSchema('signedOrder', signedOrder, schemas.signedOrderSchema);
|
||||
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
|
||||
assert.isValidSignature(orderHash, signedOrder.ecSignature, signedOrder.maker);
|
||||
this._orderByOrderHash[orderHash] = signedOrder;
|
||||
this._addToDependentOrderHashes(signedOrder, orderHash);
|
||||
const expirationUnixTimestampMs = signedOrder.expirationUnixTimestampSec.times(1000);
|
||||
this._expirationWatcher.addOrder(orderHash, expirationUnixTimestampMs);
|
||||
}
|
||||
/**
|
||||
* Removes an order from the orderStateWatcher
|
||||
* @param orderHash The orderHash of the order you wish to stop watching.
|
||||
*/
|
||||
public removeOrder(orderHash: string): void {
|
||||
assert.doesConformToSchema('orderHash', orderHash, schemas.orderHashSchema);
|
||||
const signedOrder = this._orderByOrderHash[orderHash];
|
||||
if (_.isUndefined(signedOrder)) {
|
||||
return; // noop
|
||||
}
|
||||
delete this._orderByOrderHash[orderHash];
|
||||
delete this._orderStateByOrderHashCache[orderHash];
|
||||
const exchange = (this._orderFilledCancelledLazyStore as any)._exchangeWrapper as ExchangeWrapper;
|
||||
const zrxTokenAddress = exchange.getZRXTokenAddress();
|
||||
|
||||
this._removeFromDependentOrderHashes(signedOrder.maker, zrxTokenAddress, orderHash);
|
||||
if (zrxTokenAddress !== signedOrder.makerTokenAddress) {
|
||||
this._removeFromDependentOrderHashes(signedOrder.maker, signedOrder.makerTokenAddress, orderHash);
|
||||
}
|
||||
|
||||
this._expirationWatcher.removeOrder(orderHash);
|
||||
}
|
||||
/**
|
||||
* Starts an orderStateWatcher subscription. The callback will be called every time a watched order's
|
||||
* backing blockchain state has changed. This is a call-to-action for the caller to re-validate the order.
|
||||
* @param callback Receives the orderHash of the order that should be re-validated, together
|
||||
* with all the order-relevant blockchain state needed to re-validate the order.
|
||||
*/
|
||||
public subscribe(callback: OnOrderStateChangeCallback): void {
|
||||
assert.isFunction('callback', callback);
|
||||
if (!_.isUndefined(this._callbackIfExists)) {
|
||||
throw new Error(ZeroExError.SubscriptionAlreadyPresent);
|
||||
}
|
||||
this._callbackIfExists = callback;
|
||||
this._eventWatcher.subscribe(this._onEventWatcherCallbackAsync.bind(this));
|
||||
this._expirationWatcher.subscribe(this._onOrderExpired.bind(this));
|
||||
this._cleanupJobIntervalIdIfExists = intervalUtils.setAsyncExcludingInterval(
|
||||
this._cleanupAsync.bind(this),
|
||||
this._cleanupJobInterval,
|
||||
(err: Error) => {
|
||||
this.unsubscribe();
|
||||
callback(err);
|
||||
},
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Ends an orderStateWatcher subscription.
|
||||
*/
|
||||
public unsubscribe(): void {
|
||||
if (_.isUndefined(this._callbackIfExists) || _.isUndefined(this._cleanupJobIntervalIdIfExists)) {
|
||||
throw new Error(ZeroExError.SubscriptionNotFound);
|
||||
}
|
||||
this._balanceAndProxyAllowanceLazyStore.deleteAll();
|
||||
this._orderFilledCancelledLazyStore.deleteAll();
|
||||
delete this._callbackIfExists;
|
||||
this._eventWatcher.unsubscribe();
|
||||
this._expirationWatcher.unsubscribe();
|
||||
intervalUtils.clearAsyncExcludingInterval(this._cleanupJobIntervalIdIfExists);
|
||||
}
|
||||
private async _cleanupAsync(): Promise<void> {
|
||||
for (const orderHash of _.keys(this._orderByOrderHash)) {
|
||||
this._cleanupOrderRelatedState(orderHash);
|
||||
await this._emitRevalidateOrdersAsync([orderHash]);
|
||||
}
|
||||
}
|
||||
private _cleanupOrderRelatedState(orderHash: string): void {
|
||||
const signedOrder = this._orderByOrderHash[orderHash];
|
||||
|
||||
this._orderFilledCancelledLazyStore.deleteFilledTakerAmount(orderHash);
|
||||
this._orderFilledCancelledLazyStore.deleteCancelledTakerAmount(orderHash);
|
||||
|
||||
this._balanceAndProxyAllowanceLazyStore.deleteBalance(signedOrder.makerTokenAddress, signedOrder.maker);
|
||||
this._balanceAndProxyAllowanceLazyStore.deleteProxyAllowance(signedOrder.makerTokenAddress, signedOrder.maker);
|
||||
this._balanceAndProxyAllowanceLazyStore.deleteBalance(signedOrder.takerTokenAddress, signedOrder.taker);
|
||||
this._balanceAndProxyAllowanceLazyStore.deleteProxyAllowance(signedOrder.takerTokenAddress, signedOrder.taker);
|
||||
|
||||
const zrxTokenAddress = this._getZRXTokenAddress();
|
||||
if (!signedOrder.makerFee.isZero()) {
|
||||
this._balanceAndProxyAllowanceLazyStore.deleteBalance(zrxTokenAddress, signedOrder.maker);
|
||||
this._balanceAndProxyAllowanceLazyStore.deleteProxyAllowance(zrxTokenAddress, signedOrder.maker);
|
||||
}
|
||||
if (!signedOrder.takerFee.isZero()) {
|
||||
this._balanceAndProxyAllowanceLazyStore.deleteBalance(zrxTokenAddress, signedOrder.taker);
|
||||
this._balanceAndProxyAllowanceLazyStore.deleteProxyAllowance(zrxTokenAddress, signedOrder.taker);
|
||||
}
|
||||
}
|
||||
private _onOrderExpired(orderHash: string): void {
|
||||
const orderState: OrderState = {
|
||||
isValid: false,
|
||||
orderHash,
|
||||
error: ExchangeContractErrs.OrderFillExpired,
|
||||
};
|
||||
if (!_.isUndefined(this._orderByOrderHash[orderHash])) {
|
||||
this.removeOrder(orderHash);
|
||||
if (!_.isUndefined(this._callbackIfExists)) {
|
||||
this._callbackIfExists(null, orderState);
|
||||
}
|
||||
}
|
||||
}
|
||||
private async _onEventWatcherCallbackAsync(err: Error | null, logIfExists?: LogEvent): Promise<void> {
|
||||
if (!_.isNull(err)) {
|
||||
if (!_.isUndefined(this._callbackIfExists)) {
|
||||
this._callbackIfExists(err);
|
||||
this.unsubscribe();
|
||||
}
|
||||
return;
|
||||
}
|
||||
const log = logIfExists as LogEvent; // At this moment we are sure that no error occured and log is defined.
|
||||
const maybeDecodedLog = this._web3Wrapper.abiDecoder.tryToDecodeLogOrNoop<ContractEventArgs>(log);
|
||||
const isLogDecoded = !_.isUndefined(((maybeDecodedLog as any) as LogWithDecodedArgs<ContractEventArgs>).event);
|
||||
if (!isLogDecoded) {
|
||||
return; // noop
|
||||
}
|
||||
const decodedLog = (maybeDecodedLog as any) as LogWithDecodedArgs<ContractEventArgs>;
|
||||
let makerToken: string;
|
||||
let makerAddress: string;
|
||||
switch (decodedLog.event) {
|
||||
case TokenEvents.Approval: {
|
||||
// Invalidate cache
|
||||
const args = decodedLog.args as ApprovalContractEventArgs;
|
||||
this._balanceAndProxyAllowanceLazyStore.deleteProxyAllowance(decodedLog.address, args._owner);
|
||||
// Revalidate orders
|
||||
makerToken = decodedLog.address;
|
||||
makerAddress = args._owner;
|
||||
if (
|
||||
!_.isUndefined(this._dependentOrderHashes[makerAddress]) &&
|
||||
!_.isUndefined(this._dependentOrderHashes[makerAddress][makerToken])
|
||||
) {
|
||||
const orderHashes = Array.from(this._dependentOrderHashes[makerAddress][makerToken]);
|
||||
await this._emitRevalidateOrdersAsync(orderHashes);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TokenEvents.Transfer: {
|
||||
// Invalidate cache
|
||||
const args = decodedLog.args as TransferContractEventArgs;
|
||||
this._balanceAndProxyAllowanceLazyStore.deleteBalance(decodedLog.address, args._from);
|
||||
this._balanceAndProxyAllowanceLazyStore.deleteBalance(decodedLog.address, args._to);
|
||||
// Revalidate orders
|
||||
makerToken = decodedLog.address;
|
||||
makerAddress = args._from;
|
||||
if (
|
||||
!_.isUndefined(this._dependentOrderHashes[makerAddress]) &&
|
||||
!_.isUndefined(this._dependentOrderHashes[makerAddress][makerToken])
|
||||
) {
|
||||
const orderHashes = Array.from(this._dependentOrderHashes[makerAddress][makerToken]);
|
||||
await this._emitRevalidateOrdersAsync(orderHashes);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case EtherTokenEvents.Deposit: {
|
||||
// Invalidate cache
|
||||
const args = decodedLog.args as DepositContractEventArgs;
|
||||
this._balanceAndProxyAllowanceLazyStore.deleteBalance(decodedLog.address, args._owner);
|
||||
// Revalidate orders
|
||||
makerToken = decodedLog.address;
|
||||
makerAddress = args._owner;
|
||||
if (
|
||||
!_.isUndefined(this._dependentOrderHashes[makerAddress]) &&
|
||||
!_.isUndefined(this._dependentOrderHashes[makerAddress][makerToken])
|
||||
) {
|
||||
const orderHashes = Array.from(this._dependentOrderHashes[makerAddress][makerToken]);
|
||||
await this._emitRevalidateOrdersAsync(orderHashes);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case EtherTokenEvents.Withdrawal: {
|
||||
// Invalidate cache
|
||||
const args = decodedLog.args as WithdrawalContractEventArgs;
|
||||
this._balanceAndProxyAllowanceLazyStore.deleteBalance(decodedLog.address, args._owner);
|
||||
// Revalidate orders
|
||||
makerToken = decodedLog.address;
|
||||
makerAddress = args._owner;
|
||||
if (
|
||||
!_.isUndefined(this._dependentOrderHashes[makerAddress]) &&
|
||||
!_.isUndefined(this._dependentOrderHashes[makerAddress][makerToken])
|
||||
) {
|
||||
const orderHashes = Array.from(this._dependentOrderHashes[makerAddress][makerToken]);
|
||||
await this._emitRevalidateOrdersAsync(orderHashes);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ExchangeEvents.LogFill: {
|
||||
// Invalidate cache
|
||||
const args = decodedLog.args as LogFillContractEventArgs;
|
||||
this._orderFilledCancelledLazyStore.deleteFilledTakerAmount(args.orderHash);
|
||||
// Revalidate orders
|
||||
const orderHash = args.orderHash;
|
||||
const isOrderWatched = !_.isUndefined(this._orderByOrderHash[orderHash]);
|
||||
if (isOrderWatched) {
|
||||
await this._emitRevalidateOrdersAsync([orderHash]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ExchangeEvents.LogCancel: {
|
||||
// Invalidate cache
|
||||
const args = decodedLog.args as LogCancelContractEventArgs;
|
||||
this._orderFilledCancelledLazyStore.deleteCancelledTakerAmount(args.orderHash);
|
||||
// Revalidate orders
|
||||
const orderHash = args.orderHash;
|
||||
const isOrderWatched = !_.isUndefined(this._orderByOrderHash[orderHash]);
|
||||
if (isOrderWatched) {
|
||||
await this._emitRevalidateOrdersAsync([orderHash]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ExchangeEvents.LogError:
|
||||
return; // noop
|
||||
|
||||
default:
|
||||
throw utils.spawnSwitchErr('decodedLog.event', decodedLog.event);
|
||||
}
|
||||
}
|
||||
private async _emitRevalidateOrdersAsync(orderHashes: string[]): Promise<void> {
|
||||
for (const orderHash of orderHashes) {
|
||||
const signedOrder = this._orderByOrderHash[orderHash];
|
||||
// Most of these calls will never reach the network because the data is fetched from stores
|
||||
// and only updated when cache is invalidated
|
||||
const orderState = await this._orderStateUtils.getOrderStateAsync(signedOrder);
|
||||
if (_.isUndefined(this._callbackIfExists)) {
|
||||
break; // Unsubscribe was called
|
||||
}
|
||||
if (_.isEqual(orderState, this._orderStateByOrderHashCache[orderHash])) {
|
||||
// Actual order state didn't change
|
||||
continue;
|
||||
} else {
|
||||
this._orderStateByOrderHashCache[orderHash] = orderState;
|
||||
}
|
||||
this._callbackIfExists(null, orderState);
|
||||
}
|
||||
}
|
||||
private _addToDependentOrderHashes(signedOrder: SignedOrder, orderHash: string): void {
|
||||
if (_.isUndefined(this._dependentOrderHashes[signedOrder.maker])) {
|
||||
this._dependentOrderHashes[signedOrder.maker] = {};
|
||||
}
|
||||
if (_.isUndefined(this._dependentOrderHashes[signedOrder.maker][signedOrder.makerTokenAddress])) {
|
||||
this._dependentOrderHashes[signedOrder.maker][signedOrder.makerTokenAddress] = new Set();
|
||||
}
|
||||
this._dependentOrderHashes[signedOrder.maker][signedOrder.makerTokenAddress].add(orderHash);
|
||||
const zrxTokenAddress = this._getZRXTokenAddress();
|
||||
if (_.isUndefined(this._dependentOrderHashes[signedOrder.maker][zrxTokenAddress])) {
|
||||
this._dependentOrderHashes[signedOrder.maker][zrxTokenAddress] = new Set();
|
||||
}
|
||||
this._dependentOrderHashes[signedOrder.maker][zrxTokenAddress].add(orderHash);
|
||||
}
|
||||
private _removeFromDependentOrderHashes(makerAddress: string, tokenAddress: string, orderHash: string) {
|
||||
this._dependentOrderHashes[makerAddress][tokenAddress].delete(orderHash);
|
||||
if (this._dependentOrderHashes[makerAddress][tokenAddress].size === 0) {
|
||||
delete this._dependentOrderHashes[makerAddress][tokenAddress];
|
||||
}
|
||||
if (_.isEmpty(this._dependentOrderHashes[makerAddress])) {
|
||||
delete this._dependentOrderHashes[makerAddress];
|
||||
}
|
||||
}
|
||||
private _getZRXTokenAddress(): string {
|
||||
const exchange = (this._orderFilledCancelledLazyStore as any)._exchangeWrapper as ExchangeWrapper;
|
||||
const zrxTokenAddress = exchange.getZRXTokenAddress();
|
||||
return zrxTokenAddress;
|
||||
}
|
||||
}
|
||||
@@ -1,95 +0,0 @@
|
||||
import { SignedOrder } from '@0xproject/types';
|
||||
import { BigNumber } from '@0xproject/utils';
|
||||
|
||||
export class RemainingFillableCalculator {
|
||||
private _signedOrder: SignedOrder;
|
||||
private _isMakerTokenZRX: boolean;
|
||||
// Transferrable Amount is the minimum of Approval and Balance
|
||||
private _transferrableMakerTokenAmount: BigNumber;
|
||||
private _transferrableMakerFeeTokenAmount: BigNumber;
|
||||
private _remainingMakerTokenAmount: BigNumber;
|
||||
private _remainingMakerFeeAmount: BigNumber;
|
||||
constructor(
|
||||
signedOrder: SignedOrder,
|
||||
isMakerTokenZRX: boolean,
|
||||
transferrableMakerTokenAmount: BigNumber,
|
||||
transferrableMakerFeeTokenAmount: BigNumber,
|
||||
remainingMakerTokenAmount: BigNumber,
|
||||
) {
|
||||
this._signedOrder = signedOrder;
|
||||
this._isMakerTokenZRX = isMakerTokenZRX;
|
||||
this._transferrableMakerTokenAmount = transferrableMakerTokenAmount;
|
||||
this._transferrableMakerFeeTokenAmount = transferrableMakerFeeTokenAmount;
|
||||
this._remainingMakerTokenAmount = remainingMakerTokenAmount;
|
||||
this._remainingMakerFeeAmount = remainingMakerTokenAmount
|
||||
.times(signedOrder.makerFee)
|
||||
.dividedToIntegerBy(signedOrder.makerTokenAmount);
|
||||
}
|
||||
public computeRemainingMakerFillable(): BigNumber {
|
||||
if (this._hasSufficientFundsForFeeAndTransferAmount()) {
|
||||
return this._remainingMakerTokenAmount;
|
||||
}
|
||||
if (this._signedOrder.makerFee.isZero()) {
|
||||
return BigNumber.min(this._remainingMakerTokenAmount, this._transferrableMakerTokenAmount);
|
||||
}
|
||||
return this._calculatePartiallyFillableMakerTokenAmount();
|
||||
}
|
||||
public computeRemainingTakerFillable(): BigNumber {
|
||||
return this.computeRemainingMakerFillable()
|
||||
.times(this._signedOrder.takerTokenAmount)
|
||||
.dividedToIntegerBy(this._signedOrder.makerTokenAmount);
|
||||
}
|
||||
private _hasSufficientFundsForFeeAndTransferAmount(): boolean {
|
||||
if (this._isMakerTokenZRX) {
|
||||
const totalZRXTransferAmountRequired = this._remainingMakerTokenAmount.plus(this._remainingMakerFeeAmount);
|
||||
const hasSufficientFunds = this._transferrableMakerTokenAmount.greaterThanOrEqualTo(
|
||||
totalZRXTransferAmountRequired,
|
||||
);
|
||||
return hasSufficientFunds;
|
||||
} else {
|
||||
const hasSufficientFundsForTransferAmount = this._transferrableMakerTokenAmount.greaterThanOrEqualTo(
|
||||
this._remainingMakerTokenAmount,
|
||||
);
|
||||
const hasSufficientFundsForFeeAmount = this._transferrableMakerFeeTokenAmount.greaterThanOrEqualTo(
|
||||
this._remainingMakerFeeAmount,
|
||||
);
|
||||
const hasSufficientFunds = hasSufficientFundsForTransferAmount && hasSufficientFundsForFeeAmount;
|
||||
return hasSufficientFunds;
|
||||
}
|
||||
}
|
||||
private _calculatePartiallyFillableMakerTokenAmount(): BigNumber {
|
||||
// Given an order for 200 wei for 2 ZRXwei fee, find 100 wei for 1 ZRXwei. Order ratio is then 100:1
|
||||
const orderToFeeRatio = this._signedOrder.makerTokenAmount.dividedBy(this._signedOrder.makerFee);
|
||||
// The number of times the maker can fill the order, if each fill only required the transfer of a single
|
||||
// baseUnit of fee tokens.
|
||||
// Given 2 ZRXwei, the maximum amount of times Maker can fill this order, in terms of fees, is 2
|
||||
const fillableTimesInFeeTokenBaseUnits = BigNumber.min(
|
||||
this._transferrableMakerFeeTokenAmount,
|
||||
this._remainingMakerFeeAmount,
|
||||
);
|
||||
// The number of times the Maker can fill the order, given the Maker Token Balance
|
||||
// Assuming a balance of 150 wei, and an orderToFeeRatio of 100:1, maker can fill this order 1 time.
|
||||
let fillableTimesInMakerTokenUnits = this._transferrableMakerTokenAmount.dividedBy(orderToFeeRatio);
|
||||
if (this._isMakerTokenZRX) {
|
||||
// If ZRX is the maker token, the Fee and the Maker amount need to be removed from the same pool;
|
||||
// 200 ZRXwei for 2ZRXwei fee can only be filled once (need 202 ZRXwei)
|
||||
const totalZRXTokenPooled = this._transferrableMakerTokenAmount;
|
||||
// The purchasing power here is less as the tokens are taken from the same Pool
|
||||
// For every one number of fills, we have to take an extra ZRX out of the pool
|
||||
fillableTimesInMakerTokenUnits = totalZRXTokenPooled.dividedBy(orderToFeeRatio.plus(new BigNumber(1)));
|
||||
}
|
||||
// When Ratio is not fully divisible there can be remainders which cannot be represented, so they are floored.
|
||||
// This can result in a RoundingError being thrown by the Exchange Contract.
|
||||
const partiallyFillableMakerTokenAmount = fillableTimesInMakerTokenUnits
|
||||
.times(this._signedOrder.makerTokenAmount)
|
||||
.dividedToIntegerBy(this._signedOrder.makerFee);
|
||||
const partiallyFillableFeeTokenAmount = fillableTimesInFeeTokenBaseUnits
|
||||
.times(this._signedOrder.makerTokenAmount)
|
||||
.dividedToIntegerBy(this._signedOrder.makerFee);
|
||||
const partiallyFillableAmount = BigNumber.min(
|
||||
partiallyFillableMakerTokenAmount,
|
||||
partiallyFillableFeeTokenAmount,
|
||||
);
|
||||
return partiallyFillableAmount;
|
||||
}
|
||||
}
|
||||
@@ -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',
|
||||
],
|
||||
};
|
||||
|
||||
@@ -1,15 +1,29 @@
|
||||
const networkNameToId: { [networkName: string]: number } = {
|
||||
mainnet: 1,
|
||||
ropsten: 3,
|
||||
rinkeby: 4,
|
||||
kovan: 42,
|
||||
ganache: 50,
|
||||
};
|
||||
|
||||
export const zeroExPublicNetworkConfigSchema = {
|
||||
id: '/ZeroExPublicNetworkConfig',
|
||||
properties: {
|
||||
networkId: {
|
||||
type: 'number',
|
||||
enum: [1, 3, 4, 42, 50],
|
||||
enum: [
|
||||
networkNameToId.mainnet,
|
||||
networkNameToId.ropsten,
|
||||
networkNameToId.rinkeby,
|
||||
networkNameToId.kovan,
|
||||
networkNameToId.ganache,
|
||||
],
|
||||
},
|
||||
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: {
|
||||
|
||||
@@ -1,91 +0,0 @@
|
||||
import { BlockParamLiteral } from '@0xproject/types';
|
||||
import { BigNumber } from '@0xproject/utils';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { BalanceAndProxyAllowanceFetcher } from '../abstract/balance_and_proxy_allowance_fetcher';
|
||||
import { TokenWrapper } from '../contract_wrappers/token_wrapper';
|
||||
|
||||
/**
|
||||
* Copy on read store for balances/proxyAllowances of tokens/accounts
|
||||
*/
|
||||
export class BalanceAndProxyAllowanceLazyStore implements BalanceAndProxyAllowanceFetcher {
|
||||
private _tokenWrapper: TokenWrapper;
|
||||
private _defaultBlock: BlockParamLiteral;
|
||||
private _balance: {
|
||||
[tokenAddress: string]: {
|
||||
[userAddress: string]: BigNumber;
|
||||
};
|
||||
};
|
||||
private _proxyAllowance: {
|
||||
[tokenAddress: string]: {
|
||||
[userAddress: string]: BigNumber;
|
||||
};
|
||||
};
|
||||
constructor(token: TokenWrapper, defaultBlock: BlockParamLiteral) {
|
||||
this._tokenWrapper = token;
|
||||
this._defaultBlock = defaultBlock;
|
||||
this._balance = {};
|
||||
this._proxyAllowance = {};
|
||||
}
|
||||
public async getBalanceAsync(tokenAddress: string, userAddress: string): Promise<BigNumber> {
|
||||
if (_.isUndefined(this._balance[tokenAddress]) || _.isUndefined(this._balance[tokenAddress][userAddress])) {
|
||||
const methodOpts = {
|
||||
defaultBlock: this._defaultBlock,
|
||||
};
|
||||
const balance = await this._tokenWrapper.getBalanceAsync(tokenAddress, userAddress, methodOpts);
|
||||
this.setBalance(tokenAddress, userAddress, balance);
|
||||
}
|
||||
const cachedBalance = this._balance[tokenAddress][userAddress];
|
||||
return cachedBalance;
|
||||
}
|
||||
public setBalance(tokenAddress: string, userAddress: string, balance: BigNumber): void {
|
||||
if (_.isUndefined(this._balance[tokenAddress])) {
|
||||
this._balance[tokenAddress] = {};
|
||||
}
|
||||
this._balance[tokenAddress][userAddress] = balance;
|
||||
}
|
||||
public deleteBalance(tokenAddress: string, userAddress: string): void {
|
||||
if (!_.isUndefined(this._balance[tokenAddress])) {
|
||||
delete this._balance[tokenAddress][userAddress];
|
||||
if (_.isEmpty(this._balance[tokenAddress])) {
|
||||
delete this._balance[tokenAddress];
|
||||
}
|
||||
}
|
||||
}
|
||||
public async getProxyAllowanceAsync(tokenAddress: string, userAddress: string): Promise<BigNumber> {
|
||||
if (
|
||||
_.isUndefined(this._proxyAllowance[tokenAddress]) ||
|
||||
_.isUndefined(this._proxyAllowance[tokenAddress][userAddress])
|
||||
) {
|
||||
const methodOpts = {
|
||||
defaultBlock: this._defaultBlock,
|
||||
};
|
||||
const proxyAllowance = await this._tokenWrapper.getProxyAllowanceAsync(
|
||||
tokenAddress,
|
||||
userAddress,
|
||||
methodOpts,
|
||||
);
|
||||
this.setProxyAllowance(tokenAddress, userAddress, proxyAllowance);
|
||||
}
|
||||
const cachedProxyAllowance = this._proxyAllowance[tokenAddress][userAddress];
|
||||
return cachedProxyAllowance;
|
||||
}
|
||||
public setProxyAllowance(tokenAddress: string, userAddress: string, proxyAllowance: BigNumber): void {
|
||||
if (_.isUndefined(this._proxyAllowance[tokenAddress])) {
|
||||
this._proxyAllowance[tokenAddress] = {};
|
||||
}
|
||||
this._proxyAllowance[tokenAddress][userAddress] = proxyAllowance;
|
||||
}
|
||||
public deleteProxyAllowance(tokenAddress: string, userAddress: string): void {
|
||||
if (!_.isUndefined(this._proxyAllowance[tokenAddress])) {
|
||||
delete this._proxyAllowance[tokenAddress][userAddress];
|
||||
if (_.isEmpty(this._proxyAllowance[tokenAddress])) {
|
||||
delete this._proxyAllowance[tokenAddress];
|
||||
}
|
||||
}
|
||||
}
|
||||
public deleteAll(): void {
|
||||
this._balance = {};
|
||||
this._proxyAllowance = {};
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
import { BlockParamLiteral } from '@0xproject/types';
|
||||
import { BigNumber } from '@0xproject/utils';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { OrderFilledCancelledFetcher } from '../abstract/order_filled_cancelled_fetcher';
|
||||
import { ExchangeWrapper } from '../contract_wrappers/exchange_wrapper';
|
||||
|
||||
/**
|
||||
* Copy on read store for filled/cancelled taker amounts
|
||||
*/
|
||||
export class OrderFilledCancelledLazyStore implements OrderFilledCancelledFetcher {
|
||||
private _exchangeWrapper: ExchangeWrapper;
|
||||
private _defaultBlock: BlockParamLiteral;
|
||||
private _filledTakerAmount: {
|
||||
[orderHash: string]: BigNumber;
|
||||
};
|
||||
private _cancelledTakerAmount: {
|
||||
[orderHash: string]: BigNumber;
|
||||
};
|
||||
constructor(exchange: ExchangeWrapper, defaultBlock: BlockParamLiteral) {
|
||||
this._exchangeWrapper = exchange;
|
||||
this._defaultBlock = defaultBlock;
|
||||
this._filledTakerAmount = {};
|
||||
this._cancelledTakerAmount = {};
|
||||
}
|
||||
public async getFilledTakerAmountAsync(orderHash: string): Promise<BigNumber> {
|
||||
if (_.isUndefined(this._filledTakerAmount[orderHash])) {
|
||||
const methodOpts = {
|
||||
defaultBlock: this._defaultBlock,
|
||||
};
|
||||
const filledTakerAmount = await this._exchangeWrapper.getFilledTakerAmountAsync(orderHash, methodOpts);
|
||||
this.setFilledTakerAmount(orderHash, filledTakerAmount);
|
||||
}
|
||||
const cachedFilled = this._filledTakerAmount[orderHash];
|
||||
return cachedFilled;
|
||||
}
|
||||
public setFilledTakerAmount(orderHash: string, filledTakerAmount: BigNumber): void {
|
||||
this._filledTakerAmount[orderHash] = filledTakerAmount;
|
||||
}
|
||||
public deleteFilledTakerAmount(orderHash: string): void {
|
||||
delete this._filledTakerAmount[orderHash];
|
||||
}
|
||||
public async getCancelledTakerAmountAsync(orderHash: string): Promise<BigNumber> {
|
||||
if (_.isUndefined(this._cancelledTakerAmount[orderHash])) {
|
||||
const methodOpts = {
|
||||
defaultBlock: this._defaultBlock,
|
||||
};
|
||||
const cancelledTakerAmount = await this._exchangeWrapper.getCancelledTakerAmountAsync(
|
||||
orderHash,
|
||||
methodOpts,
|
||||
);
|
||||
this.setCancelledTakerAmount(orderHash, cancelledTakerAmount);
|
||||
}
|
||||
const cachedCancelled = this._cancelledTakerAmount[orderHash];
|
||||
return cachedCancelled;
|
||||
}
|
||||
public setCancelledTakerAmount(orderHash: string, cancelledTakerAmount: BigNumber): void {
|
||||
this._cancelledTakerAmount[orderHash] = cancelledTakerAmount;
|
||||
}
|
||||
public deleteCancelledTakerAmount(orderHash: string): void {
|
||||
delete this._cancelledTakerAmount[orderHash];
|
||||
}
|
||||
public deleteAll(): void {
|
||||
this._filledTakerAmount = {};
|
||||
this._cancelledTakerAmount = {};
|
||||
}
|
||||
}
|
||||
@@ -1,277 +1,7 @@
|
||||
import { BigNumber } from '@0xproject/utils';
|
||||
|
||||
import {
|
||||
BlockParam,
|
||||
BlockParamLiteral,
|
||||
ContractAbi,
|
||||
ContractEventArg,
|
||||
FilterObject,
|
||||
LogEntryEvent,
|
||||
LogWithDecodedArgs,
|
||||
Order,
|
||||
SignedOrder,
|
||||
} from '@0xproject/types';
|
||||
|
||||
import * as Web3 from 'web3';
|
||||
|
||||
import { EtherTokenContractEventArgs, EtherTokenEvents } from './contract_wrappers/generated/ether_token';
|
||||
import { ExchangeContractEventArgs, ExchangeEvents } from './contract_wrappers/generated/exchange';
|
||||
import { TokenContractEventArgs, TokenEvents } from './contract_wrappers/generated/token';
|
||||
|
||||
export enum ZeroExError {
|
||||
ExchangeContractDoesNotExist = 'EXCHANGE_CONTRACT_DOES_NOT_EXIST',
|
||||
ZRXContractDoesNotExist = 'ZRX_CONTRACT_DOES_NOT_EXIST',
|
||||
EtherTokenContractDoesNotExist = 'ETHER_TOKEN_CONTRACT_DOES_NOT_EXIST',
|
||||
TokenTransferProxyContractDoesNotExist = 'TOKEN_TRANSFER_PROXY_CONTRACT_DOES_NOT_EXIST',
|
||||
TokenRegistryContractDoesNotExist = 'TOKEN_REGISTRY_CONTRACT_DOES_NOT_EXIST',
|
||||
TokenContractDoesNotExist = 'TOKEN_CONTRACT_DOES_NOT_EXIST',
|
||||
UnhandledError = 'UNHANDLED_ERROR',
|
||||
UserHasNoAssociatedAddress = 'USER_HAS_NO_ASSOCIATED_ADDRESSES',
|
||||
InvalidSignature = 'INVALID_SIGNATURE',
|
||||
ContractNotDeployedOnNetwork = 'CONTRACT_NOT_DEPLOYED_ON_NETWORK',
|
||||
InsufficientAllowanceForTransfer = 'INSUFFICIENT_ALLOWANCE_FOR_TRANSFER',
|
||||
InsufficientBalanceForTransfer = 'INSUFFICIENT_BALANCE_FOR_TRANSFER',
|
||||
InsufficientEthBalanceForDeposit = 'INSUFFICIENT_ETH_BALANCE_FOR_DEPOSIT',
|
||||
InsufficientWEthBalanceForWithdrawal = 'INSUFFICIENT_WETH_BALANCE_FOR_WITHDRAWAL',
|
||||
InvalidJump = 'INVALID_JUMP',
|
||||
OutOfGas = 'OUT_OF_GAS',
|
||||
NoNetworkId = 'NO_NETWORK_ID',
|
||||
SubscriptionNotFound = 'SUBSCRIPTION_NOT_FOUND',
|
||||
SubscriptionAlreadyPresent = 'SUBSCRIPTION_ALREADY_PRESENT',
|
||||
}
|
||||
|
||||
export enum InternalZeroExError {
|
||||
NoAbiDecoder = 'NO_ABI_DECODER',
|
||||
ZrxNotInTokenRegistry = 'ZRX_NOT_IN_TOKEN_REGISTRY',
|
||||
WethNotInTokenRegistry = 'WETH_NOT_IN_TOKEN_REGISTRY',
|
||||
}
|
||||
|
||||
export type OrderAddresses = [string, string, string, string, string];
|
||||
|
||||
export type OrderValues = [BigNumber, BigNumber, BigNumber, BigNumber, BigNumber, BigNumber];
|
||||
|
||||
export type LogEvent = LogEntryEvent;
|
||||
export interface DecodedLogEvent<ArgsType> {
|
||||
isRemoved: boolean;
|
||||
log: LogWithDecodedArgs<ArgsType>;
|
||||
}
|
||||
|
||||
export type EventCallback<ArgsType> = (err: null | Error, log?: DecodedLogEvent<ArgsType>) => void;
|
||||
export type EventWatcherCallback = (err: null | Error, log?: LogEvent) => void;
|
||||
|
||||
export enum ExchangeContractErrCodes {
|
||||
ERROR_FILL_EXPIRED, // Order has already expired
|
||||
ERROR_FILL_NO_VALUE, // Order has already been fully filled or cancelled
|
||||
ERROR_FILL_TRUNCATION, // Rounding error too large
|
||||
ERROR_FILL_BALANCE_ALLOWANCE, // Insufficient balance or allowance for token transfer
|
||||
ERROR_CANCEL_EXPIRED, // Order has already expired
|
||||
ERROR_CANCEL_NO_VALUE, // Order has already been fully filled or cancelled
|
||||
}
|
||||
|
||||
export enum ExchangeContractErrs {
|
||||
OrderFillExpired = 'ORDER_FILL_EXPIRED',
|
||||
OrderCancelExpired = 'ORDER_CANCEL_EXPIRED',
|
||||
OrderCancelAmountZero = 'ORDER_CANCEL_AMOUNT_ZERO',
|
||||
OrderAlreadyCancelledOrFilled = 'ORDER_ALREADY_CANCELLED_OR_FILLED',
|
||||
OrderFillAmountZero = 'ORDER_FILL_AMOUNT_ZERO',
|
||||
OrderRemainingFillAmountZero = 'ORDER_REMAINING_FILL_AMOUNT_ZERO',
|
||||
OrderFillRoundingError = 'ORDER_FILL_ROUNDING_ERROR',
|
||||
FillBalanceAllowanceError = 'FILL_BALANCE_ALLOWANCE_ERROR',
|
||||
InsufficientTakerBalance = 'INSUFFICIENT_TAKER_BALANCE',
|
||||
InsufficientTakerAllowance = 'INSUFFICIENT_TAKER_ALLOWANCE',
|
||||
InsufficientMakerBalance = 'INSUFFICIENT_MAKER_BALANCE',
|
||||
InsufficientMakerAllowance = 'INSUFFICIENT_MAKER_ALLOWANCE',
|
||||
InsufficientTakerFeeBalance = 'INSUFFICIENT_TAKER_FEE_BALANCE',
|
||||
InsufficientTakerFeeAllowance = 'INSUFFICIENT_TAKER_FEE_ALLOWANCE',
|
||||
InsufficientMakerFeeBalance = 'INSUFFICIENT_MAKER_FEE_BALANCE',
|
||||
InsufficientMakerFeeAllowance = 'INSUFFICIENT_MAKER_FEE_ALLOWANCE',
|
||||
TransactionSenderIsNotFillOrderTaker = 'TRANSACTION_SENDER_IS_NOT_FILL_ORDER_TAKER',
|
||||
MultipleMakersInSingleCancelBatchDisallowed = 'MULTIPLE_MAKERS_IN_SINGLE_CANCEL_BATCH_DISALLOWED',
|
||||
InsufficientRemainingFillAmount = 'INSUFFICIENT_REMAINING_FILL_AMOUNT',
|
||||
MultipleTakerTokensInFillUpToDisallowed = 'MULTIPLE_TAKER_TOKENS_IN_FILL_UP_TO_DISALLOWED',
|
||||
BatchOrdersMustHaveSameExchangeAddress = 'BATCH_ORDERS_MUST_HAVE_SAME_EXCHANGE_ADDRESS',
|
||||
BatchOrdersMustHaveAtLeastOneItem = 'BATCH_ORDERS_MUST_HAVE_AT_LEAST_ONE_ITEM',
|
||||
}
|
||||
|
||||
export interface ContractEvent {
|
||||
logIndex: number;
|
||||
transactionIndex: number;
|
||||
transactionHash: string;
|
||||
blockHash: string;
|
||||
blockNumber: number;
|
||||
address: string;
|
||||
type: string;
|
||||
event: string;
|
||||
args: ContractEventArgs;
|
||||
}
|
||||
|
||||
export type ContractEventArgs = ExchangeContractEventArgs | TokenContractEventArgs | EtherTokenContractEventArgs;
|
||||
|
||||
// [address, name, symbol, decimals, ipfsHash, swarmHash]
|
||||
export type TokenMetadata = [string, string, string, number, string, string];
|
||||
|
||||
export interface Token {
|
||||
name: string;
|
||||
address: string;
|
||||
symbol: string;
|
||||
decimals: number;
|
||||
}
|
||||
|
||||
export interface TxOpts {
|
||||
from: string;
|
||||
gas?: number;
|
||||
value?: BigNumber;
|
||||
gasPrice?: BigNumber;
|
||||
}
|
||||
|
||||
export interface TokenAddressBySymbol {
|
||||
[symbol: string]: string;
|
||||
}
|
||||
|
||||
export type ContractEvents = TokenEvents | ExchangeEvents | EtherTokenEvents;
|
||||
|
||||
export interface IndexedFilterValues {
|
||||
[index: string]: ContractEventArg;
|
||||
}
|
||||
|
||||
export interface BlockRange {
|
||||
fromBlock: BlockParam;
|
||||
toBlock: BlockParam;
|
||||
}
|
||||
|
||||
export type DoneCallback = (err?: Error) => void;
|
||||
|
||||
export interface OrderCancellationRequest {
|
||||
order: Order | SignedOrder;
|
||||
takerTokenCancelAmount: BigNumber;
|
||||
}
|
||||
|
||||
export interface OrderFillRequest {
|
||||
signedOrder: SignedOrder;
|
||||
takerTokenFillAmount: BigNumber;
|
||||
}
|
||||
|
||||
export type AsyncMethod = (...args: any[]) => Promise<any>;
|
||||
export type SyncMethod = (...args: any[]) => any;
|
||||
|
||||
/**
|
||||
* orderExpirationCheckingIntervalMs: How often to check for expired orders. Default=50.
|
||||
* eventPollingIntervalMs: How often to poll the Ethereum node for new events. Default=200.
|
||||
* expirationMarginMs: Amount of time before order expiry that you'd like to be notified
|
||||
* of an orders expiration. Default=0.
|
||||
* cleanupJobIntervalMs: How often to run a cleanup job which revalidates all the orders. Default=1hr.
|
||||
* stateLayer: Optional blockchain state layer OrderWatcher will monitor for new events. Default=latest.
|
||||
*/
|
||||
export interface OrderStateWatcherConfig {
|
||||
orderExpirationCheckingIntervalMs?: number;
|
||||
eventPollingIntervalMs?: number;
|
||||
expirationMarginMs?: number;
|
||||
cleanupJobIntervalMs?: number;
|
||||
stateLayer: BlockParamLiteral;
|
||||
}
|
||||
|
||||
/**
|
||||
* networkId: The id of the underlying ethereum network your provider is connected to. (1-mainnet, 3-ropsten, 4-rinkeby, 42-kovan, 50-testrpc)
|
||||
* gasPrice: Gas price to use with every transaction
|
||||
* exchangeContractAddress: The address of an exchange contract to use
|
||||
* zrxContractAddress: The address of the ZRX contract to use
|
||||
* tokenRegistryContractAddress: The address of a token registry contract to use
|
||||
* tokenTransferProxyContractAddress: The address of the token transfer proxy contract to use
|
||||
* orderWatcherConfig: All the configs related to the orderWatcher
|
||||
*/
|
||||
export interface ZeroExConfig {
|
||||
networkId: number;
|
||||
gasPrice?: BigNumber;
|
||||
exchangeContractAddress?: string;
|
||||
zrxContractAddress?: string;
|
||||
tokenRegistryContractAddress?: string;
|
||||
tokenTransferProxyContractAddress?: string;
|
||||
orderWatcherConfig?: OrderStateWatcherConfig;
|
||||
}
|
||||
|
||||
export type ArtifactContractName = 'ZRX' | 'TokenTransferProxy' | 'TokenRegistry' | 'Token' | 'Exchange' | 'EtherToken';
|
||||
|
||||
export interface Artifact {
|
||||
contract_name: ArtifactContractName;
|
||||
abi: ContractAbi;
|
||||
networks: {
|
||||
[networkId: number]: {
|
||||
address: string;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* expectedFillTakerTokenAmount: If specified, the validation method will ensure that the
|
||||
* supplied order maker has a sufficient allowance/balance to fill this amount of the order's
|
||||
* takerTokenAmount. If not specified, the validation method ensures that the maker has a sufficient
|
||||
* allowance/balance to fill the entire remaining order amount.
|
||||
*/
|
||||
export interface ValidateOrderFillableOpts {
|
||||
expectedFillTakerTokenAmount?: BigNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* defaultBlock: The block up to which to query the blockchain state. Setting this to a historical block number
|
||||
* let's the user query the blockchain's state at an arbitrary point in time. In order for this to work, the
|
||||
* backing Ethereum node must keep the entire historical state of the chain (e.g setting `--pruning=archive`
|
||||
* flag when running Parity).
|
||||
*/
|
||||
export interface MethodOpts {
|
||||
defaultBlock?: BlockParam;
|
||||
}
|
||||
|
||||
/**
|
||||
* gasPrice: Gas price in Wei to use for a transaction
|
||||
* gasLimit: The amount of gas to send with a transaction
|
||||
*/
|
||||
export interface TransactionOpts {
|
||||
gasPrice?: BigNumber;
|
||||
gasLimit?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* shouldValidate: Flag indicating whether the library should make attempts to validate a transaction before
|
||||
* broadcasting it. For example, order has a valid signature, maker has sufficient funds, etc. Default=true.
|
||||
*/
|
||||
export interface OrderTransactionOpts extends TransactionOpts {
|
||||
shouldValidate?: boolean;
|
||||
}
|
||||
|
||||
export enum TradeSide {
|
||||
Maker = 'maker',
|
||||
Taker = 'taker',
|
||||
}
|
||||
|
||||
export enum TransferType {
|
||||
Trade = 'trade',
|
||||
Fee = 'fee',
|
||||
}
|
||||
|
||||
export interface OrderRelevantState {
|
||||
makerBalance: BigNumber;
|
||||
makerProxyAllowance: BigNumber;
|
||||
makerFeeBalance: BigNumber;
|
||||
makerFeeProxyAllowance: BigNumber;
|
||||
filledTakerTokenAmount: BigNumber;
|
||||
cancelledTakerTokenAmount: BigNumber;
|
||||
remainingFillableMakerTokenAmount: BigNumber;
|
||||
remainingFillableTakerTokenAmount: BigNumber;
|
||||
}
|
||||
|
||||
export interface OrderStateValid {
|
||||
isValid: true;
|
||||
orderHash: string;
|
||||
orderRelevantState: OrderRelevantState;
|
||||
}
|
||||
|
||||
export interface OrderStateInvalid {
|
||||
isValid: false;
|
||||
orderHash: string;
|
||||
error: ExchangeContractErrs;
|
||||
}
|
||||
|
||||
export type OrderState = OrderStateValid | OrderStateInvalid;
|
||||
|
||||
export type OnOrderStateChangeCallback = (err: Error | null, orderState?: OrderState) => void;
|
||||
// tslint:disable:max-file-line-count
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
import { assert as sharedAssert } from '@0xproject/assert';
|
||||
// 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 } from '@0xproject/json-schemas';
|
||||
// tslint:disable-next-line:no-unused-variable
|
||||
import { ECSignature } from '@0xproject/types';
|
||||
import { BigNumber } from '@0xproject/utils';
|
||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { signatureUtils } from '../utils/signature_utils';
|
||||
|
||||
export const assert = {
|
||||
...sharedAssert,
|
||||
isValidSignature(orderHash: string, ecSignature: ECSignature, signerAddress: string) {
|
||||
const isValidSignature = signatureUtils.isValidSignature(orderHash, ecSignature, signerAddress);
|
||||
this.assert(isValidSignature, `Expected order with hash '${orderHash}' to have a valid signature`);
|
||||
},
|
||||
async isSenderAddressAsync(
|
||||
variableName: string,
|
||||
senderAddressHex: string,
|
||||
web3Wrapper: Web3Wrapper,
|
||||
): Promise<void> {
|
||||
sharedAssert.isETHAddressHex(variableName, senderAddressHex);
|
||||
const isSenderAddressAvailable = await web3Wrapper.isSenderAddressAvailableAsync(senderAddressHex);
|
||||
sharedAssert.assert(
|
||||
isSenderAddressAvailable,
|
||||
`Specified ${variableName} ${senderAddressHex} isn't available through the supplied web3 provider`,
|
||||
);
|
||||
},
|
||||
async isUserAddressAvailableAsync(web3Wrapper: Web3Wrapper): Promise<void> {
|
||||
const availableAddresses = await web3Wrapper.getAvailableAddressesAsync();
|
||||
this.assert(!_.isEmpty(availableAddresses), 'No addresses were available on the provided web3 provider');
|
||||
},
|
||||
};
|
||||
@@ -1,12 +1,4 @@
|
||||
import { BigNumber } from '@0xproject/utils';
|
||||
|
||||
export const constants = {
|
||||
NULL_ADDRESS: '0x0000000000000000000000000000000000000000',
|
||||
TESTRPC_NETWORK_ID: 50,
|
||||
MAX_DIGITS_IN_UNSIGNED_256_INT: 78,
|
||||
INVALID_JUMP_PATTERN: 'invalid JUMP at',
|
||||
OUT_OF_GAS_PATTERN: 'out of gas',
|
||||
INVALID_TAKER_FORMAT: 'instance.taker is not of a type(s) string',
|
||||
UNLIMITED_ALLOWANCE_IN_BASE_UNITS: new BigNumber(2).pow(256).minus(1),
|
||||
DEFAULT_BLOCK_POLLING_INTERVAL: 1000,
|
||||
};
|
||||
|
||||
@@ -1,138 +0,0 @@
|
||||
import { SignedOrder } from '@0xproject/types';
|
||||
import { BigNumber } from '@0xproject/utils';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { ZeroEx } from '../0x';
|
||||
import { BalanceAndProxyAllowanceFetcher } from '../abstract/balance_and_proxy_allowance_fetcher';
|
||||
import { OrderFilledCancelledFetcher } from '../abstract/order_filled_cancelled_fetcher';
|
||||
import { ExchangeWrapper } from '../contract_wrappers/exchange_wrapper';
|
||||
import { RemainingFillableCalculator } from '../order_watcher/remaining_fillable_calculator';
|
||||
import { ExchangeContractErrs, OrderRelevantState, OrderState, OrderStateInvalid, OrderStateValid } from '../types';
|
||||
|
||||
const ACCEPTABLE_RELATIVE_ROUNDING_ERROR = 0.0001;
|
||||
|
||||
export class OrderStateUtils {
|
||||
private _balanceAndProxyAllowanceFetcher: BalanceAndProxyAllowanceFetcher;
|
||||
private _orderFilledCancelledFetcher: OrderFilledCancelledFetcher;
|
||||
private static _validateIfOrderIsValid(signedOrder: SignedOrder, orderRelevantState: OrderRelevantState): void {
|
||||
const unavailableTakerTokenAmount = orderRelevantState.cancelledTakerTokenAmount.add(
|
||||
orderRelevantState.filledTakerTokenAmount,
|
||||
);
|
||||
const availableTakerTokenAmount = signedOrder.takerTokenAmount.minus(unavailableTakerTokenAmount);
|
||||
if (availableTakerTokenAmount.eq(0)) {
|
||||
throw new Error(ExchangeContractErrs.OrderRemainingFillAmountZero);
|
||||
}
|
||||
|
||||
if (orderRelevantState.makerBalance.eq(0)) {
|
||||
throw new Error(ExchangeContractErrs.InsufficientMakerBalance);
|
||||
}
|
||||
if (orderRelevantState.makerProxyAllowance.eq(0)) {
|
||||
throw new Error(ExchangeContractErrs.InsufficientMakerAllowance);
|
||||
}
|
||||
if (!signedOrder.makerFee.eq(0)) {
|
||||
if (orderRelevantState.makerFeeBalance.eq(0)) {
|
||||
throw new Error(ExchangeContractErrs.InsufficientMakerFeeBalance);
|
||||
}
|
||||
if (orderRelevantState.makerFeeProxyAllowance.eq(0)) {
|
||||
throw new Error(ExchangeContractErrs.InsufficientMakerFeeAllowance);
|
||||
}
|
||||
}
|
||||
const minFillableTakerTokenAmountWithinNoRoundingErrorRange = signedOrder.takerTokenAmount
|
||||
.dividedBy(ACCEPTABLE_RELATIVE_ROUNDING_ERROR)
|
||||
.dividedBy(signedOrder.makerTokenAmount);
|
||||
if (
|
||||
orderRelevantState.remainingFillableTakerTokenAmount.lessThan(
|
||||
minFillableTakerTokenAmountWithinNoRoundingErrorRange,
|
||||
)
|
||||
) {
|
||||
throw new Error(ExchangeContractErrs.OrderFillRoundingError);
|
||||
}
|
||||
}
|
||||
constructor(
|
||||
balanceAndProxyAllowanceFetcher: BalanceAndProxyAllowanceFetcher,
|
||||
orderFilledCancelledFetcher: OrderFilledCancelledFetcher,
|
||||
) {
|
||||
this._balanceAndProxyAllowanceFetcher = balanceAndProxyAllowanceFetcher;
|
||||
this._orderFilledCancelledFetcher = orderFilledCancelledFetcher;
|
||||
}
|
||||
public async getOrderStateAsync(signedOrder: SignedOrder): Promise<OrderState> {
|
||||
const orderRelevantState = await this.getOrderRelevantStateAsync(signedOrder);
|
||||
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
|
||||
try {
|
||||
OrderStateUtils._validateIfOrderIsValid(signedOrder, orderRelevantState);
|
||||
const orderState: OrderStateValid = {
|
||||
isValid: true,
|
||||
orderHash,
|
||||
orderRelevantState,
|
||||
};
|
||||
return orderState;
|
||||
} catch (err) {
|
||||
const orderState: OrderStateInvalid = {
|
||||
isValid: false,
|
||||
orderHash,
|
||||
error: err.message,
|
||||
};
|
||||
return orderState;
|
||||
}
|
||||
}
|
||||
public async getOrderRelevantStateAsync(signedOrder: SignedOrder): Promise<OrderRelevantState> {
|
||||
// HACK: We access the private property here but otherwise the interface will be less nice.
|
||||
// If we pass it from the instantiator - there is no opportunity to get it there
|
||||
// because JS doesn't support async constructors.
|
||||
// Moreover - it's cached under the hood so it's equivalent to an async constructor.
|
||||
const exchange = (this._orderFilledCancelledFetcher as any)._exchangeWrapper as ExchangeWrapper;
|
||||
const zrxTokenAddress = exchange.getZRXTokenAddress();
|
||||
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
|
||||
const makerBalance = await this._balanceAndProxyAllowanceFetcher.getBalanceAsync(
|
||||
signedOrder.makerTokenAddress,
|
||||
signedOrder.maker,
|
||||
);
|
||||
const makerProxyAllowance = await this._balanceAndProxyAllowanceFetcher.getProxyAllowanceAsync(
|
||||
signedOrder.makerTokenAddress,
|
||||
signedOrder.maker,
|
||||
);
|
||||
const makerFeeBalance = await this._balanceAndProxyAllowanceFetcher.getBalanceAsync(
|
||||
zrxTokenAddress,
|
||||
signedOrder.maker,
|
||||
);
|
||||
const makerFeeProxyAllowance = await this._balanceAndProxyAllowanceFetcher.getProxyAllowanceAsync(
|
||||
zrxTokenAddress,
|
||||
signedOrder.maker,
|
||||
);
|
||||
const filledTakerTokenAmount = await this._orderFilledCancelledFetcher.getFilledTakerAmountAsync(orderHash);
|
||||
const cancelledTakerTokenAmount = await this._orderFilledCancelledFetcher.getCancelledTakerAmountAsync(
|
||||
orderHash,
|
||||
);
|
||||
const unavailableTakerTokenAmount = await exchange.getUnavailableTakerAmountAsync(orderHash);
|
||||
const totalMakerTokenAmount = signedOrder.makerTokenAmount;
|
||||
const totalTakerTokenAmount = signedOrder.takerTokenAmount;
|
||||
const remainingTakerTokenAmount = totalTakerTokenAmount.minus(unavailableTakerTokenAmount);
|
||||
const remainingMakerTokenAmount = remainingTakerTokenAmount
|
||||
.times(totalMakerTokenAmount)
|
||||
.dividedToIntegerBy(totalTakerTokenAmount);
|
||||
const transferrableMakerTokenAmount = BigNumber.min([makerProxyAllowance, makerBalance]);
|
||||
const transferrableFeeTokenAmount = BigNumber.min([makerFeeProxyAllowance, makerFeeBalance]);
|
||||
|
||||
const isMakerTokenZRX = signedOrder.makerTokenAddress === zrxTokenAddress;
|
||||
const remainingFillableCalculator = new RemainingFillableCalculator(
|
||||
signedOrder,
|
||||
isMakerTokenZRX,
|
||||
transferrableMakerTokenAmount,
|
||||
transferrableFeeTokenAmount,
|
||||
remainingMakerTokenAmount,
|
||||
);
|
||||
const remainingFillableMakerTokenAmount = remainingFillableCalculator.computeRemainingMakerFillable();
|
||||
const remainingFillableTakerTokenAmount = remainingFillableCalculator.computeRemainingTakerFillable();
|
||||
const orderRelevantState = {
|
||||
makerBalance,
|
||||
makerProxyAllowance,
|
||||
makerFeeBalance,
|
||||
makerFeeProxyAllowance,
|
||||
filledTakerTokenAmount,
|
||||
cancelledTakerTokenAmount,
|
||||
remainingFillableMakerTokenAmount,
|
||||
remainingFillableTakerTokenAmount,
|
||||
};
|
||||
return orderRelevantState;
|
||||
}
|
||||
}
|
||||
@@ -1,217 +0,0 @@
|
||||
import { Order, SignedOrder } from '@0xproject/types';
|
||||
import { BigNumber } from '@0xproject/utils';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { ZeroEx } from '../0x';
|
||||
import { ExchangeWrapper } from '../contract_wrappers/exchange_wrapper';
|
||||
import { ExchangeContractErrs, TradeSide, TransferType, ZeroExError } from '../types';
|
||||
import { constants } from '../utils/constants';
|
||||
import { utils } from '../utils/utils';
|
||||
|
||||
import { ExchangeTransferSimulator } from './exchange_transfer_simulator';
|
||||
|
||||
export class OrderValidationUtils {
|
||||
private _exchangeWrapper: ExchangeWrapper;
|
||||
public static validateCancelOrderThrowIfInvalid(
|
||||
order: Order,
|
||||
cancelTakerTokenAmount: BigNumber,
|
||||
unavailableTakerTokenAmount: BigNumber,
|
||||
): void {
|
||||
if (cancelTakerTokenAmount.eq(0)) {
|
||||
throw new Error(ExchangeContractErrs.OrderCancelAmountZero);
|
||||
}
|
||||
if (order.takerTokenAmount.eq(unavailableTakerTokenAmount)) {
|
||||
throw new Error(ExchangeContractErrs.OrderAlreadyCancelledOrFilled);
|
||||
}
|
||||
const currentUnixTimestampSec = utils.getCurrentUnixTimestampSec();
|
||||
if (order.expirationUnixTimestampSec.lessThan(currentUnixTimestampSec)) {
|
||||
throw new Error(ExchangeContractErrs.OrderCancelExpired);
|
||||
}
|
||||
}
|
||||
public static async validateFillOrderBalancesAllowancesThrowIfInvalidAsync(
|
||||
exchangeTradeEmulator: ExchangeTransferSimulator,
|
||||
signedOrder: SignedOrder,
|
||||
fillTakerTokenAmount: BigNumber,
|
||||
senderAddress: string,
|
||||
zrxTokenAddress: string,
|
||||
): Promise<void> {
|
||||
const fillMakerTokenAmount = OrderValidationUtils._getPartialAmount(
|
||||
fillTakerTokenAmount,
|
||||
signedOrder.takerTokenAmount,
|
||||
signedOrder.makerTokenAmount,
|
||||
);
|
||||
await exchangeTradeEmulator.transferFromAsync(
|
||||
signedOrder.makerTokenAddress,
|
||||
signedOrder.maker,
|
||||
senderAddress,
|
||||
fillMakerTokenAmount,
|
||||
TradeSide.Maker,
|
||||
TransferType.Trade,
|
||||
);
|
||||
await exchangeTradeEmulator.transferFromAsync(
|
||||
signedOrder.takerTokenAddress,
|
||||
senderAddress,
|
||||
signedOrder.maker,
|
||||
fillTakerTokenAmount,
|
||||
TradeSide.Taker,
|
||||
TransferType.Trade,
|
||||
);
|
||||
const makerFeeAmount = OrderValidationUtils._getPartialAmount(
|
||||
fillTakerTokenAmount,
|
||||
signedOrder.takerTokenAmount,
|
||||
signedOrder.makerFee,
|
||||
);
|
||||
await exchangeTradeEmulator.transferFromAsync(
|
||||
zrxTokenAddress,
|
||||
signedOrder.maker,
|
||||
signedOrder.feeRecipient,
|
||||
makerFeeAmount,
|
||||
TradeSide.Maker,
|
||||
TransferType.Fee,
|
||||
);
|
||||
const takerFeeAmount = OrderValidationUtils._getPartialAmount(
|
||||
fillTakerTokenAmount,
|
||||
signedOrder.takerTokenAmount,
|
||||
signedOrder.takerFee,
|
||||
);
|
||||
await exchangeTradeEmulator.transferFromAsync(
|
||||
zrxTokenAddress,
|
||||
senderAddress,
|
||||
signedOrder.feeRecipient,
|
||||
takerFeeAmount,
|
||||
TradeSide.Taker,
|
||||
TransferType.Fee,
|
||||
);
|
||||
}
|
||||
private static _validateRemainingFillAmountNotZeroOrThrow(
|
||||
takerTokenAmount: BigNumber,
|
||||
unavailableTakerTokenAmount: BigNumber,
|
||||
) {
|
||||
if (takerTokenAmount.eq(unavailableTakerTokenAmount)) {
|
||||
throw new Error(ExchangeContractErrs.OrderRemainingFillAmountZero);
|
||||
}
|
||||
}
|
||||
private static _validateOrderNotExpiredOrThrow(expirationUnixTimestampSec: BigNumber) {
|
||||
const currentUnixTimestampSec = utils.getCurrentUnixTimestampSec();
|
||||
if (expirationUnixTimestampSec.lessThan(currentUnixTimestampSec)) {
|
||||
throw new Error(ExchangeContractErrs.OrderFillExpired);
|
||||
}
|
||||
}
|
||||
private static _getPartialAmount(numerator: BigNumber, denominator: BigNumber, target: BigNumber): BigNumber {
|
||||
const fillMakerTokenAmount = numerator
|
||||
.mul(target)
|
||||
.div(denominator)
|
||||
.round(0);
|
||||
return fillMakerTokenAmount;
|
||||
}
|
||||
constructor(exchangeWrapper: ExchangeWrapper) {
|
||||
this._exchangeWrapper = exchangeWrapper;
|
||||
}
|
||||
public async validateOrderFillableOrThrowAsync(
|
||||
exchangeTradeEmulator: ExchangeTransferSimulator,
|
||||
signedOrder: SignedOrder,
|
||||
zrxTokenAddress: string,
|
||||
expectedFillTakerTokenAmount?: BigNumber,
|
||||
): Promise<void> {
|
||||
const orderHash = utils.getOrderHashHex(signedOrder);
|
||||
const unavailableTakerTokenAmount = await this._exchangeWrapper.getUnavailableTakerAmountAsync(orderHash);
|
||||
OrderValidationUtils._validateRemainingFillAmountNotZeroOrThrow(
|
||||
signedOrder.takerTokenAmount,
|
||||
unavailableTakerTokenAmount,
|
||||
);
|
||||
OrderValidationUtils._validateOrderNotExpiredOrThrow(signedOrder.expirationUnixTimestampSec);
|
||||
let fillTakerTokenAmount = signedOrder.takerTokenAmount.minus(unavailableTakerTokenAmount);
|
||||
if (!_.isUndefined(expectedFillTakerTokenAmount)) {
|
||||
fillTakerTokenAmount = expectedFillTakerTokenAmount;
|
||||
}
|
||||
const fillMakerTokenAmount = OrderValidationUtils._getPartialAmount(
|
||||
fillTakerTokenAmount,
|
||||
signedOrder.takerTokenAmount,
|
||||
signedOrder.makerTokenAmount,
|
||||
);
|
||||
await exchangeTradeEmulator.transferFromAsync(
|
||||
signedOrder.makerTokenAddress,
|
||||
signedOrder.maker,
|
||||
signedOrder.taker,
|
||||
fillMakerTokenAmount,
|
||||
TradeSide.Maker,
|
||||
TransferType.Trade,
|
||||
);
|
||||
const makerFeeAmount = OrderValidationUtils._getPartialAmount(
|
||||
fillTakerTokenAmount,
|
||||
signedOrder.takerTokenAmount,
|
||||
signedOrder.makerFee,
|
||||
);
|
||||
await exchangeTradeEmulator.transferFromAsync(
|
||||
zrxTokenAddress,
|
||||
signedOrder.maker,
|
||||
signedOrder.feeRecipient,
|
||||
makerFeeAmount,
|
||||
TradeSide.Maker,
|
||||
TransferType.Fee,
|
||||
);
|
||||
}
|
||||
public async validateFillOrderThrowIfInvalidAsync(
|
||||
exchangeTradeEmulator: ExchangeTransferSimulator,
|
||||
signedOrder: SignedOrder,
|
||||
fillTakerTokenAmount: BigNumber,
|
||||
takerAddress: string,
|
||||
zrxTokenAddress: string,
|
||||
): Promise<BigNumber> {
|
||||
if (fillTakerTokenAmount.eq(0)) {
|
||||
throw new Error(ExchangeContractErrs.OrderFillAmountZero);
|
||||
}
|
||||
const orderHash = utils.getOrderHashHex(signedOrder);
|
||||
if (!ZeroEx.isValidSignature(orderHash, signedOrder.ecSignature, signedOrder.maker)) {
|
||||
throw new Error(ZeroExError.InvalidSignature);
|
||||
}
|
||||
const unavailableTakerTokenAmount = await this._exchangeWrapper.getUnavailableTakerAmountAsync(orderHash);
|
||||
OrderValidationUtils._validateRemainingFillAmountNotZeroOrThrow(
|
||||
signedOrder.takerTokenAmount,
|
||||
unavailableTakerTokenAmount,
|
||||
);
|
||||
if (signedOrder.taker !== constants.NULL_ADDRESS && signedOrder.taker !== takerAddress) {
|
||||
throw new Error(ExchangeContractErrs.TransactionSenderIsNotFillOrderTaker);
|
||||
}
|
||||
OrderValidationUtils._validateOrderNotExpiredOrThrow(signedOrder.expirationUnixTimestampSec);
|
||||
const remainingTakerTokenAmount = signedOrder.takerTokenAmount.minus(unavailableTakerTokenAmount);
|
||||
const filledTakerTokenAmount = remainingTakerTokenAmount.lessThan(fillTakerTokenAmount)
|
||||
? remainingTakerTokenAmount
|
||||
: fillTakerTokenAmount;
|
||||
await OrderValidationUtils.validateFillOrderBalancesAllowancesThrowIfInvalidAsync(
|
||||
exchangeTradeEmulator,
|
||||
signedOrder,
|
||||
filledTakerTokenAmount,
|
||||
takerAddress,
|
||||
zrxTokenAddress,
|
||||
);
|
||||
|
||||
const wouldRoundingErrorOccur = await this._exchangeWrapper.isRoundingErrorAsync(
|
||||
filledTakerTokenAmount,
|
||||
signedOrder.takerTokenAmount,
|
||||
signedOrder.makerTokenAmount,
|
||||
);
|
||||
if (wouldRoundingErrorOccur) {
|
||||
throw new Error(ExchangeContractErrs.OrderFillRoundingError);
|
||||
}
|
||||
return filledTakerTokenAmount;
|
||||
}
|
||||
public async validateFillOrKillOrderThrowIfInvalidAsync(
|
||||
exchangeTradeEmulator: ExchangeTransferSimulator,
|
||||
signedOrder: SignedOrder,
|
||||
fillTakerTokenAmount: BigNumber,
|
||||
takerAddress: string,
|
||||
zrxTokenAddress: string,
|
||||
): Promise<void> {
|
||||
const filledTakerTokenAmount = await this.validateFillOrderThrowIfInvalidAsync(
|
||||
exchangeTradeEmulator,
|
||||
signedOrder,
|
||||
fillTakerTokenAmount,
|
||||
takerAddress,
|
||||
zrxTokenAddress,
|
||||
);
|
||||
if (filledTakerTokenAmount !== fillTakerTokenAmount) {
|
||||
throw new Error(ExchangeContractErrs.InsufficientRemainingFillAmount);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
import { ECSignature } from '@0xproject/types';
|
||||
import * as ethUtil from 'ethereumjs-util';
|
||||
|
||||
export const signatureUtils = {
|
||||
isValidSignature(data: string, signature: ECSignature, signerAddress: string): boolean {
|
||||
const dataBuff = ethUtil.toBuffer(data);
|
||||
const msgHashBuff = ethUtil.hashPersonalMessage(dataBuff);
|
||||
try {
|
||||
const pubKey = ethUtil.ecrecover(
|
||||
msgHashBuff,
|
||||
signature.v,
|
||||
ethUtil.toBuffer(signature.r),
|
||||
ethUtil.toBuffer(signature.s),
|
||||
);
|
||||
const retrievedAddress = ethUtil.bufferToHex(ethUtil.pubToAddress(pubKey));
|
||||
return retrievedAddress === signerAddress;
|
||||
} catch (err) {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
parseSignatureHexAsVRS(signatureHex: string): ECSignature {
|
||||
const signatureBuffer = ethUtil.toBuffer(signatureHex);
|
||||
let v = signatureBuffer[0];
|
||||
if (v < 27) {
|
||||
v += 27;
|
||||
}
|
||||
const r = signatureBuffer.slice(1, 33);
|
||||
const s = signatureBuffer.slice(33, 65);
|
||||
const ecSignature: ECSignature = {
|
||||
v,
|
||||
r: ethUtil.bufferToHex(r),
|
||||
s: ethUtil.bufferToHex(s),
|
||||
};
|
||||
return ecSignature;
|
||||
},
|
||||
parseSignatureHexAsRSV(signatureHex: string): ECSignature {
|
||||
const { v, r, s } = ethUtil.fromRpcSig(signatureHex);
|
||||
const ecSignature: ECSignature = {
|
||||
v,
|
||||
r: ethUtil.bufferToHex(r),
|
||||
s: ethUtil.bufferToHex(s),
|
||||
};
|
||||
return ecSignature;
|
||||
},
|
||||
};
|
||||
@@ -1,63 +0,0 @@
|
||||
import { Order, SignedOrder, SolidityTypes } from '@0xproject/types';
|
||||
import { BigNumber } from '@0xproject/utils';
|
||||
import BN = require('bn.js');
|
||||
import * as ethABI from 'ethereumjs-abi';
|
||||
import * as ethUtil from 'ethereumjs-util';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
export const utils = {
|
||||
/**
|
||||
* Converts BigNumber instance to BN
|
||||
* The only reason we convert to BN is to remain compatible with `ethABI. soliditySHA3` that
|
||||
* expects values of Solidity type `uint` to be passed as type `BN`.
|
||||
* We do not use BN anywhere else in the codebase.
|
||||
*/
|
||||
bigNumberToBN(value: BigNumber) {
|
||||
return new BN(value.toString(), 10);
|
||||
},
|
||||
spawnSwitchErr(name: string, value: any): Error {
|
||||
return new Error(`Unexpected switch value: ${value} encountered for ${name}`);
|
||||
},
|
||||
getOrderHashHex(order: Order | SignedOrder): string {
|
||||
const orderParts = [
|
||||
{ value: order.exchangeContractAddress, type: SolidityTypes.Address },
|
||||
{ value: order.maker, type: SolidityTypes.Address },
|
||||
{ value: order.taker, type: SolidityTypes.Address },
|
||||
{ value: order.makerTokenAddress, type: SolidityTypes.Address },
|
||||
{ value: order.takerTokenAddress, type: SolidityTypes.Address },
|
||||
{ value: order.feeRecipient, type: SolidityTypes.Address },
|
||||
{
|
||||
value: utils.bigNumberToBN(order.makerTokenAmount),
|
||||
type: SolidityTypes.Uint256,
|
||||
},
|
||||
{
|
||||
value: utils.bigNumberToBN(order.takerTokenAmount),
|
||||
type: SolidityTypes.Uint256,
|
||||
},
|
||||
{
|
||||
value: utils.bigNumberToBN(order.makerFee),
|
||||
type: SolidityTypes.Uint256,
|
||||
},
|
||||
{
|
||||
value: utils.bigNumberToBN(order.takerFee),
|
||||
type: SolidityTypes.Uint256,
|
||||
},
|
||||
{
|
||||
value: utils.bigNumberToBN(order.expirationUnixTimestampSec),
|
||||
type: SolidityTypes.Uint256,
|
||||
},
|
||||
{ value: utils.bigNumberToBN(order.salt), type: SolidityTypes.Uint256 },
|
||||
];
|
||||
const types = _.map(orderParts, o => o.type);
|
||||
const values = _.map(orderParts, o => o.value);
|
||||
const hashBuff = ethABI.soliditySHA3(types, values);
|
||||
const hashHex = ethUtil.bufferToHex(hashBuff);
|
||||
return hashHex;
|
||||
},
|
||||
getCurrentUnixTimestampSec(): BigNumber {
|
||||
return new BigNumber(Date.now() / 1000).round();
|
||||
},
|
||||
getCurrentUnixTimestampMs(): BigNumber {
|
||||
return new BigNumber(Date.now());
|
||||
},
|
||||
};
|
||||
@@ -1,34 +1,23 @@
|
||||
import { Deployer } from '@0xproject/deployer';
|
||||
import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils';
|
||||
// HACK: This dependency is optional since it is only available when run from within
|
||||
// the monorepo. tslint doesn't handle optional dependencies
|
||||
// tslint:disable-next-line:no-implicit-dependencies
|
||||
import { runMigrationsAsync } from '@0xproject/migrations';
|
||||
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 * as path from 'path';
|
||||
import * as Sinon from 'sinon';
|
||||
|
||||
import { ApprovalContractEventArgs, LogWithDecodedArgs, Order, TokenEvents, ZeroEx } from '../src';
|
||||
import { ERC20TokenApprovalEventArgs, ERC20TokenEvents, LogWithDecodedArgs, ZeroEx } from '../src';
|
||||
|
||||
import { chaiSetup } from './utils/chai_setup';
|
||||
import { constants } from './utils/constants';
|
||||
import { deployer } from './utils/deployer';
|
||||
import { TokenUtils } from './utils/token_utils';
|
||||
import { tokenUtils } from './utils/token_utils';
|
||||
import { provider, web3Wrapper } from './utils/web3_wrapper';
|
||||
|
||||
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
||||
chaiSetup.configure();
|
||||
const expect = chai.expect;
|
||||
|
||||
const SHOULD_ADD_PERSONAL_MESSAGE_PREFIX = false;
|
||||
|
||||
describe('ZeroEx library', () => {
|
||||
let zeroEx: ZeroEx;
|
||||
before(async () => {
|
||||
await runMigrationsAsync(deployer);
|
||||
const config = {
|
||||
networkId: constants.TESTRPC_NETWORK_ID,
|
||||
};
|
||||
@@ -38,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;
|
||||
@@ -48,83 +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 web3 wrapper instances return the updated provider
|
||||
const nestedWeb3WrapperProvider = (zeroEx as any)._web3Wrapper.getProvider();
|
||||
expect(nestedWeb3WrapperProvider.zeroExTestId).to.be.a('number');
|
||||
// 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 () => {
|
||||
expect(ZeroEx.isValidSignature('0x0', signature, address)).to.be.false();
|
||||
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';
|
||||
expect(ZeroEx.isValidSignature(dataHex, signature, validUnrelatedAddress)).to.be.false();
|
||||
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 });
|
||||
expect(ZeroEx.isValidSignature(dataHex, wrongSignature, address)).to.be.false();
|
||||
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 () => {
|
||||
const isValidSignatureLocal = ZeroEx.isValidSignature(dataHex, signature, address);
|
||||
expect(isValidSignatureLocal).to.be.true();
|
||||
return expect(
|
||||
(zeroEx.exchange as any)._isValidSignatureUsingContractCallAsync(dataHex, signature, address),
|
||||
).to.become(true);
|
||||
});
|
||||
});
|
||||
describe('#generateSalt', () => {
|
||||
it('generates different salts', () => {
|
||||
const equal = ZeroEx.generatePseudoRandomSalt().eq(ZeroEx.generatePseudoRandomSalt());
|
||||
expect(equal).to.be.false();
|
||||
});
|
||||
it('generates salt in range [0..2^256)', () => {
|
||||
const salt = ZeroEx.generatePseudoRandomSalt();
|
||||
expect(salt.greaterThanOrEqualTo(0)).to.be.true();
|
||||
const twoPow256 = new BigNumber(2).pow(256);
|
||||
expect(salt.lessThan(twoPow256)).to.be.true();
|
||||
});
|
||||
});
|
||||
describe('#isValidOrderHash', () => {
|
||||
it('returns false if the value is not a hex string', () => {
|
||||
const isValid = ZeroEx.isValidOrderHash('not a hex');
|
||||
expect(isValid).to.be.false();
|
||||
});
|
||||
it('returns false if the length is wrong', () => {
|
||||
const isValid = ZeroEx.isValidOrderHash('0xdeadbeef');
|
||||
expect(isValid).to.be.false();
|
||||
});
|
||||
it('returns true if order hash is correct', () => {
|
||||
const isValid = ZeroEx.isValidOrderHash('0x' + Array(65).join('0'));
|
||||
expect(isValid).to.be.true();
|
||||
return expect((zeroEx.exchange as any).isValidSignatureAsync(dataHex, address, ethSignSignature)).to.become(
|
||||
true,
|
||||
);
|
||||
});
|
||||
});
|
||||
describe('#toUnitAmount', () => {
|
||||
@@ -159,106 +106,6 @@ describe('ZeroEx library', () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
describe('#getOrderHashHex', () => {
|
||||
const expectedOrderHash = '0x39da987067a3c9e5f1617694f1301326ba8c8b0498ebef5df4863bed394e3c83';
|
||||
const fakeExchangeContractAddress = '0xb69e673309512a9d726f87304c6984054f87a93b';
|
||||
const order: Order = {
|
||||
maker: constants.NULL_ADDRESS,
|
||||
taker: constants.NULL_ADDRESS,
|
||||
feeRecipient: constants.NULL_ADDRESS,
|
||||
makerTokenAddress: constants.NULL_ADDRESS,
|
||||
takerTokenAddress: constants.NULL_ADDRESS,
|
||||
exchangeContractAddress: fakeExchangeContractAddress,
|
||||
salt: new BigNumber(0),
|
||||
makerFee: new BigNumber(0),
|
||||
takerFee: new BigNumber(0),
|
||||
makerTokenAmount: new BigNumber(0),
|
||||
takerTokenAmount: new BigNumber(0),
|
||||
expirationUnixTimestampSec: new BigNumber(0),
|
||||
};
|
||||
it('calculates the order hash', async () => {
|
||||
const orderHash = ZeroEx.getOrderHashHex(order);
|
||||
expect(orderHash).to.be.equal(expectedOrderHash);
|
||||
});
|
||||
it('throws a readable error message if taker format is invalid', async () => {
|
||||
const orderWithInvalidtakerFormat = {
|
||||
...order,
|
||||
taker: (null as any) as string,
|
||||
};
|
||||
const expectedErrorMessage =
|
||||
'Order taker must be of type string. If you want anyone to be able to fill an order - pass ZeroEx.NULL_ADDRESS';
|
||||
expect(() => ZeroEx.getOrderHashHex(orderWithInvalidtakerFormat)).to.throw(expectedErrorMessage);
|
||||
});
|
||||
});
|
||||
describe('#signOrderHashAsync', () => {
|
||||
let stubs: Sinon.SinonStub[] = [];
|
||||
let makerAddress: string;
|
||||
before(async () => {
|
||||
const availableAddreses = await zeroEx.getAvailableAddressesAsync();
|
||||
makerAddress = availableAddreses[0];
|
||||
});
|
||||
afterEach(() => {
|
||||
// clean up any stubs after the test has completed
|
||||
_.each(stubs, s => s.restore());
|
||||
stubs = [];
|
||||
});
|
||||
it('Should return the correct ECSignature', async () => {
|
||||
const orderHash = '0x6927e990021d23b1eb7b8789f6a6feaf98fe104bb0cf8259421b79f9a34222b0';
|
||||
const expectedECSignature = {
|
||||
v: 27,
|
||||
r: '0x61a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33',
|
||||
s: '0x40349190569279751135161d22529dc25add4f6069af05be04cacbda2ace2254',
|
||||
};
|
||||
const ecSignature = await zeroEx.signOrderHashAsync(
|
||||
orderHash,
|
||||
makerAddress,
|
||||
SHOULD_ADD_PERSONAL_MESSAGE_PREFIX,
|
||||
);
|
||||
expect(ecSignature).to.deep.equal(expectedECSignature);
|
||||
});
|
||||
it('should return the correct ECSignature for signatureHex concatenated as R + S + V', async () => {
|
||||
const orderHash = '0x34decbedc118904df65f379a175bb39ca18209d6ce41d5ed549d54e6e0a95004';
|
||||
const signature =
|
||||
'0x22109d11d79cb8bf96ed88625e1cd9558800c4073332a9a02857499883ee5ce3050aa3cc1f2c435e67e114cdce54b9527b4f50548342401bc5d2b77adbdacb021b';
|
||||
const expectedECSignature = {
|
||||
v: 27,
|
||||
r: '0x22109d11d79cb8bf96ed88625e1cd9558800c4073332a9a02857499883ee5ce3',
|
||||
s: '0x050aa3cc1f2c435e67e114cdce54b9527b4f50548342401bc5d2b77adbdacb02',
|
||||
};
|
||||
stubs = [
|
||||
Sinon.stub((zeroEx as any)._web3Wrapper, 'signMessageAsync').returns(Promise.resolve(signature)),
|
||||
Sinon.stub(ZeroEx, 'isValidSignature').returns(true),
|
||||
];
|
||||
|
||||
const ecSignature = await zeroEx.signOrderHashAsync(
|
||||
orderHash,
|
||||
makerAddress,
|
||||
SHOULD_ADD_PERSONAL_MESSAGE_PREFIX,
|
||||
);
|
||||
expect(ecSignature).to.deep.equal(expectedECSignature);
|
||||
});
|
||||
it('should return the correct ECSignature for signatureHex concatenated as V + R + S', async () => {
|
||||
const orderHash = '0xc793e33ffded933b76f2f48d9aa3339fc090399d5e7f5dec8d3660f5480793f7';
|
||||
const signature =
|
||||
'0x1bc80bedc6756722672753413efdd749b5adbd4fd552595f59c13427407ee9aee02dea66f25a608bbae457e020fb6decb763deb8b7192abab624997242da248960';
|
||||
const expectedECSignature = {
|
||||
v: 27,
|
||||
r: '0xc80bedc6756722672753413efdd749b5adbd4fd552595f59c13427407ee9aee0',
|
||||
s: '0x2dea66f25a608bbae457e020fb6decb763deb8b7192abab624997242da248960',
|
||||
};
|
||||
stubs = [
|
||||
Sinon.stub((zeroEx as any)._web3Wrapper, 'signMessageAsync').returns(Promise.resolve(signature)),
|
||||
Sinon.stub(ZeroEx, 'isValidSignature').returns(true),
|
||||
];
|
||||
|
||||
const ecSignature = await zeroEx.signOrderHashAsync(
|
||||
orderHash,
|
||||
makerAddress,
|
||||
SHOULD_ADD_PERSONAL_MESSAGE_PREFIX,
|
||||
);
|
||||
expect(ecSignature).to.deep.equal(expectedECSignature);
|
||||
});
|
||||
});
|
||||
describe('#awaitTransactionMinedAsync', () => {
|
||||
beforeEach(async () => {
|
||||
await blockchainLifecycle.startAsync();
|
||||
@@ -269,17 +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);
|
||||
const log = txReceiptWithDecodedLogs.logs[0] as LogWithDecodedArgs<ApprovalContractEventArgs>;
|
||||
expect(log.event).to.be.equal(TokenEvents.Approval);
|
||||
// tslint:disable-next-line:no-unnecessary-type-assertion
|
||||
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', () => {
|
||||
@@ -291,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,49 +0,0 @@
|
||||
import { web3Factory } from '@0xproject/dev-utils';
|
||||
import * as fs from 'fs';
|
||||
|
||||
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.create({ rpcUrl: kovanRpcUrl }).currentProvider;
|
||||
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.create({ rpcUrl: ropstenRpcUrl }).currentProvider;
|
||||
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,43 +0,0 @@
|
||||
import { web3Factory } from '@0xproject/dev-utils';
|
||||
import * as chai from 'chai';
|
||||
import 'mocha';
|
||||
|
||||
import { ZeroEx } from '../src';
|
||||
import { assert } from '../src/utils/assert';
|
||||
|
||||
import { constants } from './utils/constants';
|
||||
import { provider } from './utils/web3_wrapper';
|
||||
|
||||
const expect = chai.expect;
|
||||
|
||||
describe('Assertion library', () => {
|
||||
const config = {
|
||||
networkId: constants.TESTRPC_NETWORK_ID,
|
||||
};
|
||||
const zeroEx = new ZeroEx(provider, config);
|
||||
describe('#isSenderAddressHexAsync', () => {
|
||||
it('throws when address is invalid', async () => {
|
||||
const address = '0xdeadbeef';
|
||||
const varName = 'address';
|
||||
return expect(
|
||||
assert.isSenderAddressAsync(varName, address, (zeroEx as any)._web3Wrapper),
|
||||
).to.be.rejectedWith(`Expected ${varName} to be of type ETHAddressHex, encountered: ${address}`);
|
||||
});
|
||||
it('throws when address is unavailable', async () => {
|
||||
const validUnrelatedAddress = '0x8b0292b11a196601eddce54b665cafeca0347d42';
|
||||
const varName = 'address';
|
||||
return expect(
|
||||
assert.isSenderAddressAsync(varName, validUnrelatedAddress, (zeroEx as any)._web3Wrapper),
|
||||
).to.be.rejectedWith(
|
||||
`Specified ${varName} ${validUnrelatedAddress} isn't available through the supplied web3 provider`,
|
||||
);
|
||||
});
|
||||
it("doesn't throw if address is available", async () => {
|
||||
const availableAddress = (await zeroEx.getAvailableAddressesAsync())[0];
|
||||
const varName = 'address';
|
||||
return expect(
|
||||
assert.isSenderAddressAsync(varName, availableAddress, (zeroEx as any)._web3Wrapper),
|
||||
).to.become(undefined);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,125 +0,0 @@
|
||||
import { web3Factory } from '@0xproject/dev-utils';
|
||||
import { LogEntry } from '@0xproject/types';
|
||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||
import * as chai from 'chai';
|
||||
import * as _ from 'lodash';
|
||||
import 'mocha';
|
||||
import * as Sinon from 'sinon';
|
||||
|
||||
import { LogEvent } from '../src';
|
||||
import { EventWatcher } from '../src/order_watcher/event_watcher';
|
||||
import { DoneCallback } from '../src/types';
|
||||
|
||||
import { chaiSetup } from './utils/chai_setup';
|
||||
import { reportNodeCallbackErrors } from './utils/report_callback_errors';
|
||||
import { provider } from './utils/web3_wrapper';
|
||||
|
||||
chaiSetup.configure();
|
||||
const expect = chai.expect;
|
||||
|
||||
describe('EventWatcher', () => {
|
||||
let stubs: Sinon.SinonStub[] = [];
|
||||
let eventWatcher: EventWatcher;
|
||||
let web3Wrapper: Web3Wrapper;
|
||||
const logA: LogEntry = {
|
||||
address: '0x71d271f8b14adef568f8f28f1587ce7271ac4ca5',
|
||||
blockHash: null,
|
||||
blockNumber: null,
|
||||
data: '',
|
||||
logIndex: null,
|
||||
topics: [],
|
||||
transactionHash: '0x004881d38cd4a8f72f1a0d68c8b9b8124504706041ff37019c1d1ed6bfda8e17',
|
||||
transactionIndex: 0,
|
||||
};
|
||||
const logB: LogEntry = {
|
||||
address: '0x8d12a197cb00d4747a1fe03395095ce2a5cc6819',
|
||||
blockHash: null,
|
||||
blockNumber: null,
|
||||
data: '',
|
||||
logIndex: null,
|
||||
topics: ['0xf341246adaac6f497bc2a656f546ab9e182111d630394f0c57c710a59a2cb567'],
|
||||
transactionHash: '0x01ef3c048b18d9b09ea195b4ed94cf8dd5f3d857a1905ff886b152cfb1166f25',
|
||||
transactionIndex: 0,
|
||||
};
|
||||
const logC: LogEntry = {
|
||||
address: '0x1d271f8b174adef58f1587ce68f8f27271ac4ca5',
|
||||
blockHash: null,
|
||||
blockNumber: null,
|
||||
data: '',
|
||||
logIndex: null,
|
||||
topics: ['0xf341246adaac6f497bc2a656f546ab9e182111d630394f0c57c710a59a2cb567'],
|
||||
transactionHash: '0x01ef3c048b18d9b09ea195b4ed94cf8dd5f3d857a1905ff886b152cfb1166f25',
|
||||
transactionIndex: 0,
|
||||
};
|
||||
before(async () => {
|
||||
const pollingIntervalMs = 10;
|
||||
web3Wrapper = new Web3Wrapper(provider);
|
||||
eventWatcher = new EventWatcher(web3Wrapper, pollingIntervalMs);
|
||||
});
|
||||
afterEach(() => {
|
||||
// clean up any stubs after the test has completed
|
||||
_.each(stubs, s => s.restore());
|
||||
stubs = [];
|
||||
eventWatcher.unsubscribe();
|
||||
});
|
||||
it('correctly emits initial log events', (done: DoneCallback) => {
|
||||
const logs: LogEntry[] = [logA, logB];
|
||||
const expectedLogEvents = [
|
||||
{
|
||||
removed: false,
|
||||
...logA,
|
||||
},
|
||||
{
|
||||
removed: false,
|
||||
...logB,
|
||||
},
|
||||
];
|
||||
const getLogsStub = Sinon.stub(web3Wrapper, 'getLogsAsync');
|
||||
getLogsStub.onCall(0).returns(logs);
|
||||
stubs.push(getLogsStub);
|
||||
const expectedToBeCalledOnce = false;
|
||||
const callback = reportNodeCallbackErrors(done, expectedToBeCalledOnce)((event: LogEvent) => {
|
||||
const expectedLogEvent = expectedLogEvents.shift();
|
||||
expect(event).to.be.deep.equal(expectedLogEvent);
|
||||
if (_.isEmpty(expectedLogEvents)) {
|
||||
done();
|
||||
}
|
||||
});
|
||||
eventWatcher.subscribe(callback);
|
||||
});
|
||||
it('correctly computes the difference and emits only changes', (done: DoneCallback) => {
|
||||
const initialLogs: LogEntry[] = [logA, logB];
|
||||
const changedLogs: LogEntry[] = [logA, logC];
|
||||
const expectedLogEvents = [
|
||||
{
|
||||
removed: false,
|
||||
...logA,
|
||||
},
|
||||
{
|
||||
removed: false,
|
||||
...logB,
|
||||
},
|
||||
{
|
||||
removed: true,
|
||||
...logB,
|
||||
},
|
||||
{
|
||||
removed: false,
|
||||
...logC,
|
||||
},
|
||||
];
|
||||
const getLogsStub = Sinon.stub(web3Wrapper, 'getLogsAsync');
|
||||
getLogsStub.onCall(0).returns(initialLogs);
|
||||
getLogsStub.onCall(1).returns(changedLogs);
|
||||
stubs.push(getLogsStub);
|
||||
const expectedToBeCalledOnce = false;
|
||||
const callback = reportNodeCallbackErrors(done, expectedToBeCalledOnce)((event: LogEvent) => {
|
||||
const expectedLogEvent = expectedLogEvents.shift();
|
||||
expect(event).to.be.deep.equal(expectedLogEvent);
|
||||
if (_.isEmpty(expectedLogEvents)) {
|
||||
done();
|
||||
}
|
||||
});
|
||||
eventWatcher.subscribe(callback);
|
||||
});
|
||||
});
|
||||
@@ -1,117 +0,0 @@
|
||||
import { BlockchainLifecycle, devConstants } from '@0xproject/dev-utils';
|
||||
import { BlockParamLiteral } from '@0xproject/types';
|
||||
import { BigNumber } from '@0xproject/utils';
|
||||
import * as chai from 'chai';
|
||||
|
||||
import { ExchangeContractErrs, Token, ZeroEx } from '../src';
|
||||
import { TradeSide, TransferType } from '../src/types';
|
||||
import { ExchangeTransferSimulator } from '../src/utils/exchange_transfer_simulator';
|
||||
|
||||
import { chaiSetup } from './utils/chai_setup';
|
||||
import { constants } from './utils/constants';
|
||||
import { provider, web3Wrapper } from './utils/web3_wrapper';
|
||||
|
||||
chaiSetup.configure();
|
||||
const expect = chai.expect;
|
||||
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
||||
|
||||
describe('ExchangeTransferSimulator', () => {
|
||||
const config = {
|
||||
networkId: constants.TESTRPC_NETWORK_ID,
|
||||
};
|
||||
const zeroEx = new ZeroEx(provider, config);
|
||||
const transferAmount = new BigNumber(5);
|
||||
let userAddresses: string[];
|
||||
let tokens: Token[];
|
||||
let coinbase: string;
|
||||
let sender: string;
|
||||
let recipient: string;
|
||||
let exampleTokenAddress: string;
|
||||
let exchangeTransferSimulator: ExchangeTransferSimulator;
|
||||
let txHash: string;
|
||||
before(async () => {
|
||||
userAddresses = await zeroEx.getAvailableAddressesAsync();
|
||||
[coinbase, sender, recipient] = userAddresses;
|
||||
tokens = await zeroEx.tokenRegistry.getTokensAsync();
|
||||
exampleTokenAddress = tokens[0].address;
|
||||
});
|
||||
beforeEach(async () => {
|
||||
await blockchainLifecycle.startAsync();
|
||||
});
|
||||
afterEach(async () => {
|
||||
await blockchainLifecycle.revertAsync();
|
||||
});
|
||||
describe('#transferFromAsync', () => {
|
||||
beforeEach(() => {
|
||||
exchangeTransferSimulator = new ExchangeTransferSimulator(zeroEx.token, BlockParamLiteral.Latest);
|
||||
});
|
||||
it("throws if the user doesn't have enough allowance", async () => {
|
||||
return expect(
|
||||
exchangeTransferSimulator.transferFromAsync(
|
||||
exampleTokenAddress,
|
||||
sender,
|
||||
recipient,
|
||||
transferAmount,
|
||||
TradeSide.Taker,
|
||||
TransferType.Trade,
|
||||
),
|
||||
).to.be.rejectedWith(ExchangeContractErrs.InsufficientTakerAllowance);
|
||||
});
|
||||
it("throws if the user doesn't have enough balance", async () => {
|
||||
txHash = await zeroEx.token.setProxyAllowanceAsync(exampleTokenAddress, sender, transferAmount);
|
||||
await zeroEx.awaitTransactionMinedAsync(txHash);
|
||||
return expect(
|
||||
exchangeTransferSimulator.transferFromAsync(
|
||||
exampleTokenAddress,
|
||||
sender,
|
||||
recipient,
|
||||
transferAmount,
|
||||
TradeSide.Maker,
|
||||
TransferType.Trade,
|
||||
),
|
||||
).to.be.rejectedWith(ExchangeContractErrs.InsufficientMakerBalance);
|
||||
});
|
||||
it('updates balances and proxyAllowance after transfer', async () => {
|
||||
txHash = await zeroEx.token.transferAsync(exampleTokenAddress, coinbase, sender, transferAmount);
|
||||
await zeroEx.awaitTransactionMinedAsync(txHash);
|
||||
txHash = await zeroEx.token.setProxyAllowanceAsync(exampleTokenAddress, sender, transferAmount);
|
||||
await zeroEx.awaitTransactionMinedAsync(txHash);
|
||||
await exchangeTransferSimulator.transferFromAsync(
|
||||
exampleTokenAddress,
|
||||
sender,
|
||||
recipient,
|
||||
transferAmount,
|
||||
TradeSide.Taker,
|
||||
TransferType.Trade,
|
||||
);
|
||||
const store = (exchangeTransferSimulator as any)._store;
|
||||
const senderBalance = await store.getBalanceAsync(exampleTokenAddress, sender);
|
||||
const recipientBalance = await store.getBalanceAsync(exampleTokenAddress, recipient);
|
||||
const senderProxyAllowance = await store.getProxyAllowanceAsync(exampleTokenAddress, sender);
|
||||
expect(senderBalance).to.be.bignumber.equal(0);
|
||||
expect(recipientBalance).to.be.bignumber.equal(transferAmount);
|
||||
expect(senderProxyAllowance).to.be.bignumber.equal(0);
|
||||
});
|
||||
it("doesn't update proxyAllowance after transfer if unlimited", async () => {
|
||||
txHash = await zeroEx.token.transferAsync(exampleTokenAddress, coinbase, sender, transferAmount);
|
||||
await zeroEx.awaitTransactionMinedAsync(txHash);
|
||||
txHash = await zeroEx.token.setUnlimitedProxyAllowanceAsync(exampleTokenAddress, sender);
|
||||
await zeroEx.awaitTransactionMinedAsync(txHash);
|
||||
await exchangeTransferSimulator.transferFromAsync(
|
||||
exampleTokenAddress,
|
||||
sender,
|
||||
recipient,
|
||||
transferAmount,
|
||||
TradeSide.Taker,
|
||||
TransferType.Trade,
|
||||
);
|
||||
const store = (exchangeTransferSimulator as any)._store;
|
||||
const senderBalance = await store.getBalanceAsync(exampleTokenAddress, sender);
|
||||
const recipientBalance = await store.getBalanceAsync(exampleTokenAddress, recipient);
|
||||
const senderProxyAllowance = await store.getProxyAllowanceAsync(exampleTokenAddress, sender);
|
||||
expect(senderBalance).to.be.bignumber.equal(0);
|
||||
expect(recipientBalance).to.be.bignumber.equal(transferAmount);
|
||||
expect(senderProxyAllowance).to.be.bignumber.equal(zeroEx.token.UNLIMITED_ALLOWANCE_IN_BASE_UNITS);
|
||||
});
|
||||
});
|
||||
});
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,156 +0,0 @@
|
||||
import { BlockchainLifecycle, devConstants } from '@0xproject/dev-utils';
|
||||
import { BigNumber } from '@0xproject/utils';
|
||||
import * as chai from 'chai';
|
||||
import * as _ from 'lodash';
|
||||
import 'mocha';
|
||||
import * as Sinon from 'sinon';
|
||||
|
||||
import { ZeroEx } from '../src/0x';
|
||||
import { ExpirationWatcher } from '../src/order_watcher/expiration_watcher';
|
||||
import { DoneCallback, Token } from '../src/types';
|
||||
import { utils } from '../src/utils/utils';
|
||||
|
||||
import { chaiSetup } from './utils/chai_setup';
|
||||
import { constants } from './utils/constants';
|
||||
import { FillScenarios } from './utils/fill_scenarios';
|
||||
import { reportNoErrorCallbackErrors } from './utils/report_callback_errors';
|
||||
import { TokenUtils } from './utils/token_utils';
|
||||
import { provider, web3Wrapper } from './utils/web3_wrapper';
|
||||
|
||||
chaiSetup.configure();
|
||||
const expect = chai.expect;
|
||||
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
||||
|
||||
describe('ExpirationWatcher', () => {
|
||||
let zeroEx: ZeroEx;
|
||||
let tokenUtils: TokenUtils;
|
||||
let tokens: Token[];
|
||||
let userAddresses: string[];
|
||||
let zrxTokenAddress: string;
|
||||
let fillScenarios: FillScenarios;
|
||||
let exchangeContractAddress: string;
|
||||
let makerTokenAddress: string;
|
||||
let takerTokenAddress: string;
|
||||
let coinbase: string;
|
||||
let makerAddress: string;
|
||||
let takerAddress: string;
|
||||
let feeRecipient: string;
|
||||
const fillableAmount = new BigNumber(5);
|
||||
let currentUnixTimestampSec: BigNumber;
|
||||
let timer: Sinon.SinonFakeTimers;
|
||||
let expirationWatcher: ExpirationWatcher;
|
||||
before(async () => {
|
||||
const config = {
|
||||
networkId: constants.TESTRPC_NETWORK_ID,
|
||||
};
|
||||
zeroEx = new ZeroEx(provider, config);
|
||||
exchangeContractAddress = zeroEx.exchange.getContractAddress();
|
||||
userAddresses = await zeroEx.getAvailableAddressesAsync();
|
||||
tokens = await zeroEx.tokenRegistry.getTokensAsync();
|
||||
tokenUtils = new TokenUtils(tokens);
|
||||
zrxTokenAddress = tokenUtils.getProtocolTokenOrThrow().address;
|
||||
fillScenarios = new FillScenarios(zeroEx, userAddresses, tokens, zrxTokenAddress, exchangeContractAddress);
|
||||
[coinbase, makerAddress, takerAddress, feeRecipient] = userAddresses;
|
||||
tokens = await zeroEx.tokenRegistry.getTokensAsync();
|
||||
const [makerToken, takerToken] = tokenUtils.getDummyTokens();
|
||||
makerTokenAddress = makerToken.address;
|
||||
takerTokenAddress = takerToken.address;
|
||||
});
|
||||
beforeEach(async () => {
|
||||
await blockchainLifecycle.startAsync();
|
||||
const sinonTimerConfig = { shouldAdvanceTime: true } as any;
|
||||
// This constructor has incorrect types
|
||||
timer = Sinon.useFakeTimers(sinonTimerConfig);
|
||||
currentUnixTimestampSec = utils.getCurrentUnixTimestampSec();
|
||||
expirationWatcher = new ExpirationWatcher();
|
||||
});
|
||||
afterEach(async () => {
|
||||
await blockchainLifecycle.revertAsync();
|
||||
timer.restore();
|
||||
expirationWatcher.unsubscribe();
|
||||
});
|
||||
it('correctly emits events when order expires', (done: DoneCallback) => {
|
||||
(async () => {
|
||||
const orderLifetimeSec = 60;
|
||||
const expirationUnixTimestampSec = currentUnixTimestampSec.plus(orderLifetimeSec);
|
||||
const signedOrder = await fillScenarios.createFillableSignedOrderAsync(
|
||||
makerTokenAddress,
|
||||
takerTokenAddress,
|
||||
makerAddress,
|
||||
takerAddress,
|
||||
fillableAmount,
|
||||
expirationUnixTimestampSec,
|
||||
);
|
||||
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
|
||||
expirationWatcher.addOrder(orderHash, signedOrder.expirationUnixTimestampSec.times(1000));
|
||||
const callbackAsync = reportNoErrorCallbackErrors(done)((hash: string) => {
|
||||
expect(hash).to.be.equal(orderHash);
|
||||
expect(utils.getCurrentUnixTimestampSec()).to.be.bignumber.gte(expirationUnixTimestampSec);
|
||||
});
|
||||
expirationWatcher.subscribe(callbackAsync);
|
||||
timer.tick(orderLifetimeSec * 1000);
|
||||
})().catch(done);
|
||||
});
|
||||
it("doesn't emit events before order expires", (done: DoneCallback) => {
|
||||
(async () => {
|
||||
const orderLifetimeSec = 60;
|
||||
const expirationUnixTimestampSec = currentUnixTimestampSec.plus(orderLifetimeSec);
|
||||
const signedOrder = await fillScenarios.createFillableSignedOrderAsync(
|
||||
makerTokenAddress,
|
||||
takerTokenAddress,
|
||||
makerAddress,
|
||||
takerAddress,
|
||||
fillableAmount,
|
||||
expirationUnixTimestampSec,
|
||||
);
|
||||
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
|
||||
expirationWatcher.addOrder(orderHash, signedOrder.expirationUnixTimestampSec.times(1000));
|
||||
const callbackAsync = reportNoErrorCallbackErrors(done)(async (hash: string) => {
|
||||
done(new Error('Emitted expiration went before the order actually expired'));
|
||||
});
|
||||
expirationWatcher.subscribe(callbackAsync);
|
||||
const notEnoughTime = orderLifetimeSec - 1;
|
||||
timer.tick(notEnoughTime * 1000);
|
||||
done();
|
||||
})().catch(done);
|
||||
});
|
||||
it('emits events in correct order', (done: DoneCallback) => {
|
||||
(async () => {
|
||||
const order1Lifetime = 60;
|
||||
const order2Lifetime = 120;
|
||||
const order1ExpirationUnixTimestampSec = currentUnixTimestampSec.plus(order1Lifetime);
|
||||
const order2ExpirationUnixTimestampSec = currentUnixTimestampSec.plus(order2Lifetime);
|
||||
const signedOrder1 = await fillScenarios.createFillableSignedOrderAsync(
|
||||
makerTokenAddress,
|
||||
takerTokenAddress,
|
||||
makerAddress,
|
||||
takerAddress,
|
||||
fillableAmount,
|
||||
order1ExpirationUnixTimestampSec,
|
||||
);
|
||||
const signedOrder2 = await fillScenarios.createFillableSignedOrderAsync(
|
||||
makerTokenAddress,
|
||||
takerTokenAddress,
|
||||
makerAddress,
|
||||
takerAddress,
|
||||
fillableAmount,
|
||||
order2ExpirationUnixTimestampSec,
|
||||
);
|
||||
const orderHash1 = ZeroEx.getOrderHashHex(signedOrder1);
|
||||
const orderHash2 = ZeroEx.getOrderHashHex(signedOrder2);
|
||||
expirationWatcher.addOrder(orderHash2, signedOrder2.expirationUnixTimestampSec.times(1000));
|
||||
expirationWatcher.addOrder(orderHash1, signedOrder1.expirationUnixTimestampSec.times(1000));
|
||||
const expirationOrder = [orderHash1, orderHash2];
|
||||
const expectToBeCalledOnce = false;
|
||||
const callbackAsync = reportNoErrorCallbackErrors(done, expectToBeCalledOnce)((hash: string) => {
|
||||
const orderHash = expirationOrder.shift();
|
||||
expect(hash).to.be.equal(orderHash);
|
||||
if (_.isEmpty(expirationOrder)) {
|
||||
done();
|
||||
}
|
||||
});
|
||||
expirationWatcher.subscribe(callbackAsync);
|
||||
timer.tick(order2Lifetime * 1000);
|
||||
})().catch(done);
|
||||
});
|
||||
});
|
||||
17
packages/0x.js/test/global_hooks.ts
Normal file
17
packages/0x.js/test/global_hooks.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { devConstants } from '@0xproject/dev-utils';
|
||||
import { runV2MigrationsAsync } from '@0xproject/migrations';
|
||||
|
||||
import { provider } from './utils/web3_wrapper';
|
||||
|
||||
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); // tslint:disable-line:no-invalid-this
|
||||
const txDefaults = {
|
||||
gas: devConstants.GAS_LIMIT,
|
||||
from: devConstants.TESTRPC_FIRST_ADDRESS,
|
||||
};
|
||||
const artifactsDir = `../migrations/artifacts/2.0.0`;
|
||||
await runV2MigrationsAsync(provider, artifactsDir, txDefaults);
|
||||
});
|
||||
@@ -1,558 +0,0 @@
|
||||
import { BlockchainLifecycle, devConstants } from '@0xproject/dev-utils';
|
||||
import { BigNumber } from '@0xproject/utils';
|
||||
import * as chai from 'chai';
|
||||
import * as _ from 'lodash';
|
||||
import 'mocha';
|
||||
|
||||
import {
|
||||
ExchangeContractErrs,
|
||||
OrderState,
|
||||
OrderStateInvalid,
|
||||
OrderStateValid,
|
||||
SignedOrder,
|
||||
Token,
|
||||
ZeroEx,
|
||||
ZeroExError,
|
||||
} from '../src';
|
||||
import { OrderStateWatcher } from '../src/order_watcher/order_state_watcher';
|
||||
import { DoneCallback } from '../src/types';
|
||||
|
||||
import { chaiSetup } from './utils/chai_setup';
|
||||
import { constants } from './utils/constants';
|
||||
import { FillScenarios } from './utils/fill_scenarios';
|
||||
import { reportNodeCallbackErrors } from './utils/report_callback_errors';
|
||||
import { TokenUtils } from './utils/token_utils';
|
||||
import { provider, web3Wrapper } from './utils/web3_wrapper';
|
||||
|
||||
const TIMEOUT_MS = 150;
|
||||
|
||||
chaiSetup.configure();
|
||||
const expect = chai.expect;
|
||||
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
||||
|
||||
describe('OrderStateWatcher', () => {
|
||||
let zeroEx: ZeroEx;
|
||||
let tokens: Token[];
|
||||
let tokenUtils: TokenUtils;
|
||||
let fillScenarios: FillScenarios;
|
||||
let userAddresses: string[];
|
||||
let zrxTokenAddress: string;
|
||||
let exchangeContractAddress: string;
|
||||
let makerToken: Token;
|
||||
let takerToken: Token;
|
||||
let maker: string;
|
||||
let taker: string;
|
||||
let signedOrder: SignedOrder;
|
||||
let orderStateWatcher: OrderStateWatcher;
|
||||
const config = {
|
||||
networkId: constants.TESTRPC_NETWORK_ID,
|
||||
};
|
||||
const decimals = constants.ZRX_DECIMALS;
|
||||
const fillableAmount = ZeroEx.toBaseUnitAmount(new BigNumber(5), decimals);
|
||||
before(async () => {
|
||||
zeroEx = new ZeroEx(provider, config);
|
||||
orderStateWatcher = zeroEx.createOrderStateWatcher();
|
||||
exchangeContractAddress = zeroEx.exchange.getContractAddress();
|
||||
userAddresses = await zeroEx.getAvailableAddressesAsync();
|
||||
[, maker, taker] = userAddresses;
|
||||
tokens = await zeroEx.tokenRegistry.getTokensAsync();
|
||||
tokenUtils = new TokenUtils(tokens);
|
||||
zrxTokenAddress = tokenUtils.getProtocolTokenOrThrow().address;
|
||||
fillScenarios = new FillScenarios(zeroEx, userAddresses, tokens, zrxTokenAddress, exchangeContractAddress);
|
||||
await fillScenarios.initTokenBalancesAsync();
|
||||
[makerToken, takerToken] = tokenUtils.getDummyTokens();
|
||||
});
|
||||
beforeEach(async () => {
|
||||
await blockchainLifecycle.startAsync();
|
||||
});
|
||||
afterEach(async () => {
|
||||
await blockchainLifecycle.revertAsync();
|
||||
});
|
||||
describe('#removeOrder', async () => {
|
||||
it('should successfully remove existing order', async () => {
|
||||
signedOrder = await fillScenarios.createFillableSignedOrderAsync(
|
||||
makerToken.address,
|
||||
takerToken.address,
|
||||
maker,
|
||||
taker,
|
||||
fillableAmount,
|
||||
);
|
||||
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
|
||||
orderStateWatcher.addOrder(signedOrder);
|
||||
expect((orderStateWatcher as any)._orderByOrderHash).to.include({
|
||||
[orderHash]: signedOrder,
|
||||
});
|
||||
let dependentOrderHashes = (orderStateWatcher as any)._dependentOrderHashes;
|
||||
expect(dependentOrderHashes[signedOrder.maker][signedOrder.makerTokenAddress]).to.have.keys(orderHash);
|
||||
orderStateWatcher.removeOrder(orderHash);
|
||||
expect((orderStateWatcher as any)._orderByOrderHash).to.not.include({
|
||||
[orderHash]: signedOrder,
|
||||
});
|
||||
dependentOrderHashes = (orderStateWatcher as any)._dependentOrderHashes;
|
||||
expect(dependentOrderHashes[signedOrder.maker]).to.be.undefined();
|
||||
});
|
||||
it('should no-op when removing a non-existing order', async () => {
|
||||
signedOrder = await fillScenarios.createFillableSignedOrderAsync(
|
||||
makerToken.address,
|
||||
takerToken.address,
|
||||
maker,
|
||||
taker,
|
||||
fillableAmount,
|
||||
);
|
||||
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
|
||||
const nonExistentOrderHash = `0x${orderHash
|
||||
.substr(2)
|
||||
.split('')
|
||||
.reverse()
|
||||
.join('')}`;
|
||||
orderStateWatcher.removeOrder(nonExistentOrderHash);
|
||||
});
|
||||
});
|
||||
describe('#subscribe', async () => {
|
||||
afterEach(async () => {
|
||||
orderStateWatcher.unsubscribe();
|
||||
});
|
||||
it('should fail when trying to subscribe twice', async () => {
|
||||
orderStateWatcher.subscribe(_.noop);
|
||||
expect(() => orderStateWatcher.subscribe(_.noop)).to.throw(ZeroExError.SubscriptionAlreadyPresent);
|
||||
});
|
||||
});
|
||||
describe('tests with cleanup', async () => {
|
||||
afterEach(async () => {
|
||||
orderStateWatcher.unsubscribe();
|
||||
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
|
||||
orderStateWatcher.removeOrder(orderHash);
|
||||
});
|
||||
it('should emit orderStateInvalid when maker allowance set to 0 for watched order', (done: DoneCallback) => {
|
||||
(async () => {
|
||||
signedOrder = await fillScenarios.createFillableSignedOrderAsync(
|
||||
makerToken.address,
|
||||
takerToken.address,
|
||||
maker,
|
||||
taker,
|
||||
fillableAmount,
|
||||
);
|
||||
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
|
||||
orderStateWatcher.addOrder(signedOrder);
|
||||
const callback = reportNodeCallbackErrors(done)((orderState: OrderState) => {
|
||||
expect(orderState.isValid).to.be.false();
|
||||
const invalidOrderState = orderState as OrderStateInvalid;
|
||||
expect(invalidOrderState.orderHash).to.be.equal(orderHash);
|
||||
expect(invalidOrderState.error).to.be.equal(ExchangeContractErrs.InsufficientMakerAllowance);
|
||||
});
|
||||
orderStateWatcher.subscribe(callback);
|
||||
await zeroEx.token.setProxyAllowanceAsync(makerToken.address, maker, new BigNumber(0));
|
||||
})().catch(done);
|
||||
});
|
||||
it('should not emit an orderState event when irrelevant Transfer event received', (done: DoneCallback) => {
|
||||
(async () => {
|
||||
signedOrder = await fillScenarios.createFillableSignedOrderAsync(
|
||||
makerToken.address,
|
||||
takerToken.address,
|
||||
maker,
|
||||
taker,
|
||||
fillableAmount,
|
||||
);
|
||||
orderStateWatcher.addOrder(signedOrder);
|
||||
const callback = reportNodeCallbackErrors(done)((orderState: OrderState) => {
|
||||
throw new Error('OrderState callback fired for irrelevant order');
|
||||
});
|
||||
orderStateWatcher.subscribe(callback);
|
||||
const notTheMaker = userAddresses[0];
|
||||
const anyRecipient = taker;
|
||||
const transferAmount = new BigNumber(2);
|
||||
await zeroEx.token.transferAsync(makerToken.address, notTheMaker, anyRecipient, transferAmount);
|
||||
setTimeout(() => {
|
||||
done();
|
||||
}, TIMEOUT_MS);
|
||||
})().catch(done);
|
||||
});
|
||||
it('should emit orderStateInvalid when maker moves balance backing watched order', (done: DoneCallback) => {
|
||||
(async () => {
|
||||
signedOrder = await fillScenarios.createFillableSignedOrderAsync(
|
||||
makerToken.address,
|
||||
takerToken.address,
|
||||
maker,
|
||||
taker,
|
||||
fillableAmount,
|
||||
);
|
||||
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
|
||||
orderStateWatcher.addOrder(signedOrder);
|
||||
const callback = reportNodeCallbackErrors(done)((orderState: OrderState) => {
|
||||
expect(orderState.isValid).to.be.false();
|
||||
const invalidOrderState = orderState as OrderStateInvalid;
|
||||
expect(invalidOrderState.orderHash).to.be.equal(orderHash);
|
||||
expect(invalidOrderState.error).to.be.equal(ExchangeContractErrs.InsufficientMakerBalance);
|
||||
});
|
||||
orderStateWatcher.subscribe(callback);
|
||||
const anyRecipient = taker;
|
||||
const makerBalance = await zeroEx.token.getBalanceAsync(makerToken.address, maker);
|
||||
await zeroEx.token.transferAsync(makerToken.address, maker, anyRecipient, makerBalance);
|
||||
})().catch(done);
|
||||
});
|
||||
it('should emit orderStateInvalid when watched order fully filled', (done: DoneCallback) => {
|
||||
(async () => {
|
||||
signedOrder = await fillScenarios.createFillableSignedOrderAsync(
|
||||
makerToken.address,
|
||||
takerToken.address,
|
||||
maker,
|
||||
taker,
|
||||
fillableAmount,
|
||||
);
|
||||
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
|
||||
orderStateWatcher.addOrder(signedOrder);
|
||||
|
||||
const callback = reportNodeCallbackErrors(done)((orderState: OrderState) => {
|
||||
expect(orderState.isValid).to.be.false();
|
||||
const invalidOrderState = orderState as OrderStateInvalid;
|
||||
expect(invalidOrderState.orderHash).to.be.equal(orderHash);
|
||||
expect(invalidOrderState.error).to.be.equal(ExchangeContractErrs.OrderRemainingFillAmountZero);
|
||||
});
|
||||
orderStateWatcher.subscribe(callback);
|
||||
|
||||
const shouldThrowOnInsufficientBalanceOrAllowance = true;
|
||||
await zeroEx.exchange.fillOrderAsync(
|
||||
signedOrder,
|
||||
fillableAmount,
|
||||
shouldThrowOnInsufficientBalanceOrAllowance,
|
||||
taker,
|
||||
);
|
||||
})().catch(done);
|
||||
});
|
||||
it('should emit orderStateValid when watched order partially filled', (done: DoneCallback) => {
|
||||
(async () => {
|
||||
signedOrder = await fillScenarios.createFillableSignedOrderAsync(
|
||||
makerToken.address,
|
||||
takerToken.address,
|
||||
maker,
|
||||
taker,
|
||||
fillableAmount,
|
||||
);
|
||||
|
||||
const makerBalance = await zeroEx.token.getBalanceAsync(makerToken.address, maker);
|
||||
const fillAmountInBaseUnits = new BigNumber(2);
|
||||
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
|
||||
orderStateWatcher.addOrder(signedOrder);
|
||||
|
||||
const callback = reportNodeCallbackErrors(done)((orderState: OrderState) => {
|
||||
expect(orderState.isValid).to.be.true();
|
||||
const validOrderState = orderState as OrderStateValid;
|
||||
expect(validOrderState.orderHash).to.be.equal(orderHash);
|
||||
const orderRelevantState = validOrderState.orderRelevantState;
|
||||
const remainingMakerBalance = makerBalance.sub(fillAmountInBaseUnits);
|
||||
const remainingFillable = fillableAmount.minus(fillAmountInBaseUnits);
|
||||
expect(orderRelevantState.remainingFillableMakerTokenAmount).to.be.bignumber.equal(
|
||||
remainingFillable,
|
||||
);
|
||||
expect(orderRelevantState.remainingFillableTakerTokenAmount).to.be.bignumber.equal(
|
||||
remainingFillable,
|
||||
);
|
||||
expect(orderRelevantState.makerBalance).to.be.bignumber.equal(remainingMakerBalance);
|
||||
});
|
||||
orderStateWatcher.subscribe(callback);
|
||||
const shouldThrowOnInsufficientBalanceOrAllowance = true;
|
||||
await zeroEx.exchange.fillOrderAsync(
|
||||
signedOrder,
|
||||
fillAmountInBaseUnits,
|
||||
shouldThrowOnInsufficientBalanceOrAllowance,
|
||||
taker,
|
||||
);
|
||||
})().catch(done);
|
||||
});
|
||||
it('should trigger the callback when orders backing ZRX allowance changes', (done: DoneCallback) => {
|
||||
(async () => {
|
||||
const makerFee = ZeroEx.toBaseUnitAmount(new BigNumber(2), 18);
|
||||
const takerFee = ZeroEx.toBaseUnitAmount(new BigNumber(0), 18);
|
||||
signedOrder = await fillScenarios.createFillableSignedOrderWithFeesAsync(
|
||||
makerToken.address,
|
||||
takerToken.address,
|
||||
makerFee,
|
||||
takerFee,
|
||||
maker,
|
||||
taker,
|
||||
fillableAmount,
|
||||
taker,
|
||||
);
|
||||
const callback = reportNodeCallbackErrors(done)();
|
||||
orderStateWatcher.addOrder(signedOrder);
|
||||
orderStateWatcher.subscribe(callback);
|
||||
await zeroEx.token.setProxyAllowanceAsync(zrxTokenAddress, maker, new BigNumber(0));
|
||||
})().catch(done);
|
||||
});
|
||||
describe('remainingFillable(M|T)akerTokenAmount', () => {
|
||||
it('should calculate correct remaining fillable', (done: DoneCallback) => {
|
||||
(async () => {
|
||||
const takerFillableAmount = ZeroEx.toBaseUnitAmount(new BigNumber(10), decimals);
|
||||
const makerFillableAmount = ZeroEx.toBaseUnitAmount(new BigNumber(20), decimals);
|
||||
signedOrder = await fillScenarios.createAsymmetricFillableSignedOrderAsync(
|
||||
makerToken.address,
|
||||
takerToken.address,
|
||||
maker,
|
||||
taker,
|
||||
makerFillableAmount,
|
||||
takerFillableAmount,
|
||||
);
|
||||
const fillAmountInBaseUnits = ZeroEx.toBaseUnitAmount(new BigNumber(2), decimals);
|
||||
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
|
||||
orderStateWatcher.addOrder(signedOrder);
|
||||
const callback = reportNodeCallbackErrors(done)((orderState: OrderState) => {
|
||||
expect(orderState.isValid).to.be.true();
|
||||
const validOrderState = orderState as OrderStateValid;
|
||||
expect(validOrderState.orderHash).to.be.equal(orderHash);
|
||||
const orderRelevantState = validOrderState.orderRelevantState;
|
||||
expect(orderRelevantState.remainingFillableMakerTokenAmount).to.be.bignumber.equal(
|
||||
ZeroEx.toBaseUnitAmount(new BigNumber(16), decimals),
|
||||
);
|
||||
expect(orderRelevantState.remainingFillableTakerTokenAmount).to.be.bignumber.equal(
|
||||
ZeroEx.toBaseUnitAmount(new BigNumber(8), decimals),
|
||||
);
|
||||
});
|
||||
orderStateWatcher.subscribe(callback);
|
||||
const shouldThrowOnInsufficientBalanceOrAllowance = true;
|
||||
await zeroEx.exchange.fillOrderAsync(
|
||||
signedOrder,
|
||||
fillAmountInBaseUnits,
|
||||
shouldThrowOnInsufficientBalanceOrAllowance,
|
||||
taker,
|
||||
);
|
||||
})().catch(done);
|
||||
});
|
||||
it('should equal approved amount when approved amount is lowest', (done: DoneCallback) => {
|
||||
(async () => {
|
||||
signedOrder = await fillScenarios.createFillableSignedOrderAsync(
|
||||
makerToken.address,
|
||||
takerToken.address,
|
||||
maker,
|
||||
taker,
|
||||
fillableAmount,
|
||||
);
|
||||
|
||||
const changedMakerApprovalAmount = ZeroEx.toBaseUnitAmount(new BigNumber(3), decimals);
|
||||
orderStateWatcher.addOrder(signedOrder);
|
||||
|
||||
const callback = reportNodeCallbackErrors(done)((orderState: OrderState) => {
|
||||
const validOrderState = orderState as OrderStateValid;
|
||||
const orderRelevantState = validOrderState.orderRelevantState;
|
||||
expect(orderRelevantState.remainingFillableMakerTokenAmount).to.be.bignumber.equal(
|
||||
changedMakerApprovalAmount,
|
||||
);
|
||||
expect(orderRelevantState.remainingFillableTakerTokenAmount).to.be.bignumber.equal(
|
||||
changedMakerApprovalAmount,
|
||||
);
|
||||
});
|
||||
orderStateWatcher.subscribe(callback);
|
||||
await zeroEx.token.setProxyAllowanceAsync(makerToken.address, maker, changedMakerApprovalAmount);
|
||||
})().catch(done);
|
||||
});
|
||||
it('should equal balance amount when balance amount is lowest', (done: DoneCallback) => {
|
||||
(async () => {
|
||||
signedOrder = await fillScenarios.createFillableSignedOrderAsync(
|
||||
makerToken.address,
|
||||
takerToken.address,
|
||||
maker,
|
||||
taker,
|
||||
fillableAmount,
|
||||
);
|
||||
|
||||
const makerBalance = await zeroEx.token.getBalanceAsync(makerToken.address, maker);
|
||||
|
||||
const remainingAmount = ZeroEx.toBaseUnitAmount(new BigNumber(1), decimals);
|
||||
const transferAmount = makerBalance.sub(remainingAmount);
|
||||
orderStateWatcher.addOrder(signedOrder);
|
||||
|
||||
const callback = reportNodeCallbackErrors(done)((orderState: OrderState) => {
|
||||
expect(orderState.isValid).to.be.true();
|
||||
const validOrderState = orderState as OrderStateValid;
|
||||
const orderRelevantState = validOrderState.orderRelevantState;
|
||||
expect(orderRelevantState.remainingFillableMakerTokenAmount).to.be.bignumber.equal(
|
||||
remainingAmount,
|
||||
);
|
||||
expect(orderRelevantState.remainingFillableTakerTokenAmount).to.be.bignumber.equal(
|
||||
remainingAmount,
|
||||
);
|
||||
});
|
||||
orderStateWatcher.subscribe(callback);
|
||||
await zeroEx.token.transferAsync(makerToken.address, maker, ZeroEx.NULL_ADDRESS, transferAmount);
|
||||
})().catch(done);
|
||||
});
|
||||
it('should equal remaining amount when partially cancelled and order has fees', (done: DoneCallback) => {
|
||||
(async () => {
|
||||
const takerFee = ZeroEx.toBaseUnitAmount(new BigNumber(0), decimals);
|
||||
const makerFee = ZeroEx.toBaseUnitAmount(new BigNumber(5), decimals);
|
||||
const feeRecipient = taker;
|
||||
signedOrder = await fillScenarios.createFillableSignedOrderWithFeesAsync(
|
||||
makerToken.address,
|
||||
takerToken.address,
|
||||
makerFee,
|
||||
takerFee,
|
||||
maker,
|
||||
taker,
|
||||
fillableAmount,
|
||||
feeRecipient,
|
||||
);
|
||||
|
||||
const remainingTokenAmount = ZeroEx.toBaseUnitAmount(new BigNumber(4), decimals);
|
||||
const transferTokenAmount = makerFee.sub(remainingTokenAmount);
|
||||
orderStateWatcher.addOrder(signedOrder);
|
||||
|
||||
const callback = reportNodeCallbackErrors(done)((orderState: OrderState) => {
|
||||
expect(orderState.isValid).to.be.true();
|
||||
const validOrderState = orderState as OrderStateValid;
|
||||
const orderRelevantState = validOrderState.orderRelevantState;
|
||||
expect(orderRelevantState.remainingFillableMakerTokenAmount).to.be.bignumber.equal(
|
||||
remainingTokenAmount,
|
||||
);
|
||||
});
|
||||
orderStateWatcher.subscribe(callback);
|
||||
await zeroEx.exchange.cancelOrderAsync(signedOrder, transferTokenAmount);
|
||||
})().catch(done);
|
||||
});
|
||||
it('should equal ratio amount when fee balance is lowered', (done: DoneCallback) => {
|
||||
(async () => {
|
||||
const takerFee = ZeroEx.toBaseUnitAmount(new BigNumber(0), decimals);
|
||||
const makerFee = ZeroEx.toBaseUnitAmount(new BigNumber(5), decimals);
|
||||
const feeRecipient = taker;
|
||||
signedOrder = await fillScenarios.createFillableSignedOrderWithFeesAsync(
|
||||
makerToken.address,
|
||||
takerToken.address,
|
||||
makerFee,
|
||||
takerFee,
|
||||
maker,
|
||||
taker,
|
||||
fillableAmount,
|
||||
feeRecipient,
|
||||
);
|
||||
|
||||
const remainingFeeAmount = ZeroEx.toBaseUnitAmount(new BigNumber(3), decimals);
|
||||
|
||||
const remainingTokenAmount = ZeroEx.toBaseUnitAmount(new BigNumber(4), decimals);
|
||||
const transferTokenAmount = makerFee.sub(remainingTokenAmount);
|
||||
orderStateWatcher.addOrder(signedOrder);
|
||||
|
||||
const callback = reportNodeCallbackErrors(done)((orderState: OrderState) => {
|
||||
const validOrderState = orderState as OrderStateValid;
|
||||
const orderRelevantState = validOrderState.orderRelevantState;
|
||||
expect(orderRelevantState.remainingFillableMakerTokenAmount).to.be.bignumber.equal(
|
||||
remainingFeeAmount,
|
||||
);
|
||||
});
|
||||
orderStateWatcher.subscribe(callback);
|
||||
await zeroEx.token.setProxyAllowanceAsync(zrxTokenAddress, maker, remainingFeeAmount);
|
||||
await zeroEx.token.transferAsync(
|
||||
makerToken.address,
|
||||
maker,
|
||||
ZeroEx.NULL_ADDRESS,
|
||||
transferTokenAmount,
|
||||
);
|
||||
})().catch(done);
|
||||
});
|
||||
it('should calculate full amount when all available and non-divisible', (done: DoneCallback) => {
|
||||
(async () => {
|
||||
const takerFee = ZeroEx.toBaseUnitAmount(new BigNumber(0), decimals);
|
||||
const makerFee = ZeroEx.toBaseUnitAmount(new BigNumber(2), decimals);
|
||||
const feeRecipient = taker;
|
||||
signedOrder = await fillScenarios.createFillableSignedOrderWithFeesAsync(
|
||||
makerToken.address,
|
||||
takerToken.address,
|
||||
makerFee,
|
||||
takerFee,
|
||||
maker,
|
||||
taker,
|
||||
fillableAmount,
|
||||
feeRecipient,
|
||||
);
|
||||
|
||||
orderStateWatcher.addOrder(signedOrder);
|
||||
|
||||
const callback = reportNodeCallbackErrors(done)((orderState: OrderState) => {
|
||||
const validOrderState = orderState as OrderStateValid;
|
||||
const orderRelevantState = validOrderState.orderRelevantState;
|
||||
expect(orderRelevantState.remainingFillableMakerTokenAmount).to.be.bignumber.equal(
|
||||
fillableAmount,
|
||||
);
|
||||
});
|
||||
orderStateWatcher.subscribe(callback);
|
||||
await zeroEx.token.setProxyAllowanceAsync(
|
||||
makerToken.address,
|
||||
maker,
|
||||
ZeroEx.toBaseUnitAmount(new BigNumber(100), decimals),
|
||||
);
|
||||
})().catch(done);
|
||||
});
|
||||
});
|
||||
it('should emit orderStateInvalid when watched order cancelled', (done: DoneCallback) => {
|
||||
(async () => {
|
||||
signedOrder = await fillScenarios.createFillableSignedOrderAsync(
|
||||
makerToken.address,
|
||||
takerToken.address,
|
||||
maker,
|
||||
taker,
|
||||
fillableAmount,
|
||||
);
|
||||
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
|
||||
orderStateWatcher.addOrder(signedOrder);
|
||||
|
||||
const callback = reportNodeCallbackErrors(done)((orderState: OrderState) => {
|
||||
expect(orderState.isValid).to.be.false();
|
||||
const invalidOrderState = orderState as OrderStateInvalid;
|
||||
expect(invalidOrderState.orderHash).to.be.equal(orderHash);
|
||||
expect(invalidOrderState.error).to.be.equal(ExchangeContractErrs.OrderRemainingFillAmountZero);
|
||||
});
|
||||
orderStateWatcher.subscribe(callback);
|
||||
|
||||
await zeroEx.exchange.cancelOrderAsync(signedOrder, fillableAmount);
|
||||
})().catch(done);
|
||||
});
|
||||
it('should emit orderStateInvalid when within rounding error range', (done: DoneCallback) => {
|
||||
(async () => {
|
||||
const remainingFillableAmountInBaseUnits = new BigNumber(100);
|
||||
signedOrder = await fillScenarios.createFillableSignedOrderAsync(
|
||||
makerToken.address,
|
||||
takerToken.address,
|
||||
maker,
|
||||
taker,
|
||||
fillableAmount,
|
||||
);
|
||||
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
|
||||
orderStateWatcher.addOrder(signedOrder);
|
||||
|
||||
const callback = reportNodeCallbackErrors(done)((orderState: OrderState) => {
|
||||
expect(orderState.isValid).to.be.false();
|
||||
const invalidOrderState = orderState as OrderStateInvalid;
|
||||
expect(invalidOrderState.orderHash).to.be.equal(orderHash);
|
||||
expect(invalidOrderState.error).to.be.equal(ExchangeContractErrs.OrderFillRoundingError);
|
||||
});
|
||||
orderStateWatcher.subscribe(callback);
|
||||
await zeroEx.exchange.cancelOrderAsync(
|
||||
signedOrder,
|
||||
fillableAmount.minus(remainingFillableAmountInBaseUnits),
|
||||
);
|
||||
})().catch(done);
|
||||
});
|
||||
it('should emit orderStateValid when watched order partially cancelled', (done: DoneCallback) => {
|
||||
(async () => {
|
||||
signedOrder = await fillScenarios.createFillableSignedOrderAsync(
|
||||
makerToken.address,
|
||||
takerToken.address,
|
||||
maker,
|
||||
taker,
|
||||
fillableAmount,
|
||||
);
|
||||
|
||||
const cancelAmountInBaseUnits = new BigNumber(2);
|
||||
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
|
||||
orderStateWatcher.addOrder(signedOrder);
|
||||
|
||||
const callback = reportNodeCallbackErrors(done)((orderState: OrderState) => {
|
||||
expect(orderState.isValid).to.be.true();
|
||||
const validOrderState = orderState as OrderStateValid;
|
||||
expect(validOrderState.orderHash).to.be.equal(orderHash);
|
||||
const orderRelevantState = validOrderState.orderRelevantState;
|
||||
expect(orderRelevantState.cancelledTakerTokenAmount).to.be.bignumber.equal(cancelAmountInBaseUnits);
|
||||
});
|
||||
orderStateWatcher.subscribe(callback);
|
||||
await zeroEx.exchange.cancelOrderAsync(signedOrder, cancelAmountInBaseUnits);
|
||||
})().catch(done);
|
||||
});
|
||||
});
|
||||
}); // tslint:disable:max-file-line-count
|
||||
@@ -1,472 +0,0 @@
|
||||
import { BlockchainLifecycle, devConstants } from '@0xproject/dev-utils';
|
||||
import { BlockParamLiteral } from '@0xproject/types';
|
||||
import { BigNumber } from '@0xproject/utils';
|
||||
import * as chai from 'chai';
|
||||
import * as Sinon from 'sinon';
|
||||
|
||||
import { ExchangeContractErrs, SignedOrder, Token, ZeroEx, ZeroExError } from '../src';
|
||||
import { TradeSide, TransferType } from '../src/types';
|
||||
import { ExchangeTransferSimulator } from '../src/utils/exchange_transfer_simulator';
|
||||
import { OrderValidationUtils } from '../src/utils/order_validation_utils';
|
||||
|
||||
import { chaiSetup } from './utils/chai_setup';
|
||||
import { constants } from './utils/constants';
|
||||
import { FillScenarios } from './utils/fill_scenarios';
|
||||
import { TokenUtils } from './utils/token_utils';
|
||||
import { provider, web3Wrapper } from './utils/web3_wrapper';
|
||||
|
||||
chaiSetup.configure();
|
||||
const expect = chai.expect;
|
||||
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
||||
|
||||
describe('OrderValidation', () => {
|
||||
let zeroEx: ZeroEx;
|
||||
let userAddresses: string[];
|
||||
let tokens: Token[];
|
||||
let tokenUtils: TokenUtils;
|
||||
let exchangeContractAddress: string;
|
||||
let zrxTokenAddress: string;
|
||||
let fillScenarios: FillScenarios;
|
||||
let makerTokenAddress: string;
|
||||
let takerTokenAddress: string;
|
||||
let coinbase: string;
|
||||
let makerAddress: string;
|
||||
let takerAddress: string;
|
||||
let feeRecipient: string;
|
||||
const fillableAmount = new BigNumber(5);
|
||||
const fillTakerAmount = new BigNumber(5);
|
||||
const config = {
|
||||
networkId: constants.TESTRPC_NETWORK_ID,
|
||||
};
|
||||
before(async () => {
|
||||
zeroEx = new ZeroEx(provider, config);
|
||||
exchangeContractAddress = zeroEx.exchange.getContractAddress();
|
||||
userAddresses = await zeroEx.getAvailableAddressesAsync();
|
||||
[coinbase, makerAddress, takerAddress, feeRecipient] = userAddresses;
|
||||
tokens = await zeroEx.tokenRegistry.getTokensAsync();
|
||||
tokenUtils = new TokenUtils(tokens);
|
||||
zrxTokenAddress = tokenUtils.getProtocolTokenOrThrow().address;
|
||||
fillScenarios = new FillScenarios(zeroEx, userAddresses, tokens, zrxTokenAddress, exchangeContractAddress);
|
||||
const [makerToken, takerToken] = tokenUtils.getDummyTokens();
|
||||
makerTokenAddress = makerToken.address;
|
||||
takerTokenAddress = takerToken.address;
|
||||
});
|
||||
beforeEach(async () => {
|
||||
await blockchainLifecycle.startAsync();
|
||||
});
|
||||
afterEach(async () => {
|
||||
await blockchainLifecycle.revertAsync();
|
||||
});
|
||||
describe('validateOrderFillableOrThrowAsync', () => {
|
||||
it('should succeed if the order is fillable', async () => {
|
||||
const signedOrder = await fillScenarios.createFillableSignedOrderAsync(
|
||||
makerTokenAddress,
|
||||
takerTokenAddress,
|
||||
makerAddress,
|
||||
takerAddress,
|
||||
fillableAmount,
|
||||
);
|
||||
await zeroEx.exchange.validateOrderFillableOrThrowAsync(signedOrder);
|
||||
});
|
||||
it('should succeed if the order is asymmetric and fillable', async () => {
|
||||
const makerFillableAmount = fillableAmount;
|
||||
const takerFillableAmount = fillableAmount.minus(4);
|
||||
const signedOrder = await fillScenarios.createAsymmetricFillableSignedOrderAsync(
|
||||
makerTokenAddress,
|
||||
takerTokenAddress,
|
||||
makerAddress,
|
||||
takerAddress,
|
||||
makerFillableAmount,
|
||||
takerFillableAmount,
|
||||
);
|
||||
await zeroEx.exchange.validateOrderFillableOrThrowAsync(signedOrder);
|
||||
});
|
||||
it('should throw when the order is fully filled or cancelled', async () => {
|
||||
const signedOrder = await fillScenarios.createFillableSignedOrderAsync(
|
||||
makerTokenAddress,
|
||||
takerTokenAddress,
|
||||
makerAddress,
|
||||
takerAddress,
|
||||
fillableAmount,
|
||||
);
|
||||
await zeroEx.exchange.cancelOrderAsync(signedOrder, fillableAmount);
|
||||
return expect(zeroEx.exchange.validateOrderFillableOrThrowAsync(signedOrder)).to.be.rejectedWith(
|
||||
ExchangeContractErrs.OrderRemainingFillAmountZero,
|
||||
);
|
||||
});
|
||||
it('should throw when order is expired', async () => {
|
||||
const expirationInPast = new BigNumber(1496826058); // 7th Jun 2017
|
||||
const signedOrder = await fillScenarios.createFillableSignedOrderAsync(
|
||||
makerTokenAddress,
|
||||
takerTokenAddress,
|
||||
makerAddress,
|
||||
takerAddress,
|
||||
fillableAmount,
|
||||
expirationInPast,
|
||||
);
|
||||
return expect(zeroEx.exchange.validateOrderFillableOrThrowAsync(signedOrder)).to.be.rejectedWith(
|
||||
ExchangeContractErrs.OrderFillExpired,
|
||||
);
|
||||
});
|
||||
});
|
||||
describe('validateFillOrderAndThrowIfInvalidAsync', () => {
|
||||
it('should throw when the fill amount is zero', async () => {
|
||||
const signedOrder = await fillScenarios.createFillableSignedOrderAsync(
|
||||
makerTokenAddress,
|
||||
takerTokenAddress,
|
||||
makerAddress,
|
||||
takerAddress,
|
||||
fillableAmount,
|
||||
);
|
||||
const zeroFillAmount = new BigNumber(0);
|
||||
return expect(
|
||||
zeroEx.exchange.validateFillOrderThrowIfInvalidAsync(signedOrder, zeroFillAmount, takerAddress),
|
||||
).to.be.rejectedWith(ExchangeContractErrs.OrderFillAmountZero);
|
||||
});
|
||||
it('should throw when the signature is invalid', async () => {
|
||||
const signedOrder = await fillScenarios.createFillableSignedOrderAsync(
|
||||
makerTokenAddress,
|
||||
takerTokenAddress,
|
||||
makerAddress,
|
||||
takerAddress,
|
||||
fillableAmount,
|
||||
);
|
||||
// 27 <--> 28
|
||||
signedOrder.ecSignature.v = 28 - signedOrder.ecSignature.v + 27;
|
||||
return expect(
|
||||
zeroEx.exchange.validateFillOrderThrowIfInvalidAsync(signedOrder, fillableAmount, takerAddress),
|
||||
).to.be.rejectedWith(ZeroExError.InvalidSignature);
|
||||
});
|
||||
it('should throw when the order is fully filled or cancelled', async () => {
|
||||
const signedOrder = await fillScenarios.createFillableSignedOrderAsync(
|
||||
makerTokenAddress,
|
||||
takerTokenAddress,
|
||||
makerAddress,
|
||||
takerAddress,
|
||||
fillableAmount,
|
||||
);
|
||||
await zeroEx.exchange.cancelOrderAsync(signedOrder, fillableAmount);
|
||||
return expect(
|
||||
zeroEx.exchange.validateFillOrderThrowIfInvalidAsync(signedOrder, fillableAmount, takerAddress),
|
||||
).to.be.rejectedWith(ExchangeContractErrs.OrderRemainingFillAmountZero);
|
||||
});
|
||||
it('should throw when sender is not a taker', async () => {
|
||||
const signedOrder = await fillScenarios.createFillableSignedOrderAsync(
|
||||
makerTokenAddress,
|
||||
takerTokenAddress,
|
||||
makerAddress,
|
||||
takerAddress,
|
||||
fillableAmount,
|
||||
);
|
||||
const nonTakerAddress = userAddresses[6];
|
||||
return expect(
|
||||
zeroEx.exchange.validateFillOrderThrowIfInvalidAsync(signedOrder, fillTakerAmount, nonTakerAddress),
|
||||
).to.be.rejectedWith(ExchangeContractErrs.TransactionSenderIsNotFillOrderTaker);
|
||||
});
|
||||
it('should throw when order is expired', async () => {
|
||||
const expirationInPast = new BigNumber(1496826058); // 7th Jun 2017
|
||||
const signedOrder = await fillScenarios.createFillableSignedOrderAsync(
|
||||
makerTokenAddress,
|
||||
takerTokenAddress,
|
||||
makerAddress,
|
||||
takerAddress,
|
||||
fillableAmount,
|
||||
expirationInPast,
|
||||
);
|
||||
return expect(
|
||||
zeroEx.exchange.validateFillOrderThrowIfInvalidAsync(signedOrder, fillTakerAmount, takerAddress),
|
||||
).to.be.rejectedWith(ExchangeContractErrs.OrderFillExpired);
|
||||
});
|
||||
it('should throw when there a rounding error would have occurred', async () => {
|
||||
const makerAmount = new BigNumber(3);
|
||||
const takerAmount = new BigNumber(5);
|
||||
const signedOrder = await fillScenarios.createAsymmetricFillableSignedOrderAsync(
|
||||
makerTokenAddress,
|
||||
takerTokenAddress,
|
||||
makerAddress,
|
||||
takerAddress,
|
||||
makerAmount,
|
||||
takerAmount,
|
||||
);
|
||||
const fillTakerAmountThatCausesRoundingError = new BigNumber(3);
|
||||
return expect(
|
||||
zeroEx.exchange.validateFillOrderThrowIfInvalidAsync(
|
||||
signedOrder,
|
||||
fillTakerAmountThatCausesRoundingError,
|
||||
takerAddress,
|
||||
),
|
||||
).to.be.rejectedWith(ExchangeContractErrs.OrderFillRoundingError);
|
||||
});
|
||||
});
|
||||
describe('#validateFillOrKillOrderAndThrowIfInvalidAsync', () => {
|
||||
it('should throw if remaining fillAmount is less then the desired fillAmount', async () => {
|
||||
const signedOrder = await fillScenarios.createFillableSignedOrderAsync(
|
||||
makerTokenAddress,
|
||||
takerTokenAddress,
|
||||
makerAddress,
|
||||
takerAddress,
|
||||
fillableAmount,
|
||||
);
|
||||
const tooLargeFillAmount = new BigNumber(7);
|
||||
const fillAmountDifference = tooLargeFillAmount.minus(fillableAmount);
|
||||
await zeroEx.token.transferAsync(takerTokenAddress, coinbase, takerAddress, fillAmountDifference);
|
||||
await zeroEx.token.setProxyAllowanceAsync(takerTokenAddress, takerAddress, tooLargeFillAmount);
|
||||
await zeroEx.token.transferAsync(makerTokenAddress, coinbase, makerAddress, fillAmountDifference);
|
||||
await zeroEx.token.setProxyAllowanceAsync(makerTokenAddress, makerAddress, tooLargeFillAmount);
|
||||
|
||||
return expect(
|
||||
zeroEx.exchange.validateFillOrKillOrderThrowIfInvalidAsync(
|
||||
signedOrder,
|
||||
tooLargeFillAmount,
|
||||
takerAddress,
|
||||
),
|
||||
).to.be.rejectedWith(ExchangeContractErrs.InsufficientRemainingFillAmount);
|
||||
});
|
||||
});
|
||||
describe('validateCancelOrderAndThrowIfInvalidAsync', () => {
|
||||
let signedOrder: SignedOrder;
|
||||
const cancelAmount = new BigNumber(3);
|
||||
beforeEach(async () => {
|
||||
[coinbase, makerAddress, takerAddress] = userAddresses;
|
||||
const [makerToken, takerToken] = tokenUtils.getDummyTokens();
|
||||
makerTokenAddress = makerToken.address;
|
||||
takerTokenAddress = takerToken.address;
|
||||
signedOrder = await fillScenarios.createFillableSignedOrderAsync(
|
||||
makerTokenAddress,
|
||||
takerTokenAddress,
|
||||
makerAddress,
|
||||
takerAddress,
|
||||
fillableAmount,
|
||||
);
|
||||
});
|
||||
it('should throw when cancel amount is zero', async () => {
|
||||
const zeroCancelAmount = new BigNumber(0);
|
||||
return expect(
|
||||
zeroEx.exchange.validateCancelOrderThrowIfInvalidAsync(signedOrder, zeroCancelAmount),
|
||||
).to.be.rejectedWith(ExchangeContractErrs.OrderCancelAmountZero);
|
||||
});
|
||||
it('should throw when order is expired', async () => {
|
||||
const expirationInPast = new BigNumber(1496826058); // 7th Jun 2017
|
||||
const expiredSignedOrder = await fillScenarios.createFillableSignedOrderAsync(
|
||||
makerTokenAddress,
|
||||
takerTokenAddress,
|
||||
makerAddress,
|
||||
takerAddress,
|
||||
fillableAmount,
|
||||
expirationInPast,
|
||||
);
|
||||
return expect(
|
||||
zeroEx.exchange.validateCancelOrderThrowIfInvalidAsync(expiredSignedOrder, cancelAmount),
|
||||
).to.be.rejectedWith(ExchangeContractErrs.OrderCancelExpired);
|
||||
});
|
||||
it('should throw when order is already cancelled or filled', async () => {
|
||||
await zeroEx.exchange.cancelOrderAsync(signedOrder, fillableAmount);
|
||||
return expect(
|
||||
zeroEx.exchange.validateCancelOrderThrowIfInvalidAsync(signedOrder, fillableAmount),
|
||||
).to.be.rejectedWith(ExchangeContractErrs.OrderAlreadyCancelledOrFilled);
|
||||
});
|
||||
});
|
||||
describe('#validateFillOrderBalancesAllowancesThrowIfInvalidAsync', () => {
|
||||
let exchangeTransferSimulator: ExchangeTransferSimulator;
|
||||
let transferFromAsync: Sinon.SinonSpy;
|
||||
const bigNumberMatch = (expected: BigNumber) => {
|
||||
return Sinon.match((value: BigNumber) => value.eq(expected));
|
||||
};
|
||||
beforeEach('create exchangeTransferSimulator', async () => {
|
||||
exchangeTransferSimulator = new ExchangeTransferSimulator(zeroEx.token, BlockParamLiteral.Latest);
|
||||
transferFromAsync = Sinon.spy();
|
||||
exchangeTransferSimulator.transferFromAsync = transferFromAsync as any;
|
||||
});
|
||||
it('should call exchangeTransferSimulator.transferFrom in a correct order', async () => {
|
||||
const makerFee = new BigNumber(2);
|
||||
const takerFee = new BigNumber(2);
|
||||
const signedOrder = await fillScenarios.createFillableSignedOrderWithFeesAsync(
|
||||
makerTokenAddress,
|
||||
takerTokenAddress,
|
||||
makerFee,
|
||||
takerFee,
|
||||
makerAddress,
|
||||
takerAddress,
|
||||
fillableAmount,
|
||||
feeRecipient,
|
||||
);
|
||||
await OrderValidationUtils.validateFillOrderBalancesAllowancesThrowIfInvalidAsync(
|
||||
exchangeTransferSimulator,
|
||||
signedOrder,
|
||||
fillableAmount,
|
||||
takerAddress,
|
||||
zrxTokenAddress,
|
||||
);
|
||||
expect(transferFromAsync.callCount).to.be.equal(4);
|
||||
expect(
|
||||
transferFromAsync
|
||||
.getCall(0)
|
||||
.calledWith(
|
||||
makerTokenAddress,
|
||||
makerAddress,
|
||||
takerAddress,
|
||||
bigNumberMatch(fillableAmount),
|
||||
TradeSide.Maker,
|
||||
TransferType.Trade,
|
||||
),
|
||||
).to.be.true();
|
||||
expect(
|
||||
transferFromAsync
|
||||
.getCall(1)
|
||||
.calledWith(
|
||||
takerTokenAddress,
|
||||
takerAddress,
|
||||
makerAddress,
|
||||
bigNumberMatch(fillableAmount),
|
||||
TradeSide.Taker,
|
||||
TransferType.Trade,
|
||||
),
|
||||
).to.be.true();
|
||||
expect(
|
||||
transferFromAsync
|
||||
.getCall(2)
|
||||
.calledWith(
|
||||
zrxTokenAddress,
|
||||
makerAddress,
|
||||
feeRecipient,
|
||||
bigNumberMatch(makerFee),
|
||||
TradeSide.Maker,
|
||||
TransferType.Fee,
|
||||
),
|
||||
).to.be.true();
|
||||
expect(
|
||||
transferFromAsync
|
||||
.getCall(3)
|
||||
.calledWith(
|
||||
zrxTokenAddress,
|
||||
takerAddress,
|
||||
feeRecipient,
|
||||
bigNumberMatch(takerFee),
|
||||
TradeSide.Taker,
|
||||
TransferType.Fee,
|
||||
),
|
||||
).to.be.true();
|
||||
});
|
||||
it('should call exchangeTransferSimulator.transferFrom with correct values for an open order', async () => {
|
||||
const makerFee = new BigNumber(2);
|
||||
const takerFee = new BigNumber(2);
|
||||
const signedOrder = await fillScenarios.createFillableSignedOrderWithFeesAsync(
|
||||
makerTokenAddress,
|
||||
takerTokenAddress,
|
||||
makerFee,
|
||||
takerFee,
|
||||
makerAddress,
|
||||
ZeroEx.NULL_ADDRESS,
|
||||
fillableAmount,
|
||||
feeRecipient,
|
||||
);
|
||||
await OrderValidationUtils.validateFillOrderBalancesAllowancesThrowIfInvalidAsync(
|
||||
exchangeTransferSimulator,
|
||||
signedOrder,
|
||||
fillableAmount,
|
||||
takerAddress,
|
||||
zrxTokenAddress,
|
||||
);
|
||||
expect(transferFromAsync.callCount).to.be.equal(4);
|
||||
expect(
|
||||
transferFromAsync
|
||||
.getCall(0)
|
||||
.calledWith(
|
||||
makerTokenAddress,
|
||||
makerAddress,
|
||||
takerAddress,
|
||||
bigNumberMatch(fillableAmount),
|
||||
TradeSide.Maker,
|
||||
TransferType.Trade,
|
||||
),
|
||||
).to.be.true();
|
||||
expect(
|
||||
transferFromAsync
|
||||
.getCall(1)
|
||||
.calledWith(
|
||||
takerTokenAddress,
|
||||
takerAddress,
|
||||
makerAddress,
|
||||
bigNumberMatch(fillableAmount),
|
||||
TradeSide.Taker,
|
||||
TransferType.Trade,
|
||||
),
|
||||
).to.be.true();
|
||||
expect(
|
||||
transferFromAsync
|
||||
.getCall(2)
|
||||
.calledWith(
|
||||
zrxTokenAddress,
|
||||
makerAddress,
|
||||
feeRecipient,
|
||||
bigNumberMatch(makerFee),
|
||||
TradeSide.Maker,
|
||||
TransferType.Fee,
|
||||
),
|
||||
).to.be.true();
|
||||
expect(
|
||||
transferFromAsync
|
||||
.getCall(3)
|
||||
.calledWith(
|
||||
zrxTokenAddress,
|
||||
takerAddress,
|
||||
feeRecipient,
|
||||
bigNumberMatch(takerFee),
|
||||
TradeSide.Taker,
|
||||
TransferType.Fee,
|
||||
),
|
||||
).to.be.true();
|
||||
});
|
||||
it('should correctly round the fillMakerTokenAmount', async () => {
|
||||
const makerTokenAmount = new BigNumber(3);
|
||||
const takerTokenAmount = new BigNumber(1);
|
||||
const signedOrder = await fillScenarios.createAsymmetricFillableSignedOrderAsync(
|
||||
makerTokenAddress,
|
||||
takerTokenAddress,
|
||||
makerAddress,
|
||||
takerAddress,
|
||||
makerTokenAmount,
|
||||
takerTokenAmount,
|
||||
);
|
||||
await OrderValidationUtils.validateFillOrderBalancesAllowancesThrowIfInvalidAsync(
|
||||
exchangeTransferSimulator,
|
||||
signedOrder,
|
||||
takerTokenAmount,
|
||||
takerAddress,
|
||||
zrxTokenAddress,
|
||||
);
|
||||
expect(transferFromAsync.callCount).to.be.equal(4);
|
||||
const makerFillAmount = transferFromAsync.getCall(0).args[3];
|
||||
expect(makerFillAmount).to.be.bignumber.equal(makerTokenAmount);
|
||||
});
|
||||
it('should correctly round the makerFeeAmount', async () => {
|
||||
const makerFee = new BigNumber(2);
|
||||
const takerFee = new BigNumber(4);
|
||||
const signedOrder = await fillScenarios.createFillableSignedOrderWithFeesAsync(
|
||||
makerTokenAddress,
|
||||
takerTokenAddress,
|
||||
makerFee,
|
||||
takerFee,
|
||||
makerAddress,
|
||||
takerAddress,
|
||||
fillableAmount,
|
||||
ZeroEx.NULL_ADDRESS,
|
||||
);
|
||||
const fillTakerTokenAmount = fillableAmount.div(2).round(0);
|
||||
await OrderValidationUtils.validateFillOrderBalancesAllowancesThrowIfInvalidAsync(
|
||||
exchangeTransferSimulator,
|
||||
signedOrder,
|
||||
fillTakerTokenAmount,
|
||||
takerAddress,
|
||||
zrxTokenAddress,
|
||||
);
|
||||
const makerPartialFee = makerFee.div(2);
|
||||
const takerPartialFee = takerFee.div(2);
|
||||
expect(transferFromAsync.callCount).to.be.equal(4);
|
||||
const partialMakerFee = transferFromAsync.getCall(2).args[3];
|
||||
expect(partialMakerFee).to.be.bignumber.equal(makerPartialFee);
|
||||
const partialTakerFee = transferFromAsync.getCall(3).args[3];
|
||||
expect(partialTakerFee).to.be.bignumber.equal(takerPartialFee);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,234 +0,0 @@
|
||||
import { ECSignature, SignedOrder } from '@0xproject/types';
|
||||
import { BigNumber } from '@0xproject/utils';
|
||||
import * as chai from 'chai';
|
||||
import 'mocha';
|
||||
|
||||
import { ZeroEx } from '../src/0x';
|
||||
import { RemainingFillableCalculator } from '../src/order_watcher/remaining_fillable_calculator';
|
||||
|
||||
import { chaiSetup } from './utils/chai_setup';
|
||||
|
||||
chaiSetup.configure();
|
||||
const expect = chai.expect;
|
||||
|
||||
describe('RemainingFillableCalculator', () => {
|
||||
let calculator: RemainingFillableCalculator;
|
||||
let signedOrder: SignedOrder;
|
||||
let transferrableMakerTokenAmount: BigNumber;
|
||||
let transferrableMakerFeeTokenAmount: BigNumber;
|
||||
let remainingMakerTokenAmount: BigNumber;
|
||||
let makerAmount: BigNumber;
|
||||
let takerAmount: BigNumber;
|
||||
let makerFeeAmount: BigNumber;
|
||||
let isMakerTokenZRX: boolean;
|
||||
const makerToken: string = '0x1';
|
||||
const takerToken: string = '0x2';
|
||||
const decimals: number = 4;
|
||||
const zero: BigNumber = new BigNumber(0);
|
||||
const zeroAddress = '0x0';
|
||||
const signature: ECSignature = { v: 27, r: '', s: '' };
|
||||
beforeEach(async () => {
|
||||
[makerAmount, takerAmount, makerFeeAmount] = [
|
||||
ZeroEx.toBaseUnitAmount(new BigNumber(50), decimals),
|
||||
ZeroEx.toBaseUnitAmount(new BigNumber(5), decimals),
|
||||
ZeroEx.toBaseUnitAmount(new BigNumber(1), decimals),
|
||||
];
|
||||
[transferrableMakerTokenAmount, transferrableMakerFeeTokenAmount] = [
|
||||
ZeroEx.toBaseUnitAmount(new BigNumber(50), decimals),
|
||||
ZeroEx.toBaseUnitAmount(new BigNumber(5), decimals),
|
||||
];
|
||||
});
|
||||
function buildSignedOrder(): SignedOrder {
|
||||
return {
|
||||
ecSignature: signature,
|
||||
exchangeContractAddress: zeroAddress,
|
||||
feeRecipient: zeroAddress,
|
||||
maker: zeroAddress,
|
||||
taker: zeroAddress,
|
||||
makerFee: makerFeeAmount,
|
||||
takerFee: zero,
|
||||
makerTokenAmount: makerAmount,
|
||||
takerTokenAmount: takerAmount,
|
||||
makerTokenAddress: makerToken,
|
||||
takerTokenAddress: takerToken,
|
||||
salt: zero,
|
||||
expirationUnixTimestampSec: zero,
|
||||
};
|
||||
}
|
||||
describe('Maker token is NOT ZRX', () => {
|
||||
before(async () => {
|
||||
isMakerTokenZRX = false;
|
||||
});
|
||||
it('calculates the correct amount when unfilled and funds available', () => {
|
||||
signedOrder = buildSignedOrder();
|
||||
remainingMakerTokenAmount = signedOrder.makerTokenAmount;
|
||||
calculator = new RemainingFillableCalculator(
|
||||
signedOrder,
|
||||
isMakerTokenZRX,
|
||||
transferrableMakerTokenAmount,
|
||||
transferrableMakerFeeTokenAmount,
|
||||
remainingMakerTokenAmount,
|
||||
);
|
||||
expect(calculator.computeRemainingMakerFillable()).to.be.bignumber.equal(remainingMakerTokenAmount);
|
||||
});
|
||||
it('calculates the correct amount when partially filled and funds available', () => {
|
||||
signedOrder = buildSignedOrder();
|
||||
remainingMakerTokenAmount = ZeroEx.toBaseUnitAmount(new BigNumber(1), decimals);
|
||||
calculator = new RemainingFillableCalculator(
|
||||
signedOrder,
|
||||
isMakerTokenZRX,
|
||||
transferrableMakerTokenAmount,
|
||||
transferrableMakerFeeTokenAmount,
|
||||
remainingMakerTokenAmount,
|
||||
);
|
||||
expect(calculator.computeRemainingMakerFillable()).to.be.bignumber.equal(remainingMakerTokenAmount);
|
||||
});
|
||||
it('calculates the amount to be 0 when all fee funds are transferred', () => {
|
||||
signedOrder = buildSignedOrder();
|
||||
transferrableMakerFeeTokenAmount = zero;
|
||||
remainingMakerTokenAmount = signedOrder.makerTokenAmount;
|
||||
calculator = new RemainingFillableCalculator(
|
||||
signedOrder,
|
||||
isMakerTokenZRX,
|
||||
transferrableMakerTokenAmount,
|
||||
transferrableMakerFeeTokenAmount,
|
||||
remainingMakerTokenAmount,
|
||||
);
|
||||
expect(calculator.computeRemainingMakerFillable()).to.be.bignumber.equal(zero);
|
||||
});
|
||||
it('calculates the correct amount when balance is less than remaining fillable', () => {
|
||||
signedOrder = buildSignedOrder();
|
||||
const partiallyFilledAmount = ZeroEx.toBaseUnitAmount(new BigNumber(2), decimals);
|
||||
remainingMakerTokenAmount = signedOrder.makerTokenAmount.minus(partiallyFilledAmount);
|
||||
transferrableMakerTokenAmount = remainingMakerTokenAmount.minus(partiallyFilledAmount);
|
||||
calculator = new RemainingFillableCalculator(
|
||||
signedOrder,
|
||||
isMakerTokenZRX,
|
||||
transferrableMakerTokenAmount,
|
||||
transferrableMakerFeeTokenAmount,
|
||||
remainingMakerTokenAmount,
|
||||
);
|
||||
expect(calculator.computeRemainingMakerFillable()).to.be.bignumber.equal(transferrableMakerTokenAmount);
|
||||
});
|
||||
describe('Order to Fee Ratio is < 1', () => {
|
||||
beforeEach(async () => {
|
||||
[makerAmount, takerAmount, makerFeeAmount] = [
|
||||
ZeroEx.toBaseUnitAmount(new BigNumber(3), decimals),
|
||||
ZeroEx.toBaseUnitAmount(new BigNumber(6), decimals),
|
||||
ZeroEx.toBaseUnitAmount(new BigNumber(6), decimals),
|
||||
];
|
||||
});
|
||||
it('calculates the correct amount when funds unavailable', () => {
|
||||
signedOrder = buildSignedOrder();
|
||||
remainingMakerTokenAmount = signedOrder.makerTokenAmount;
|
||||
const transferredAmount = ZeroEx.toBaseUnitAmount(new BigNumber(2), decimals);
|
||||
transferrableMakerTokenAmount = remainingMakerTokenAmount.minus(transferredAmount);
|
||||
calculator = new RemainingFillableCalculator(
|
||||
signedOrder,
|
||||
isMakerTokenZRX,
|
||||
transferrableMakerTokenAmount,
|
||||
transferrableMakerFeeTokenAmount,
|
||||
remainingMakerTokenAmount,
|
||||
);
|
||||
expect(calculator.computeRemainingMakerFillable()).to.be.bignumber.equal(transferrableMakerTokenAmount);
|
||||
});
|
||||
});
|
||||
describe('Ratio is not evenly divisble', () => {
|
||||
beforeEach(async () => {
|
||||
[makerAmount, takerAmount, makerFeeAmount] = [
|
||||
ZeroEx.toBaseUnitAmount(new BigNumber(3), decimals),
|
||||
ZeroEx.toBaseUnitAmount(new BigNumber(7), decimals),
|
||||
ZeroEx.toBaseUnitAmount(new BigNumber(7), decimals),
|
||||
];
|
||||
});
|
||||
it('calculates the correct amount when funds unavailable', () => {
|
||||
signedOrder = buildSignedOrder();
|
||||
remainingMakerTokenAmount = signedOrder.makerTokenAmount;
|
||||
const transferredAmount = ZeroEx.toBaseUnitAmount(new BigNumber(2), decimals);
|
||||
transferrableMakerTokenAmount = remainingMakerTokenAmount.minus(transferredAmount);
|
||||
calculator = new RemainingFillableCalculator(
|
||||
signedOrder,
|
||||
isMakerTokenZRX,
|
||||
transferrableMakerTokenAmount,
|
||||
transferrableMakerFeeTokenAmount,
|
||||
remainingMakerTokenAmount,
|
||||
);
|
||||
const calculatedFillableAmount = calculator.computeRemainingMakerFillable();
|
||||
expect(calculatedFillableAmount.lessThanOrEqualTo(transferrableMakerTokenAmount)).to.be.true();
|
||||
expect(calculatedFillableAmount).to.be.bignumber.greaterThan(new BigNumber(0));
|
||||
const orderToFeeRatio = signedOrder.makerTokenAmount.dividedBy(signedOrder.makerFee);
|
||||
const calculatedFeeAmount = calculatedFillableAmount.dividedBy(orderToFeeRatio);
|
||||
expect(calculatedFeeAmount).to.be.bignumber.lessThan(transferrableMakerFeeTokenAmount);
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('Maker Token is ZRX', () => {
|
||||
before(async () => {
|
||||
isMakerTokenZRX = true;
|
||||
});
|
||||
it('calculates the correct amount when unfilled and funds available', () => {
|
||||
signedOrder = buildSignedOrder();
|
||||
transferrableMakerTokenAmount = makerAmount.plus(makerFeeAmount);
|
||||
transferrableMakerFeeTokenAmount = transferrableMakerTokenAmount;
|
||||
remainingMakerTokenAmount = signedOrder.makerTokenAmount;
|
||||
calculator = new RemainingFillableCalculator(
|
||||
signedOrder,
|
||||
isMakerTokenZRX,
|
||||
transferrableMakerTokenAmount,
|
||||
transferrableMakerFeeTokenAmount,
|
||||
remainingMakerTokenAmount,
|
||||
);
|
||||
expect(calculator.computeRemainingMakerFillable()).to.be.bignumber.equal(remainingMakerTokenAmount);
|
||||
});
|
||||
it('calculates the correct amount when partially filled and funds available', () => {
|
||||
signedOrder = buildSignedOrder();
|
||||
remainingMakerTokenAmount = ZeroEx.toBaseUnitAmount(new BigNumber(1), decimals);
|
||||
calculator = new RemainingFillableCalculator(
|
||||
signedOrder,
|
||||
isMakerTokenZRX,
|
||||
transferrableMakerTokenAmount,
|
||||
transferrableMakerFeeTokenAmount,
|
||||
remainingMakerTokenAmount,
|
||||
);
|
||||
expect(calculator.computeRemainingMakerFillable()).to.be.bignumber.equal(remainingMakerTokenAmount);
|
||||
});
|
||||
it('calculates the amount to be 0 when all fee funds are transferred', () => {
|
||||
signedOrder = buildSignedOrder();
|
||||
transferrableMakerTokenAmount = zero;
|
||||
transferrableMakerFeeTokenAmount = zero;
|
||||
remainingMakerTokenAmount = signedOrder.makerTokenAmount;
|
||||
calculator = new RemainingFillableCalculator(
|
||||
signedOrder,
|
||||
isMakerTokenZRX,
|
||||
transferrableMakerTokenAmount,
|
||||
transferrableMakerFeeTokenAmount,
|
||||
remainingMakerTokenAmount,
|
||||
);
|
||||
expect(calculator.computeRemainingMakerFillable()).to.be.bignumber.equal(zero);
|
||||
});
|
||||
it('calculates the correct amount when balance is less than remaining fillable', () => {
|
||||
signedOrder = buildSignedOrder();
|
||||
const partiallyFilledAmount = ZeroEx.toBaseUnitAmount(new BigNumber(2), decimals);
|
||||
remainingMakerTokenAmount = signedOrder.makerTokenAmount.minus(partiallyFilledAmount);
|
||||
transferrableMakerTokenAmount = remainingMakerTokenAmount.minus(partiallyFilledAmount);
|
||||
transferrableMakerFeeTokenAmount = transferrableMakerTokenAmount;
|
||||
|
||||
const orderToFeeRatio = signedOrder.makerTokenAmount.dividedToIntegerBy(signedOrder.makerFee);
|
||||
const expectedFillableAmount = new BigNumber(450980);
|
||||
calculator = new RemainingFillableCalculator(
|
||||
signedOrder,
|
||||
isMakerTokenZRX,
|
||||
transferrableMakerTokenAmount,
|
||||
transferrableMakerFeeTokenAmount,
|
||||
remainingMakerTokenAmount,
|
||||
);
|
||||
const calculatedFillableAmount = calculator.computeRemainingMakerFillable();
|
||||
const numberOfFillsInRatio = calculatedFillableAmount.dividedToIntegerBy(orderToFeeRatio);
|
||||
const calculatedFillableAmountPlusFees = calculatedFillableAmount.plus(numberOfFillsInRatio);
|
||||
expect(calculatedFillableAmountPlusFees).to.be.bignumber.lessThan(transferrableMakerTokenAmount);
|
||||
expect(calculatedFillableAmountPlusFees).to.be.bignumber.lessThan(remainingMakerTokenAmount);
|
||||
expect(calculatedFillableAmount).to.be.bignumber.equal(expectedFillableAmount);
|
||||
expect(numberOfFillsInRatio.decimalPlaces()).to.be.equal(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,82 +0,0 @@
|
||||
import { BlockchainLifecycle, devConstants } from '@0xproject/dev-utils';
|
||||
import { BigNumber } from '@0xproject/utils';
|
||||
import * as _ from 'lodash';
|
||||
import 'mocha';
|
||||
import * as Sinon from 'sinon';
|
||||
|
||||
import { ApprovalContractEventArgs, DecodedLogEvent, Token, TokenEvents, ZeroEx } from '../src';
|
||||
import { DoneCallback } from '../src/types';
|
||||
|
||||
import { chaiSetup } from './utils/chai_setup';
|
||||
import { constants } from './utils/constants';
|
||||
import { assertNodeCallbackError } from './utils/report_callback_errors';
|
||||
import { provider, web3Wrapper } from './utils/web3_wrapper';
|
||||
|
||||
chaiSetup.configure();
|
||||
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
||||
|
||||
describe('SubscriptionTest', () => {
|
||||
let zeroEx: ZeroEx;
|
||||
let userAddresses: string[];
|
||||
let tokens: Token[];
|
||||
let coinbase: string;
|
||||
let addressWithoutFunds: string;
|
||||
const config = {
|
||||
networkId: constants.TESTRPC_NETWORK_ID,
|
||||
};
|
||||
before(async () => {
|
||||
zeroEx = new ZeroEx(provider, config);
|
||||
userAddresses = await zeroEx.getAvailableAddressesAsync();
|
||||
tokens = await zeroEx.tokenRegistry.getTokensAsync();
|
||||
coinbase = userAddresses[0];
|
||||
addressWithoutFunds = userAddresses[1];
|
||||
});
|
||||
beforeEach(async () => {
|
||||
await blockchainLifecycle.startAsync();
|
||||
});
|
||||
afterEach(async () => {
|
||||
await blockchainLifecycle.revertAsync();
|
||||
});
|
||||
describe('#subscribe', () => {
|
||||
const indexFilterValues = {};
|
||||
let tokenAddress: string;
|
||||
const allowanceAmount = new BigNumber(42);
|
||||
let stubs: Sinon.SinonStub[] = [];
|
||||
before(() => {
|
||||
const token = tokens[0];
|
||||
tokenAddress = token.address;
|
||||
});
|
||||
afterEach(() => {
|
||||
zeroEx.token.unsubscribeAll();
|
||||
_.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 = assertNodeCallbackError(done, errMsg);
|
||||
stubs = [Sinon.stub((zeroEx as any)._web3Wrapper, 'getBlockAsync').throws(new Error(errMsg))];
|
||||
zeroEx.token.subscribe(tokenAddress, TokenEvents.Approval, indexFilterValues, callback);
|
||||
await zeroEx.token.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 = assertNodeCallbackError(done, errMsg);
|
||||
stubs = [Sinon.stub((zeroEx as any)._web3Wrapper, 'getLogsAsync').throws(new Error(errMsg))];
|
||||
zeroEx.token.subscribe(tokenAddress, TokenEvents.Approval, indexFilterValues, callback);
|
||||
await zeroEx.token.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<ApprovalContractEventArgs>) => _.noop;
|
||||
zeroEx.token.subscribe(tokenAddress, TokenEvents.Approval, indexFilterValues, callback);
|
||||
stubs = [Sinon.stub((zeroEx as any)._web3Wrapper, 'getBlockAsync').throws(new Error('JSON RPC error'))];
|
||||
zeroEx.token.unsubscribeAll();
|
||||
done();
|
||||
})().catch(done);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,128 +0,0 @@
|
||||
import { BlockchainLifecycle, devConstants } from '@0xproject/dev-utils';
|
||||
import { schemas, SchemaValidator } from '@0xproject/json-schemas';
|
||||
import * as chai from 'chai';
|
||||
import * as _ from 'lodash';
|
||||
import 'mocha';
|
||||
|
||||
import { Token, ZeroEx } from '../src';
|
||||
|
||||
import { chaiSetup } from './utils/chai_setup';
|
||||
import { constants } from './utils/constants';
|
||||
import { provider, web3Wrapper } from './utils/web3_wrapper';
|
||||
|
||||
chaiSetup.configure();
|
||||
const expect = chai.expect;
|
||||
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
||||
|
||||
const TOKEN_REGISTRY_SIZE_AFTER_MIGRATION = 7;
|
||||
|
||||
describe('TokenRegistryWrapper', () => {
|
||||
let zeroEx: ZeroEx;
|
||||
let tokens: Token[];
|
||||
const tokenAddressBySymbol: { [symbol: string]: string } = {};
|
||||
const tokenAddressByName: { [symbol: string]: string } = {};
|
||||
const tokenBySymbol: { [symbol: string]: Token } = {};
|
||||
const tokenByName: { [symbol: string]: Token } = {};
|
||||
const registeredSymbol = 'ZRX';
|
||||
const registeredName = '0x Protocol Token';
|
||||
const unregisteredSymbol = 'MAL';
|
||||
const unregisteredName = 'Malicious Token';
|
||||
const config = {
|
||||
networkId: constants.TESTRPC_NETWORK_ID,
|
||||
};
|
||||
before(async () => {
|
||||
zeroEx = new ZeroEx(provider, config);
|
||||
tokens = await zeroEx.tokenRegistry.getTokensAsync();
|
||||
_.map(tokens, token => {
|
||||
tokenAddressBySymbol[token.symbol] = token.address;
|
||||
tokenAddressByName[token.name] = token.address;
|
||||
tokenBySymbol[token.symbol] = token;
|
||||
tokenByName[token.name] = token;
|
||||
});
|
||||
});
|
||||
beforeEach(async () => {
|
||||
await blockchainLifecycle.startAsync();
|
||||
});
|
||||
afterEach(async () => {
|
||||
await blockchainLifecycle.revertAsync();
|
||||
});
|
||||
describe('#getTokensAsync', () => {
|
||||
it('should return all the tokens added to the tokenRegistry during the migration', async () => {
|
||||
expect(tokens).to.have.lengthOf(TOKEN_REGISTRY_SIZE_AFTER_MIGRATION);
|
||||
|
||||
const schemaValidator = new SchemaValidator();
|
||||
_.each(tokens, token => {
|
||||
const validationResult = schemaValidator.validate(token, schemas.tokenSchema);
|
||||
expect(validationResult.errors).to.have.lengthOf(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('#getTokenAddressesAsync', () => {
|
||||
it('should return all the token addresses added to the tokenRegistry during the migration', async () => {
|
||||
const tokenAddresses = await zeroEx.tokenRegistry.getTokenAddressesAsync();
|
||||
expect(tokenAddresses).to.have.lengthOf(TOKEN_REGISTRY_SIZE_AFTER_MIGRATION);
|
||||
|
||||
const schemaValidator = new SchemaValidator();
|
||||
_.each(tokenAddresses, tokenAddress => {
|
||||
const validationResult = schemaValidator.validate(tokenAddress, schemas.addressSchema);
|
||||
expect(validationResult.errors).to.have.lengthOf(0);
|
||||
expect(tokenAddress).to.not.be.equal(ZeroEx.NULL_ADDRESS);
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('#getTokenAddressBySymbol', () => {
|
||||
it('should return correct address for a token in the registry', async () => {
|
||||
const tokenAddress = await zeroEx.tokenRegistry.getTokenAddressBySymbolIfExistsAsync(registeredSymbol);
|
||||
expect(tokenAddress).to.be.equal(tokenAddressBySymbol[registeredSymbol]);
|
||||
});
|
||||
it('should return undefined for a token out of registry', async () => {
|
||||
const tokenAddress = await zeroEx.tokenRegistry.getTokenAddressBySymbolIfExistsAsync(unregisteredSymbol);
|
||||
expect(tokenAddress).to.be.undefined();
|
||||
});
|
||||
});
|
||||
describe('#getTokenAddressByName', () => {
|
||||
it('should return correct address for a token in the registry', async () => {
|
||||
const tokenAddress = await zeroEx.tokenRegistry.getTokenAddressByNameIfExistsAsync(registeredName);
|
||||
expect(tokenAddress).to.be.equal(tokenAddressByName[registeredName]);
|
||||
});
|
||||
it('should return undefined for a token out of registry', async () => {
|
||||
const tokenAddress = await zeroEx.tokenRegistry.getTokenAddressByNameIfExistsAsync(unregisteredName);
|
||||
expect(tokenAddress).to.be.undefined();
|
||||
});
|
||||
});
|
||||
describe('#getTokenBySymbol', () => {
|
||||
it('should return correct token for a token in the registry', async () => {
|
||||
const token = await zeroEx.tokenRegistry.getTokenBySymbolIfExistsAsync(registeredSymbol);
|
||||
expect(token).to.be.deep.equal(tokenBySymbol[registeredSymbol]);
|
||||
});
|
||||
it('should return undefined for a token out of registry', async () => {
|
||||
const token = await zeroEx.tokenRegistry.getTokenBySymbolIfExistsAsync(unregisteredSymbol);
|
||||
expect(token).to.be.undefined();
|
||||
});
|
||||
});
|
||||
describe('#getTokenByName', () => {
|
||||
it('should return correct token for a token in the registry', async () => {
|
||||
const token = await zeroEx.tokenRegistry.getTokenByNameIfExistsAsync(registeredName);
|
||||
expect(token).to.be.deep.equal(tokenByName[registeredName]);
|
||||
});
|
||||
it('should return undefined for a token out of registry', async () => {
|
||||
const token = await zeroEx.tokenRegistry.getTokenByNameIfExistsAsync(unregisteredName);
|
||||
expect(token).to.be.undefined();
|
||||
});
|
||||
});
|
||||
describe('#getTokenIfExistsAsync', () => {
|
||||
it('should return the token added to the tokenRegistry during the migration', async () => {
|
||||
const aToken = tokens[0];
|
||||
|
||||
const token = await zeroEx.tokenRegistry.getTokenIfExistsAsync(aToken.address);
|
||||
const schemaValidator = new SchemaValidator();
|
||||
const validationResult = schemaValidator.validate(token, schemas.tokenSchema);
|
||||
expect(validationResult.errors).to.have.lengthOf(0);
|
||||
});
|
||||
it('should return return undefined when passed a token address not in the tokenRegistry', async () => {
|
||||
const unregisteredTokenAddress = '0x5409ed021d9299bf6814279a6a1411a7e866a631';
|
||||
const tokenIfExists = await zeroEx.tokenRegistry.getTokenIfExistsAsync(unregisteredTokenAddress);
|
||||
expect(tokenIfExists).to.be.undefined();
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -4,7 +4,7 @@ import ChaiBigNumber = require('chai-bignumber');
|
||||
import * as dirtyChai from 'dirty-chai';
|
||||
|
||||
export const chaiSetup = {
|
||||
configure() {
|
||||
configure(): void {
|
||||
chai.config.includeStack = true;
|
||||
chai.use(ChaiBigNumber());
|
||||
chai.use(dirtyChai);
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
import { Deployer } from '@0xproject/deployer';
|
||||
import { devConstants } from '@0xproject/dev-utils';
|
||||
import * as path from 'path';
|
||||
|
||||
import { constants } from './constants';
|
||||
|
||||
import { provider } from './web3_wrapper';
|
||||
|
||||
const artifactsDir = path.resolve('test', 'artifacts');
|
||||
const deployerOpts = {
|
||||
artifactsDir,
|
||||
provider,
|
||||
networkId: constants.TESTRPC_NETWORK_ID,
|
||||
defaults: {
|
||||
gas: devConstants.GAS_ESTIMATE,
|
||||
},
|
||||
};
|
||||
export const deployer = new Deployer(deployerOpts);
|
||||
@@ -1,203 +0,0 @@
|
||||
import { BigNumber } from '@0xproject/utils';
|
||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||
|
||||
import { SignedOrder, Token, ZeroEx } from '../../src';
|
||||
import { artifacts } from '../../src/artifacts';
|
||||
import { DummyTokenContract } from '../../src/contract_wrappers/generated/dummy_token';
|
||||
import { orderFactory } from '../utils/order_factory';
|
||||
|
||||
import { constants } from './constants';
|
||||
|
||||
const INITIAL_COINBASE_TOKEN_SUPPLY_IN_UNITS = new BigNumber(100);
|
||||
|
||||
export class FillScenarios {
|
||||
private _zeroEx: ZeroEx;
|
||||
private _userAddresses: string[];
|
||||
private _tokens: Token[];
|
||||
private _coinbase: string;
|
||||
private _zrxTokenAddress: string;
|
||||
private _exchangeContractAddress: string;
|
||||
constructor(
|
||||
zeroEx: ZeroEx,
|
||||
userAddresses: string[],
|
||||
tokens: Token[],
|
||||
zrxTokenAddress: string,
|
||||
exchangeContractAddress: string,
|
||||
) {
|
||||
this._zeroEx = zeroEx;
|
||||
this._userAddresses = userAddresses;
|
||||
this._tokens = tokens;
|
||||
this._coinbase = userAddresses[0];
|
||||
this._zrxTokenAddress = zrxTokenAddress;
|
||||
this._exchangeContractAddress = exchangeContractAddress;
|
||||
}
|
||||
public async initTokenBalancesAsync() {
|
||||
const web3Wrapper = (this._zeroEx as any)._web3Wrapper as Web3Wrapper;
|
||||
for (const token of this._tokens) {
|
||||
if (token.symbol !== 'ZRX' && token.symbol !== 'WETH') {
|
||||
const defaults = {};
|
||||
const dummyToken = new DummyTokenContract(
|
||||
artifacts.DummyTokenArtifact.abi,
|
||||
token.address,
|
||||
web3Wrapper.getProvider(),
|
||||
web3Wrapper.getContractDefaults(),
|
||||
);
|
||||
const tokenSupply = ZeroEx.toBaseUnitAmount(INITIAL_COINBASE_TOKEN_SUPPLY_IN_UNITS, token.decimals);
|
||||
const txHash = await dummyToken.setBalance.sendTransactionAsync(this._coinbase, tokenSupply, {
|
||||
from: this._coinbase,
|
||||
});
|
||||
await this._zeroEx.awaitTransactionMinedAsync(txHash);
|
||||
}
|
||||
}
|
||||
}
|
||||
public async createFillableSignedOrderAsync(
|
||||
makerTokenAddress: string,
|
||||
takerTokenAddress: string,
|
||||
makerAddress: string,
|
||||
takerAddress: string,
|
||||
fillableAmount: BigNumber,
|
||||
expirationUnixTimestampSec?: BigNumber,
|
||||
): Promise<SignedOrder> {
|
||||
return this.createAsymmetricFillableSignedOrderAsync(
|
||||
makerTokenAddress,
|
||||
takerTokenAddress,
|
||||
makerAddress,
|
||||
takerAddress,
|
||||
fillableAmount,
|
||||
fillableAmount,
|
||||
expirationUnixTimestampSec,
|
||||
);
|
||||
}
|
||||
public async createFillableSignedOrderWithFeesAsync(
|
||||
makerTokenAddress: string,
|
||||
takerTokenAddress: string,
|
||||
makerFee: BigNumber,
|
||||
takerFee: BigNumber,
|
||||
makerAddress: string,
|
||||
takerAddress: string,
|
||||
fillableAmount: BigNumber,
|
||||
feeRecepient: string,
|
||||
expirationUnixTimestampSec?: BigNumber,
|
||||
): Promise<SignedOrder> {
|
||||
return this._createAsymmetricFillableSignedOrderWithFeesAsync(
|
||||
makerTokenAddress,
|
||||
takerTokenAddress,
|
||||
makerFee,
|
||||
takerFee,
|
||||
makerAddress,
|
||||
takerAddress,
|
||||
fillableAmount,
|
||||
fillableAmount,
|
||||
feeRecepient,
|
||||
expirationUnixTimestampSec,
|
||||
);
|
||||
}
|
||||
public async createAsymmetricFillableSignedOrderAsync(
|
||||
makerTokenAddress: string,
|
||||
takerTokenAddress: string,
|
||||
makerAddress: string,
|
||||
takerAddress: string,
|
||||
makerFillableAmount: BigNumber,
|
||||
takerFillableAmount: BigNumber,
|
||||
expirationUnixTimestampSec?: BigNumber,
|
||||
): Promise<SignedOrder> {
|
||||
const makerFee = new BigNumber(0);
|
||||
const takerFee = new BigNumber(0);
|
||||
const feeRecepient = constants.NULL_ADDRESS;
|
||||
return this._createAsymmetricFillableSignedOrderWithFeesAsync(
|
||||
makerTokenAddress,
|
||||
takerTokenAddress,
|
||||
makerFee,
|
||||
takerFee,
|
||||
makerAddress,
|
||||
takerAddress,
|
||||
makerFillableAmount,
|
||||
takerFillableAmount,
|
||||
feeRecepient,
|
||||
expirationUnixTimestampSec,
|
||||
);
|
||||
}
|
||||
public async createPartiallyFilledSignedOrderAsync(
|
||||
makerTokenAddress: string,
|
||||
takerTokenAddress: string,
|
||||
takerAddress: string,
|
||||
fillableAmount: BigNumber,
|
||||
partialFillAmount: BigNumber,
|
||||
) {
|
||||
const [makerAddress] = this._userAddresses;
|
||||
const signedOrder = await this.createAsymmetricFillableSignedOrderAsync(
|
||||
makerTokenAddress,
|
||||
takerTokenAddress,
|
||||
makerAddress,
|
||||
takerAddress,
|
||||
fillableAmount,
|
||||
fillableAmount,
|
||||
);
|
||||
const shouldThrowOnInsufficientBalanceOrAllowance = false;
|
||||
await this._zeroEx.exchange.fillOrderAsync(
|
||||
signedOrder,
|
||||
partialFillAmount,
|
||||
shouldThrowOnInsufficientBalanceOrAllowance,
|
||||
takerAddress,
|
||||
);
|
||||
return signedOrder;
|
||||
}
|
||||
private async _createAsymmetricFillableSignedOrderWithFeesAsync(
|
||||
makerTokenAddress: string,
|
||||
takerTokenAddress: string,
|
||||
makerFee: BigNumber,
|
||||
takerFee: BigNumber,
|
||||
makerAddress: string,
|
||||
takerAddress: string,
|
||||
makerFillableAmount: BigNumber,
|
||||
takerFillableAmount: BigNumber,
|
||||
feeRecepient: string,
|
||||
expirationUnixTimestampSec?: BigNumber,
|
||||
): Promise<SignedOrder> {
|
||||
await Promise.all([
|
||||
this._increaseBalanceAndAllowanceAsync(makerTokenAddress, makerAddress, makerFillableAmount),
|
||||
this._increaseBalanceAndAllowanceAsync(takerTokenAddress, takerAddress, takerFillableAmount),
|
||||
]);
|
||||
await Promise.all([
|
||||
this._increaseBalanceAndAllowanceAsync(this._zrxTokenAddress, makerAddress, makerFee),
|
||||
this._increaseBalanceAndAllowanceAsync(this._zrxTokenAddress, takerAddress, takerFee),
|
||||
]);
|
||||
|
||||
const signedOrder = await orderFactory.createSignedOrderAsync(
|
||||
this._zeroEx,
|
||||
makerAddress,
|
||||
takerAddress,
|
||||
makerFee,
|
||||
takerFee,
|
||||
makerFillableAmount,
|
||||
makerTokenAddress,
|
||||
takerFillableAmount,
|
||||
takerTokenAddress,
|
||||
this._exchangeContractAddress,
|
||||
feeRecepient,
|
||||
expirationUnixTimestampSec,
|
||||
);
|
||||
return signedOrder;
|
||||
}
|
||||
private async _increaseBalanceAndAllowanceAsync(
|
||||
tokenAddress: string,
|
||||
address: string,
|
||||
amount: BigNumber,
|
||||
): Promise<void> {
|
||||
if (amount.isZero() || address === ZeroEx.NULL_ADDRESS) {
|
||||
return; // noop
|
||||
}
|
||||
await Promise.all([
|
||||
this._increaseBalanceAsync(tokenAddress, address, amount),
|
||||
this._increaseAllowanceAsync(tokenAddress, address, amount),
|
||||
]);
|
||||
}
|
||||
private async _increaseBalanceAsync(tokenAddress: string, address: string, amount: BigNumber): Promise<void> {
|
||||
await this._zeroEx.token.transferAsync(tokenAddress, this._coinbase, address, amount);
|
||||
}
|
||||
private async _increaseAllowanceAsync(tokenAddress: string, address: string, amount: BigNumber): Promise<void> {
|
||||
const oldMakerAllowance = await this._zeroEx.token.getProxyAllowanceAsync(tokenAddress, address);
|
||||
const newMakerAllowance = oldMakerAllowance.plus(amount);
|
||||
await this._zeroEx.token.setProxyAllowanceAsync(tokenAddress, address, newMakerAllowance);
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
import { BigNumber } from '@0xproject/utils';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { SignedOrder, ZeroEx } from '../../src';
|
||||
|
||||
const SHOULD_ADD_PERSONAL_MESSAGE_PREFIX = false;
|
||||
|
||||
export const orderFactory = {
|
||||
async createSignedOrderAsync(
|
||||
zeroEx: ZeroEx,
|
||||
maker: string,
|
||||
taker: string,
|
||||
makerFee: BigNumber,
|
||||
takerFee: BigNumber,
|
||||
makerTokenAmount: BigNumber,
|
||||
makerTokenAddress: string,
|
||||
takerTokenAmount: BigNumber,
|
||||
takerTokenAddress: string,
|
||||
exchangeContractAddress: string,
|
||||
feeRecipient: string,
|
||||
expirationUnixTimestampSecIfExists?: BigNumber,
|
||||
): Promise<SignedOrder> {
|
||||
const defaultExpirationUnixTimestampSec = new BigNumber(2524604400); // Close to infinite
|
||||
const expirationUnixTimestampSec = _.isUndefined(expirationUnixTimestampSecIfExists)
|
||||
? defaultExpirationUnixTimestampSec
|
||||
: expirationUnixTimestampSecIfExists;
|
||||
const order = {
|
||||
maker,
|
||||
taker,
|
||||
makerFee,
|
||||
takerFee,
|
||||
makerTokenAmount,
|
||||
takerTokenAmount,
|
||||
makerTokenAddress,
|
||||
takerTokenAddress,
|
||||
salt: ZeroEx.generatePseudoRandomSalt(),
|
||||
exchangeContractAddress,
|
||||
feeRecipient,
|
||||
expirationUnixTimestampSec,
|
||||
};
|
||||
const orderHash = ZeroEx.getOrderHashHex(order);
|
||||
const ecSignature = await zeroEx.signOrderHashAsync(orderHash, maker, SHOULD_ADD_PERSONAL_MESSAGE_PREFIX);
|
||||
const signedOrder: SignedOrder = _.assign(order, { ecSignature });
|
||||
return signedOrder;
|
||||
},
|
||||
};
|
||||
@@ -1,66 +0,0 @@
|
||||
import * as chai from 'chai';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { DoneCallback } from '../../src/types';
|
||||
|
||||
const expect = chai.expect;
|
||||
|
||||
export const reportNoErrorCallbackErrors = (done: DoneCallback, expectToBeCalledOnce = true) => {
|
||||
return <T>(f?: (value: T) => void) => {
|
||||
const wrapped = (value: T) => {
|
||||
if (_.isUndefined(f)) {
|
||||
done();
|
||||
return;
|
||||
}
|
||||
try {
|
||||
f(value);
|
||||
if (expectToBeCalledOnce) {
|
||||
done();
|
||||
}
|
||||
} catch (err) {
|
||||
done(err);
|
||||
}
|
||||
};
|
||||
return wrapped;
|
||||
};
|
||||
};
|
||||
|
||||
export const reportNodeCallbackErrors = (done: DoneCallback, expectToBeCalledOnce = true) => {
|
||||
return <T>(f?: (value: T) => void) => {
|
||||
const wrapped = (error: Error | null, value: T | undefined) => {
|
||||
if (!_.isNull(error)) {
|
||||
done(error);
|
||||
} else {
|
||||
if (_.isUndefined(f)) {
|
||||
done();
|
||||
return;
|
||||
}
|
||||
try {
|
||||
f(value as T);
|
||||
if (expectToBeCalledOnce) {
|
||||
done();
|
||||
}
|
||||
} catch (err) {
|
||||
done(err);
|
||||
}
|
||||
}
|
||||
};
|
||||
return wrapped;
|
||||
};
|
||||
};
|
||||
|
||||
export const assertNodeCallbackError = (done: DoneCallback, errMsg: string) => {
|
||||
const wrapped = <T>(error: Error | null, value: T | undefined) => {
|
||||
if (_.isNull(error)) {
|
||||
done(new Error('Expected callback to receive an error'));
|
||||
} else {
|
||||
try {
|
||||
expect(error.message).to.be.equal(errMsg);
|
||||
done();
|
||||
} catch (err) {
|
||||
done(err);
|
||||
}
|
||||
}
|
||||
};
|
||||
return wrapped;
|
||||
};
|
||||
@@ -1,33 +1,9 @@
|
||||
import * as _ from 'lodash';
|
||||
import { artifacts } from '../../src/artifacts';
|
||||
|
||||
import { InternalZeroExError, Token } 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,12 +1,12 @@
|
||||
import { devConstants, web3Factory } from '@0xproject/dev-utils';
|
||||
import { Provider } from '@0xproject/types';
|
||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||
import * as Web3 from 'web3';
|
||||
import { Provider } from 'ethereum-types';
|
||||
|
||||
import { constants } from './constants';
|
||||
const txDefaults = {
|
||||
from: devConstants.TESTRPC_FIRST_ADDRESS,
|
||||
gas: devConstants.GAS_LIMIT,
|
||||
};
|
||||
const provider: Provider = web3Factory.getRpcProvider({ shouldUseInProcessGanache: true });
|
||||
const web3Wrapper = new Web3Wrapper(provider);
|
||||
|
||||
const web3 = web3Factory.create({ shouldUseInProcessGanache: true });
|
||||
const provider: Provider = web3.currentProvider;
|
||||
const web3Wrapper = new Web3Wrapper(web3.currentProvider);
|
||||
|
||||
export { provider, web3Wrapper };
|
||||
export { provider, web3Wrapper, txDefaults };
|
||||
|
||||
@@ -1,4 +1,123 @@
|
||||
[
|
||||
{
|
||||
"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",
|
||||
"pr": 822
|
||||
},
|
||||
{
|
||||
"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"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1529397769,
|
||||
"version": "0.3.2",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"version": "0.3.1",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Incorrect publish that was unpublished"
|
||||
}
|
||||
],
|
||||
"timestamp": 1527810075
|
||||
},
|
||||
{
|
||||
"version": "0.3.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Properly export the executable binary",
|
||||
"pr": 588
|
||||
}
|
||||
],
|
||||
"timestamp": 1527008270
|
||||
},
|
||||
{
|
||||
"timestamp": 1525477860,
|
||||
"version": "0.2.13",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1525428773,
|
||||
"version": "0.2.12",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1524044013,
|
||||
"version": "0.2.11",
|
||||
|
||||
@@ -1,15 +1,65 @@
|
||||
<!--
|
||||
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
|
||||
|
||||
## v0.3.1 - _June 1, 2018_
|
||||
|
||||
* Incorrect publish that was unpublished
|
||||
|
||||
## v0.3.0 - _May 22, 2018_
|
||||
|
||||
* Properly export the executable binary (#588)
|
||||
|
||||
## v0.2.13 - _May 5, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.2.12 - _May 4, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.2.11 - _April 18, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.2.10 - _April 12, 2018_
|
||||
## v0.2.10 - _April 11, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
@@ -21,26 +71,26 @@ CHANGELOG
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.2.5 - _March 18, 2018_
|
||||
## v0.2.5 - _March 17, 2018_
|
||||
|
||||
* Consolidate all `console.log` calls into `logUtils` in the `@0xproject/utils` package (#452)
|
||||
|
||||
## v0.2.4 - _March 4, 2018_
|
||||
## v0.2.4 - _March 3, 2018_
|
||||
|
||||
* Add a `backend` parameter that allows you to specify the Ethereum library you use in your templates (`web3` or `ethers`). Ethers auto-converts small ints to numbers whereas Web3 doesn't. Defaults to `web3` (#413)
|
||||
* Add support for [tuple types](https://solidity.readthedocs.io/en/develop/abi-spec.html#handling-tuple-types) (#413)
|
||||
* Add `hasReturnValue` to context data (#413)
|
||||
|
||||
## v0.2.1 - _February 9, 2018_
|
||||
## v0.2.1 - _February 8, 2018_
|
||||
|
||||
* Fix publishing issue where .npmignore was not properly excluding undesired content (#389)
|
||||
|
||||
## v0.2.0 - _February 7, 2018_
|
||||
## v0.2.0 - _February 6, 2018_
|
||||
|
||||
* Added CLI options for explicit specifying location of partials and main template (#346)
|
||||
* Added CLI option to specify networkId, adding support for the JSON artifact format found in @0xproject/contracts (#388)
|
||||
|
||||
## v0.1.0 - _January 11, 2018_
|
||||
## v0.1.0 - _January 10, 2018_
|
||||
|
||||
* Fixed array typings with union types (#295)
|
||||
* Add event ABIs to context data passed to templates (#302)
|
||||
|
||||
@@ -4,8 +4,7 @@ This package allows you to generate TypeScript contract wrappers from ABI files.
|
||||
It's heavily inspired by [Geth abigen](https://github.com/ethereum/go-ethereum/wiki/Native-DApps:-Go-bindings-to-Ethereum-contracts) but takes a different approach.
|
||||
You can write your custom handlebars templates which will allow you to seamlessly integrate the generated code into your existing codebase with existing conventions.
|
||||
|
||||
For an example of the generated [wrapper files](https://github.com/0xProject/0x-monorepo/tree/development/packages/0x.js/src/contract_wrappers/generated) check out 0x.js.
|
||||
[Here](https://github.com/0xProject/0x-monorepo/tree/development/packages/0x.js/contract_templates) are the templates used to generate those files.
|
||||
[Here](https://github.com/0xProject/0x-monorepo/tree/development/packages/0x.js/contract_templates) are the templates used to generate the contract wrappers used by 0x.js.e
|
||||
|
||||
## Installation
|
||||
|
||||
@@ -45,7 +44,7 @@ You need to also specify the location of your main template used for every contr
|
||||
|
||||
## How to write custom templates?
|
||||
|
||||
The best way to get started is to copy [0x.js templates](https://github.com/0xProject/0x-monorepo/tree/development/packages/0x.js/contract_templates) and start adjusting them for your needs.
|
||||
The best way to get started is to copy [0x.js templates](https://github.com/0xProject/0x-monorepo/tree/development/packages/contract_templates) and start adjusting them for your needs.
|
||||
We use [handlebars](http://handlebarsjs.com/) template engine under the hood.
|
||||
You need to have a master template called `contract.mustache`. it will be used to generate each contract wrapper. Although - you don't need and probably shouldn't write all your logic in a single template file. You can write [partial templates](http://handlebarsjs.com/partials.html) and as long as they are within a partials folder - they will be registered and available.
|
||||
|
||||
@@ -80,28 +79,16 @@ yarn install
|
||||
|
||||
### Build
|
||||
|
||||
If this is your **first** time building this package, you must first build **all** packages within the monorepo. This is because packages that depend on other packages located inside this monorepo are symlinked when run from **within** the monorepo. This allows you to make changes across multiple packages without first publishing dependent packages to NPM. To build all packages, run the following from the monorepo root directory:
|
||||
To build this package and all other monorepo packages that it depends on, run the following from the monorepo root directory:
|
||||
|
||||
```bash
|
||||
yarn lerna:rebuild
|
||||
PKG=@0xproject/abi-gen yarn build
|
||||
```
|
||||
|
||||
Or continuously rebuild on change:
|
||||
|
||||
```bash
|
||||
yarn dev
|
||||
```
|
||||
|
||||
You can also build this specific package by running the following from within its directory:
|
||||
|
||||
```bash
|
||||
yarn build
|
||||
```
|
||||
|
||||
or continuously rebuild on change:
|
||||
|
||||
```bash
|
||||
yarn build:watch
|
||||
PKG=@0xproject/abi-gen yarn watch
|
||||
```
|
||||
|
||||
### Clean
|
||||
|
||||
2
packages/abi-gen/bin/abi-gen.js
Executable file
2
packages/abi-gen/bin/abi-gen.js
Executable file
@@ -0,0 +1,2 @@
|
||||
#!/usr/bin/env node
|
||||
require('../lib/src/index.js');
|
||||
@@ -1,18 +1,26 @@
|
||||
{
|
||||
"name": "@0xproject/abi-gen",
|
||||
"version": "0.2.10",
|
||||
"version": "1.0.3",
|
||||
"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": {
|
||||
"build:watch": "tsc -w",
|
||||
"lint": "tslint --project . 'src/**/*.ts'",
|
||||
"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": {
|
||||
"abi-gen": "lib/index.js"
|
||||
"abi-gen": "bin/abi-gen.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -24,29 +32,37 @@
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/0x-monorepo/packages/abi-gen/README.md",
|
||||
"dependencies": {
|
||||
"@0xproject/types": "^0.6.0",
|
||||
"@0xproject/typescript-typings": "^0.1.0",
|
||||
"@0xproject/utils": "^0.5.1",
|
||||
"@0xproject/typescript-typings": "^1.0.3",
|
||||
"@0xproject/utils": "^1.0.3",
|
||||
"chalk": "^2.3.0",
|
||||
"ethereum-types": "^1.0.3",
|
||||
"glob": "^7.1.2",
|
||||
"handlebars": "^4.0.11",
|
||||
"lodash": "^4.17.4",
|
||||
"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.1.17",
|
||||
"@0xproject/tslint-config": "^0.4.15",
|
||||
"@types/glob": "^5.0.33",
|
||||
"@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": {
|
||||
|
||||
@@ -1,18 +1,15 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import { AbiDefinition, ConstructorAbi, EventAbi, MethodAbi } from '@0xproject/types';
|
||||
import { abiUtils, logUtils } from '@0xproject/utils';
|
||||
import chalk from 'chalk';
|
||||
import * as fs from 'fs';
|
||||
import { AbiDefinition, ConstructorAbi, EventAbi, MethodAbi } from 'ethereum-types';
|
||||
import { sync as globSync } from 'glob';
|
||||
import * as Handlebars from 'handlebars';
|
||||
import * as _ from 'lodash';
|
||||
import * as mkdirp from 'mkdirp';
|
||||
import * as yargs from 'yargs';
|
||||
|
||||
import toSnakeCase = require('to-snake-case');
|
||||
|
||||
import { ContextData, ContractsBackend, Method, ParamKind } from './types';
|
||||
import { ContextData, ContractsBackend, ParamKind } from './types';
|
||||
import { utils } from './utils';
|
||||
|
||||
const ABI_TYPE_CONSTRUCTOR = 'constructor';
|
||||
@@ -61,24 +58,13 @@ const args = yargs
|
||||
'Full usage example',
|
||||
).argv;
|
||||
|
||||
function registerPartials(partialsGlob: string) {
|
||||
function registerPartials(partialsGlob: string): void {
|
||||
const partialTemplateFileNames = globSync(partialsGlob);
|
||||
logUtils.log(`Found ${chalk.green(`${partialTemplateFileNames.length}`)} ${chalk.bold('partial')} templates`);
|
||||
for (const partialTemplateFileName of partialTemplateFileNames) {
|
||||
const namedContent = utils.getNamedContent(partialTemplateFileName);
|
||||
Handlebars.registerPartial(namedContent.name, namedContent.content);
|
||||
}
|
||||
return partialsGlob;
|
||||
}
|
||||
|
||||
function writeOutputFile(name: string, renderedTsCode: string): void {
|
||||
let fileName = toSnakeCase(name);
|
||||
if (fileName === 'z_r_x_token') {
|
||||
fileName = 'zrx_token';
|
||||
}
|
||||
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));
|
||||
@@ -108,17 +94,25 @@ for (const abiFileName of abiFileNames) {
|
||||
ABI = parsedContent; // ABI file
|
||||
} else if (!_.isUndefined(parsedContent.abi)) {
|
||||
ABI = parsedContent.abi; // Truffle artifact
|
||||
} else if (!_.isUndefined(parsedContent.networks) && !_.isUndefined(parsedContent.networks[args.networkId])) {
|
||||
ABI = parsedContent.networks[args.networkId].abi; // 0x contracts package artifact
|
||||
} else if (!_.isUndefined(parsedContent.compilerOutput.abi)) {
|
||||
ABI = parsedContent.compilerOutput.abi; // 0x artifact
|
||||
}
|
||||
if (_.isUndefined(ABI)) {
|
||||
logUtils.log(`${chalk.red(`ABI not found in ${abiFileName}.`)}`);
|
||||
logUtils.log(
|
||||
`Please make sure your ABI file is either an array with ABI entries or a truffle artifact or 0x deployer artifact`,
|
||||
`Please make sure your ABI file is either an array with ABI entries or a truffle artifact or 0x sol-compiler artifact`,
|
||||
);
|
||||
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
|
||||
@@ -153,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)}`);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { EventAbi, MethodAbi } from '@0xproject/types';
|
||||
import { EventAbi, MethodAbi } from 'ethereum-types';
|
||||
|
||||
export enum ParamKind {
|
||||
Input = 'input',
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { AbiType, ConstructorAbi, DataItem } from '@0xproject/types';
|
||||
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';
|
||||
|
||||
@@ -56,7 +57,7 @@ export const utils = {
|
||||
const componentType = `${component.name}: ${componentValueType}`;
|
||||
return componentType;
|
||||
});
|
||||
const tsType = `{${componentsType}}`;
|
||||
const tsType = `{${componentsType.join(';')}}`;
|
||||
return tsType;
|
||||
}
|
||||
throw new Error(`Unknown Solidity type found: ${solType}`);
|
||||
@@ -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,4 +1,114 @@
|
||||
[
|
||||
{
|
||||
"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":
|
||||
"Fix bug in string enum assertion. We erroneously were checking against the enum keys, not values",
|
||||
"pr": 821
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"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",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"version": "0.2.11",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Incorrect publish that was unpublished"
|
||||
}
|
||||
],
|
||||
"timestamp": 1527810075
|
||||
},
|
||||
{
|
||||
"timestamp": 1527008270,
|
||||
"version": "0.2.10",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1525477860,
|
||||
"version": "0.2.9",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1525428773,
|
||||
"version": "0.2.8",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1524044013,
|
||||
"version": "0.2.7",
|
||||
|
||||
@@ -1,15 +1,63 @@
|
||||
<!--
|
||||
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
|
||||
|
||||
## v0.2.11 - _June 1, 2018_
|
||||
|
||||
* Incorrect publish that was unpublished
|
||||
|
||||
## v0.2.10 - _May 22, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.2.9 - _May 5, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.2.8 - _May 4, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.2.7 - _April 18, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.2.6 - _April 12, 2018_
|
||||
## v0.2.6 - _April 11, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
@@ -21,20 +69,20 @@ CHANGELOG
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.2.0 - _March 8, 2018_
|
||||
## v0.2.0 - _March 7, 2018_
|
||||
|
||||
* Rename `isHttpUrl` to `isWebUri` (#412)
|
||||
|
||||
## v0.1.0 - _March 4, 2018_
|
||||
## v0.1.0 - _March 3, 2018_
|
||||
|
||||
* Remove isETHAddressHex checksum address check and assume address will be lowercased (#373)
|
||||
* Add an optional parameter `subSchemas` to `doesConformToSchema` method (#385)
|
||||
|
||||
## v0.0.18 - _February 9, 2017_
|
||||
## v0.0.18 - _February 8, 2017_
|
||||
|
||||
* Fix publishing issue where .npmignore was not properly excluding undesired content (#389)
|
||||
|
||||
## v0.0.4 - _November 14, 2017_
|
||||
## v0.0.4 - _November 13, 2017_
|
||||
|
||||
* Re-publish Assert previously published under NPM package @0xproject/0x-assert
|
||||
* Added assertion isValidBaseUnitAmount which checks both that the value is a valid bigNumber and that it does not contain decimals.
|
||||
|
||||
@@ -46,28 +46,16 @@ yarn install
|
||||
|
||||
### Build
|
||||
|
||||
If this is your **first** time building this package, you must first build **all** packages within the monorepo. This is because packages that depend on other packages located inside this monorepo are symlinked when run from **within** the monorepo. This allows you to make changes across multiple packages without first publishing dependent packages to NPM. To build all packages, run the following from the monorepo root directory:
|
||||
To build this package and all other monorepo packages that it depends on, run the following from the monorepo root directory:
|
||||
|
||||
```bash
|
||||
yarn lerna:rebuild
|
||||
PKG=@0xproject/assert yarn build
|
||||
```
|
||||
|
||||
Or continuously rebuild on change:
|
||||
|
||||
```bash
|
||||
yarn dev
|
||||
```
|
||||
|
||||
You can also build this specific package by running the following from within its directory:
|
||||
|
||||
```bash
|
||||
yarn build
|
||||
```
|
||||
|
||||
or continuously rebuild on change:
|
||||
|
||||
```bash
|
||||
yarn build:watch
|
||||
PKG=@0xproject/assert yarn watch
|
||||
```
|
||||
|
||||
### Clean
|
||||
|
||||
@@ -1,17 +1,20 @@
|
||||
{
|
||||
"name": "@0xproject/assert",
|
||||
"version": "0.2.6",
|
||||
"version": "1.0.3",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
"description": "Provides a standard way of performing type and schema validation across 0x projects",
|
||||
"main": "lib/src/index.js",
|
||||
"types": "lib/src/index.d.ts",
|
||||
"scripts": {
|
||||
"build:watch": "tsc -w",
|
||||
"watch_without_deps": "tsc -w",
|
||||
"build": "tsc && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts",
|
||||
"clean": "shx rm -rf lib test_temp scripts",
|
||||
"lint": "tslint --project . 'src/**/*.ts' 'test/**/*.ts'",
|
||||
"run_mocha": "mocha lib/test/**/*_test.js --exit",
|
||||
"prepublishOnly": "run-p build",
|
||||
"test": "run-s clean build run_mocha",
|
||||
"lint": "tslint --project .",
|
||||
"run_mocha": "mocha --require source-map-support/register --require make-promises-safe lib/test/**/*_test.js --exit",
|
||||
"test": "yarn run_mocha",
|
||||
"rebuild_and_test": "run-s clean build test",
|
||||
"test:coverage": "nyc npm run test --all && yarn coverage:report:lcov",
|
||||
"coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info",
|
||||
"test:circleci": "yarn test:coverage",
|
||||
@@ -27,25 +30,26 @@
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/0x-monorepo/packages/assert/README.md",
|
||||
"devDependencies": {
|
||||
"@0xproject/monorepo-scripts": "^0.1.17",
|
||||
"@0xproject/tslint-config": "^0.4.15",
|
||||
"@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",
|
||||
"chai": "^4.0.1",
|
||||
"copyfiles": "^1.2.0",
|
||||
"dirty-chai": "^2.0.1",
|
||||
"make-promises-safe": "^1.1.0",
|
||||
"mocha": "^4.0.1",
|
||||
"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": "^0.7.20",
|
||||
"@0xproject/typescript-typings": "^0.1.0",
|
||||
"@0xproject/utils": "^0.5.1",
|
||||
"@0xproject/json-schemas": "^1.0.1-rc.2",
|
||||
"@0xproject/typescript-typings": "^1.0.3",
|
||||
"@0xproject/utils": "^1.0.3",
|
||||
"lodash": "^4.17.4",
|
||||
"valid-url": "^1.0.9"
|
||||
},
|
||||
|
||||
@@ -8,41 +8,41 @@ 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) {
|
||||
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,
|
||||
value: string,
|
||||
stringEnum: any /* There is no base type for every string enum */,
|
||||
): void {
|
||||
const doesBelongToStringEnum = !_.isUndefined(stringEnum[value]);
|
||||
const enumValues = _.keys(stringEnum);
|
||||
const enumValues = _.values(stringEnum);
|
||||
const doesBelongToStringEnum = _.includes(enumValues, value);
|
||||
const enumValuesAsStrings = _.map(enumValues, enumValue => `'${enumValue}'`);
|
||||
const enumValuesAsString = enumValuesAsStrings.join(', ');
|
||||
assert.assert(
|
||||
@@ -51,19 +51,22 @@ 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)) {
|
||||
throw new Error(`${variableName} can't be undefined`);
|
||||
}
|
||||
const schemaValidator = new SchemaValidator();
|
||||
if (!_.isUndefined(subSchemas)) {
|
||||
_.map(subSchemas, schemaValidator.addSchema.bind(schemaValidator));
|
||||
@@ -73,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) {
|
||||
|
||||
@@ -10,6 +10,7 @@ chai.config.includeStack = true;
|
||||
chai.use(dirtyChai);
|
||||
const expect = chai.expect;
|
||||
|
||||
// tslint:disable:custom-no-magic-numbers
|
||||
describe('Assertions', () => {
|
||||
const variableName = 'variable';
|
||||
describe('#isBigNumber', () => {
|
||||
@@ -48,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', () => {
|
||||
@@ -251,3 +252,4 @@ describe('Assertions', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
// tslint:enable:custom-no-magic-numbers
|
||||
|
||||
@@ -1,4 +1,114 @@
|
||||
[
|
||||
{
|
||||
"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": [
|
||||
{
|
||||
"note":
|
||||
"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"
|
||||
}
|
||||
],
|
||||
"timestamp": 1529397769
|
||||
},
|
||||
{
|
||||
"timestamp": 1527810075,
|
||||
"version": "0.3.3",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Incorrect publish that was unpublished"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1527008270,
|
||||
"version": "0.3.2",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1525477860,
|
||||
"version": "0.3.1",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"version": "0.3.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Update ethers-contracts to ethers.js",
|
||||
"pr": 540
|
||||
}
|
||||
],
|
||||
"timestamp": 1525428773
|
||||
},
|
||||
{
|
||||
"timestamp": 1524044013,
|
||||
"version": "0.2.1",
|
||||
|
||||
@@ -1,15 +1,63 @@
|
||||
<!--
|
||||
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
|
||||
|
||||
## v0.3.3 - _June 1, 2018_
|
||||
|
||||
* Incorrect publish that was unpublished
|
||||
|
||||
## v0.3.2 - _May 22, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.3.1 - _May 5, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.3.0 - _May 4, 2018_
|
||||
|
||||
* Update ethers-contracts to ethers.js (#540)
|
||||
|
||||
## v0.2.1 - _April 18, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.2.0 - _April 12, 2018_
|
||||
## v0.2.0 - _April 11, 2018_
|
||||
|
||||
* Contract wrappers now accept Provider and defaults instead of Web3Wrapper (#501)
|
||||
|
||||
@@ -23,6 +71,6 @@ CHANGELOG
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.0.2 - _March 4, 2018_
|
||||
## v0.0.2 - _March 3, 2018_
|
||||
|
||||
* Initial release
|
||||
|
||||
@@ -44,14 +44,16 @@ yarn install
|
||||
|
||||
### Build
|
||||
|
||||
To build this package and all other monorepo packages that it depends on, run the following from the monorepo root directory:
|
||||
|
||||
```bash
|
||||
yarn build
|
||||
PKG=@0xproject/base-contract yarn build
|
||||
```
|
||||
|
||||
or
|
||||
Or continuously rebuild on change:
|
||||
|
||||
```bash
|
||||
yarn build:watch
|
||||
PKG=@0xproject/base-contract yarn watch
|
||||
```
|
||||
|
||||
### Lint
|
||||
|
||||
@@ -1,19 +1,23 @@
|
||||
{
|
||||
"name": "@0xproject/base-contract",
|
||||
"version": "0.2.0",
|
||||
"version": "1.0.3",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
"description": "0x Base TS contract",
|
||||
"main": "lib/src/index.js",
|
||||
"types": "lib/src/index.d.ts",
|
||||
"scripts": {
|
||||
"build:watch": "tsc -w",
|
||||
"build": "tsc && copyfiles -u 2 './lib/monorepo_scripts/**/*' ./scripts",
|
||||
"watch_without_deps": "tsc -w",
|
||||
"build": "tsc && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts",
|
||||
"clean": "shx rm -rf lib scripts",
|
||||
"test": "run-s clean build run_mocha",
|
||||
"test": "yarn run_mocha",
|
||||
"rebuild_and_test": "run-s clean build test",
|
||||
"test:circleci": "yarn test:coverage",
|
||||
"run_mocha": "mocha lib/test/**/*_test.js --bail --exit",
|
||||
"run_mocha": "mocha --require source-map-support/register --require make-promises-safe lib/test/**/*_test.js --bail --exit",
|
||||
"test:coverage": "nyc npm run test --all && yarn coverage:report:lcov",
|
||||
"coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info",
|
||||
"lint": "tslint --project .",
|
||||
"lint": "tslint --project . --exclude **/src/contract_wrappers/**/*",
|
||||
"manual:postpublish": "yarn build; node ./scripts/postpublish.js"
|
||||
},
|
||||
"license": "Apache-2.0",
|
||||
@@ -26,23 +30,24 @@
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/0x-monorepo/packages/base-contract/README.md",
|
||||
"devDependencies": {
|
||||
"@0xproject/monorepo-scripts": "^0.1.17",
|
||||
"@0xproject/tslint-config": "^0.4.15",
|
||||
"@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",
|
||||
"make-promises-safe": "^1.1.0",
|
||||
"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": {
|
||||
"@0xproject/types": "^0.6.0",
|
||||
"@0xproject/typescript-typings": "^0.1.0",
|
||||
"@0xproject/utils": "^0.5.1",
|
||||
"@0xproject/web3-wrapper": "^0.6.0",
|
||||
"ethers-contracts": "^2.2.1",
|
||||
"@0xproject/typescript-typings": "^1.0.3",
|
||||
"@0xproject/utils": "^1.0.3",
|
||||
"@0xproject/web3-wrapper": "^1.1.1",
|
||||
"ethereum-types": "^1.0.3",
|
||||
"ethers": "3.0.22",
|
||||
"lodash": "^4.17.4"
|
||||
},
|
||||
"publishConfig": {
|
||||
|
||||
@@ -1,22 +1,23 @@
|
||||
import { abiUtils, BigNumber } from '@0xproject/utils';
|
||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||
import {
|
||||
AbiDefinition,
|
||||
AbiType,
|
||||
ConstructorAbi,
|
||||
ContractAbi,
|
||||
DataItem,
|
||||
MethodAbi,
|
||||
Provider,
|
||||
TxData,
|
||||
TxDataPayable,
|
||||
} from '@0xproject/types';
|
||||
import { abiUtils, BigNumber } from '@0xproject/utils';
|
||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
||||
import * as ethersContracts from 'ethers-contracts';
|
||||
} from 'ethereum-types';
|
||||
import * as ethers from 'ethers';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { formatABIDataItem } from './utils';
|
||||
|
||||
export interface EthersInterfaceByFunctionSignature {
|
||||
[key: string]: ethersContracts.Interface;
|
||||
[key: string]: ethers.Interface;
|
||||
}
|
||||
|
||||
export class BaseContract {
|
||||
@@ -24,6 +25,8 @@ export class BaseContract {
|
||||
protected _web3Wrapper: Web3Wrapper;
|
||||
public abi: ContractAbi;
|
||||
public address: string;
|
||||
public contractName: string;
|
||||
public constructorArgs: any[] = [];
|
||||
protected static _formatABIDataItemList(
|
||||
abis: DataItem[],
|
||||
values: any[],
|
||||
@@ -34,35 +37,52 @@ export class BaseContract {
|
||||
protected static _lowercaseAddress(type: string, value: string): string {
|
||||
return type === 'address' ? value.toLowerCase() : value;
|
||||
}
|
||||
protected static _bigNumberToString(type: string, value: any): any {
|
||||
protected static _bigNumberToString(_type: string, value: any): any {
|
||||
return _.isObject(value) && value.isBigNumber ? value.toString() : value;
|
||||
}
|
||||
protected static _bnToBigNumber(type: string, value: any): any {
|
||||
protected static _lookupConstructorAbi(abi: ContractAbi): ConstructorAbi {
|
||||
const constructorAbiIfExists = _.find(
|
||||
abi,
|
||||
(abiDefinition: AbiDefinition) => abiDefinition.type === AbiType.Constructor,
|
||||
// tslint:disable-next-line:no-unnecessary-type-assertion
|
||||
) as ConstructorAbi | undefined;
|
||||
if (!_.isUndefined(constructorAbiIfExists)) {
|
||||
return constructorAbiIfExists;
|
||||
} else {
|
||||
// If the constructor is not explicitly defined, it won't be included in the ABI. It is
|
||||
// still callable however, so we construct what the ABI would look like were it to exist.
|
||||
const defaultConstructorAbi: ConstructorAbi = {
|
||||
type: AbiType.Constructor,
|
||||
stateMutability: 'nonpayable',
|
||||
payable: false,
|
||||
inputs: [],
|
||||
};
|
||||
return defaultConstructorAbi;
|
||||
}
|
||||
}
|
||||
protected static _bnToBigNumber(_type: string, value: any): any {
|
||||
return _.isObject(value) && value._bn ? new BigNumber(value.toString()) : value;
|
||||
}
|
||||
protected async _applyDefaultsToTxDataAsync<T extends Partial<TxData | TxDataPayable>>(
|
||||
protected static async _applyDefaultsToTxDataAsync<T extends Partial<TxData | TxDataPayable>>(
|
||||
txData: T,
|
||||
txDefaults: Partial<TxData>,
|
||||
estimateGasAsync?: (txData: T) => Promise<number>,
|
||||
): Promise<TxData> {
|
||||
// Gas amount sourced with the following priorities:
|
||||
// 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 = ({
|
||||
to: this.address,
|
||||
...removeUndefinedProperties(this._web3Wrapper.getContractDefaults()),
|
||||
...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) as TxData;
|
||||
const removeUndefinedProperties = _.pickBy.bind(_);
|
||||
const txDataWithDefaults = {
|
||||
...removeUndefinedProperties(txDefaults),
|
||||
...removeUndefinedProperties(txData),
|
||||
};
|
||||
if (_.isUndefined(txDataWithDefaults.gas) && !_.isUndefined(estimateGasAsync)) {
|
||||
const estimatedGas = await estimateGasAsync(txData);
|
||||
txDataWithDefaults.gas = estimatedGas;
|
||||
txDataWithDefaults.gas = await estimateGasAsync(txDataWithDefaults);
|
||||
}
|
||||
return txDataWithDefaults;
|
||||
}
|
||||
protected _lookupEthersInterface(functionSignature: string): ethersContracts.Interface {
|
||||
protected _lookupEthersInterface(functionSignature: string): ethers.Interface {
|
||||
const ethersInterface = this._ethersInterfacesByFunctionSignature[functionSignature];
|
||||
if (_.isUndefined(ethersInterface)) {
|
||||
throw new Error(`Failed to lookup method with function signature '${functionSignature}'`);
|
||||
@@ -82,8 +102,15 @@ export class BaseContract {
|
||||
}) as MethodAbi;
|
||||
return methodAbi;
|
||||
}
|
||||
constructor(abi: ContractAbi, address: string, provider: Provider, defaults?: Partial<TxData>) {
|
||||
this._web3Wrapper = new Web3Wrapper(provider, defaults);
|
||||
constructor(
|
||||
contractName: string,
|
||||
abi: ContractAbi,
|
||||
address: string,
|
||||
provider: Provider,
|
||||
txDefaults?: Partial<TxData>,
|
||||
) {
|
||||
this.contractName = contractName;
|
||||
this._web3Wrapper = new Web3Wrapper(provider, txDefaults);
|
||||
this.abi = abi;
|
||||
this.address = address;
|
||||
const methodAbis = this.abi.filter(
|
||||
@@ -92,7 +119,7 @@ export class BaseContract {
|
||||
this._ethersInterfacesByFunctionSignature = {};
|
||||
_.each(methodAbis, methodAbi => {
|
||||
const functionSignature = abiUtils.getFunctionSignature(methodAbi);
|
||||
this._ethersInterfacesByFunctionSignature[functionSignature] = new ethersContracts.Interface([methodAbi]);
|
||||
this._ethersInterfacesByFunctionSignature[functionSignature] = new ethers.Interface([methodAbi]);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { DataItem } from '@0xproject/types';
|
||||
import { DataItem } from 'ethereum-types';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
// tslint:disable-next-line:completed-docs
|
||||
|
||||
@@ -1,4 +1,113 @@
|
||||
[
|
||||
{
|
||||
"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",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1527616612,
|
||||
"version": "0.6.14",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1527008270,
|
||||
"version": "0.6.13",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1525477860,
|
||||
"version": "0.6.12",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1525428773,
|
||||
"version": "0.6.11",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Dependencies updated"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1524044013,
|
||||
"version": "0.6.10",
|
||||
|
||||
@@ -1,15 +1,63 @@
|
||||
<!--
|
||||
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
|
||||
|
||||
## v0.6.14 - _May 29, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.6.13 - _May 22, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.6.12 - _May 5, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.6.11 - _May 4, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.6.10 - _April 18, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.6.9 - _April 12, 2018_
|
||||
## v0.6.9 - _April 11, 2018_
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
@@ -21,44 +69,44 @@ CHANGELOG
|
||||
|
||||
* Dependencies updated
|
||||
|
||||
## v0.6.4 - _March 18, 2018_
|
||||
## v0.6.4 - _March 17, 2018_
|
||||
|
||||
* Consolidate `Order`, `SignedOrder`, and `ECSignature` into the `@0xproject/types` package (#456)
|
||||
|
||||
## v0.6.2 - _February 16, 2018_
|
||||
## v0.6.2 - _February 15, 2018_
|
||||
|
||||
* Fix JSON parse empty response (#407)
|
||||
|
||||
## v0.6.0 - _February 16, 2018_
|
||||
## v0.6.0 - _February 15, 2018_
|
||||
|
||||
* Add pagination options to HttpClient methods (#393)
|
||||
* Add heartbeat configuration to WebSocketOrderbookChannel constructor (#406)
|
||||
|
||||
## v0.5.7 - _February 9, 2018_
|
||||
## v0.5.7 - _February 8, 2018_
|
||||
|
||||
* Fix publishing issue where .npmignore was not properly excluding undesired content (#389)
|
||||
|
||||
## v0.5.0 - _January 17, 2018_
|
||||
## v0.5.0 - _January 16, 2018_
|
||||
|
||||
* Sanitize api endpoint url and remove trailing slashes (#318)
|
||||
* Improve error message text in HttpClient (#318)
|
||||
* Stop appending '/v0' to api endpoint url in HttpClient (#318)
|
||||
|
||||
## v0.4.0 - _January 11, 2018_
|
||||
## v0.4.0 - _January 10, 2018_
|
||||
|
||||
* Prevent getFeesAsync method on HttpClient from mutating input (#296)
|
||||
|
||||
## v0.3.0 - _December 8, 2017_
|
||||
## v0.3.0 - _December 7, 2017_
|
||||
|
||||
* Expose WebSocketOrderbookChannel and associated types to public interface (#251)
|
||||
* Remove tokenA and tokenB fields from OrdersRequest (#256)
|
||||
|
||||
## v0.2.0 - _November 29, 2017_
|
||||
## v0.2.0 - _November 28, 2017_
|
||||
|
||||
* Add SignedOrder and TokenTradeInfo to the public interface
|
||||
* Add ECSignature and Order to the public interface
|
||||
* Remove dependency on 0x.js
|
||||
|
||||
## v0.1.0 - _November 22, 2017_
|
||||
## v0.1.0 - _November 21, 2017_
|
||||
|
||||
* Provide a HttpClient class for interacting with standard relayer api compliant HTTP urls
|
||||
|
||||
@@ -43,28 +43,16 @@ yarn install
|
||||
|
||||
### Build
|
||||
|
||||
If this is your **first** time building this package, you must first build **all** packages within the monorepo. This is because packages that depend on other packages located inside this monorepo are symlinked when run from **within** the monorepo. This allows you to make changes across multiple packages without first publishing dependent packages to NPM. To build all packages, run the following from the monorepo root directory:
|
||||
To build this package and all other monorepo packages that it depends on, run the following from the monorepo root directory:
|
||||
|
||||
```bash
|
||||
yarn lerna:rebuild
|
||||
PKG=@0xproject/connect yarn build
|
||||
```
|
||||
|
||||
Or continuously rebuild on change:
|
||||
|
||||
```bash
|
||||
yarn dev
|
||||
```
|
||||
|
||||
You can also build this specific package by running the following from within its directory:
|
||||
|
||||
```bash
|
||||
yarn build
|
||||
```
|
||||
|
||||
or continuously rebuild on change:
|
||||
|
||||
```bash
|
||||
yarn build:watch
|
||||
PKG=@0xproject/connect yarn watch
|
||||
```
|
||||
|
||||
### Clean
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
{
|
||||
"name": "@0xproject/connect",
|
||||
"version": "0.6.9",
|
||||
"version": "1.0.3",
|
||||
"engines": {
|
||||
"node": ">=6.12"
|
||||
},
|
||||
"description": "A javascript library for interacting with the standard relayer api",
|
||||
"keywords": [
|
||||
"connect",
|
||||
@@ -12,18 +15,19 @@
|
||||
"main": "lib/src/index.js",
|
||||
"types": "lib/src/index.d.ts",
|
||||
"scripts": {
|
||||
"build:watch": "tsc -w",
|
||||
"watch_without_deps": "tsc -w",
|
||||
"build": "tsc && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts",
|
||||
"clean": "shx rm -rf lib test_temp scripts",
|
||||
"copy_test_fixtures": "copyfiles -u 2 './test/fixtures/**/*.json' ./lib/test/fixtures",
|
||||
"lint": "tslint --project . 'src/**/*.ts' 'test/**/*.ts'",
|
||||
"run_mocha": "mocha lib/test/**/*_test.js --exit",
|
||||
"test": "run-s clean build copy_test_fixtures run_mocha",
|
||||
"lint": "tslint --project .",
|
||||
"run_mocha": "mocha --require source-map-support/register --require make-promises-safe lib/test/**/*_test.js --exit",
|
||||
"test": "run-s copy_test_fixtures run_mocha",
|
||||
"rebuild_and_test": "run-s clean build test",
|
||||
"test:coverage": "nyc npm run test --all && yarn coverage:report:lcov",
|
||||
"coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info",
|
||||
"test:circleci": "yarn test:coverage",
|
||||
"manual:postpublish": "yarn build; node ./scripts/postpublish.js",
|
||||
"docs:stage": "yarn build && node ./scripts/stage_docs.js",
|
||||
"docs:stage": "node scripts/stage_docs.js",
|
||||
"docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --json $JSON_FILE_PATH $PROJECT_FILES",
|
||||
"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"
|
||||
},
|
||||
@@ -42,43 +46,42 @@
|
||||
},
|
||||
"author": "Brandon Millman",
|
||||
"license": "Apache-2.0",
|
||||
"engines": {
|
||||
"node": ">=6.0.0"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/0xProject/0x-monorepo/issues"
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/0x-monorepo/packages/connect/README.md",
|
||||
"dependencies": {
|
||||
"@0xproject/assert": "^0.2.6",
|
||||
"@0xproject/json-schemas": "^0.7.20",
|
||||
"@0xproject/types": "^0.6.0",
|
||||
"@0xproject/typescript-typings": "^0.1.0",
|
||||
"@0xproject/utils": "^0.5.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.3",
|
||||
"lodash": "^4.17.4",
|
||||
"query-string": "^5.0.1",
|
||||
"sinon": "^4.0.0",
|
||||
"websocket": "^1.0.25"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@0xproject/monorepo-scripts": "^0.1.17",
|
||||
"@0xproject/tslint-config": "^0.4.15",
|
||||
"@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",
|
||||
"copyfiles": "^1.2.0",
|
||||
"dirty-chai": "^2.0.1",
|
||||
"fetch-mock": "^5.13.1",
|
||||
"make-promises-safe": "^1.1.0",
|
||||
"mocha": "^4.0.1",
|
||||
"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
|
||||
*/
|
||||
@@ -48,7 +48,7 @@ export class HttpClient implements Client {
|
||||
return '';
|
||||
}
|
||||
// format params into a form the api expects
|
||||
const formattedParams = _.mapKeys(params, (value: any, key: string) => {
|
||||
const formattedParams = _.mapKeys(params, (_value: any, key: string) => {
|
||||
return _.get(OPTS_TO_QUERY_FIELD_MAP, key, key);
|
||||
});
|
||||
// stringify the formatted object
|
||||
@@ -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 { ECSignature, Order, SignedOrder } from '@0xproject/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,
|
||||
},
|
||||
},
|
||||
};
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ECSignature, Order, SignedOrder } from '@0xproject/types';
|
||||
import { SignedOrder } from '@0xproject/types';
|
||||
import { BigNumber } from '@0xproject/utils';
|
||||
|
||||
export interface Client {
|
||||
@@ -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,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { assert } from '@0xproject/assert';
|
||||
import { schemas } from '@0xproject/json-schemas';
|
||||
import { SignedOrder } from '@0xproject/types';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { FeesResponse, OrderbookResponse, TokenPairsItem } from '../types';
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user